:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f0f3f5;
  --surface-blue: #edf4ff;
  --ink: #1d242c;
  --ink-strong: #111820;
  --muted: #65707a;
  --faint: #8a949d;
  --line: #dfe4e8;
  --line-strong: #c7d0d7;
  --accent: #2468d8;
  --accent-dark: #194eac;
  --accent-soft: #e8f0ff;
  --green: #1c805f;
  --green-soft: #e4f4ed;
  --amber: #9a641a;
  --amber-soft: #fff2da;
  --red: #b33c45;
  --red-soft: #fbe9eb;
  --purple: #7356ad;
  --purple-soft: #eee9f8;
  --shadow: 0 12px 32px rgba(25, 36, 48, 0.08);
  --radius: 8px;
  --sidebar: 250px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { color: var(--ink-strong); letter-spacing: 0; }
svg { display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(140deg, #f6f7f9 0%, #edf3f6 100%); }
.login-panel { width: min(100%, 430px); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 38px; border-radius: var(--radius); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid var(--ink-strong); background: var(--ink-strong); color: white; font-family: Georgia, serif; font-size: 24px; line-height: 1; }
.brand-mark.small { width: 34px; height: 34px; font-size: 18px; flex: 0 0 34px; }
.eyebrow { margin-top: 22px; color: var(--accent); font-size: 11px; line-height: 1.3; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase; }
.login-panel h1 { margin-top: 10px; font-size: 30px; line-height: 1.16; }
.login-copy { margin-top: 12px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.stack-form { display: grid; gap: 16px; margin-top: 26px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span, .field-label { color: var(--ink-strong); font-size: 12px; font-weight: 700; }
.field small { color: var(--faint); font-size: 11px; line-height: 1.55; }
input, textarea, select { width: 100%; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; outline: none; transition: border-color .16s, box-shadow .16s, background .16s; }
input, select { min-height: 40px; padding: 0 12px; }
textarea { min-height: 130px; padding: 12px; line-height: 1.65; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 104, 216, .12); }
input::placeholder, textarea::placeholder { color: #a2abb2; }
.form-error { margin-top: 15px; color: var(--red); background: var(--red-soft); border: 1px solid #f1c8cc; border-radius: 6px; padding: 10px 12px; font-size: 12px; line-height: 1.5; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fafbfc; padding: 24px 16px 16px; z-index: 20; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { min-width: 0; display: grid; gap: 3px; }
.brand-text strong { color: var(--ink-strong); font-size: 13px; white-space: nowrap; }
.brand-text small { color: var(--faint); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-nav { display: grid; gap: 4px; margin-top: 36px; }
.nav-item { width: 100%; min-height: 40px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); padding: 0 11px; text-align: left; font-size: 13px; transition: background .16s, color .16s; }
.nav-item svg { width: 17px; height: 17px; stroke-width: 1.8; flex: 0 0 17px; }
.nav-item:hover { background: var(--surface-soft); color: var(--ink-strong); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 750; }
.nav-count { min-width: 20px; height: 20px; display: grid; place-items: center; margin-left: auto; border-radius: 10px; background: var(--accent); color: white; font-size: 10px; }
.sidebar-bottom { display: grid; gap: 12px; margin-top: auto; }
.sync-status { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 11px; padding: 0 11px; }
.status-dot { width: 7px; height: 7px; display: inline-block; flex: 0 0 7px; border-radius: 50%; background: var(--amber); }
.status-dot.ok { background: var(--green); }
.status-dot.error { background: var(--red); }
.logout-item { border-top: 1px solid var(--line); border-radius: 0; padding-top: 13px; }
.main-content { min-width: 0; }
.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(246, 247, 249, .92); }
.breadcrumb { min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12px; }
.breadcrumb svg { width: 14px; height: 14px; }
.breadcrumb strong { color: var(--ink-strong); font-weight: 750; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.private-pill { display: inline-flex; align-items: center; gap: 5px; color: var(--green); background: var(--green-soft); border: 1px solid #cbe7da; padding: 6px 9px; border-radius: 5px; font-size: 11px; white-space: nowrap; }
.private-pill svg { width: 13px; height: 13px; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); }
.icon-button:hover { color: var(--ink-strong); border-color: var(--line); background: var(--surface); }
.icon-button svg { width: 17px; height: 17px; }
.mobile-only { display: none; }
.view-root { width: min(100%, 1480px); margin: 0 auto; padding: 34px; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.view-head h1 { font-size: 25px; line-height: 1.25; }
.view-head p { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.view-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 0 13px; font-size: 12px; font-weight: 700; white-space: nowrap; transition: background .16s, border-color .16s, color .16s; }
.button svg { width: 15px; height: 15px; }
.button:hover { border-color: #9ca9b4; background: var(--surface-soft); }
.button-primary { border-color: var(--accent); background: var(--accent); color: white; }
.button-primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.button-secondary { background: var(--surface-blue); border-color: #c9dcfb; color: var(--accent-dark); }
.button-danger { background: var(--red-soft); border-color: #f0c7cc; color: var(--red); }
.button-quiet { color: var(--muted); background: transparent; }
.button-wide { width: 100%; }
.button-small { min-height: 31px; padding: 0 9px; font-size: 11px; }
.button:focus-visible, .icon-button:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 18px; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel.pad { padding: 22px; }
.panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-title h2, .panel-title h3 { font-size: 16px; line-height: 1.3; }
.panel-title p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.capture-panel { background: linear-gradient(145deg, #ffffff, #f6f9fc); }
.capture-panel textarea { min-height: 220px; margin-top: 18px; border-color: #cad8e5; background: rgba(255, 255, 255, .82); }
.capture-options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.capture-submit-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.helper-text { color: var(--faint); font-size: 11px; line-height: 1.45; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 17px; }
.stat-label { color: var(--muted); font-size: 11px; }
.stat-value { display: block; margin-top: 8px; color: var(--ink-strong); font-size: 25px; font-weight: 780; line-height: 1; }
.stat-value.accent { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }
.dashboard-side { display: grid; gap: 18px; }
.model-card { min-height: 142px; }
.model-state { margin-top: 18px; display: flex; align-items: center; gap: 10px; }
.model-state strong { color: var(--ink-strong); font-size: 14px; }
.model-state small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.empty { display: grid; place-items: center; min-height: 150px; padding: 24px; color: var(--muted); text-align: center; }
.empty.compact { min-height: 86px; padding: 14px; }
.empty svg { width: 25px; height: 25px; margin-bottom: 10px; color: var(--faint); }
.empty strong { display: block; color: var(--ink-strong); font-size: 13px; }
.empty p { margin-top: 5px; font-size: 12px; line-height: 1.55; }
.list { display: grid; }
.list-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row.stale { background: #fffaf0; }
.list-main { min-width: 0; }
.list-main strong { display: block; overflow: hidden; color: var(--ink-strong); font-size: 13px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.list-main small { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.list-main .ai-run-line { color: var(--faint); }
.list-meta { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; flex: 0 0 auto; }
.tag, .status-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }
.tag.warning { background: var(--amber-soft); border-color: #efdcba; color: var(--amber); }
.status-badge.current, .status-badge.approved, .status-badge.accepted, .status-badge.succeeded, .status-badge.healthy { background: var(--green-soft); border-color: #cce6d9; color: var(--green); }
.status-badge.review, .status-badge.pending, .status-badge.edited, .status-badge.analyzing, .status-badge.running { background: var(--amber-soft); border-color: #efdcba; color: var(--amber); }
.status-badge.historical, .status-badge.compact { background: var(--purple-soft); border-color: #ddd2f0; color: var(--purple); }
.status-badge.failed, .status-badge.rejected, .status-badge.archived, .status-badge.error { background: var(--red-soft); border-color: #f0c7cc; color: var(--red); }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.toolbar .search { flex: 1 1 260px; position: relative; }
.toolbar .search svg { position: absolute; top: 12px; left: 12px; width: 15px; height: 15px; color: var(--faint); }
.toolbar .search input { padding-left: 36px; }
.split-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 18px; align-items: start; }
.tree-panel { position: sticky; top: 20px; padding: 15px 10px; }
.tree-heading { padding: 0 9px 10px; color: var(--faint); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.tree-item { width: 100%; min-height: 34px; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); padding: 0 9px; text-align: left; font-size: 12px; }
.tree-item:hover, .tree-item.active { background: var(--accent-soft); color: var(--accent-dark); }
.tree-item svg { width: 14px; height: 14px; flex: 0 0 14px; }
.tree-item.child { padding-left: 28px; }
.document-list { display: grid; gap: 9px; }
.document-card { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 17px; cursor: pointer; transition: border-color .16s, box-shadow .16s, transform .16s; }
.document-card:hover, .document-card.selected { border-color: #a9c5ec; box-shadow: 0 5px 18px rgba(35, 103, 216, .08); transform: translateY(-1px); }
.document-card h3 { overflow: hidden; font-size: 15px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.document-card p { display: -webkit-box; overflow: hidden; margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.document-card .card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.document-card .card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; color: var(--faint); font-size: 10px; }
.detail-panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.detail-head { display: flex; justify-content: space-between; gap: 14px; padding: 21px; border-bottom: 1px solid var(--line); }
.detail-head h2 { font-size: 19px; line-height: 1.3; }
.detail-head p { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.detail-actions { display: flex; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.block-stack { display: grid; }
.knowledge-block { padding: 20px 21px; border-bottom: 1px solid var(--line); }
.knowledge-block:last-child { border-bottom: 0; }
.block-top { display: flex; justify-content: space-between; gap: 10px; }
.block-top h3 { min-width: 0; font-size: 14px; line-height: 1.45; }
.block-top small { color: var(--faint); font-size: 10px; }
.markdown-body { margin-top: 13px; color: #38434d; font-size: 13px; line-height: 1.75; overflow-wrap: anywhere; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 18px 0 8px; font-size: 15px; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body pre { margin: 9px 0; }
.markdown-body ul, .markdown-body ol { padding-left: 22px; }
.markdown-body code { padding: 2px 4px; border-radius: 3px; background: var(--surface-soft); font-size: 12px; }
.markdown-body pre { overflow: auto; padding: 12px; border-radius: 6px; background: #202a32; color: #e8eff3; }
.markdown-body pre code { padding: 0; background: transparent; color: inherit; }
.markdown-body blockquote { margin-left: 0; padding: 2px 0 2px 13px; border-left: 3px solid #b7cbea; color: var(--muted); }
.source-line { margin-top: 14px; color: var(--faint); font-size: 10px; }

.review-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; align-items: start; }
.review-list { position: sticky; top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.review-list .list-row { align-items: flex-start; cursor: pointer; }
.review-list .list-row.active { background: var(--accent-soft); }
.review-detail { min-width: 0; display: grid; gap: 14px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare-pane { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.compare-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); font-size: 11px; font-weight: 750; }
.compare-content { min-height: 120px; max-height: 430px; overflow: auto; padding: 14px; color: var(--muted); font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.proposal-summary { display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px; }
.info-list { display: grid; gap: 7px; }
.info-row { display: flex; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding-bottom: 7px; color: var(--muted); font-size: 11px; }
.info-row strong { color: var(--ink-strong); text-align: right; font-size: 11px; }
.operation-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.operation-card.conflict { border-color: #e6b9be; }
.operation-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 15px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.operation-card-head h3 { font-size: 13px; line-height: 1.45; }
.operation-card-head p { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.operation-card-body { padding: 15px; }
.operation-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.warning-box { display: flex; gap: 9px; padding: 12px; border: 1px solid #efdcba; border-radius: 6px; background: var(--amber-soft); color: #835615; font-size: 12px; line-height: 1.55; }
.warning-box svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }
.ai-run-stack { display: grid; gap: 0; }
.ai-run-item { display: grid; gap: 6px; padding: 13px; border-top: 1px solid var(--line); }
.ai-run-item:first-child { border-top: 0; }
.ai-run-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ai-run-head strong { color: var(--ink-strong); font-size: 12px; }
.ai-run-item small { color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.ai-run-error { color: var(--red); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }

.context-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 18px; align-items: start; }
.context-controls { position: sticky; top: 20px; padding: 18px; }
.context-controls h2 { font-size: 15px; }
.context-controls .field { margin-top: 15px; }
.check-list { display: grid; gap: 6px; max-height: 290px; overflow: auto; margin-top: 8px; }
.check-item { display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px; border-radius: 5px; color: var(--muted); font-size: 11px; line-height: 1.45; cursor: pointer; }
.check-item:hover { background: var(--surface-soft); }
.check-item input { width: 15px; height: 15px; min-height: 15px; margin: 0; flex: 0 0 15px; accent-color: var(--accent); }
.context-output { min-width: 0; }
.context-metrics { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 13px; }
.metric { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--surface); font-size: 11px; }
.metric strong { color: var(--ink-strong); }
.context-preview { min-height: 470px; max-height: 720px; overflow: auto; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.context-preview .markdown-body { margin-top: 0; max-width: 900px; }

.settings-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-nav { position: sticky; top: 20px; display: grid; gap: 4px; }
.settings-tab { min-height: 36px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); padding: 0 11px; text-align: left; font-size: 12px; }
.settings-tab:hover, .settings-tab.active { background: var(--surface); color: var(--accent-dark); box-shadow: 0 0 0 1px var(--line); }
.settings-section { display: grid; gap: 14px; }
.settings-card { padding: 19px; }
.settings-card h2 { font-size: 15px; }
.settings-card > p { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.provider-grid { display: grid; gap: 10px; margin-top: 16px; }
.provider-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 15px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
.provider-card h3 { font-size: 13px; }
.provider-card p { margin-top: 5px; color: var(--muted); font-size: 11px; }
.provider-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.provider-key-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.provider-key-row .button { min-height: 42px; }
.model-discovery { display: grid; gap: 12px; padding: 13px; border: 1px solid #c9dcfb; border-radius: 6px; background: var(--surface-blue); }
.model-discovery[hidden] { display: none; }
.model-discovery .panel-title { padding: 0; }
.model-discovery .panel-title h3 { font-size: 13px; }
.model-picker { display: grid; gap: 7px; max-height: 230px; overflow: auto; padding-right: 2px; }
.model-option { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 9px; align-items: start; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.model-option input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--accent); }
.model-option strong { display: block; color: var(--ink-strong); font-size: 12px; line-height: 1.35; }
.model-option small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.settings-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 17px; }
.settings-form-grid .full { grid-column: 1 / -1; }
.inline-check { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.inline-check input { width: 16px; height: 16px; min-height: 16px; accent-color: var(--accent); }
.table-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); color: var(--muted); text-align: left; font-size: 11px; vertical-align: middle; }
th { color: var(--faint); background: var(--surface-soft); font-size: 10px; font-weight: 750; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
td strong { color: var(--ink-strong); }
.setting-note { margin-top: 13px; padding: 11px 12px; border: 1px solid #c9dcfb; border-radius: 6px; background: var(--surface-blue); color: #345e9b; font-size: 11px; line-height: 1.6; }

.modal { width: min(100% - 28px, 700px); max-height: calc(100vh - 28px); padding: 0; border: 0; background: transparent; }
.modal::backdrop { background: rgba(17, 24, 32, .42); }
.modal-card { max-height: calc(100vh - 28px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 24px 80px rgba(10, 18, 26, .2); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-head p { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.modal-body { display: grid; gap: 14px; padding: 21px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 21px; border-top: 1px solid var(--line); background: var(--surface-soft); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; gap: 8px; width: min(360px, calc(100vw - 44px)); }
.toast { display: flex; align-items: flex-start; gap: 9px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 12px; line-height: 1.5; animation: toast-in .18s ease-out; }
.toast.ok { border-color: #cbe7da; }
.toast.error { border-color: #f0c7cc; color: var(--red); }
.toast svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.loading { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.loading::before { width: 14px; height: 14px; content: ""; display: inline-block; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  :root { --sidebar: 220px; }
  .view-root { padding: 26px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: 1fr 1fr; }
  .context-layout, .review-layout { grid-template-columns: 250px minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(290px, calc(100vw - 46px)); transform: translateX(-100%); transition: transform .2s ease; box-shadow: 18px 0 45px rgba(14, 25, 35, .12); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .topbar { padding: 0 18px; }
  .view-root { padding: 22px 18px 36px; }
  .dashboard-side { grid-template-columns: 1fr; }
  .split-layout, .review-layout, .context-layout, .settings-layout { grid-template-columns: 1fr; }
  .tree-panel, .review-list, .context-controls, .settings-nav { position: static; }
  .tree-panel { display: flex; gap: 5px; overflow-x: auto; padding: 9px; }
  .tree-heading { align-self: center; padding: 0 6px; white-space: nowrap; }
  .tree-item { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .tree-item.child { padding-left: 9px; }
  .settings-nav { display: flex; overflow-x: auto; padding-bottom: 3px; }
  .settings-tab { flex: 0 0 auto; white-space: nowrap; }
  .review-list { max-height: 280px; overflow-y: auto; }
}

@media (max-width: 620px) {
  .private-pill { display: none; }
  .view-head { display: block; }
  .view-actions { justify-content: flex-start; margin-top: 15px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .capture-options, .settings-form-grid, .two-col, .compare-grid, .proposal-summary { grid-template-columns: 1fr; }
  .provider-key-row { grid-template-columns: 1fr; align-items: stretch; }
  .capture-submit-row { align-items: stretch; flex-direction: column; }
  .capture-submit-row .button { width: 100%; }
  .list-row { align-items: flex-start; flex-direction: column; gap: 9px; }
  .list-meta { justify-content: flex-start; }
  .document-card { grid-template-columns: 1fr; }
  .document-card .card-side { align-items: flex-start; flex-direction: row; }
  .detail-head { display: block; }
  .detail-actions { justify-content: flex-start; margin-top: 14px; }
  .login-panel { padding: 28px 22px; }
  .modal { width: calc(100% - 18px); }
  .modal-body, .modal-head { padding-left: 16px; padding-right: 16px; }
  .modal-foot { padding-left: 16px; padding-right: 16px; }
}
