:root{
  --bg-app:#EDF1F4;
  --bg-surface:#FFFFFF;
  --bg-surface-2:#F4F7FA;
  --bg-sidebar:#0E1521;
  --text-primary:#111A28;
  --text-secondary:#4A5568;
  --text-muted:#8792A6;
  --text-on-sidebar:#D3DAE6;
  --text-on-sidebar-muted:#7A879C;
  --border:#DCE2EA;
  --border-strong:#C3CCD9;
  --accent:#177E75;
  --accent-hover:#136A62;
  --accent-soft:#E4F2F0;
  --accent-contrast:#FFFFFF;
  --risk-critical:#B23A30;
  --risk-critical-bg:#FBEAE8;
  --risk-warning:#A5710D;
  --risk-warning-bg:#FBF0DA;
  --risk-clear:#2F7A4C;
  --risk-clear-bg:#E7F4EC;
  --shadow-sm:0 1px 2px rgba(15,23,42,0.05);
  --shadow-md:0 4px 14px rgba(15,23,42,0.08);
  --radius-sm:4px;
  --radius-md:6px;
  --font-ui:'Archivo Var','Archivo',system-ui,-apple-system,sans-serif;
  --font-display:'Source Serif Display','Source Serif 4',Georgia,serif;
  --font-mono:'IBM Plex Mono',ui-monospace,'SF Mono',Menlo,monospace;
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg-app:#0A0F18;
    --bg-surface:#131B29;
    --bg-surface-2:#182333;
    --bg-sidebar:#080C13;
    --text-primary:#E8EDF5;
    --text-secondary:#A2AEC2;
    --text-muted:#67728A;
    --text-on-sidebar:#C7D0E0;
    --text-on-sidebar-muted:#57647A;
    --border:#243044;
    --border-strong:#324160;
    --accent:#31A296;
    --accent-hover:#3FB6A9;
    --accent-soft:#132B29;
    --accent-contrast:#04120F;
    --risk-critical:#E2685C;
    --risk-critical-bg:#33191A;
    --risk-warning:#D7A344;
    --risk-warning-bg:#332711;
    --risk-clear:#5CB483;
    --risk-clear-bg:#122A1E;
    --shadow-sm:0 1px 2px rgba(0,0,0,0.3);
    --shadow-md:0 12px 28px rgba(0,0,0,0.45);
  }
}
:root[data-theme="dark"]{
  --bg-app:#0A0F18;
  --bg-surface:#131B29;
  --bg-surface-2:#182333;
  --bg-sidebar:#080C13;
  --text-primary:#E8EDF5;
  --text-secondary:#A2AEC2;
  --text-muted:#67728A;
  --text-on-sidebar:#C7D0E0;
  --text-on-sidebar-muted:#57647A;
  --border:#243044;
  --border-strong:#324160;
  --accent:#31A296;
  --accent-hover:#3FB6A9;
  --accent-soft:#132B29;
  --accent-contrast:#04120F;
  --risk-critical:#E2685C;
  --risk-critical-bg:#33191A;
  --risk-warning:#D7A344;
  --risk-warning-bg:#332711;
  --risk-clear:#5CB483;
  --risk-clear-bg:#122A1E;
  --shadow-sm:0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:0 12px 28px rgba(0,0,0,0.45);
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--bg-app);
  color:var(--text-primary);
  font-family:var(--font-ui);
  font-size:14px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;}
::selection{background:var(--accent-soft);}
a{color:inherit;}
.hidden{display:none !important;}
.tabular{font-variant-numeric:tabular-nums;font-family:var(--font-mono);}

/* ---------- Prototype chrome (not part of the product) ---------- */
.proto-bar{
  position:fixed; top:0; left:0; right:0; z-index:100;
  display:flex; align-items:center; gap:8px;
  padding:8px 16px;
  background:var(--bg-sidebar);
  border-bottom:1px solid rgba(255,255,255,0.06);
  font-size:11px;
  letter-spacing:0.06em;
  text-transform:uppercase;
  color:var(--text-on-sidebar-muted);
}
.proto-bar b{color:var(--text-on-sidebar); font-weight:600; margin-right:6px;}
.proto-bar .spacer{flex:1;}
.proto-note{
  text-transform:none; letter-spacing:0; font-size:11.5px; opacity:0.85;
}
[data-app]{ padding-top:34px; }

