:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent: #1e3a8a;
  --accent-hover: #172e6e;
  --accent-soft: #eef2ff;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.18);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --g-tax: #dc2626;
  --g-fin: #7c3aed;
  --g-id: #2563eb;
  --g-loc: #0891b2;
  --g-contact: #d97706;
  --g-date: #059669;
  --g-other: #64748b;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  height: 62px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: #0f172a; color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px; letter-spacing: -0.03em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: -0.01em; }
.brand-text small { color: var(--muted); font-size: 11.5px; }
.topnav { display: flex; gap: 4px; }
.navlink {
  border: 0; background: none; padding: 8px 12px; border-radius: 8px;
  color: var(--muted); font-weight: 500; cursor: pointer;
}
.navlink:hover { background: var(--surface-2); color: var(--text); }
.navlink.is-active { color: var(--accent); background: var(--accent-soft); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 650; font-size: 12px;
  text-transform: uppercase; border: 1px solid #dbe3f8;
}

/* ------------------------------------------------------------------ bits */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  padding: 9px 14px; font-weight: 550; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; }

.pill svg { width: 13px; height: 13px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.pill-quiet { background: #f1f5f9; }
.pill-ok { background: var(--ok-soft); border-color: #bbf7d0; color: var(--ok); }
.pill-warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.pill-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-head { padding: 16px 18px 0; }
.card-body { padding: 16px 18px; }

input[type="text"], input[type="search"], select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 9px 11px; background: var(--surface); width: 100%;
  outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  border-color: #93a7d8; box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.10);
}
label.field { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

/* ------------------------------------------------------------------ home */
.app { min-height: calc(100vh - 62px); }
.home { max-width: 1120px; margin: 0 auto; padding: 34px 24px 60px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; flex-wrap: wrap; }
.hero > div:first-child { flex: 1 1 520px; min-width: 0; }
.hero h1 { font-size: 27px; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin-top: 6px; max-width: 640px; }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; }
.hero-badges .pill { white-space: nowrap; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.dropzone {
  position: relative; border: 1.5px dashed #c3cfe3; border-radius: 14px;
  background: linear-gradient(180deg, #fbfcfe 0%, #f5f8fd 100%);
  padding: 40px 28px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); background: #f2f6ff; }
.dropzone.is-drag { transform: scale(0.995); }
.dropzone-icon {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 14px;
  background: #fff; border: 1px solid var(--border); display: grid; place-items: center;
  box-shadow: var(--shadow-sm); color: var(--accent);
}
.dropzone-icon svg { width: 24px; height: 24px; }
.dropzone h3 { font-size: 16px; }
.dropzone p { color: var(--muted); margin-top: 5px; font-size: 13px; }
.dropzone .browse { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.file-types { margin-top: 14px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

.file-card {
  display: flex; align-items: center; gap: 13px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow-sm); margin-top: 14px; text-align: left;
}
.file-icon {
  width: 40px; height: 40px; border-radius: 9px; background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 11px;
  flex: 0 0 auto;
}
.file-name { font-weight: 600; word-break: break-all; }
.file-meta { color: var(--muted); font-size: 12.5px; }

.context-card .card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.context-card h3 { font-size: 15px; }
.chip-field { margin-bottom: 13px; }
.chips {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 8px;
  border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface);
  min-height: 42px; align-items: center; cursor: text;
}
.chips:focus-within { border-color: #93a7d8; box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.10); }
.chips input { border: 0; box-shadow: none; padding: 3px 2px; width: 90px; flex: 1; min-width: 90px; background: transparent; }
.chips input:focus { box-shadow: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; background: #eef2f7;
  border: 1px solid #dfe6ef; border-radius: 999px; padding: 2px 8px 2px 9px;
  font-size: 12.5px; font-weight: 500; max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--danger); }
.chip-add { border: 1px dashed var(--border-strong); background: transparent; color: var(--muted); cursor: pointer; border-radius: 999px; padding: 3px 9px; font-size: 12.5px; }

.recent { margin-top: 30px; }
.recent-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.recent-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.recent-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 16px; align-items: center;
  background: var(--surface); padding: 12px 16px; cursor: pointer;
}
.recent-row:hover { background: var(--surface-2); }
.recent-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { color: var(--muted); font-size: 12.5px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* -------------------------------------------------------------- processing */
.processing {
  max-width: 560px; margin: 60px auto; text-align: center;
}
.spinner {
  width: 46px; height: 46px; border-radius: 50%; margin: 0 auto 18px;
  border: 3px solid #dbe3ef; border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-steps { display: flex; flex-direction: column; gap: 10px; margin: 26px auto 0; max-width: 380px; text-align: left; }
.progress-step { display: flex; align-items: center; gap: 10px; color: var(--muted-2); font-size: 13px; }
.progress-step .dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; font-size: 10px; }
.progress-step.is-done { color: var(--text); }
.progress-step.is-done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.progress-step.is-active { color: var(--accent); font-weight: 600; }
.progress-step.is-active .dot { border-color: var(--accent); }

/* ----------------------------------------------------------------- review */
.review { display: flex; flex-direction: column; height: calc(100vh - 62px); }
.review-toolbar {
  height: 56px; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.review-title { min-width: 0; }
.review-title h2 { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.review-title .meta { color: var(--muted); font-size: 12px; }
.review-toolbar .spacer { flex: 1; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.segmented button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 7px;
  font-size: 12.5px; font-weight: 550; color: var(--muted); cursor: pointer;
}
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.workspace { flex: 1; display: grid; grid-template-columns: 148px minmax(0, 1fr) 392px; min-height: 0; }

.pages-rail {
  border-right: 1px solid var(--border); background: #fbfcfe; overflow-y: auto; padding: 14px 10px;
}
.rail-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); font-weight: 700; padding: 0 6px 8px; }
.page-thumb {
  border: 1.5px solid transparent; border-radius: 8px; padding: 4px; cursor: pointer;
  margin-bottom: 8px; background: transparent; display: block; width: 100%; text-align: center;
}
.page-thumb img { width: 100%; border: 1px solid var(--border); border-radius: 4px; display: block; background: #fff; }
.page-thumb .num { font-size: 11px; color: var(--muted); margin-top: 3px; }
.page-thumb:hover { background: #f1f5fb; }
.page-thumb.is-active { border-color: var(--accent); background: #eef2ff; }
.page-thumb.is-active .num { color: var(--accent); font-weight: 650; }
.section-list { display: flex; flex-direction: column; gap: 2px; }
.section-item { padding: 7px 8px; border-radius: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.section-item:hover { background: #f1f5fb; color: var(--text); }

.canvas-wrap { min-width: 0; overflow: auto; background: #eef1f6; position: relative; }
.canvas-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: rgba(238, 241, 246, 0.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid #e2e7ef;
}
.canvas-toolbar .spacer { flex: 1; }
.zoom-label { font-size: 12px; color: var(--muted); min-width: 42px; text-align: center; }
.canvas { padding: 22px 22px 60px; display: flex; justify-content: center; }
.page-stage { position: relative; background: #fff; box-shadow: var(--shadow); border-radius: 3px; }
.page-stage img { display: block; width: 100%; border-radius: 3px; }
.page-stage .overlay { position: absolute; inset: 0; }
.hl {
  position: absolute; border-radius: 2px; cursor: pointer;
  background: rgba(37, 99, 235, 0.16);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.55);
  transition: background 0.1s, box-shadow 0.1s;
}
.hl:hover { background: rgba(37, 99, 235, 0.26); }
.hl.is-selected { background: rgba(37, 99, 235, 0.3); box-shadow: inset 0 0 0 2px #1d4ed8, 0 0 0 3px rgba(29, 78, 216, 0.15); }
.hl.is-off { background: rgba(100, 116, 139, 0.06); box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.35); }
.hl.g-tax_id { background: rgba(220, 38, 38, 0.14); box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.6); }
.hl.g-financial { background: rgba(124, 58, 237, 0.13); box-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.55); }
.hl.g-identity { background: rgba(37, 99, 235, 0.14); box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.55); }
.hl.g-location { background: rgba(8, 145, 178, 0.13); box-shadow: inset 0 0 0 1px rgba(8, 145, 178, 0.5); }
.hl.g-contact { background: rgba(217, 119, 6, 0.13); box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.55); }
.hl.g-date { background: rgba(5, 150, 105, 0.13); box-shadow: inset 0 0 0 1px rgba(5, 150, 105, 0.5); }
.hl.is-selected { outline: 2px solid #1d4ed8; outline-offset: 1px; }

.page-empty { color: var(--muted); text-align: center; padding: 80px 20px; }

.text-doc {
  background: #fff; box-shadow: var(--shadow); border-radius: 4px;
  padding: 42px 48px; max-width: 780px; width: 100%;
  font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word;
}
.text-doc .unit { margin-bottom: 12px; }
.text-doc .unit-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); margin-bottom: 3px; }
.text-doc mark {
  background: rgba(37, 99, 235, 0.15); color: inherit; border-radius: 2px;
  padding: 1px 1px; cursor: pointer; box-shadow: inset 0 -1px 0 rgba(37, 99, 235, 0.6);
}
.text-doc mark.g-tax_id { background: rgba(220, 38, 38, 0.14); box-shadow: inset 0 -1px 0 rgba(220, 38, 38, 0.65); }
.text-doc mark.g-financial { background: rgba(124, 58, 237, 0.13); box-shadow: inset 0 -1px 0 rgba(124, 58, 237, 0.6); }
.text-doc mark.g-location { background: rgba(8, 145, 178, 0.13); box-shadow: inset 0 -1px 0 rgba(8, 145, 178, 0.6); }
.text-doc mark.g-contact { background: rgba(217, 119, 6, 0.14); box-shadow: inset 0 -1px 0 rgba(217, 119, 6, 0.6); }
.text-doc mark.is-off { background: transparent; box-shadow: inset 0 -1px 0 rgba(100, 116, 139, 0.5); color: var(--muted); }
.text-doc mark.is-selected { outline: 2px solid #1d4ed8; outline-offset: 1px; background: rgba(37, 99, 235, 0.28); }

.sel-toolbar {
  position: fixed; z-index: 60; background: #0f172a; color: #fff; border-radius: 9px;
  box-shadow: var(--shadow-lg); padding: 6px; display: flex; align-items: center; gap: 6px;
  transform: translate(-50%, -100%);
}
.sel-toolbar select {
  width: auto; background: #1e293b; color: #fff; border-color: #334155; padding: 5px 7px; font-size: 12px;
}
.sel-toolbar button { background: #fff; color: #0f172a; border: 0; border-radius: 6px; padding: 5px 9px; font-size: 12px; font-weight: 650; cursor: pointer; }
.sel-toolbar .arrow { position: absolute; bottom: -5px; left: 50%; width: 10px; height: 10px; background: #0f172a; transform: translateX(-50%) rotate(45deg); }

/* ------------------------------------------------------------------ panel */
.panel { border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.panel-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 12px; flex: 0 0 auto; }
.panel-tab {
  border: 0; background: none; padding: 13px 10px 11px; font-size: 13px; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer;
}
.panel-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.panel-tab .count { background: #eef2f7; color: var(--muted); border-radius: 999px; padding: 1px 6px; font-size: 11px; margin-left: 5px; }
.panel-body { overflow-y: auto; flex: 1; min-height: 0; }
.panel-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-2); margin-bottom: 10px; }

.summary-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 124px; overflow-y: auto; padding-right: 2px; }
.summary-chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 999px; padding: 4px 9px; font-size: 12px; cursor: pointer;
}
.summary-chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.summary-chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.summary-chip.is-off { opacity: 0.45; text-decoration: line-through; }
.summary-chip:hover { border-color: var(--border-strong); }

.det-list { display: flex; flex-direction: column; }
.det-row {
  display: flex; gap: 9px; padding: 10px 14px; border-bottom: 1px solid #f1f4f8;
  cursor: pointer; align-items: flex-start;
}
.det-row:hover { background: var(--surface-2); }
.det-row.is-selected { background: var(--accent-soft); }
.det-row.is-off { opacity: 0.5; }
.det-row .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; }
.det-main { min-width: 0; flex: 1; }
.det-title { display: flex; align-items: center; gap: 7px; }
.det-title code { font-size: 12px; font-weight: 650; color: var(--text); }
.det-title .conf { font-size: 10.5px; color: var(--muted-2); }
.det-text { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.det-meta { color: var(--muted-2); font-size: 10.5px; margin-top: 2px; }
.det-actions { display: flex; gap: 2px; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted-2); padding: 4px; border-radius: 6px;
  cursor: pointer; line-height: 0;
}
.icon-btn:hover { background: #eef2f7; color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }
.det-detail { padding: 10px 14px 14px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.det-detail label { font-size: 11px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 4px; }
.det-detail .row { display: flex; gap: 8px; align-items: center; }
.det-detail .orig { font-family: var(--mono); font-size: 12px; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; word-break: break-all; margin-bottom: 8px; }

.add-term { display: flex; gap: 6px; }
.add-term input { flex: 1; }
.add-term select { width: 120px; flex: 0 0 auto; }

.leak-card svg { width: 15px; height: 15px; vertical-align: -2px; }
.leak-card { border-radius: 9px; padding: 10px 12px; font-size: 12.5px; }
.leak-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #bbf7d0; }
.leak-bad { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

.actionbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: var(--surface); border-top: 1px solid var(--border);
}
.actionbar .summary { color: var(--muted); font-size: 12.5px; }
.actionbar .spacer { flex: 1; }

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 80; padding: 24px;
  animation: fade 0.12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
}
.modal.wide { width: min(760px, 100%); }
.modal-head { padding: 20px 22px 0; }
.modal-head h2 { font-size: 18px; }
.modal-head p { color: var(--muted); margin-top: 5px; font-size: 13px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-close { position: absolute; top: 14px; right: 16px; }
.modal-wrap { position: relative; }

.format-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.format-option {
  display: flex; gap: 9px; align-items: flex-start; border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 12px; cursor: pointer;
}
.format-option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.format-option input { margin-top: 2px; }
.format-option .t { font-weight: 600; font-size: 13px; }
.format-option .d { color: var(--muted); font-size: 11.5px; }

.dest-box svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted); }
.dest-box {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 12.5px;
  color: var(--muted); word-break: break-all;
}
.checkline { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; margin-top: 14px; }
.checkline input { margin-top: 3px; }

.result-file {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 9px; margin-bottom: 8px;
}
.result-file .ext { width: 38px; height: 38px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.result-file .name { font-weight: 600; font-size: 13px; word-break: break-all; }
.result-file .path { color: var(--muted); font-size: 11.5px; word-break: break-all; }
.result-file .btn { margin-left: auto; }

.findings { margin: 10px 0 0; padding: 0; list-style: none; max-height: 180px; overflow-y: auto; }
.findings li { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed #f0d5d5; font-size: 12px; }
.findings .ftype { font-weight: 600; }
.findings .fsample { font-family: var(--mono); color: var(--muted); }

.help-section { margin-bottom: 18px; }
.help-section h3 { font-size: 14px; margin-bottom: 6px; }
.help-section p, .help-section li { color: var(--muted); font-size: 13px; }
.help-section ol, .help-section ul { margin: 6px 0 0; padding-left: 20px; }
.help-section li { margin-bottom: 4px; }
.kbd { font-family: var(--mono); font-size: 11.5px; background: #f1f5f9; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 9px;
  font-size: 13px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s; z-index: 100; max-width: 90vw;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: #991b1b; }

.empty-state { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty-state svg { width: 30px; height: 30px; color: var(--muted-2); margin-bottom: 8px; }

/* --------------------------------------------------------------- login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: #eef1f6; }
.login-card { width: min(400px, 92vw); background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; margin: 22px 0 6px; }
.login-card form { margin-top: 18px; display: flex; flex-direction: column; gap: 13px; }
.login-card label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.alert { border-radius: 8px; padding: 9px 11px; font-size: 12.5px; margin-top: 12px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 120px minmax(0, 1fr) 340px; }
}
@media (max-width: 980px) {
  .home-grid { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: minmax(0, 1fr) 320px; }
  .pages-rail { display: none; }
}
@media (max-width: 760px) {
  .topnav { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .panel { position: fixed; inset: auto 0 0 0; height: 55vh; z-index: 30; border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); }
  .review-toolbar .meta { display: none; }
  .text-doc { padding: 24px 20px; }
}

/* ------------------------------------------------------------------ dashboard */
.dash { max-width: 1180px; margin: 0 auto; padding: 24px 28px 0; }
.dash .hero { margin-bottom: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 15px; box-shadow: var(--shadow-sm); }
.stat-card .stat-label { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.stat-card .stat-note { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.stat-card.is-accent { background: linear-gradient(180deg, #0f1b2d, #16233a); border-color: #16233a; color: #fff; }
.stat-card.is-accent .stat-label, .stat-card.is-accent .stat-note { color: #9fb0c9; }
.stat-card.is-warn .stat-value { color: #b45309; }
.stat-card.is-ok .stat-value { color: #0f766e; }

.dash-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; margin-bottom: 16px; }
.dash-grid.wide-left { grid-template-columns: 1.3fr .7fr; }
.dash-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.dash-card .card-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dash-card .card-head h3 { font-size: 14px; }
.dash-card .card-body { padding: 16px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 148px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar-stack { width: 100%; height: 120px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar { width: 9px; border-radius: 3px 3px 0 0; transition: height .3s ease; }
.bar-doc { background: #1f3a5f; }
.bar-exp { background: #0f766e; }
.bar-label { font-size: 10px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.type-row { display: grid; grid-template-columns: 132px 1fr 42px; align-items: center; gap: 10px; padding: 6px 0; }
.type-row .t { font-size: 12.5px; color: var(--ink-2); }
.type-track { display: block; height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.type-fill { display: block; height: 100%; background: linear-gradient(90deg, #1f3a5f, #3d6491); border-radius: 99px; }
.type-row .n { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mini th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; padding: 0 8px 8px 0; border-bottom: 1px solid var(--line); }
table.mini td { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--line-2); }
table.mini tr:last-child td { border-bottom: 0; }
table.mini td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.mini .client-name { font-weight: 600; }

.feed { display: flex; flex-direction: column; gap: 2px; }
.feed-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.feed-item:last-child { border-bottom: 0; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; background: #1f3a5f; }
.feed-dot.ok { background: #0f766e; }
.feed-dot.warn { background: #b45309; }
.feed-main { min-width: 0; flex: 1; }
.feed-title { font-size: 12.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.dash-foot { display: flex; flex-wrap: wrap; gap: 18px; font-size: 11.5px; color: var(--muted); padding: 4px 2px 24px; }
.dash-empty { text-align: center; padding: 40px 20px; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-grid, .dash-grid.wide-left { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.client-row { margin-bottom: 18px; }
.client-row .input { width: 100%; margin: 6px 0 5px; }
.field-label { display: block; }

/* ---------------------------------------------------------------- tier 1-3 */
.page { max-width: 1180px; margin: 0 auto; padding: 34px 28px 80px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 6px; color: var(--text); }
.page-head p { margin: 0; max-width: 640px; font-size: 13.5px; line-height: 1.55; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.client-picker { display: grid; grid-template-columns: 1fr; gap: 6px; }
.client-picker > * { min-width: 0; }
.client-picker select.input { text-overflow: ellipsis; }
.client-row .tiny.muted { margin-top: 4px; line-height: 1.4; }
.client-name { font-weight: 600; color: var(--text); }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th { text-align: left; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted-2); font-weight: 700; padding: 10px 10px; border-bottom: 1px solid var(--border); }
table.mini td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini .num { text-align: right; font-variant-numeric: tabular-nums; }

.dropzone-sm { padding: 22px 16px; }
.dropzone-sm h3 { font-size: 14px; margin: 6px 0 2px; }
.dropzone-sm p { font-size: 12px; margin: 0; }
.progress { height: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #3b6fd4); border-radius: 999px; transition: width .4s ease; }

.checkrow { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }
.check input { accent-color: var(--accent); }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.45; margin-top: 14px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.checkline input { margin-top: 2px; accent-color: var(--accent); }

.rec-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rec-row:last-child { border-bottom: 0; }
.rec-name { font-weight: 600; font-size: 13.5px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.rec-name .ph { font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 6px; border-radius: 5px; }
.rec-row code { font-family: var(--mono); font-size: 11px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }
.rec-actions { display: flex; align-items: center; gap: 8px; }
.policy-row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.policy-row:last-child { border-bottom: 0; }
.policy-row strong { font-weight: 600; }
.test-box { margin-top: 14px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.bad { color: var(--danger); }
.good { color: var(--ok); font-weight: 600; }

.modal-wide { max-width: 760px; }
.modal textarea.input { font-family: var(--font); resize: vertical; }
.modal .input.mono, .input.mono { font-family: var(--mono); font-size: 12px; }

.approval-strip { display: flex; align-items: center; gap: 12px; padding: 10px 22px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; }
.approval-strip.is-pending { background: var(--warn-soft); border-top-color: #fde68a; }
.approval-strip.is-approved { background: var(--ok-soft); border-top-color: #a7f3d0; }
.approval-badge { font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); }
.approval-strip.is-approved .approval-badge { color: var(--ok); }
.approval-strip:not(.is-pending):not(.is-approved) .approval-badge { color: var(--muted); }
.approval-meta { color: var(--muted); }
.fx-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.fx-actions .btn.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.triage-chips { display: flex; gap: 6px; padding: 9px 14px 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px; cursor: pointer; }
.chip span { font-variant-numeric: tabular-nums; color: var(--muted-2); margin-left: 3px; }
.chip:hover { border-color: var(--border-strong); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.is-active span { color: rgba(255,255,255,.75); }

.draw-layer { position: absolute; inset: 0; cursor: crosshair; z-index: 6; }
.draw-rect { position: absolute; border: 1.5px dashed var(--accent); background: rgba(30, 58, 138, .12); pointer-events: none; }
.hl.is-region { outline: 1.5px dashed rgba(30, 58, 138, .8); outline-offset: -1px; background: rgba(30, 58, 138, .10); }

/* form fields used by modals and the batch/client screens */
.field { display: block; margin: 0 0 12px; }
.field > span, .field > label, .field > .field-label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
.field .input, .field input.input, .field select.input, .field textarea.input { width: 100%; }
.field .tiny { margin-top: 4px; }
.field .checkrow { margin-top: 2px; }

/* review layout hardening: never let the page overflow its column */
.page-stage { max-width: 100%; }
.actionbar { flex-wrap: wrap; row-gap: 8px; height: auto; min-height: 58px; padding-top: 10px; padding-bottom: 10px; }
.fx-actions .btn { white-space: nowrap; }
@media (max-width: 1280px) {
  .workspace { grid-template-columns: 116px minmax(0, 1fr) 340px; }
  .review-title h2 { max-width: 260px; }
}
@media (max-width: 1020px) {
  .workspace { grid-template-columns: 96px minmax(0, 1fr) 300px; }
  .fx-actions { order: 3; width: 100%; }
}
