:root {
  color: #1d1d1f;
  background: #f5f5f7;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", sans-serif;
  font-size: 15px;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, .82);
  --surface-strong: #fff;
  --line: rgba(60, 60, 67, .14);
  --line-strong: rgba(60, 60, 67, .22);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --blue: #007aff;
  --blue-soft: #e8f1ff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% -10%, rgba(0, 122, 255, .08), transparent 28%),
    radial-gradient(circle at 100% 0%, rgba(52, 199, 89, .08), transparent 26%),
    var(--bg);
  color: var(--text);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(245, 245, 247, .62);
  backdrop-filter: blur(18px);
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .18);
}

.login-card h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-card input {
  min-height: 48px;
  font-size: 18px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.login-card button {
  min-height: 48px;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.link-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .9);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 13px;
  cursor: pointer;
  min-height: 40px;
  transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease;
}

button:hover,
.link-btn:hover {
  border-color: rgba(0, 122, 255, .42);
  box-shadow: 0 8px 22px rgba(0, 122, 255, .08);
}

button:active {
  transform: scale(.98);
}

button:disabled {
  opacity: .52;
  cursor: not-allowed;
}

.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
}

.ghost {
  background: rgba(255, 255, 255, .72);
}

.topbar {
  height: 74px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .76);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1,
.section-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

.top-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.records-view {
  height: calc(100vh - 74px);
  overflow: auto;
  padding: 14px;
}

.records-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 200px 92px;
  gap: 10px;
  padding-bottom: 12px;
  background: linear-gradient(var(--bg), rgba(245, 245, 247, .86));
  backdrop-filter: blur(18px);
}

input,
select,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .94);
  color: var(--text);
  min-width: 0;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 122, 255, .62);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, .12);
}

.records-list {
  display: grid;
  gap: 10px;
}

.empty,
.muted {
  color: var(--muted);
}

.empty {
  margin: 0;
  padding: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.record-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(4, 88px) 76px;
  gap: 12px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .04);
  backdrop-filter: blur(20px);
}

.record-card h2 {
  margin: 0 0 6px;
  font-size: 17px;
}

.record-card p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 13px;
}

.record-card .metric {
  min-height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, .7);
  color: var(--muted);
  font-size: 12px;
}

.record-card .metric b {
  display: block;
  color: var(--text);
  font-size: 19px;
}

.status-chip,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--blue-soft);
  color: #075dcc;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.pill {
  min-width: 58px;
}

.pill.warn {
  background: #fff3df;
  color: #b85b00;
}

.workspace {
  height: calc(100vh - 74px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(520px, 1.24fr) minmax(360px, .82fr) minmax(340px, .82fr);
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.listen-panel {
  order: 1;
}

.report-panel {
  order: 2;
}

.sop-panel {
  order: 3;
}

.panel {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.section-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex: 0 0 auto;
}

.section-head h2 {
  font-size: 18px;
  line-height: 1.25;
}

.record-meta {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}

.record-meta strong {
  color: var(--text);
}

.phase-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 14px 7px;
  overflow-x: auto;
  flex: 0 0 auto;
}

.phase-tabs button {
  white-space: nowrap;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
}

.phase-tabs button.active {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #fff;
}

.step-meter {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  padding: 0 16px 10px;
  flex: 0 0 auto;
}

.step-meter span {
  height: 5px;
  background: rgba(60, 60, 67, .14);
  border-radius: 999px;
}

.step-meter span.done {
  background: var(--green);
}

.step-meter span.active {
  background: var(--blue);
}

.sop-list,
.transcript-list,
.annotation-list {
  overflow: auto;
  min-height: 0;
  scroll-behavior: smooth;
}

.sop-list {
  flex: 1 1 auto;
  padding: 0 14px 14px;
}

.sop-step {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, .72);
  margin-bottom: 8px;
}

.sop-step.active {
  border-color: rgba(0, 122, 255, .34);
  background: linear-gradient(180deg, rgba(232, 241, 255, .88), rgba(255, 255, 255, .9));
  box-shadow: inset 4px 0 0 var(--blue);
}

.sop-step.marked {
  box-shadow: inset 4px 0 0 var(--orange);
}

.sop-step.active.marked {
  box-shadow: inset 4px 0 0 var(--blue), inset 8px 0 0 var(--orange);
}

.sop-step-title {
  width: 100%;
  border: 0;
  border-radius: 0;
  min-height: 54px;
  text-align: left;
  display: grid;
  gap: 3px;
  padding: 10px 14px;
  background: transparent;
  color: var(--text);
}

.sop-step-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.sop-step-title strong {
  font-size: 15px;
}

.sop-step-body {
  padding: 0 14px 14px;
}

.sop-step h3 {
  margin: 5px 0 10px;
  font-size: 18px;
  line-height: 1.25;
}

.sop-step p {
  margin: 8px 0;
  color: #424245;
  line-height: 1.65;
}

.sop-step .script {
  color: #006a5b;
}

.auto-match {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  color: #075dcc;
  background: rgba(0, 122, 255, .11);
  font-size: 12px;
  font-weight: 760;
}

.listen-tools {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 170px;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.listen-tools input,
.listen-tools select {
  min-height: 42px;
}

.transcript-list {
  flex: 1 1 auto;
  padding: 16px 18px 18px;
}

.utterance {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 16px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
}

.utterance:hover {
  background: rgba(0, 122, 255, .05);
}

.utterance.active {
  background: var(--blue-soft);
  border-color: rgba(0, 122, 255, .24);
  box-shadow: inset 4px 0 0 var(--blue);
}

.speaker-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.utterance-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}

.utterance-head strong {
  font-size: 13px;
}

.utterance-head time {
  color: var(--muted);
  font-size: 12px;
}

