/* Vance CS Content Review - design system
   Style: Accessible & Ethical (WCAG-minded, healthcare).
   Palette: slate primary, blue CTA. Type: Figtree + Noto Sans
   (loaded non-blocking from index.html; falls back to system fonts offline). */

:root {
  /* ---- Vance brand palette ----
     #008080 teal · #78BFBF · #AEDBDB · #DEF4F4 · #F4FFFF
     #8E7DBE lavender · #2F4F6F navy · #708090 slate · #DDE2E6 grey */
  --brand-teal: #008080;
  --brand-teal-2: #78bfbf;
  --brand-teal-3: #aedbdb;
  --brand-mist: #def4f4;
  --brand-tint: #f4ffff;
  --brand-purple: #8e7dbe;
  --brand-navy: #2f4f6f;
  --brand-slate: #708090;
  --brand-grey: #dde2e6;

  --primary: #2f4f6f;       /* brand navy */
  --primary-dark: #243d56;
  --secondary: #708090;     /* brand slate */
  --cta: #008080;           /* brand teal */
  --cta-dark: #006a6a;
  --bg: #f4ffff;            /* brand tint */
  --surface: #ffffff;
  --surface-2: #eef7f7;     /* soft teal hover */
  --text: #213547;          /* deep navy-slate, AAA on white */
  --text-muted: #44586b;
  --text-faint: #708090;    /* brand slate */
  --border: #dde2e6;        /* brand grey */
  --border-strong: #c3ccd4;

  /* status */
  --draft: #b45309;     --draft-bg: #fffbeb;   --draft-bd:#fde68a;
  --review: #0f6f8c;    --review-bg: #e6f6fa;  --review-bd:#b6e3ee;
  --approved: #15803d;  --approved-bg:#f0fdf4; --approved-bd:#bbf7d0;

  /* severity / callouts */
  --critical:#b91c1c; --critical-bg:#fef2f2; --critical-bd:#fecaca;
  --warning:#b45309;  --warning-bg:#fffbeb;  --warning-bd:#fde68a;
  --info:#0c6b73;     --info-bg:#def4f4;     --info-bd:#aedbdb;   /* brand teal info */
  --tip:#0f766e;      --tip-bg:#f0fdfa;      --tip-bd:#99f6e4;
  --compliance:#6d5aa6; --compliance-bg:#f3f1fb; --compliance-bd:#d9d2ef; /* brand lavender */

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.14);
  --sidebar-w: 320px;
  --header-h: 70px;
  --font-head: 'Figtree', system-ui, sans-serif;
  --font-body: 'Noto Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }  /* app-shell: window never scrolls */
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
}
h1,h2,h3,h4 { font-family: var(--font-head); color: var(--text); line-height: 1.3; }
a { color: var(--cta); }
button { font-family: var(--font-body); cursor: pointer; }
:focus-visible { outline: 3px solid var(--cta); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- layout ---------- */
.app { display: grid; grid-template-rows: var(--header-h) minmax(0, 1fr); height: 100vh; }

/* ---------- Home view ---------- */
.home { max-width: 940px; }
.home-hero { text-align: center; padding: 24px 0 4px; }
.home-logo { height: 76px; width: auto; margin-bottom: 12px; }
.home-hero h1 { font-size: 32px; margin: 4px 0; color: var(--brand-navy); }
.home-desc { color: var(--text-muted); max-width: 700px; margin: 10px auto 0; font-size: 15.5px; line-height: 1.6; }
.home-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 30px; }
.home-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, transform .12s; min-height: 188px; }
.home-card:hover { border-color: var(--brand-teal-3); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.home-card-icon { display: inline-flex; color: var(--cta); background: var(--brand-mist); border-radius: 12px; padding: 11px; }
.home-card-icon svg { width: 26px; height: 26px; }
.home-card-title { font-family: var(--font-head); font-weight: 700; font-size: 19px; color: var(--brand-navy); }
.home-card-desc { color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.home-card-meta { margin-top: auto; font-size: 12px; font-weight: 700; color: var(--cta); background: var(--brand-mist); padding: 3px 10px; border-radius: 999px; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } }

/* ---------- CONTENT nav panel (sidebar card, REVIEW-style; expandable buttons) ---------- */
.nav-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; margin-bottom: 12px; box-shadow: var(--shadow); }
.nav-panel .rh-title { font-family: var(--font-head); font-weight: 700; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-navy); padding: 2px 4px 8px; }
.np-group { margin-bottom: 4px; }
.np-btn { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--brand-navy); padding: 9px 10px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.np-btn:hover { background: var(--surface-2); border-color: var(--brand-teal-3); }
.np-btn.active { border-color: var(--cta); }
.np-group.open > .np-btn { background: var(--brand-mist); border-color: var(--brand-teal-3); color: var(--cta); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.np-icon { display: inline-flex; color: var(--cta); }
.np-icon svg { width: 17px; height: 17px; }
.np-label { flex: 1; }
.np-caret { display: inline-flex; color: var(--text-faint); transition: transform .15s; }
.np-caret svg { width: 13px; height: 13px; }
.np-group.open .np-caret { transform: rotate(90deg); }
.np-menu { border: 1px solid var(--brand-teal-3); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: var(--brand-tint); padding: 6px; }
.np-viewall { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; border: 1px solid var(--brand-teal-3); background: #fff; color: var(--cta); font-size: 12.5px; font-weight: 600; padding: 6px 9px; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 4px; }
.np-viewall:hover, .np-viewall.active { background: var(--brand-mist); }
.np-viewall .caret svg { width: 14px; height: 14px; }
.np-subgroup { font-family: var(--font-head); font-weight: 700; font-size: 10.5px; letter-spacing: .03em; text-transform: uppercase; color: var(--text-faint); padding: 7px 8px 2px; }
.np-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: none; background: none; color: var(--text); font-size: 13.5px; padding: 6px 9px; border-radius: var(--radius-sm); cursor: pointer; transition: background .12s; }
.np-item:hover { background: #fff; }
.np-item.active { background: #fff; color: var(--cta); font-weight: 600; box-shadow: inset 2px 0 0 var(--cta); }
.np-item.sub { padding-left: 14px; }
.np-item .np-num { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 11.5px; min-width: 18px; flex-shrink: 0; }
.np-item.sub .np-num { min-width: 44px; }
.np-item .badge { margin-left: auto; }
.header {
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border), 0 2px 10px rgba(0,128,128,.06);
  z-index: 30;
}
.header .brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header .brand-home { border: none; background: none; padding: 0; cursor: pointer; border-radius: var(--radius-sm); }
.header .brand-home:hover .brand-text b { color: var(--cta); }
.header .brand-logo { height: 52px; width: auto; display: block; }
.header .brand-sep { width: 1px; height: 26px; background: var(--border); }
.header .brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.header .brand-text b { font-family: var(--font-head); font-weight: 700; font-size: 15px; color: var(--brand-navy); white-space: nowrap; }
.header .brand-text span { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.header .spacer { flex: 1; }
.header .savestate { font-size: 12.5px; color: var(--text-faint); display:flex; align-items:center; gap:6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--approved); display:inline-block; }
.dot.saving { background: var(--draft); }
.dot.error { background: var(--critical); }

.main { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 0; height: 100%; }

/* ---------- sidebar ---------- */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; min-height: 0; overscroll-behavior: contain; padding: 12px; }
/* subtle, unobtrusive scrollbar - only shows as a fallback on short screens */
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--brand-grey); border-radius: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar { scrollbar-width: thin; scrollbar-color: var(--brand-grey) transparent; }
.nav-group-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  border: none; background: none; color: var(--text-muted);
  font-family: var(--font-head); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em;
  padding: 7px 8px; border-radius: var(--radius-sm); transition: background .12s;
}
.nav-group-toggle:hover { background: var(--surface-2); color: var(--brand-navy); }
.nav-group-toggle .caret { display: inline-flex; transition: transform .15s; color: var(--text-faint); }
.nav-group-toggle .caret svg { width: 14px; height: 14px; }
.nav-group-toggle.open .caret { transform: rotate(90deg); }
.nav-group-toggle .badge { margin-left: auto; }
.search { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px; background: var(--surface); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.chip-toggle {
  font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-muted); transition: background .15s, color .15s, border-color .15s;
}
.chip-toggle[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.nav-group { margin-top: 8px; }
.nav-group > .nav-title {
  font-family: var(--font-head); font-weight: 700; font-size: 12px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-faint); padding: 8px 8px 4px;
}
.nav-item, .nav-sub {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: none; background: none; color: var(--text); padding: 7px 9px; border-radius: var(--radius-sm);
  font-size: 14px; transition: background .12s;
}
.nav-item:hover, .nav-sub:hover { background: var(--surface-2); }
.nav-item.active, .nav-sub.active { background: var(--brand-mist); color: var(--cta); font-weight: 600; box-shadow: inset 3px 0 0 var(--cta); }
.nav-sub { padding-left: 18px; font-size: 13.5px; }
.nav-item .num { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 12.5px; min-width: 26px; }
.nav-item .badge, .nav-sub .badge { margin-left: auto; }
.nav-caret { margin-left:auto; color: var(--text-faint); font-size: 12px; }

