:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1c2024;
  --muted: #6b7280;
  --line: #e4e7eb;
  --brand: #1f6f6b;
  --brand-soft: #e8f2f1;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #116b3d;
  --ok-soft: #e7f5ed;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e6efee, transparent 60%), var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: .5px; }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,107,.12); }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 9px 16px;
  color: var(--ink);
  transition: .15s;
}
.btn:hover { background: #f4f6f7; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #18605c; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }

/* ---------- app shell ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: .4px; }
.brand small { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.topbar .spacer { flex: 1; }
.user { color: var(--muted); font-size: 13px; }

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 300px;
  flex: 0 0 300px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sidebar .grow { flex: 1; overflow: auto; min-height: 0; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); letter-spacing: .6px; margin-bottom: 10px;
}
.device {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c6ccd2; flex: 0 0 8px; }
.dot.on { background: #1f9d55; box-shadow: 0 0 0 3px rgba(31,157,85,.14); }
.device .name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device .when { color: var(--muted); font-size: 11px; }

.session-item {
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 4px;
}
.session-item:hover { background: #f6f8f8; }
.session-item.active { background: var(--brand-soft); border-color: #cfe3e1; }
.session-item .line1 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.session-item .code { font-weight: 600; font-size: 13px; }
.session-item .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #eef1f4; color: #4b5563; white-space: nowrap;
}
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.ended { background: #eef1f4; color: #4b5563; }
.pill.created { background: var(--warn-soft); color: var(--warn); }
.pill.transcribed { background: var(--brand-soft); color: var(--brand); }
.pill.signed { background: var(--ok-soft); color: var(--ok); }
.pill.draft { background: var(--warn-soft); color: var(--warn); }

.main { flex: 1; min-width: 0; overflow: auto; }
.empty {
  height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 13px;
}
.detail { padding: 22px 26px 60px; max-width: 1100px; }
.detail-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; font-size: 19px; letter-spacing: .3px; }
.detail-head .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.tabs { display: flex; gap: 4px; margin: 18px 0 16px; border-bottom: 1px solid var(--line); }
.tab {
  border: none; background: none; padding: 9px 14px; color: var(--muted); font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 14px; letter-spacing: .3px; }
.card .muted { color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 980px) { .grid2 { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.banner {
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px;
  border: 1px solid transparent;
}
.banner.warn { background: var(--warn-soft); border-color: #f3d9ae; color: #8a4b0f; }
.banner.danger { background: var(--danger-soft); border-color: #f6c9c4; color: #8a1f14; }
.banner.ok { background: var(--ok-soft); border-color: #bfe3cf; color: #0f5c34; }
.banner.info { background: #eef3f9; border-color: #d5e2f0; color: #26496f; }

.transcript { display: flex; flex-direction: column; gap: 6px; }
.seg { display: flex; gap: 10px; padding: 7px 8px; border-radius: 8px; }
.seg:hover { background: #f7f9f9; }
.seg .time { flex: 0 0 44px; color: #9aa3ab; font-size: 11px; padding-top: 3px; font-variant-numeric: tabular-nums; }
.seg .text { flex: 1; font-size: 13.5px; }
.role {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  font-size: 11px; padding: 2px 9px; flex: 0 0 auto; height: 22px; margin-top: 1px;
}
.role.counselor { background: var(--brand-soft); border-color: #cfe3e1; color: var(--brand); }
.role.client { background: #f3f0ff; border-color: #ddd6f3; color: #5b45a8; }
.role.unknown { color: var(--muted); }

textarea.report {
  width: 100%; min-height: 320px; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; line-height: 1.75; font-size: 13px; resize: vertical; background: #fcfcfd;
}
.section-list { display: flex; flex-direction: column; gap: 12px; }
.section-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.section-block.missing { border-color: #f0c9a8; background: var(--warn-soft); }
.section-block h4 { margin: 0 0 6px; font-size: 13px; }
.section-block .body { white-space: pre-wrap; font-size: 13px; color: #2b3036; }
.section-block .body:empty::before { content: "本段未生成"; color: var(--warn); }

.report-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.link-box {
  display: flex; gap: 8px; align-items: center; background: #f7f9f9;
  border: 1px dashed var(--line); border-radius: 9px; padding: 8px 10px; font-size: 12px;
}
.link-box input { flex: 1; border: none; background: transparent; font-size: 12px; color: var(--muted); }

dialog {
  border: none; border-radius: 16px; padding: 0; width: min(520px, 92vw);
  box-shadow: 0 24px 60px rgba(16,24,40,.18);
}
dialog::backdrop { background: rgba(17,24,39,.35); }
.dialog-body { padding: 24px 24px 20px; }
.dialog-body h3 { margin: 0 0 16px; font-size: 17px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 24px 22px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: #374151; margin-bottom: 9px; }
.check input { margin-top: 3px; }
.pair-code {
  font: 600 40px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 10px; text-align: center; padding: 18px 0 8px; color: var(--brand);
}
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px);
  background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

.log { font: 12px/1.7 ui-monospace, Menlo, monospace; color: var(--muted); white-space: pre-wrap; }

/* ---------- v0.2：导航 / 看板 / 风险 ---------- */
.nav { display: flex; gap: 2px; margin-left: 18px; }
.nav-btn {
  border: none; background: none; padding: 7px 12px; border-radius: 8px;
  color: var(--muted); font-size: 13px; position: relative;
}
.nav-btn:hover { background: #f4f6f7; color: var(--ink); }
.nav-btn.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px;
  padding: 0 4px; margin-left: 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10px; text-align: center;
}
.site-select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  background: #fff; font-size: 13px; margin-right: 12px; max-width: 180px;
}
.detail.wide { max-width: 1280px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 1100px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { font-size: 26px; font-weight: 600; letter-spacing: .5px; margin: 4px 0 2px; }
.metric-sub { color: var(--muted); font-size: 11.5px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 10px; border-bottom: 1px solid #f0f2f4; }
.table tr:last-child td { border-bottom: none; }
.judgment { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fcfcfd; }
.judgment .jtitle { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.jactions { display: flex; gap: 8px; margin-top: 10px; }
.risk-card .body { margin: 8px 0; font-size: 13.5px; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