/* ---------- Login ---------- */
.login-shell{
  min-height:100vh;
  display:grid;
  grid-template-columns:minmax(0,1.05fr) minmax(0,1fr);
}
@media (max-width:860px){ .login-shell{grid-template-columns:1fr;} .login-brand{display:none;} }

.login-brand{
  position:relative;
  background:
    radial-gradient(560px 420px at 18% 12%, rgba(49,162,150,0.20), transparent 60%),
    var(--bg-sidebar);
  color:var(--text-on-sidebar);
  padding:56px;
  display:flex; flex-direction:column; justify-content:space-between;
  overflow:hidden;
}
.login-brand .mark{
  display:flex; align-items:center; gap:10px;
}
.login-brand .mark svg{ width:26px; height:26px; }
.login-brand .mark span{
  font-family:var(--font-display); font-weight:600; font-size:20px; letter-spacing:0.01em;
  color:#F2F5F9;
}
.scan{
  position:relative; width:100%; max-width:380px; aspect-ratio:1; margin:24px auto;
  align-self:center;
}
.scan svg{ width:100%; height:100%; }
.scan-ring{ fill:none; stroke:rgba(49,162,150,0.35); stroke-width:1; }
.scan-ring.bright{ stroke:rgba(49,162,150,0.65); }
.scan-sweep{
  transform-origin:150px 150px;
  animation:sweep 6s linear infinite;
}
@media (prefers-reduced-motion:reduce){ .scan-sweep{ animation:none; } }
@keyframes sweep{ to{ transform:rotate(360deg); } }
.scan-dot{ fill:#EAC26B; }

.login-brand .copy h1{
  font-family:var(--font-display); font-weight:600; font-size:32px; line-height:1.15;
  margin:0 0 12px; color:#F5F7FA; text-wrap:balance; letter-spacing:-0.01em;
}
.login-brand .copy p{
  margin:0; max-width:38ch; color:var(--text-on-sidebar-muted); font-size:14.5px;
}
.trustrow{ display:flex; gap:18px; flex-wrap:wrap; }
.trustrow span{
  font-size:10.5px; letter-spacing:0.08em; text-transform:uppercase;
  color:var(--text-on-sidebar-muted); border-top:1px solid rgba(255,255,255,0.12); padding-top:8px;
}

.login-form-wrap{
  display:flex; align-items:center; justify-content:center; padding:32px;
  background:var(--bg-app);
}
.login-card{
  width:100%; max-width:380px; background:var(--bg-surface);
  border:1px solid var(--border); border-radius:var(--radius-md);
  box-shadow:var(--shadow-md); padding:36px 32px;
}
.login-card h2{ margin:0 0 4px; font-size:20px; font-weight:700; }
.login-card .sub{ margin:0 0 26px; color:var(--text-secondary); font-size:13px; }
.field{ margin-bottom:16px; }
.field label{
  display:block; font-size:12px; font-weight:600; color:var(--text-secondary);
  margin-bottom:6px; letter-spacing:0.01em;
}
.field input{
  width:100%; padding:10px 12px; border-radius:var(--radius-sm);
  border:1px solid var(--border-strong); background:var(--bg-surface);
  color:var(--text-primary); font-size:14px;
}
.field input:focus{ outline:2px solid var(--accent); outline-offset:1px; border-color:var(--accent); }
.row-between{ display:flex; justify-content:space-between; align-items:center; margin:2px 0 22px; }
.link-muted{ font-size:12.5px; color:var(--accent); text-decoration:none; font-weight:600; }
.link-muted:hover{ text-decoration:underline; }
.remember{ display:flex; align-items:center; gap:6px; font-size:12.5px; color:var(--text-secondary); }

.btn{
  appearance:none; border:none; cursor:pointer; border-radius:var(--radius-sm);
  font-weight:700; font-size:13.5px; padding:10px 16px; letter-spacing:0.01em;
  transition:background 120ms ease, box-shadow 120ms ease, transform 60ms ease;
}
.btn:active{ transform:translateY(1px); }
.btn-primary{ background:var(--accent); color:var(--accent-contrast); }
.btn-block{ width:100%; }
.btn-primary:hover{ background:var(--accent-hover); }
.btn-outline{
  background:transparent; color:var(--text-primary); border:1px solid var(--border-strong);
}
.btn-outline:hover{ border-color:var(--accent); color:var(--accent); }
.btn-ghost{ background:transparent; color:var(--text-secondary); border:none; }
.btn-ghost:hover{ color:var(--text-primary); }
.btn-danger-outline{ background:transparent; color:var(--risk-critical); border:1px solid var(--risk-critical); }
.btn-danger-outline:hover{ background:var(--risk-critical-bg); }
.btn-sm{ padding:6px 10px; font-size:12.5px; }

.foot-note{ margin-top:20px; text-align:center; font-size:12px; color:var(--text-muted); }

/* ---------- App shell ---------- */
.app-shell{ min-height:100vh; }
.main{ display:flex; flex-direction:column; min-width:0; }
.topbar{
  display:flex; align-items:center; gap:16px; padding:12px 24px;
  border-bottom:1px solid var(--border); background:var(--bg-surface);
  position:sticky; top:0; z-index:10;
}
.brand-inline{
  display:flex; align-items:center; gap:9px; border:none; background:none; cursor:pointer;
  padding:4px 2px; color:inherit;
}
.brand-inline svg{ width:19px; height:19px; flex:none; }
.brand-inline span{ font-family:var(--font-display); font-weight:600; font-size:16px; color:var(--text-primary); }
.topbar-divider{ width:1px; align-self:stretch; background:var(--border); margin:0 2px; }
.search{
  flex:1; max-width:380px; display:flex; align-items:center; gap:8px;
  background:var(--bg-surface-2); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:8px 12px; color:var(--text-muted);
}
.search svg{ width:15px; height:15px; flex:none; }
.search input{ border:none; background:none; outline:none; font-size:13px; color:var(--text-primary); width:100%; }
.topbar .spacer{ flex:1; }
.user-chip{
  display:flex; align-items:center; gap:10px; cursor:pointer;
  border:none; background:none; padding:4px; border-radius:var(--radius-sm); color:inherit;
}
.user-chip:hover{ background:var(--bg-surface-2); }
.avatar{
  width:32px; height:32px; border-radius:50%; background:var(--accent-soft); color:var(--accent);
  display:flex; align-items:center; justify-content:center; font-weight:700; font-size:12.5px; flex:none;
}
.user-chip .who{ display:flex; flex-direction:column; line-height:1.25; text-align:left; }
.user-chip .who b{ font-size:13px; }
.user-chip .who small{ font-size:11px; color:var(--text-muted); }

.usermenu-wrap{ position:relative; }
.usermenu{
  display:none; position:absolute; right:0; top:calc(100% + 6px); min-width:212px; z-index:20;
  background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-md);
  box-shadow:var(--shadow-md); padding:6px; flex-direction:column;
}
.usermenu.open{ display:flex; }
.usermenu-label{ font-size:10.5px; text-transform:uppercase; letter-spacing:0.05em; color:var(--text-muted); font-weight:700; padding:6px 10px 4px; }
.usermenu-item{
  display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:var(--radius-sm);
  border:none; background:none; cursor:pointer; font-size:13px; font-weight:600; color:var(--text-primary); text-align:left;
}
.usermenu-item svg{ width:16px; height:16px; flex:none; color:var(--text-muted); }
.usermenu-item:hover{ background:var(--bg-surface-2); }
.usermenu-item[disabled]{ opacity:0.42; cursor:default; }
.usermenu-item[disabled]:hover{ background:none; }
.usermenu-divider{ height:1px; background:var(--border); margin:6px 4px; }