.utterance p {
  margin: 0;
  line-height: 1.72;
}

.player {
  position: relative;
  border-top: 1px solid var(--line);
  padding: 10px 16px 14px;
  background: rgba(255, 255, 255, .9);
  flex: 0 0 auto;
}

#progressRange {
  width: 100%;
  accent-color: var(--blue);
}

.player-controls {
  display: grid;
  grid-template-columns: 42px 54px 54px 58px minmax(120px, 1fr) 86px 62px 42px;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

.wide-icon {
  border-radius: 999px;
  min-width: 58px;
  font-size: 13px;
}

.segment-btn {
  min-width: 62px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 149, 0, .14);
  border-color: rgba(255, 149, 0, .36);
  color: #b85b00;
  font-weight: 800;
}

.time {
  font-weight: 760;
  letter-spacing: 0;
}

.player select {
  background: rgba(245, 245, 247, .9);
  border-radius: 999px;
  padding: 8px 10px;
}

.popover {
  position: absolute;
  right: 14px;
  bottom: 64px;
  min-width: 240px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(29, 29, 31, .92);
  color: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .24);
  z-index: 10;
  backdrop-filter: blur(18px);
}

.popover.compact {
  right: auto;
  left: 150px;
  min-width: 190px;
}

.popover label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 4px;
}

.current-evidence {
  margin: 12px 14px 0;
  padding: 12px;
  border-radius: 16px;
  background: rgba(232, 241, 255, .72);
  border: 1px solid rgba(0, 122, 255, .2);
  flex: 0 0 auto;
}

.current-evidence p {
  margin: 8px 0 0;
  color: #424245;
  line-height: 1.6;
  max-height: 112px;
  overflow: auto;
}

.evidence-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.evidence-title span {
  color: var(--blue);
  font-weight: 800;
}

.annotation-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 12px 14px;
  flex: 0 0 auto;
}

.annotation-actions button {
  min-height: 46px;
  font-weight: 780;
}

.annotation-actions button[data-status="达标"] {
  color: #087c2f;
}

.annotation-actions button[data-status="不足"],
.annotation-actions button[data-status="缺失"] {
  color: #075dcc;
}

.annotation-actions button[data-status="风险"] {
  color: #b42318;
}

.annotation-form {
  display: grid;
  gap: 10px;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.annotation-form label,
.create-grid label,
.advanced-grid label,
.create-options label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.annotation-form textarea {
  min-height: 72px;
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.advanced-annotation,
.optional-create {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .66);
  overflow: hidden;
}

.advanced-annotation summary,
.optional-create summary {
  cursor: pointer;
  padding: 10px 12px;
  color: #075dcc;
  font-weight: 760;
}

.advanced-grid,
.create-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 12px 12px;
}

.advanced-grid textarea,
.create-options textarea,
.create-grid textarea {
  min-height: 82px;
  resize: vertical;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: auto;
}

.subsection-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px 8px;
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}

.subsection-head strong {
  color: var(--text);
  font-size: 14px;
}

.annotation-list {
  flex: 1 1 auto;
  padding: 0 14px 12px;
}

.annotation-card,
.segment-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--orange);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, .78);
}

.annotation-card.risk {
  border-left-color: var(--red);
}

.annotation-card.pass {
  border-left-color: var(--green);
}

.annotation-card h3,
.segment-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.35;
}

.annotation-card p,
.segment-card p {
  margin: 6px 0;
  color: #424245;
  line-height: 1.55;
}

.annotation-card footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.annotation-card footer button {
  min-height: 34px;
  padding: 6px 10px;
}

.segment-list {
  padding: 0 14px 10px;
  max-height: 130px;
  overflow: auto;
  flex: 0 0 auto;
}

.report-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}

.result-box {
  margin: 0 14px 14px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(245, 245, 247, .84);
  min-height: 44px;
  max-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  color: #424245;
  font-size: 12px;
  flex: 0 0 auto;
}

.create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.filename-preview {
  border: 1px dashed rgba(0, 122, 255, .28);
  border-radius: 16px;
  padding: 12px;
  color: var(--muted);
  background: rgba(232, 241, 255, .45);
  min-height: 44px;
  font-size: 13px;
  white-space: pre-wrap;
}

dialog {
  border: 0;
  border-radius: 24px;
  width: min(860px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .24);
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(0, 0, 0, .26);
  backdrop-filter: blur(8px);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 36px);
}

.dialog-body > .create-grid,
.large-text,
.mutual-list {
  overflow: auto;
}

.large-text {
  min-height: 360px;
  margin: 16px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.transcript-file-label {
  margin: 14px 16px 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.transcript-file-label + .large-text {
  margin-top: 10px;
}

.dialog-actions {
  padding: 0 16px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.mutual-list {
  padding: 12px 16px 0;
  display: grid;
  gap: 8px;
}

.mutual-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(245, 245, 247, .82);
}

.mutual-item.active {
  border-color: rgba(0, 122, 255, .5);
  background: var(--blue-soft);
}

.mutual-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mutual-item button {
  min-height: 34px;
  padding: 6px 10px;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: minmax(460px, 1fr) 340px 330px;
  }
}

@media (max-width: 1040px) {
  body {
    overflow: auto;
  }

  .workspace,
  .records-view {
    height: auto;
    min-height: calc(100vh - 74px);
    overflow: visible;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: 620px;
  }
}

@media (max-width: 680px) {
  .topbar {
    height: auto;
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .records-toolbar,
  .record-card,
  .listen-tools,
  .annotation-actions,
  .report-actions,
  .create-grid,
  .advanced-grid,
  .create-options {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 8px;
  }

  .player-controls {
    grid-template-columns: repeat(4, 1fr);
  }

  .time {
    grid-column: span 2;
  }
}