.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge.flag { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-bd); }
.badge.cmt { background: var(--info-bg); color: var(--info); border-color: var(--info-bd); }
.badge.count { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }

/* ---------- content ---------- */
.content { overflow-y: auto; min-height: 0; padding: 26px 30px 80px; }
.content-inner { max-width: 860px; margin: 0 auto; }
.back-bar { max-width: 860px; margin: 0 auto 10px; display: flex; }
.back-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.back-btn:hover:not(:disabled) { background: var(--brand-mist); color: var(--cta); border-color: var(--brand-teal-3); }
.back-btn:disabled { opacity: .4; cursor: not-allowed; }
.back-btn .back-ico { display: inline-flex; }
.back-btn .back-ico svg { width: 16px; height: 16px; }
.doc-head { margin-bottom: 6px; }
.doc-head h2 { margin: 0; font-size: 24px; }
.doc-head .sub { color: var(--text-muted); margin: 4px 0 0; font-size: 14px; }
.section-h { font-size: 19px; margin: 30px 0 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.section-h:first-of-type { border-top: none; }

/* block */
.block { position: relative; border: 1px solid transparent; border-radius: var(--radius); padding: 10px 12px; margin: 6px 0; transition: border-color .12s, background .12s; }
.block:hover { border-color: var(--border); background: #fff; }
.block.has-flag { border-left: 3px solid var(--warning); }
.block-tools { display: flex; align-items: center; gap: 6px; position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .12s; }
.block:hover .block-tools, .block.editing .block-tools, .block.tools-pinned .block-tools { opacity: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted);
  border-radius: var(--radius-sm); height: 28px; min-width: 28px; padding: 0 7px; font-size: 12px;
  transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { background: var(--review-bg); color: var(--review); border-color: var(--review-bd); }
.icon-btn svg { width: 15px; height: 15px; }

.block h3 { font-size: 16px; margin: 8px 0 2px; }
.block p { margin: 4px 0; }
.block ul { margin: 4px 0; padding-left: 22px; }
.block li { margin: 3px 0; }

/* callouts */
.callout { border-radius: var(--radius); padding: 12px 14px; border: 1px solid; }
.callout .c-title { font-family: var(--font-head); font-weight: 700; font-size: 13.5px; display:flex; align-items:center; gap:8px; margin-bottom: 4px; }
.callout .c-body { white-space: pre-wrap; font-size: 14px; }
.callout.info { background: var(--info-bg); border-color: var(--info-bd); }
.callout.info .c-title { color: var(--info); }
.callout.warning { background: var(--warning-bg); border-color: var(--warning-bd); }
.callout.warning .c-title { color: var(--warning); }
.callout.critical { background: var(--critical-bg); border-color: var(--critical-bd); }
.callout.critical .c-title { color: var(--critical); }
.callout.tip { background: var(--tip-bg); border-color: var(--tip-bd); }
.callout.tip .c-title { color: var(--tip); }
.callout.compliance { background: var(--compliance-bg); border-color: var(--compliance-bd); }
.callout.compliance .c-title { color: var(--compliance); }

/* script box */
.scriptbox { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.scriptbox .s-title { font-family: var(--font-head); font-weight: 700; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.scriptbox .s-body { white-space: pre-wrap; font-size: 14px; }

/* faq */
.faq .q { font-weight: 700; font-family: var(--font-head); margin-bottom: 4px; }
.faq .a { white-space: pre-wrap; }
.faq .compliance-note { margin-top: 8px; font-size: 13px; background: var(--compliance-bg); border: 1px solid var(--compliance-bd); color: var(--compliance); border-radius: var(--radius-sm); padding: 8px 10px; }
.faq .compliance-note b { font-family: var(--font-head); }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.data th, table.data td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
table.data th { background: var(--surface-2); font-family: var(--font-head); font-weight: 600; }
table.kv th { width: 32%; }

/* status pill + select */
.status-pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid; text-transform: uppercase; letter-spacing: .03em; }
.status-draft { color: var(--draft); background: var(--draft-bg); border-color: var(--draft-bd); }
.status-review { color: var(--review); background: var(--review-bg); border-color: var(--review-bd); }
.status-approved { color: var(--approved); background: var(--approved-bg); border-color: var(--approved-bd); }
select.status-select { font-size: 12px; padding: 3px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }

/* edit area */
.edit-area { width: 100%; font-family: var(--font-body); font-size: 14px; line-height: 1.55; padding: 10px; border: 1px solid var(--cta); border-radius: var(--radius-sm); background: #fff; resize: vertical; min-height: 90px; }
.edit-hint { font-size: 12px; color: var(--text-faint); margin: 4px 0; }
.edit-actions { display: flex; gap: 8px; margin-top: 6px; }

/* comments */
.comments { margin-top: 8px; border-top: 1px dashed var(--border-strong); padding-top: 8px; }
.comment { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin: 6px 0; }
.comment.resolved { opacity: .6; }
.comment .meta { font-size: 12px; color: var(--text-faint); display:flex; gap:8px; align-items:center; }
.comment .meta b { color: var(--text-muted); font-family: var(--font-head); }
.comment .body { white-space: pre-wrap; font-size: 13.5px; margin-top: 2px; }
.comment .reply { margin-left: 16px; border-left: 2px solid var(--border-strong); }
.comment-form { display: flex; gap: 6px; margin-top: 6px; }
.comment-form textarea { flex: 1; min-height: 38px; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 13.5px; resize: vertical; }

/* buttons */
.btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--cta); color: #fff; border-color: var(--cta); }
.btn.primary:hover { background: var(--cta-dark); }
.btn.subtle { border-color: transparent; background: transparent; color: var(--cta); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.danger { color: var(--critical); border-color: var(--critical-bd); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* flags view */
.flag-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warning); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; box-shadow: var(--shadow); }
.flag-card.sev-high { border-left-color: var(--critical); }
.flag-card.sev-medium { border-left-color: var(--warning); }
.flag-card.sev-low { border-left-color: var(--secondary); }
.flag-card.st-accepted { border-left-color: var(--approved); }
.flag-card.st-rejected { opacity: .65; }
.flag-card .fc-head { display:flex; align-items:center; gap:10px; }
.flag-card .fc-id { font-family: var(--font-head); font-weight: 700; }
.flag-card .fc-detail { color: var(--text-muted); font-size: 14px; margin: 6px 0 10px; }
.sev-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.sev-tag.high { background: var(--critical-bg); color: var(--critical); }
.sev-tag.medium { background: var(--warning-bg); color: var(--warning); }
.sev-tag.low { background: var(--surface-2); color: var(--text-muted); }
.fc-actions { display:flex; gap:8px; align-items:center; flex-wrap: wrap; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; max-height: 86vh; overflow-y: auto; padding: 22px 24px; }
.modal h3 { margin: 0 0 4px; }
.modal .muted { color: var(--text-muted); font-size: 14px; }
.modal-row { display:flex; gap:10px; align-items:center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.modal-row:last-child { border-bottom: none; }
.modal-actions { display:flex; gap:10px; justify-content:flex-end; margin-top: 16px; }
.input { padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px; width: 100%; font-family: var(--font-body); }

/* search results */
.search-results { }
.sr-item { display:block; width:100%; text-align:left; border:1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; margin: 6px 0; }
.sr-item:hover { background: var(--surface-2); }
.sr-item .sr-loc { font-size: 12px; color: var(--text-faint); }
.sr-item mark { background: #fde68a; }

.empty { color: var(--text-faint); text-align: center; padding: 40px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-size: 13.5px; box-shadow: var(--shadow-lg); z-index: 60; }
.toast.error { background: var(--critical); }
.sop-meta { display:flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.sop-meta .pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.sop-meta .pill b { color: var(--text); font-family: var(--font-head); }
.field-label { font-family: var(--font-head); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin: 12px 0 2px; }
.todo-text { color: var(--draft); }

/* clickable SOP id / title in the register overview */
.sop-link { border: none; background: none; padding: 0; cursor: pointer; color: var(--cta); font-weight: 700; font-family: var(--font-head); font-size: 13.5px; white-space: nowrap; }
.sop-link:hover { text-decoration: underline; }
.sop-link-title { border: none; background: none; padding: 0; cursor: pointer; color: var(--text); text-align: left; font-size: 13.5px; }
.sop-link-title:hover { color: var(--cta); text-decoration: underline; }

/* ---------- REVIEW hub (top of sidebar) ---------- */
.review-hub { background: linear-gradient(180deg, var(--brand-mist), #fff); border: 1px solid var(--brand-teal-3); border-radius: var(--radius); padding: 8px; margin-bottom: 12px; box-shadow: var(--shadow); }
.review-hub .rh-title { font-family: var(--font-head); font-weight: 700; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-teal); padding: 4px 8px 6px; }
.rh-row { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: none; background: none; color: var(--brand-navy); padding: 8px 9px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; transition: background .12s; }
.rh-row:hover { background: #fff; }
.rh-row.active { background: var(--brand-teal); color: #fff; box-shadow: var(--shadow); }
.rh-row.active .rh-count { background: rgba(255,255,255,.25); color: #fff; }
.rh-icon { display: inline-flex; }
.rh-icon svg { width: 17px; height: 17px; }
.rh-label { flex: 1; }
.rh-count { min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; padding: 1px 7px; border-radius: 999px; background: #fff; color: var(--brand-teal); border: 1px solid var(--brand-teal-3); }
.rh-count.zero { color: var(--text-faint); background: var(--surface-2); border-color: var(--border); }

/* ---------- FIND panel (search + filters card) ---------- */
.find-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin-bottom: 12px; box-shadow: var(--shadow); }
.find-panel .rh-title { font-family: var(--font-head); font-weight: 700; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-navy); padding: 2px 4px 8px; }
.find-panel .search { margin-bottom: 2px; }
.find-panel .filter-wrap { margin: 10px 0 2px; }

/* ---------- per-doc nav controls (View all + Jump to) ---------- */
.nav-controls { display: flex; align-items: center; gap: 6px; padding: 4px 4px 6px; }
.nav-viewall { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--brand-teal-3); background: var(--brand-mist); color: var(--cta); font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; transition: background .12s; }
.nav-viewall:hover { background: var(--brand-teal-3); }
.nav-viewall.active { background: var(--cta); color: #fff; border-color: var(--cta); }
.nav-viewall .caret svg { width: 13px; height: 13px; }
.nav-jump { flex: 1; min-width: 0; font-size: 12px; padding: 4px 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted); cursor: pointer; }

/* ---------- View-all jump bar + units ---------- */
.jump-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; background: var(--bg); border-bottom: 1px solid var(--border); padding: 8px 0; margin-bottom: 6px; }
.jump-bar .jump-label { font-family: var(--font-head); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.jump-select { flex: 1; max-width: 420px; font-size: 13.5px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; }
.jump-count { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.docall-unit { padding-top: 4px; }
.docall-sentinel { height: 1px; }
.filtered-item { margin: 4px 0 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.filtered-item .cmt-where { margin-bottom: 4px; }

/* collapsible nav title */
.nav-title-toggle { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; border: none; background: none; cursor: pointer; transition: color .12s; }
.nav-title-toggle:hover { color: var(--brand-navy); }
.nav-title-toggle .caret { display: inline-flex; color: var(--text-faint); transition: transform .15s; }
.nav-title-toggle .caret svg { width: 13px; height: 13px; }
.nav-title-toggle.open .caret { transform: rotate(90deg); }

/* filter chip counts + summary */
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; }
.chip-count { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 11px; padding: 0 5px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); }
.chip-toggle[aria-pressed="true"] .chip-count { background: rgba(255,255,255,.25); color: #fff; }
.filter-summary { font-size: 12.5px; color: var(--cta); background: var(--brand-mist); border: 1px solid var(--brand-teal-3); border-radius: var(--radius-sm); padding: 7px 10px; margin: 6px 0 10px; }

/* ---------- change log rows ---------- */
.cl-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; box-shadow: var(--shadow); }
.cl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cl-what { font-family: var(--font-head); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #fff; background: var(--secondary); padding: 2px 9px; border-radius: 999px; }
.cl-where { border: 1px solid var(--brand-teal-3); background: var(--brand-mist); color: var(--cta); font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; cursor: pointer; }
.cl-where:hover { background: var(--brand-teal-3); }
.cl-spacer { flex: 1; }
.cl-who { font-family: var(--font-head); font-weight: 600; color: var(--brand-navy); font-size: 13px; }
.cl-when { color: var(--text-faint); font-size: 12.5px; }
.cl-note { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.cl-diff { margin-top: 8px; font-size: 13px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.cl-before { background: #fef2f2; color: #b91c1c; padding: 5px 9px; white-space: pre-wrap; }
.cl-after { background: #f0fdf4; color: #15803d; padding: 5px 9px; white-space: pre-wrap; }

/* ---------- comments view ---------- */
.cmt-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; box-shadow: var(--shadow); }
.cmt-card.resolved { border-left-color: var(--approved); opacity: .72; }
.cmt-top { display: flex; align-items: center; gap: 10px; }
.cmt-author { font-family: var(--font-head); font-weight: 700; color: var(--brand-navy); }
.cmt-when { color: var(--text-faint); font-size: 12.5px; }
.cmt-where { display: inline-block; margin: 8px 0 4px; border: none; background: none; color: var(--cta); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; }
.cmt-where:hover { text-decoration: underline; }
.cmt-body { white-space: pre-wrap; }
.comment-quote { border-left: 3px solid var(--brand-teal-2); background: var(--brand-mist); color: var(--brand-navy); font-style: italic; padding: 6px 10px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 6px 0; font-size: 13.5px; }

/* ---------- to-do view ---------- */
.todo-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 6px 0; transition: background .12s, border-color .12s; }
.todo-item:hover { background: var(--surface-2); border-color: var(--brand-teal-3); }
.todo-label { flex: 1; font-size: 14px; color: var(--text); }
.todo-where { font-size: 12px; color: var(--text-faint); white-space: nowrap; }

/* ---------- filter header (Show only + Clear) ---------- */
.filter-wrap { margin: 10px 0 6px; }
.filter-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.filter-head-label { font-family: var(--font-head); font-weight: 700; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); }
.filter-head-hint { font-size: 11px; color: var(--text-faint); font-style: italic; }
.filter-clear { border: 1px solid var(--border-strong); background: var(--surface); color: var(--cta); font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; cursor: pointer; }
.filter-clear:hover { background: var(--brand-mist); border-color: var(--brand-teal-3); }

/* ---------- inline comment highlight ---------- */
.cmt-mark { background: #fdeba8; color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: inset 0 -2px 0 #e9c54a; cursor: pointer; transition: background .15s; }
.cmt-mark:hover { background: #fbe08a; }
.cmt-mark.flash { animation: cmtflash 1.8s ease; }
@keyframes cmtflash { 0%,100% { background: #fdeba8; } 25% { background: #ffd24d; } 60% { background: #ffd24d; } }

/* ---------- floating "add comment" on selection ---------- */
.sel-comment-btn { position: fixed; z-index: 55; display: inline-flex; align-items: center; gap: 6px; background: var(--brand-navy); color: #fff; border: none; border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); cursor: pointer; }
.sel-comment-btn:hover { background: var(--cta); }
.sel-comment-btn svg { width: 15px; height: 15px; }

/* ---------- sign-in ---------- */
/* The login screen replaces #root entirely, so it opts out of the app shell's
   fixed grid (html,body are overflow:hidden) and centres itself instead. */
.login-wrap { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--brand-tint) 0%, var(--brand-mist) 100%); overflow: auto; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 32px 28px 26px;
  display: flex; flex-direction: column; gap: 6px; }
.login-logo { height: 34px; width: auto; align-self: flex-start; margin-bottom: 14px; }
.login-title { font-family: var(--font-head); font-size: 21px; font-weight: 700; color: var(--primary); margin: 0; }
.login-sub { font-size: 13px; color: var(--text-muted); margin: 2px 0 16px; }
.login-card .field-label { margin-top: 10px; }
.login-card .input { width: 100%; }
.login-actions { margin-top: 18px; }
.login-actions .btn { width: 100%; justify-content: center; }
.login-msg { font-size: 12.5px; margin: 10px 0 0; min-height: 1em; color: var(--text-muted); }
.login-msg.error { color: var(--critical); font-weight: 600; }

/* Google sign-in. White with a grey border, per Google's branding rules — the
   mark keeps its own four colours and must not be recoloured or boxed in. */
a.btn.signin { display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 20px; margin-top: 8px; text-decoration: none;
  background: #fff; color: #3c4043; border-color: var(--border-strong); font-size: 14px; }
a.btn.signin:hover { background: var(--surface-2); }
a.btn.signin svg { width: 18px; height: 18px; flex: none; }
.login-domain { font-size: 12px; color: var(--text-faint); text-align: center; margin: 9px 0 0; }

/* The password fallback, folded away. Deliberately quiet: it is still the way
   in when Google is unreachable, but it should not read as the normal one. */
.pwfall { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 12px; }
.pwfall > summary { cursor: pointer; font-size: 12.5px; color: var(--text-muted); list-style: none; }
.pwfall > summary::-webkit-details-marker { display: none; }
.pwfall > summary::before { content: '▸ '; color: var(--text-faint); }
.pwfall[open] > summary::before { content: '▾ '; }
.pwfall > summary:hover { color: var(--text); }
.login-fineprint { font-size: 11.5px; color: var(--text-faint); line-height: 1.5; margin: 12px 0 0; }

/* ---------- Settings: users & access ---------- */
.users-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13.5px; }
.users-table th { text-align: left; font-family: var(--font-head); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint);
  border-bottom: 1px solid var(--border); padding: 0 10px 7px; }
.users-table td { border-bottom: 1px solid var(--border); padding: 9px 10px; vertical-align: middle; }
.users-table tr:hover td { background: var(--surface-2); }
.users-table .muted-cell { color: var(--text-muted); font-size: 12.5px; }
.users-table.removed td { color: var(--text-muted); }
.role-select { padding: 4px 8px; font-size: 12.5px; min-width: 128px; }
/* Disabled controls carry a title saying why; dimming alone reads as broken. */
.users-table select:disabled, .users-table .btn:disabled { cursor: not-allowed; }
.you-tag { margin-left: 7px; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-faint); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 6px; }

.settings-sub { font-family: var(--font-head); font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin: 26px 0 0; }
.add-user-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.add-user-row .input[type="email"] { flex: 1 1 240px; }

.access-log { margin-top: 10px; border-top: 1px solid var(--border); }
.al-row { display: flex; gap: 12px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.al-when { color: var(--text-faint); flex: none; min-width: 150px; }
.al-what { color: var(--text-muted); }

/* ---------- signed-in identity in the header ---------- */
.whoami { display: flex; align-items: center; gap: 7px; margin-right: 10px; min-width: 0; }
.whoami-email { font-size: 12.5px; color: var(--text-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.role-pill { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--cta); background: var(--brand-mist); border: 1px solid var(--brand-teal-3);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

/* ---------- approval provenance ---------- */
/* The visible end of the provenance chain: who approved this, verified
   server-side. Rendered only when the server has stamped an approver. */
.approval-line { font-size: 12px; color: var(--approved); margin-top: 6px; font-weight: 600; }
/* Change-log entries that predate server-verified identity. Muted, not alarming:
   they are ordinary history, they simply are not signed. */
.cl-unverified { font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 6px; margin-left: 6px; white-space: nowrap; }

/* ---------- Comms Queue ---------- */
/* Operational, not editorial: denser than the knowledge-base views because a
   triage list is scanned, not read. Uses the existing tokens throughout. */
.queue-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip { font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; transition: background .12s, color .12s, border-color .12s; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--brand-mist); border-color: var(--brand-teal-3); color: var(--cta); }

.queue-list { display: flex; flex-direction: column; gap: 8px; }
.queue-row { display: block; width: 100%; text-align: left; cursor: pointer; font: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; transition: border-color .12s, box-shadow .12s; }
.queue-row:hover { border-color: var(--brand-teal-3); box-shadow: var(--shadow); }
.q-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.q-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
  font-weight: 700; color: var(--cta); }
.q-channel, .q-account { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); }
.q-subject { font-size: 14px; color: var(--text); line-height: 1.45; margin-bottom: 6px;
  overflow-wrap: anywhere; }
.q-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted); }
.q-owner { margin-left: auto; font-weight: 600; }
.q-owner.none { font-weight: 400; font-style: italic; color: var(--text-faint); }

.q-status { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 999px; padding: 2px 8px; border: 1px solid var(--border); color: var(--text-muted); }
.status-open { color: var(--cta); background: var(--brand-mist); border-color: var(--brand-teal-3); }
.status-pending { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent);
  border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.status-resolved { color: var(--approved); background: color-mix(in srgb, var(--approved) 12%, transparent);
  border-color: color-mix(in srgb, var(--approved) 35%, transparent); }
.status-closed { color: var(--text-faint); }

.q-flag { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; border-radius: 4px;
  padding: 2px 6px; border: 1px solid var(--border); color: var(--text-muted); }
.flag-reg { color: var(--critical); background: color-mix(in srgb, var(--critical) 10%, transparent);
  border-color: color-mix(in srgb, var(--critical) 35%, transparent); }
.flag-care { color: var(--compliance); background: color-mix(in srgb, var(--compliance) 12%, transparent);
  border-color: color-mix(in srgb, var(--compliance) 35%, transparent); }
.flag-std { color: var(--text-muted); }

/* The SLA badge is the one thing on a row that should be able to shout. */
.sla { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.sla-ok { color: var(--text-muted); }
.sla-due_soon { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.sla-overdue { color: #fff; background: var(--critical); }

.queue-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border); }

.thread { display: flex; flex-direction: column; gap: 12px; }
.thread-item { border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 12px 14px; }
/* A public comment is visible to everyone, which changes what may be said in
   reply (gate rule 4). Mark it so a rep cannot miss that. */
.thread-item.public { border-left: 3px solid var(--warning); }
.th-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px;
  font-size: 12px; color: var(--text-muted); }
.th-who { font-weight: 700; color: var(--text); }
.th-kind { text-transform: uppercase; font-size: 10.5px; letter-spacing: .04em; }
.th-link { color: var(--cta); text-decoration: none; }
.th-link:hover { text-decoration: underline; }
.th-body { font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-wrap;
  overflow-wrap: anywhere; }
.th-gate { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
  font-size: 12.5px; color: var(--text-muted); }
.th-gate-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.th-decision { font-weight: 700; color: var(--text); text-transform: uppercase; font-size: 10.5px;
  letter-spacing: .04em; }
.th-sop, .th-cite { font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
  color: var(--cta); background: var(--brand-mist); border: 1px solid var(--brand-teal-3);
  border-radius: 4px; padding: 1px 6px; }
.th-sop:hover, .th-cite:hover { background: var(--brand-tint); }
.th-role { font-size: 11px; font-style: italic; }
.th-reason { line-height: 1.5; margin-top: 4px; }
.th-cites { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.th-trail { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.rh-count.overdue { background: var(--critical); color: #fff; }
/* A drafted reply is shown for review only — Phase 1 never sends. */
.th-draft { margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px dashed var(--border); font-size: 13px;
  line-height: 1.5; color: var(--text); }

/* ---------- Comms Queue: sources ---------- */
/* Health of the accounts the queue draws from. Deliberately above the list:
   an empty queue means nothing until you know the sources are working. */
.sources { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.src { display: flex; align-items: center; gap: 7px; font-size: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 10px; background: var(--surface); color: var(--text-muted); }
.src-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.src-name { font-weight: 700; color: var(--text); }
.src-ok .src-dot { background: var(--approved); }
.src-failing .src-dot { background: var(--critical); }
.src-failing { border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.src-never .src-dot, .src-unconnected .src-dot { background: var(--warning); }
.src-off { opacity: .55; }
.src-error { flex-basis: 100%; margin-top: 4px; font-size: 11.5px; color: var(--critical);
  overflow-wrap: anywhere; }
.src-note { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Sources page (home-card): full list, grouped by channel ---------- */
.src-group { margin-bottom: 22px; }
.src-group-title { font-family: var(--font-head); font-weight: 700; font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--brand-navy); margin-bottom: 8px; }
.src-row { display: flex; align-items: center; gap: 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; background: var(--surface); color: var(--text-muted); margin-bottom: 6px;
  flex-wrap: wrap; }
.src-row-name { font-weight: 700; color: var(--text); min-width: 160px; }
.src-row-state { font-size: 12.5px; }
.src-row-when { font-size: 12px; color: var(--text-faint); margin-left: auto; }
.src-row-planned { opacity: .65; }
.src-badge-planned { font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