.tabbar{
  display:flex; align-items:center; gap:26px; padding:0 24px;
  background:var(--bg-surface); border-bottom:1px solid var(--border);
  position:sticky; top:57px; z-index:9; overflow-x:auto;
}
.tab{
  display:flex; align-items:center; gap:8px; padding:12px 2px; margin-bottom:-1px;
  font-size:13.5px; font-weight:600; color:var(--text-muted); white-space:nowrap;
  background:none; border:none; border-bottom:2px solid transparent; cursor:pointer;
}
.tab svg{ width:16px; height:16px; flex:none; }
.tab:hover{ color:var(--text-primary); }
.tab.active{ color:var(--text-primary); border-bottom-color:var(--accent); }
.tab[disabled]{ opacity:0.42; cursor:default; }
.tab[disabled]:hover{ color:var(--text-muted); }

.view{ padding:26px 28px 48px; max-width:1240px; width:100%; margin:0 auto; }
.view-head{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:20px; gap:16px; flex-wrap:wrap; }
.view-head h1{ font-family:var(--font-display); font-size:23px; margin:0; font-weight:600; }
.view-head .meta{ color:var(--text-muted); font-size:12.5px; margin-top:3px; }

.panel{
  background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-md);
  box-shadow:var(--shadow-sm); overflow:hidden;
}
.panel-head{ display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-bottom:1px solid var(--border); }
.panel-head h2{ margin:0; font-size:14.5px; font-weight:700; }
.panel-head .hint{ font-size:12px; color:var(--text-muted); }

