/* Dark theme (html[data-theme="dark"]). Loaded after theme.css; changes colours only. */
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;margin-right:10px;border-radius:50%;border:1px solid var(--line);background:var(--surface);color:var(--ink);cursor:pointer;padding:0}
.theme-toggle:hover{border-color:var(--teal)}
html[data-theme="dark"]{color-scheme:dark;
  --bg:#0E1A20;--surface:#15252D;--ink:#E8F1F4;--ink-soft:#BBCBD1;--muted:#8DA3AB;--line:#2B3E47;
  --teal:#2FB4D8;--teal-deep:#5CCBEA;--teal-dark:#5CCBEA;--teal-soft:#123242;--violet:#5CA8E0;
  --navy:#CFE3EC;--dark:#0A1317;--nav:#0A1317;--olive:#C5CC3C;--green:#4CC38A;--green-soft:#123828;--amber:#E0A34A;--amber-soft:#3A2B10;--red:#F08A63;--red-soft:#3C1F15;
  --shadow:0 14px 34px rgba(0,0,0,.4),0 2px 6px rgba(0,0,0,.3);--shadow-lg:0 18px 44px rgba(0,0,0,.5),0 2px 8px rgba(0,0,0,.35)}
html[data-theme="dark"]{--s2:#1B2F38;--s3:#223A45}
html[data-theme="dark"] body{background:radial-gradient(900px 440px at 82% -12%,rgba(0,208,255,.10),rgba(0,208,255,0) 62%),var(--bg)!important;color:var(--ink-soft)}
/* surfaces */
html[data-theme="dark"] header,html[data-theme="dark"] .app-shell.signed-in header{background:var(--surface)!important;border-color:var(--line)!important}
html[data-theme="dark"] .panel,html[data-theme="dark"] .card,html[data-theme="dark"] .dash-card,html[data-theme="dark"] .kpi,html[data-theme="dark"] .stat,html[data-theme="dark"] .login-card,
html[data-theme="dark"] .dropdown-panel,html[data-theme="dark"] #nudge-panel,html[data-theme="dark"] dialog,html[data-theme="dark"] .pv-box,html[data-theme="dark"] .wz-card,html[data-theme="dark"] .risk-card,
html[data-theme="dark"] .finding,html[data-theme="dark"] .dash-item,html[data-theme="dark"] .empty-state,html[data-theme="dark"] .recent-item,html[data-theme="dark"] .au-table,html[data-theme="dark"] .pl-card,html[data-theme="dark"] .pl-spot{background:var(--surface)!important;border-color:var(--line)!important;color:var(--ink-soft)!important}
html[data-theme="dark"] .panel-head,html[data-theme="dark"] .panel-body,html[data-theme="dark"] .pv-head,html[data-theme="dark"] .pv-foot,html[data-theme="dark"] #nudge-log,html[data-theme="dark"] #nudge-form,html[data-theme="dark"] .wiz,html[data-theme="dark"] .wz-pane{background:transparent!important;border-color:var(--line)!important}
html[data-theme="dark"] .pv-box section,html[data-theme="dark"] .pv-grid>div,html[data-theme="dark"] .fact{background:var(--s2)!important;border-color:var(--line)!important}
/* text */
html[data-theme="dark"] h1,html[data-theme="dark"] h2,html[data-theme="dark"] h3,html[data-theme="dark"] h4,html[data-theme="dark"] .value,html[data-theme="dark"] strong,html[data-theme="dark"] b,html[data-theme="dark"] .dash-title,html[data-theme="dark"] .panel-head h3{color:var(--ink)!important}
html[data-theme="dark"] .hint,html[data-theme="dark"] small,html[data-theme="dark"] .muted,html[data-theme="dark"] .findings-sub,html[data-theme="dark"] .wz-s{color:var(--muted)!important}
html[data-theme="dark"] p,html[data-theme="dark"] li,html[data-theme="dark"] td,html[data-theme="dark"] label,html[data-theme="dark"] span{color:inherit}
html[data-theme="dark"] a{color:var(--teal-deep)}
/* controls */
html[data-theme="dark"] input,html[data-theme="dark"] select,html[data-theme="dark"] textarea{background:var(--s2)!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder{color:var(--muted)!important}
html[data-theme="dark"] button:not(.primary):not(.chip.on):not(.wz-chip):not(.nd-chip.act):not(.theme-toggle){background:var(--s2)!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-theme="dark"] button.primary{color:#04222D!important}
html[data-theme="dark"] button:disabled{opacity:.5}
html[data-theme="dark"] #topnav a{color:var(--ink)!important}
html[data-theme="dark"] #topnav a:hover{background:rgba(92,203,234,.14)!important}
html[data-theme="dark"] #topnav a.on{background:var(--teal-deep)!important;color:#04222D!important}
html[data-theme="dark"] .profile-trigger,html[data-theme="dark"] .dropdown-trigger{background:var(--s2)!important;border-color:var(--line)!important}
html[data-theme="dark"] .dropdown-panel button,html[data-theme="dark"] .dropdown-panel a{background:transparent!important;border:0!important;color:var(--ink)!important}
html[data-theme="dark"] .dropdown-panel button:hover,html[data-theme="dark"] .dropdown-panel a:hover{background:var(--s3)!important}
/* pills and chips */
html[data-theme="dark"] .pill{background:var(--s3)!important;color:var(--ink)!important;border-color:transparent!important}
html[data-theme="dark"] .pill.returned,html[data-theme="dark"] .pill.high{background:var(--red-soft)!important;color:var(--red)!important}
html[data-theme="dark"] .pill.in_review,html[data-theme="dark"] .pill.medium,html[data-theme="dark"] .pill.waiting{background:var(--amber-soft)!important;color:var(--amber)!important}
html[data-theme="dark"] .pill.resolved,html[data-theme="dark"] .pill.low{background:var(--green-soft)!important;color:var(--green)!important}
html[data-theme="dark"] .chip{background:var(--s2)!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-theme="dark"] .chip.on{background:var(--teal-deep)!important;color:#04222D!important}
/* tables */
html[data-theme="dark"] table{background:transparent!important;color:var(--ink-soft)}
html[data-theme="dark"] th{background:var(--s2)!important;color:var(--muted)!important;border-color:var(--line)!important}
html[data-theme="dark"] td{border-color:var(--line)!important;background:transparent!important}
html[data-theme="dark"] tr:hover td{background:var(--s2)!important}
/* review page */
html[data-theme="dark"] .recommendation{background:var(--green-soft)!important;color:var(--ink)!important}
html[data-theme="dark"] blockquote{background:var(--s2)!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-theme="dark"] #preview,html[data-theme="dark"] #input{background:var(--s2)!important;color:var(--ink)!important}
html[data-theme="dark"] .pdf-page-scroll,html[data-theme="dark"] #pdf-page-scroll{background:var(--s2)!important}
html[data-theme="dark"] .pv-file-preview{background:#fff;border-color:var(--line)!important}
/* sidebar stays dark; brand logo on a light chip so it stays readable */
html[data-theme="dark"] .brand-logo,html[data-theme="dark"] .login-brand-primary,html[data-theme="dark"] .login-partner-brand{background:#fff;border-radius:8px;padding:2px 6px}
/* second pass: found by scanning every page */
html[data-theme="dark"] .metric,html[data-theme="dark"] .metric.total,html[data-theme="dark"] .metric.medium,html[data-theme="dark"] .metric.resolved{background:var(--surface)!important;background-image:none!important;border-color:var(--line)!important}
html[data-theme="dark"] .metric .value,html[data-theme="dark"] .metric .label{color:var(--ink)!important}
html[data-theme="dark"] .dashboard-attention-panel,html[data-theme="dark"] .history-toolbar,html[data-theme="dark"] .pl-tools,html[data-theme="dark"] .pl-seg,html[data-theme="dark"] .pl-table,html[data-theme="dark"] .pl-metric,html[data-theme="dark"] .pl-foot,
html[data-theme="dark"] .au-box,html[data-theme="dark"] .row-menu,html[data-theme="dark"] .wz-rail,html[data-theme="dark"] .nd-m.nd-b,html[data-theme="dark"] .panel-foot,html[data-theme="dark"] .dashboard-panel-foot{background:var(--surface)!important;background-image:none!important;border-color:var(--line)!important;color:var(--ink-soft)!important}
html[data-theme="dark"] .history-tab-count,html[data-theme="dark"] .wz-n,html[data-theme="dark"] .wz-ic,html[data-theme="dark"] .pl-chip,html[data-theme="dark"] .au-chip,html[data-theme="dark"] .bar{background:var(--s3)!important;color:var(--ink)!important;border-color:transparent!important}
html[data-theme="dark"] .au-chip.bad{background:var(--red-soft)!important;color:var(--red)!important}
html[data-theme="dark"] .au-chip.mid{background:var(--amber-soft)!important;color:var(--amber)!important}
html[data-theme="dark"] .au-chip.ok{background:var(--green-soft)!important;color:var(--green)!important}
html[data-theme="dark"] .pl-chip.soon{background:var(--s2)!important;color:var(--muted)!important}
html[data-theme="dark"] tr,html[data-theme="dark"] .rtable tr{background:transparent!important}
html[data-theme="dark"] td.title,html[data-theme="dark"] .pl-metric .v,html[data-theme="dark"] .pl-metric .v *,html[data-theme="dark"] .h,html[data-theme="dark"] .history-tab{color:var(--ink)!important}
html[data-theme="dark"] .history-tab{background:var(--s2)!important;border-color:var(--line)!important}
html[data-theme="dark"] .history-tab.on,html[data-theme="dark"] .history-tab[aria-selected="true"]{background:var(--teal-deep)!important;color:#04222D!important}
html[data-theme="dark"] .wz-card.on{background:var(--teal-soft)!important;border-color:var(--teal)!important}
html[data-theme="dark"] .wz-st.now .wz-n{background:var(--teal-deep)!important;color:#04222D!important}
html[data-theme="dark"] .nd-u{background:var(--teal)!important;color:#04222D!important}
html[data-theme="dark"] #nudge-log{background:var(--bg)!important}
html[data-theme="dark"] .nd-chip{background:var(--s2)!important;color:var(--teal-deep)!important;border-color:var(--teal)!important}
html[data-theme="dark"] .dash-grid>.panel,html[data-theme="dark"] #view-dash .dash-grid>.panel,html[data-theme="dark"] .review-footer,html[data-theme="dark"] .filebar,html[data-theme="dark"] .links-panel,html[data-theme="dark"] .comments-panel,html[data-theme="dark"] .app-shell .panel{background:rgba(21,37,45,.92)!important;border-color:var(--line)!important}
html[data-theme="dark"] dialog{background:var(--surface)!important;color:var(--ink-soft)}
html[data-theme="dark"] .au-sev>div{background:var(--s2)!important;border:1px solid var(--line)!important}
html[data-theme="dark"] .au-sev>div.h{background:var(--red-soft)!important}
html[data-theme="dark"] .au-sev>div.h b,html[data-theme="dark"] .au-sev>div.h span{color:var(--red)!important}
/* review page and preview dialog leftovers */
html[data-theme="dark"] .progress,html[data-theme="dark"] .ss-dot,html[data-theme="dark"] .pv-step,html[data-theme="dark"] details.audit,html[data-theme="dark"] .audit-log,html[data-theme="dark"] pre#pv-text,html[data-theme="dark"] .pv-text,html[data-theme="dark"] #log{background:var(--s2)!important;color:var(--ink-soft)!important;border-color:var(--line)!important}
html[data-theme="dark"] .pv-step.now{background:var(--teal-soft)!important;color:var(--ink)!important}
html[data-theme="dark"] .pv-find{background:var(--s2)!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-theme="dark"] .pv-find.high{border-left:3px solid var(--red)!important}html[data-theme="dark"] .pv-find.medium{border-left:3px solid var(--amber)!important}
html[data-theme="dark"] .fstatus.open{background:var(--amber-soft)!important;color:var(--amber)!important}
html[data-theme="dark"] p.cite,html[data-theme="dark"] .f-note{background:var(--s2)!important;color:var(--muted)!important}
html[data-theme="dark"] summary,html[data-theme="dark"] .field-label{color:var(--muted)!important}
html[data-theme="dark"] #progress-bar{background:var(--teal)!important}

/* Drafts & history: keep work-type labels readable against dark table rows. */
html[data-theme="dark"] #view-home .brandtag,
html[data-theme="dark"] .history-panel .brandtag{
  background:#303d22!important;
  border-color:#586a34!important;
  color:#d9e99b!important;
}
html[data-theme="dark"] #view-home .history-toolbar .home-filters input,
html[data-theme="dark"] #view-home .history-toolbar .home-filters select{
  background:var(--s2)!important;
  border-color:var(--line)!important;
  color:var(--ink)!important;
}
html[data-theme="dark"] #view-home .history-toolbar .home-filters select option{
  background:var(--surface)!important;
  color:var(--ink)!important;
}
html[data-theme="dark"] #view-home .history-table-head,
html[data-theme="dark"] #view-home .rtable th:last-child{
  background:var(--surface)!important;
  border-color:var(--line)!important;
}
html[data-theme="dark"] #view-home .rtable tbody tr:hover td{
  background:var(--s2)!important;
}
html[data-theme="dark"] #view-review:not(.intake) .finding.preview-active{
  border-color:#4fc5e7!important;
  box-shadow:0 0 0 2px rgba(79,197,231,.16)!important;
}
html[data-theme="dark"] #view-review:not(.intake) .finding .preview-state{
  background:#123b49!important;
  border-color:#28677b!important;
  color:#8ce3fb!important;
}
html[data-theme="dark"] .doi-row label,html[data-theme="dark"] .doi-note{color:var(--muted)!important}
html[data-theme="dark"] .doi-box input{background:var(--s2)!important;border-color:var(--line)!important;color:var(--ink)!important}
html[data-theme="dark"] .doi-note.bad{color:#ff8a80!important}
html[data-theme="dark"] .doi-item{background:var(--s2)!important;border-color:var(--line)!important}html[data-theme="dark"] .doi-item b{color:var(--ink)!important}html[data-theme="dark"] .doi-item small{color:var(--muted)!important}
html[data-theme="dark"] .pv-tabs{border-color:var(--line)!important}html[data-theme="dark"] .pv-tabs button{color:var(--muted)!important}html[data-theme="dark"] .pv-tabs button[aria-selected="true"]{color:var(--teal-deep)!important}html[data-theme="dark"] .pv-text{background:var(--s2)!important;color:var(--ink-soft)!important;border-color:var(--line)!important}
html[data-theme="dark"] .ft-banner{background:var(--teal-soft)!important;border-color:var(--line)!important;color:var(--ink-soft)!important}html[data-theme="dark"] .ft-tag.ok{background:var(--green-soft)!important;color:var(--green)!important}html[data-theme="dark"] .ft-tag.warn{background:var(--amber-soft)!important;color:var(--amber)!important}
html[data-theme="dark"] .au-tabs{border-color:var(--line)!important}html[data-theme="dark"] .au-tabs button{color:var(--muted)!important}html[data-theme="dark"] .au-tabs button[aria-selected="true"]{color:var(--teal-deep)!important}
html[data-theme="dark"] .au-win,html[data-theme="dark"] .au-note,html[data-theme="dark"] .au-box h4{color:var(--muted)!important}html[data-theme="dark"] .au-win button{background:var(--s2)!important;border-color:var(--line)!important;color:var(--ink-soft)!important}html[data-theme="dark"] .au-win button[aria-pressed="true"]{background:var(--teal)!important;color:#04222D!important}
html[data-theme="dark"] .au-bar-t{background:var(--s3)!important}html[data-theme="dark"] .au-bar-t i{background:#4a8fae}html[data-theme="dark"] .au-bar-t i.teal{background:var(--teal)}html[data-theme="dark"] .au-bar-t i.amber{background:var(--amber)}
html[data-theme="dark"] .pv-note{background:var(--amber-soft)!important;border-color:var(--line)!important;color:var(--amber)!important}
html[data-theme="dark"] .pat-banner{background:var(--surface)!important;border-color:var(--line)!important;color:var(--ink-soft)!important}html[data-theme="dark"] .pat-toggle{background:var(--s2)!important;color:var(--ink-soft)!important}html[data-theme="dark"] .pat-toggle:hover{background:var(--s3)!important}html[data-theme="dark"] .pat-toggle b{color:var(--ink)!important}html[data-theme="dark"] .pat-details{border-color:var(--line)!important}html[data-theme="dark"] .pat-detail-row{background:var(--s2)!important;border-color:var(--line)!important;border-left-color:var(--teal)!important}html[data-theme="dark"] .pat-detail-row>b,html[data-theme="dark"] .pat-detail-row .pat-last{color:var(--ink)!important}html[data-theme="dark"] .pat-detail-row>span{color:var(--muted)!important}html[data-theme="dark"] .pat-detail-count{background:#3a2b10!important;border-color:#70531d!important;color:#f2c36d!important}html[data-theme="dark"] .pat-chip{background:var(--s2)!important;border-color:var(--line)!important;color:var(--amber)!important}html[data-theme="dark"] .pill.pattern{background:var(--amber-soft)!important;color:var(--amber)!important}html[data-theme="dark"] .pill.pattern.seen_before{background:var(--s2)!important;color:var(--muted)!important}
html[data-theme="dark"] .pat-detail-row button.pat-last{color:var(--teal-deep)!important}

/* Confidence tag levels */
html[data-theme="dark"] .pill.conf.tier-high{background:#12382b;color:#7fe0b4;box-shadow:inset 0 0 0 1px #1f6048}
html[data-theme="dark"] .pill.conf.tier-mid{background:#1c2f4a;color:#9cc3f5;box-shadow:inset 0 0 0 1px #2f4d78}
html[data-theme="dark"] .pill.conf.tier-low,html[data-theme="dark"] .pill.conf.low{background:#43320f;color:#f2c773;box-shadow:inset 0 0 0 1px #6b5019}

/* ---- fixes found by checking every screen in dark mode ---- */
/* New paper steps: the chips row above a question is sticky and had a white background */
html[data-theme="dark"] #view-review.intake .wz-chips{background:var(--surface)!important}
/* findings search: the shorthand background dropped the magnifier; draw a light one */
html[data-theme="dark"] #view-review:not(.intake) .finding-search{background:var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238DA3AB' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") 12px center/16px no-repeat!important;color:var(--ink)}
html[data-theme="dark"] .wz-gsearch input{background:var(--surface);border-color:var(--line);color:var(--ink)}
/* the file viewer for PDF, images, text and CSV (react-doc-viewer) is white by default */
html[data-theme="dark"] #react-doc-viewer,html[data-theme="dark"] #proxy-renderer{background:var(--surface)!important;color:var(--ink)!important}
html[data-theme="dark"] #header-bar{background:var(--s2)!important;border-bottom:1px solid var(--line)!important}
html[data-theme="dark"] #header-bar,html[data-theme="dark"] #header-bar *{color:var(--ink)!important}
html[data-theme="dark"] #header-bar button{background:var(--surface)!important;border-color:var(--line)!important}
/* Compare versions: the settings block and the dialog */
html[data-theme="dark"] .cmp-set{background:var(--amber-soft);border-color:#5a4318}html[data-theme="dark"] .cmp-set h4{color:#E8C27A}html[data-theme="dark"] .cmp-set li{color:var(--ink-soft)}
html[data-theme="dark"] #cmp-dialog{background:var(--surface);color:var(--ink);border-color:var(--line)}
html[data-theme="dark"] .cmp-head,html[data-theme="dark"] .cmp-controls,html[data-theme="dark"] .cmp-sum{background:var(--s2);border-color:var(--line)}
html[data-theme="dark"] .cmp-controls select{background:var(--surface);color:var(--ink);border-color:var(--line)}
html[data-theme="dark"] .cmp-s{color:var(--ink-soft)}html[data-theme="dark"] .cmp-s.add{background:var(--green-soft);color:#BFEBD3}html[data-theme="dark"] .cmp-s.del{background:var(--red-soft);color:#F7C9B6}html[data-theme="dark"] .cmp-s.mod{background:var(--amber-soft);color:var(--ink-soft)}
html[data-theme="dark"] .cmp-pill{background:var(--s3);color:var(--ink-soft)}html[data-theme="dark"] .cmp-pill.set{background:var(--amber-soft);color:#E8C27A}
html[data-theme="dark"] .cmp-gap{background:var(--surface);color:var(--muted);border-color:var(--line)}
/* Running state of the Run Nudge checks button keeps its dark text on the light blue */
html[data-theme="dark"] .nd-loading{color:var(--muted)}

/* ---- clearer dark theme: the measured low-contrast text and the unthemed upload box (contrast checked on every screen, target 4.5:1) ---- */
html[data-theme="dark"]{--muted:#A9BDC5;--ink-soft:#C9D7DC;--line:#34505C}
html[data-theme="dark"] :is(.dash-meta,#d-sub,.subheading,.pl-crumb,.au-crumb,.pl-metric .k,.pl-metric .d,.hint,.wz-s,.panel-sub,.help-sub){color:var(--muted)!important}
html[data-theme="dark"] :is(table td,table th,.act-table td){color:var(--ink-soft)}
html[data-theme="dark"] .upload-zone,html[data-theme="dark"] #upload-zone{background:var(--s2)!important;border-color:#4a6a78!important;color:var(--ink)}
html[data-theme="dark"] #upload-title,html[data-theme="dark"] .upload-copy strong{color:var(--ink)!important}
html[data-theme="dark"] #upload-hint,html[data-theme="dark"] .upload-copy span{color:var(--muted)!important}
html[data-theme="dark"] .upload-zone.dragover{border-color:var(--teal)!important;background:var(--teal-soft)!important}
html[data-theme="dark"] .finding-quote,html[data-theme="dark"] .finding blockquote,html[data-theme="dark"] .finding .quote{color:var(--ink-soft)!important}
html[data-theme="dark"] .wz-st:not(.now):not(.done){color:var(--muted)}
html[data-theme="dark"] :is(.ps,.page-strip .ps){color:var(--ink-soft)}
html[data-theme="dark"] :is(#findings,#findings-panel,.find-banner,.pattern-banner,#risk-card) li{color:var(--ink-soft)!important}