table{ width:100%; border-collapse:collapse; font-size:12.5px; }
thead th{
  text-align:left; font-size:10.5px; text-transform:uppercase; letter-spacing:0.05em;
  color:var(--text-muted); font-weight:700; padding:8px 14px; background:var(--bg-surface-2);
  border-bottom:1px solid var(--border);
}
tbody td{ padding:8px 14px; border-bottom:1px solid var(--border); vertical-align:middle; }
tbody tr:last-child td{ border-bottom:none; }
tbody tr:hover{ background:var(--bg-surface-2); }
.rowlink{ color:var(--accent); font-weight:700; text-decoration:none; font-size:12px; }
.rowlink:hover{ text-decoration:underline; }

/* ---- Toolbar (filters above a table, like a case-management worklist) ---- */
.statline{ display:flex; gap:16px; flex-wrap:wrap; font-size:12.5px; color:var(--text-secondary); }
.statline b{ font-family:var(--font-mono); font-weight:500; color:var(--text-primary); margin-right:4px; }
.toolbar{ display:flex; align-items:flex-end; gap:14px; padding:14px 18px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.tfield{ display:flex; flex-direction:column; gap:5px; }
.tfield.grow{ flex:1; min-width:180px; }
.tfield label{ font-size:10.5px; text-transform:uppercase; letter-spacing:0.05em; color:var(--text-muted); font-weight:700; }
.tfield .select{ min-width:150px; }
.subtabs{ display:flex; gap:2px; padding:0 18px; border-bottom:1px solid var(--border); }
.subtab{
  background:none; border:none; cursor:pointer; padding:10px 4px; margin-right:22px;
  font-size:12.5px; font-weight:700; color:var(--text-muted); border-bottom:2px solid transparent;
}
.subtab .count{ font-family:var(--font-mono); font-weight:500; color:var(--text-muted); margin-left:5px; }
.subtab.active{ color:var(--text-primary); border-bottom-color:var(--accent); }
.subtab.active .count{ color:var(--text-primary); }
.tablefoot{ display:flex; align-items:center; justify-content:space-between; padding:10px 18px; font-size:12px; color:var(--text-muted); }
.subject-cell{ display:flex; flex-direction:column; }
.subject-cell b{ font-size:13.5px; }
.subject-cell small{ color:var(--text-muted); font-size:11.5px; }

.pill{
  display:inline-flex; align-items:center; gap:6px; padding:3px 9px; border-radius:99px;
  font-size:11.5px; font-weight:700; letter-spacing:0.01em; white-space:nowrap;
}
.pill::before{ content:''; width:6px; height:6px; border-radius:50%; background:currentColor; }
.pill.critical{ background:var(--risk-critical-bg); color:var(--risk-critical); }
.pill.warning{ background:var(--risk-warning-bg); color:var(--risk-warning); }
.pill.clear{ background:var(--risk-clear-bg); color:var(--risk-clear); }
.pill.neutral{ background:var(--bg-surface-2); color:var(--text-secondary); }
.pill.accent{ background:var(--accent-soft); color:var(--accent); }

.tablewrap{ overflow-x:auto; }

/* Users view */
.role-cards{ display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:22px; }
@media (max-width:980px){ .role-cards{ grid-template-columns:repeat(2,1fr); } }
.role-card{
  background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:16px; box-shadow:var(--shadow-sm); display:flex; flex-direction:column; gap:10px;
}
.role-card.dashed{ border-style:dashed; align-items:center; justify-content:center; text-align:center; color:var(--text-muted); gap:6px; }
.role-card .rname{ font-weight:700; font-size:14px; }
.role-card .rcount{ font-size:11.5px; color:var(--text-muted); }
.chipset{ display:flex; flex-wrap:wrap; gap:6px; }
.chip{
  font-size:10.5px; font-weight:700; letter-spacing:0.01em; padding:3px 8px; border-radius:99px;
  border:1px solid var(--border-strong); color:var(--text-muted);
}
.chip.on{ background:var(--accent-soft); color:var(--accent); border-color:transparent; }

.avatar-sm{ width:26px; height:26px; border-radius:50%; background:var(--bg-surface-2); color:var(--text-secondary); display:inline-flex; align-items:center; justify-content:center; font-size:10.5px; font-weight:700; margin-right:8px; }

/* Case review */
.case-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:20px; flex-wrap:wrap; margin-bottom:18px; }
.case-head h1{ font-family:var(--font-display); font-size:26px; font-weight:600; margin:0 0 4px; }
.case-sub{ color:var(--text-secondary); font-size:13px; }
.tagrow{ display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }

.hit{ border-bottom:1px solid var(--border); padding:18px; display:grid; grid-template-columns:1fr 200px; gap:18px; }
.hit:last-child{ border-bottom:none; }
.hit-source{ font-size:11px; text-transform:uppercase; letter-spacing:0.06em; color:var(--text-muted); font-weight:700; margin-bottom:4px; }
.hit h3{ font-family:var(--font-display); font-size:16px; font-weight:600; margin:0 0 6px; line-height:1.35; }
.hit p{ margin:0 0 10px; color:var(--text-secondary); font-size:13px; }
.hit-meta{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; font-size:12px; color:var(--text-muted); }
.hit-side{ display:flex; flex-direction:column; gap:8px; align-items:flex-start; }
.hit-side label{ font-size:10.5px; text-transform:uppercase; letter-spacing:0.05em; color:var(--text-muted); font-weight:700; }
.select{
  width:100%; padding:7px 10px; border-radius:var(--radius-sm); border:1px solid var(--border-strong);
  background:var(--bg-surface); color:var(--text-primary); font-size:12.5px;
}
.confidence{ font-family:var(--font-mono); font-size:12.5px; color:var(--text-secondary); }

.review-bar{
  position:sticky; bottom:0; display:flex; gap:10px; align-items:center; justify-content:flex-end;
  padding:14px 18px; background:var(--bg-surface); border-top:1px solid var(--border);
}
.review-bar .note{ flex:1; }
.review-bar textarea{
  width:100%; resize:none; border:1px solid var(--border-strong); border-radius:var(--radius-sm);
  padding:8px 10px; font-family:inherit; font-size:12.5px; color:var(--text-primary); background:var(--bg-surface);
  height:36px;
}
