/* ---------- DESIGN TOKENS ---------- */
:root{
  --bg:#FAFAFB; --bg-2:#F4F4F7; --surface:#FFFFFF; --surface-2:#FBFBFD;
  --ink:#0B0F1A; --ink-2:#1F2937; --muted:#6B7280; --muted-2:#9CA3AF;
  --line:#ECECF1; --line-2:#D7D7DE;
  --brand:#4F46E5; --brand-hover:#4338CA; --brand-soft:#EEF2FF; --brand-soft-2:#E0E7FF; --brand-ink:#312E81;
  --teal:#0D9488; --teal-soft:#CCFBF1;
  --good:#059669; --good-soft:#ECFDF5;
  --warn:#D97706; --warn-soft:#FFFBEB;
  --bad:#DC2626;  --bad-soft:#FEF2F2;
  --shadow-sm:0 1px 2px rgba(11,15,26,.05);
  --shadow-md:0 4px 14px rgba(11,15,26,.06),0 1px 3px rgba(11,15,26,.04);
  --shadow-lg:0 24px 48px rgba(11,15,26,.10),0 2px 6px rgba(11,15,26,.05);
  --shadow-focus:0 0 0 3px rgba(79,70,229,.18);
  --r-sm:6px; --r-md:10px; --r-lg:14px; --pill:999px;
  --font-body:-apple-system,BlinkMacSystemFont,"Inter","Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --font-mono:ui-monospace,SFMono-Regular,"JetBrains Mono",Menlo,Consolas,monospace;
}
:root.dark{
  --bg:#0B0F1A; --bg-2:#0F172A; --surface:#111827; --surface-2:#0F172A;
  --ink:#F9FAFB; --ink-2:#E5E7EB; --muted:#9CA3AF; --muted-2:#6B7280;
  --line:#1F2937; --line-2:#374151;
  --brand:#818CF8; --brand-hover:#A5B4FC; --brand-soft:#1E1B4B; --brand-soft-2:#312E81; --brand-ink:#C7D2FE;
  --good:#34D399; --good-soft:#064E3B; --warn:#FBBF24; --warn-soft:#422006; --bad:#F87171; --bad-soft:#450A0A;
  --shadow-md:0 4px 14px rgba(0,0,0,.40),0 1px 3px rgba(0,0,0,.20);
}

/* ---------- RESET + BASE ---------- */
*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font-family:var(--font-body);background:var(--bg);color:var(--ink);font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;letter-spacing:-0.005em}
button,input,select,textarea{font:inherit;color:inherit}
button{background:none;border:0;cursor:pointer;padding:0}
a{color:var(--brand);text-decoration:none}
.tnum{font-variant-numeric:tabular-nums}
.mono{font-family:var(--font-mono)}

/* ---------- COMPONENTS ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:9px 14px;border-radius:var(--r-md);font-weight:600;font-size:13.5px;border:1px solid transparent;transition:all .15s ease;white-space:nowrap}
.btn-primary{background:var(--brand);color:#fff}
.btn-primary:hover{background:var(--brand-hover)}
.btn-secondary{background:var(--surface);color:var(--ink);border-color:var(--line-2)}
.btn-secondary:hover{background:var(--bg-2);border-color:var(--muted-2)}
.btn-ghost{color:var(--ink)}
.btn-ghost:hover{background:var(--bg-2)}
.btn-danger{background:var(--bad);color:#fff}
.btn:focus-visible{outline:none;box-shadow:var(--shadow-focus)}
.btn-sm{padding:6px 10px;font-size:12.5px;border-radius:var(--r-sm)}
.btn:disabled{opacity:.5;cursor:not-allowed}

.input,.select{display:block;width:100%;padding:9px 12px;border-radius:var(--r-md);background:var(--surface);color:var(--ink);border:1px solid var(--line-2);font-size:14px;transition:border-color .15s, box-shadow .15s}
.input:focus,.select:focus{outline:none;border-color:var(--brand);box-shadow:var(--shadow-focus)}
.input::placeholder{color:var(--muted-2)}
.field{display:flex;flex-direction:column;gap:6px;margin-bottom:14px}
.field label{font-size:12px;font-weight:600;color:var(--ink-2)}
.field .hint{font-size:11.5px;color:var(--muted)}

.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);box-shadow:var(--shadow-sm)}
.card-header{padding:14px 18px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:12px}
.card-header h3{margin:0;font-size:14px;font-weight:600;color:var(--ink)}
.card-body{padding:18px}
.card-footer{padding:12px 18px;border-top:1px solid var(--line);background:var(--surface-2);border-radius:0 0 var(--r-lg) var(--r-lg);display:flex;justify-content:flex-end;gap:8px}

.badge{display:inline-flex;align-items:center;gap:5px;padding:3px 9px;border-radius:var(--pill);font-size:11.5px;font-weight:600;border:1px solid transparent}
.badge::before{content:"";display:inline-block;width:6px;height:6px;border-radius:50%;background:currentColor}
.badge-good{background:var(--good-soft);color:var(--good);border-color:#A7F3D0}
.badge-warn{background:var(--warn-soft);color:var(--warn);border-color:#FCD34D}
.badge-bad {background:var(--bad-soft);color:var(--bad);border-color:#FCA5A5}
.badge-info{background:var(--brand-soft);color:var(--brand-ink);border-color:var(--brand-soft-2)}
.badge-mute{background:var(--bg-2);color:var(--muted);border-color:var(--line)}

.kbd{font-family:var(--font-mono);font-size:11px;padding:2px 6px;border-radius:5px;background:var(--bg-2);border:1px solid var(--line);color:var(--muted)}

/* ---------- LOGIN ---------- */
.login-shell{min-height:100vh;display:grid;grid-template-columns:1.05fr 1fr;background:var(--bg)}
@media (max-width:880px){.login-shell{grid-template-columns:1fr}.login-art{display:none}}
.login-form-wrap{display:flex;align-items:center;justify-content:center;padding:32px}
.login-card{width:100%;max-width:440px}
.login-card .brand{display:flex;align-items:center;gap:10px;margin-bottom:32px}
.login-card .brand .mark{width:38px;height:38px;border-radius:10px;background:var(--brand);color:#fff;display:grid;place-items:center;font-weight:800;font-size:18px;box-shadow:0 4px 12px rgba(79,70,229,.30)}
.login-card .brand .name{font-weight:700;font-size:18px;letter-spacing:-0.02em}
.login-card .study-pill{display:inline-flex;align-items:center;gap:8px;background:var(--brand-soft);border:1px solid var(--brand-soft-2);color:var(--brand-ink);padding:5px 10px;border-radius:var(--pill);font-size:11.5px;font-weight:600;margin-bottom:18px}
.login-card .study-pill .dot{width:6px;height:6px;border-radius:50%;background:var(--brand)}
.login-card h1{font-size:28px;margin:0 0 8px 0;letter-spacing:-0.025em;font-weight:700}
.login-card p.sub{color:var(--muted);margin:0 0 24px 0;font-size:14.5px;line-height:1.55}
.login-card .btn-primary{width:100%;padding:11px;font-size:14.5px;margin-top:6px}
.login-card .helpers{display:flex;justify-content:space-between;align-items:center;margin-top:18px;font-size:12.5px;color:var(--muted)}
.login-card .helpers a{color:var(--brand);font-weight:500}
.login-card .demo-hint{margin-top:24px;padding:12px 14px;background:#FFFBEB;border:1px solid #FCD34D;border-radius:var(--r-md);font-size:12.5px;color:#7C2D12;line-height:1.55}
.login-card .demo-hint b{font-weight:700}
.login-error{background:var(--bad-soft);color:var(--bad);border:1px solid #FCA5A5;border-radius:var(--r-md);padding:10px 12px;font-size:12.5px;margin-top:12px;display:none}
.login-error.show{display:block}

.login-art{
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(79,70,229,.16), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(13,148,136,.18), transparent 55%),
    linear-gradient(135deg, #1E1B4B 0%, #0F172A 100%);
  color:#E5E7EB;padding:48px;display:flex;flex-direction:column;justify-content:space-between;position:relative;overflow:hidden;
}
.login-art .study-mark{display:inline-flex;align-items:center;gap:10px;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.12);padding:6px 12px;border-radius:var(--pill);font-size:12px;color:#C7D2FE;backdrop-filter:blur(8px);width:fit-content}
.login-art .quote{font-size:22px;line-height:1.4;font-weight:500;letter-spacing:-0.015em;max-width:520px;margin-top:18px}
.login-art .quote .accent{color:#A5B4FC}
.login-art .quote-cite{color:#A1A1AA;font-size:13px;margin-top:14px}
.login-art .footer{font-size:12px;color:#A1A1AA;display:flex;gap:18px;align-items:center}
.login-art .footer .dot{width:5px;height:5px;background:#A1A1AA;border-radius:50%}

/* ---------- APP SHELL ---------- */
.app-shell{display:grid;grid-template-columns:248px 1fr;min-height:100vh}
@media (max-width:920px){.app-shell{grid-template-columns:1fr}.sidebar{display:none}}

.sidebar{background:var(--surface);border-right:1px solid var(--line);display:flex;flex-direction:column;padding:18px 14px;gap:6px;position:sticky;top:0;height:100vh}
.sidebar .brand{display:flex;align-items:center;gap:10px;padding:6px 8px 14px;border-bottom:1px solid var(--line);margin-bottom:10px}
.sidebar .brand .mark{width:30px;height:30px;border-radius:8px;background:var(--brand);color:#fff;display:grid;place-items:center;font-weight:800;font-size:14px}
.sidebar .brand .name{font-weight:700;letter-spacing:-0.015em}
.sidebar .nav-section{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted-2);padding:14px 10px 6px;font-weight:600}
.nav-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:var(--r-md);color:var(--ink-2);font-size:13.5px;font-weight:500;cursor:pointer;transition:background .15s,color .15s}
.nav-item:hover{background:var(--bg-2)}
.nav-item.active{background:var(--brand-soft);color:var(--brand-ink);font-weight:600}
.nav-item .ic{width:18px;height:18px;display:grid;place-items:center;color:var(--muted)}
.nav-item.active .ic{color:var(--brand)}
.nav-item .count{margin-left:auto;font-size:11px;color:var(--muted);background:var(--bg-2);padding:1px 8px;border-radius:var(--pill)}
.sidebar .study-card{background:var(--surface-2);border:1px solid var(--line);border-radius:var(--r-md);padding:10px 12px;margin-top:auto;margin-bottom:12px;font-size:11.5px}
.sidebar .study-card .lbl{font-size:10px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted-2);font-weight:600}
.sidebar .study-card b{display:block;font-weight:600;color:var(--ink);margin-top:2px}
.sidebar .study-card .meta{color:var(--muted);margin-top:4px;line-height:1.4}
.sidebar .footer{border-top:1px solid var(--line);padding-top:12px;display:flex;align-items:center;gap:10px}
.avatar{width:32px;height:32px;border-radius:50%;background:linear-gradient(135deg,#6366F1,#0D9488);color:#fff;display:grid;place-items:center;font-weight:700;font-size:13px}
.sidebar .footer .who{font-size:12.5px;line-height:1.3}
.sidebar .footer .who b{display:block;font-weight:600}
.sidebar .footer .who span{color:var(--muted);display:inline-flex;align-items:center;gap:3px}
.sidebar .footer .who span .icon{width:10px;height:10px}
.sidebar .footer .menu{margin-left:auto;color:var(--muted);padding:6px;border-radius:6px}
.sidebar .footer .menu:hover{background:var(--bg-2);color:var(--ink)}

.main{display:flex;flex-direction:column;min-width:0}
.topbar{background:var(--surface);border-bottom:1px solid var(--line);padding:12px 24px;display:flex;align-items:center;gap:14px;position:sticky;top:0;z-index:10;backdrop-filter:saturate(140%) blur(8px)}
.topbar .study{display:flex;align-items:center;gap:8px;background:var(--bg-2);border:1px solid var(--line);padding:6px 10px;border-radius:var(--pill);font-size:12.5px;color:var(--ink-2)}
.topbar .study b{font-weight:600}
.topbar .study .dot{width:6px;height:6px;border-radius:50%;background:var(--good)}
.topbar .search{flex:1;max-width:420px;position:relative}
.topbar .search input{width:100%;padding:8px 12px 8px 34px;border-radius:var(--r-md);background:var(--bg-2);border:1px solid transparent;color:var(--ink);font-size:13px}
.topbar .search input:focus{outline:none;background:var(--surface);border-color:var(--line-2);box-shadow:var(--shadow-focus)}
.topbar .search .ic{position:absolute;left:11px;top:50%;transform:translateY(-50%);color:var(--muted-2)}
.topbar .search .kbd{position:absolute;right:8px;top:50%;transform:translateY(-50%)}
.topbar .right{display:flex;align-items:center;gap:8px;margin-left:auto}
.topbar .icon-btn{position:relative;width:34px;height:34px;border-radius:var(--r-md);display:grid;place-items:center;color:var(--muted)}
.topbar .icon-btn:hover{background:var(--bg-2);color:var(--ink)}
.topbar .account-chip{display:flex;align-items:center;gap:10px;margin-left:6px;padding:6px 14px 6px 6px;border-radius:999px;cursor:pointer;border:1px solid var(--line);background:var(--bg-2)}
.icon-badge{position:absolute;top:-3px;right:-3px;background:var(--bad);color:#fff;font-size:10px;font-weight:700;min-width:16px;height:16px;border-radius:8px;display:flex;align-items:center;justify-content:center;padding:0 4px;line-height:1;box-shadow:0 0 0 2px var(--surface)}

/* topbar dropdown panels (notifications, help) — anchored under their
   trigger icon, appended to document.body independent of the shell's own
   render cycle so opening one never gets clobbered by the next render() */
.topbar-panel{position:fixed;width:320px;max-height:420px;overflow-y:auto;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);box-shadow:var(--shadow-lg);z-index:250;animation:popIn .15s ease}
.topbar-panel-head{padding:12px 16px;font-weight:700;font-size:13.5px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:8px}
.topbar-panel-head .count-badge{background:var(--bad-soft);color:var(--bad);font-size:11px;font-weight:700;border-radius:999px;padding:1px 7px}
.topbar-panel-body{padding:6px}
.notif-row{display:flex;gap:10px;align-items:flex-start;padding:9px 10px;border-radius:var(--r-md);cursor:pointer}
.notif-row:hover{background:var(--surface-2)}
.notif-dot{width:8px;height:8px;border-radius:50%;margin-top:5px;flex-shrink:0;background:var(--muted)}
.notif-row.bad .notif-dot{background:var(--bad)}
.notif-row.warn .notif-dot{background:var(--warn)}

.queue-row{display:flex;align-items:center;gap:12px;padding:12px 14px;border:1px solid var(--line);border-left:3px solid var(--line-2);border-radius:var(--r-md);margin-bottom:8px;cursor:pointer}
.queue-row:hover{border-color:var(--line-2)}
.queue-row.bad{border-left-color:var(--bad)}
.queue-row.warn{border-left-color:var(--warn)}
.queue-row.info{border-left-color:var(--brand)}
.queue-row-icon{flex-shrink:0;width:20px;height:20px;display:grid;place-items:center;color:var(--muted)}
.queue-row.bad .queue-row-icon{color:var(--bad)}
.queue-row.warn .queue-row-icon{color:var(--warn)}
.queue-row.info .queue-row-icon{color:var(--brand)}
.queue-row-icon .icon{width:18px;height:18px}
.queue-row-body{flex:1;min-width:0}
.queue-row-text{font-size:13.5px;font-weight:600;color:var(--ink)}
.queue-row-sub{font-size:12px;color:var(--muted);margin-top:2px}
.queue-row-ts{font-size:11px;color:var(--muted);white-space:nowrap;flex-shrink:0}
.notif-text{font-size:13px;font-weight:600;color:var(--ink)}
.notif-sub{font-size:12px;color:var(--muted);margin-top:2px}
.notif-empty{padding:20px 14px;text-align:center;color:var(--muted);font-size:13px}
.help-text{font-size:13px;color:var(--ink-2);line-height:1.5;padding:10px 14px 4px;margin:0}
.help-link{display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;font-weight:600;color:var(--brand-ink);text-decoration:none}
.help-link:hover{background:var(--surface-2)}
.help-link .icon{width:15px;height:15px}
.help-shortcut{display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:12.5px;color:var(--muted)}
.topbar .account-chip:hover{background:var(--bg-3,var(--bg-2));border-color:var(--brand)}
.topbar .account-chip .avatar{width:34px;height:34px;font-size:14px}
.topbar .account-chip .who{font-size:13px;line-height:1.3;text-align:left}
.topbar .account-chip .who b{display:block;font-weight:600}
.topbar .account-chip .who span{color:var(--muted);display:inline-flex;align-items:center;gap:3px;font-size:11.5px}
.topbar .account-chip .who span .icon{width:10px;height:10px}

.page{padding:28px 32px 64px;max-width:1320px;width:100%;margin:0 auto}

/* ---------- SUBJECT PAGE LAYOUT + VISIT NAV SIDEBAR ---------- */
.subject-layout{display:grid;grid-template-columns:250px 1fr;gap:18px;align-items:start}
@media (max-width:900px){ .subject-layout{grid-template-columns:1fr} }
.visit-nav{
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);
  box-shadow:var(--shadow-sm);position:sticky;top:16px;
  max-height:calc(100vh - 32px);overflow-y:auto;
}
.visit-nav-head{
  padding:14px 16px;font-size:11px;font-weight:700;text-transform:uppercase;
  letter-spacing:.06em;color:var(--muted);border-bottom:1px solid var(--line);
}
.visit-nav-body{padding:6px}
.nav-group{border-bottom:1px solid var(--line)}
.nav-group:last-child{border-bottom:0}
.nav-group.current .nav-visit-head{background:var(--brand-soft)}
.nav-visit-head{
  display:flex;align-items:center;gap:8px;padding:10px;cursor:pointer;
  border-radius:var(--r-md);
}
.nav-visit-head:hover{background:var(--surface-2)}
.nav-chev{display:inline-block;transition:transform .15s ease;color:var(--muted);font-size:13px}
.nav-chev.open{transform:rotate(90deg)}
.nav-visit-name{font-size:13.5px;font-weight:600;color:var(--ink)}
.nav-visit-date{margin-left:auto;font-size:11px;color:var(--muted)}
.nav-visit-tag{
  margin-left:auto;font-size:10.5px;font-weight:700;color:var(--brand-ink);
  background:var(--brand-soft-2);padding:2px 7px;border-radius:var(--pill);
}
.nav-visit-sign{padding:0 10px 8px;display:flex;justify-content:flex-end}
.sig-badge{
  font-size:10.5px;font-weight:700;padding:3px 8px;border-radius:var(--pill);
  display:inline-flex;align-items:center;gap:4px;
}
.sig-badge.signed{color:var(--good, #16794c);background:var(--good-soft, #e3f6ec)}
.sig-badge.stale{color:var(--warn);background:var(--warn-soft)}
.sign-visit-btn{font-size:11.5px;padding:4px 10px}
.nav-forms{display:none;flex-direction:column;padding-left:6px;padding-bottom:4px}
.nav-forms.open{display:flex}
.nav-form-row{
  display:flex;align-items:center;gap:9px;padding:7px 10px 7px 22px;
  border-radius:var(--r-md);cursor:pointer;font-size:12.5px;color:var(--ink-2);
}
.nav-form-row:hover{background:var(--surface-2);color:var(--ink)}
.nav-form-row .form-name{flex:1}
.page-head{display:flex;align-items:center;gap:14px;margin-bottom:22px}
.page-head h1{margin:0;font-size:22px;font-weight:700;letter-spacing:-0.025em}
.page-head .sub{color:var(--muted);font-size:13.5px;margin-top:4px}
.page-head .right{margin-left:auto;display:flex;gap:8px}

/* ---------- KPIs ---------- */
.kpi-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:22px}
@media (max-width:980px){.kpi-grid{grid-template-columns:repeat(2,1fr)}}
.kpi{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:16px 18px;box-shadow:var(--shadow-sm)}
.kpi .label{font-size:12px;color:var(--muted);font-weight:500;display:flex;align-items:center;gap:8px}
.kpi .label .ic{color:var(--brand)}
.kpi .value{font-size:26px;font-weight:700;letter-spacing:-0.025em;margin-top:8px}
.kpi .delta{font-size:12px;color:var(--muted);margin-top:4px}
.kpi .delta.up{color:var(--good)} .kpi .delta.down{color:var(--bad)}

/* ---------- STUDY OVERVIEW CARD ---------- */
.study-overview{background:linear-gradient(135deg,#F8FAFF 0%,#FFFFFF 70%);border:1px solid var(--brand-soft-2);border-radius:var(--r-lg);padding:22px 24px;margin-bottom:22px;display:grid;grid-template-columns:1fr auto;gap:18px}
:root.dark .study-overview{background:linear-gradient(135deg,#1E1B4B 0%, var(--surface) 70%)}
.study-overview .title{font-size:13px;color:var(--brand-ink);font-weight:600;letter-spacing:.04em;text-transform:uppercase;display:flex;align-items:center;gap:8px}
.study-overview h2{margin:8px 0 4px;font-size:18px;font-weight:700;letter-spacing:-0.02em}
.study-overview .meta{color:var(--muted);font-size:13px}
.study-overview .arms{display:flex;gap:10px;margin-top:14px}
.study-overview .arm{padding:8px 12px;border-radius:var(--r-md);background:var(--surface);border:1px solid var(--line);font-size:12.5px}
.study-overview .arm b{color:var(--ink);font-weight:600;display:block}
.study-overview .arm span{color:var(--muted)}
.study-overview .progress{display:flex;flex-direction:column;align-items:flex-end;gap:6px}
.study-overview .progress .bar{width:240px;height:6px;background:var(--bg-2);border-radius:var(--pill);overflow:hidden}
.study-overview .progress .bar .fill{height:100%;background:linear-gradient(90deg,var(--brand),var(--teal));border-radius:var(--pill)}
.study-overview .progress .lbl{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;font-weight:600}
.study-overview .progress .pct{font-size:18px;font-weight:700;font-variant-numeric:tabular-nums}

/* ---------- SUBJECT CARDS ---------- */
.section-head{display:flex;align-items:baseline;gap:10px;margin:8px 0 12px}
.section-head h2{margin:0;font-size:14px;font-weight:600}
.section-head .sub{color:var(--muted);font-size:12.5px}
.section-head .right{margin-left:auto;font-size:12px;color:var(--muted)}

.subject-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:16px 18px;display:grid;grid-template-columns:46px 1fr auto auto;align-items:center;gap:14px;cursor:pointer;transition:all .15s;margin-bottom:10px}
.subject-card:hover{border-color:var(--line-2);box-shadow:var(--shadow-md);transform:translateY(-1px)}
.subject-card .id-mark{width:42px;height:42px;border-radius:var(--r-md);background:var(--brand-soft);color:var(--brand-ink);display:grid;place-items:center;font-weight:700;font-size:13px}
.subject-card.alert .id-mark{background:var(--bad-soft);color:var(--bad)}
.subject-card .name{font-weight:600;color:var(--ink);font-size:14.5px;letter-spacing:-0.01em}
.subject-card .meta{color:var(--muted);font-size:12.5px;margin-top:2px}
.subject-card .stats{display:flex;gap:18px;font-size:12px;color:var(--muted)}
.subject-card .stats b{display:block;font-weight:600;color:var(--ink);font-size:14px;font-family:var(--font-mono)}
.subject-card .actions{display:flex;align-items:center;gap:8px}
.subject-card.alert{border-color:#FCA5A5;background:linear-gradient(180deg,#FEF2F2 0%,var(--surface) 60%)}
:root.dark .subject-card.alert{background:linear-gradient(180deg, #450A0A 0%, var(--surface) 60%)}
.arm-tag{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:var(--pill);font-size:11px;font-weight:600;background:var(--bg-2);color:var(--ink-2);border:1px solid var(--line)}
.arm-tag.invest{background:var(--brand-soft);color:var(--brand-ink);border-color:var(--brand-soft-2)}
.arm-tag.compar{background:var(--teal-soft);color:#115E59;border-color:#5EEAD4}
.arm-tag.masked{background:var(--bg-2);color:var(--muted);border-color:var(--line-2)}
.arm-tag.masked .icon{width:11px;height:11px}

/* ---------- ALERT BANNER ---------- */
.alert-banner{border-radius:var(--r-lg);padding:16px 18px;display:flex;gap:14px;align-items:flex-start;border:1px solid;margin-bottom:18px;font-size:14px}
.alert-banner.alert{background:var(--bad-soft);border-color:#FCA5A5;color:#7F1D1D}
.alert-banner.warn {background:var(--warn-soft);border-color:#FCD34D;color:#7C2D12}
.alert-banner.ok   {background:var(--good-soft);border-color:#A7F3D0;color:#14532D}
.alert-banner .ic-wrap{width:32px;height:32px;border-radius:8px;display:grid;place-items:center;font-weight:700;font-size:16px;flex-shrink:0}
.alert-banner.alert .ic-wrap{background:#FCA5A5;color:#7F1D1D}
.alert-banner.warn  .ic-wrap{background:#FCD34D;color:#7C2D12}
.alert-banner.ok    .ic-wrap{background:#A7F3D0;color:#14532D}
.alert-banner h4{margin:0 0 4px;font-size:14.5px;font-weight:700;letter-spacing:-0.01em}
.alert-banner p{margin:0;font-size:13.5px;line-height:1.5}
.alert-banner .why{font-size:12.5px;opacity:.85;margin-top:8px;display:flex;flex-wrap:wrap;gap:6px}
.alert-banner .pill{background:rgba(255,255,255,.55);padding:3px 9px;border-radius:var(--pill);font-family:var(--font-body);font-size:12px;font-weight:600;letter-spacing:-0.005em;font-variant-numeric:tabular-nums}
.alert-banner .gating{margin-top:10px;padding:8px 10px;background:rgba(255,255,255,.5);border-radius:var(--r-sm);font-size:12px;line-height:1.5}
.alert-banner .gating b{color:#7F1D1D;font-weight:700}
:root.dark .alert-banner .pill{background:rgba(255,255,255,.10)}
:root.dark .alert-banner .gating{background:rgba(255,255,255,.06)}
/* Dark mode: the *-soft background tokens go very dark, but these banners'
   body text stayed hardcoded to the light-mode dark-on-light shade — nearly
   invisible against the now-dark background. Lighten the text (and the
   "gating" bold callout) to match. */
:root.dark .alert-banner.ok{color:#86EFAC}
:root.dark .alert-banner.warn{color:#FCD34D}
:root.dark .alert-banner.alert{color:#FCA5A5}
:root.dark .alert-banner .gating b{color:#FCA5A5}

/* ---------- SUBJECT DETAIL ---------- */
.subject-head{display:flex;align-items:center;gap:18px;padding:18px 22px;border-bottom:1px solid var(--line)}
.subject-head .id-mark{width:48px;height:48px;border-radius:var(--r-md);background:var(--brand-soft);color:var(--brand-ink);display:grid;place-items:center;font-weight:700;font-size:14px}
.subject-head h2{margin:0;font-size:18px;font-weight:700;letter-spacing:-0.02em}
.subject-head .meta{color:var(--muted);font-size:13px;margin-top:2px}
.subject-head .vitals{margin-left:auto;display:flex;gap:24px}
.subject-head .vitals .v{display:flex;flex-direction:column;align-items:flex-end}
.subject-head .vitals .lbl{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;font-weight:600}
.subject-head .vitals .val{font-size:18px;font-weight:700;font-family:var(--font-mono);letter-spacing:-0.01em;margin-top:2px}

.tabs{display:flex;gap:2px;padding:8px 14px;border-bottom:1px solid var(--line)}
.tab{padding:8px 14px;border-radius:var(--r-md);font-size:13.5px;color:var(--muted);font-weight:500;cursor:pointer}
.tab:hover{background:var(--bg-2);color:var(--ink-2)}
.tab.active{background:var(--brand-soft);color:var(--brand-ink);font-weight:600}

.split{display:grid;grid-template-columns:1.2fr 1fr;gap:18px}
@media (max-width:1080px){.split{grid-template-columns:1fr}}

.eyebox{border:1px solid var(--line);border-radius:var(--r-md);padding:14px;background:var(--surface-2)}
.eyebox h5{margin:0 0 10px 0;font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--brand);font-weight:700}
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:12px}

/* visit window indicator */
.visit-banner{display:flex;align-items:center;gap:14px;padding:12px 18px;border-bottom:1px solid var(--line);background:var(--surface-2)}
.visit-banner .vinfo{display:flex;flex-direction:column}
.visit-banner .vinfo b{font-size:14px;font-weight:600;color:var(--ink)}
.visit-banner .vinfo span{font-size:12px;color:var(--muted)}
.visit-banner .window{margin-left:auto;display:flex;align-items:center;gap:8px}
.visit-banner .window .pill{font-family:var(--font-mono);font-size:11.5px;padding:3px 9px;border-radius:var(--pill);background:var(--bg-2);color:var(--ink-2);border:1px solid var(--line)}
.visit-banner .window .pill.in{background:var(--good-soft);color:var(--good);border-color:#A7F3D0}
.visit-banner .window .pill.out{background:var(--bad-soft);color:var(--bad);border-color:#FCA5A5}

/* assessment checklist */
.checklist{padding:16px 22px;border-bottom:1px solid var(--line);background:var(--surface)}
.checklist .lbl{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);font-weight:600;margin-bottom:10px}
.checklist .items{display:flex;flex-wrap:wrap;gap:8px}
.check-pill{display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:var(--pill);font-size:12px;background:var(--bg-2);color:var(--ink-2);border:1px solid var(--line);font-weight:500;cursor:pointer;transition:transform .12s ease, box-shadow .12s ease, border-color .12s ease}
.check-pill:hover{transform:translateY(-1px);box-shadow:var(--shadow-sm);border-color:var(--brand)}
.check-pill.done{background:var(--good-soft);color:var(--good);border-color:#A7F3D0}
.check-pill.required{border-color:var(--brand-soft-2);background:var(--brand-soft);color:var(--brand-ink)}
.check-pill .x{font-weight:700}
.check-pill .done-mark{display:inline-block;width:14px;height:14px;border-radius:50%;background:var(--good);color:#fff;font-size:9px;font-weight:800;text-align:center;line-height:14px;margin-right:2px}

/* longitudinal table */
.ltable{width:100%;border-collapse:separate;border-spacing:0;font-size:13.5px}
.ltable th{text-align:left;padding:10px 14px;font-size:11.5px;letter-spacing:0;color:var(--muted);background:var(--surface-2);border-bottom:1px solid var(--line);font-weight:500}
.ltable td{padding:11px 14px;border-bottom:1px solid var(--line);font-family:var(--font-body);color:var(--ink-2);font-variant-numeric:tabular-nums;letter-spacing:-0.005em}
.ltable tr:last-child td{border-bottom:0}
.ltable td.flag{color:var(--bad);font-weight:600}
.ltable td.flag-warn{color:var(--warn);font-weight:500}
.ltable td.best{color:var(--brand);font-weight:600;background:var(--brand-soft);border-radius:6px}
.ltable td.lowest{color:#115E59;font-weight:600;background:var(--teal-soft);border-radius:6px}
.ltable tr.pending td{background:linear-gradient(90deg, rgba(217,119,6,.08), transparent)}
.ltable tr.pending td:first-child{box-shadow:inset 3px 0 0 var(--warn)}
.ltable tr.clickable{cursor:pointer;transition:background .12s ease}
.ltable tr.clickable:hover td{background:var(--surface-2)}

/* visit forms list (Medidata-style: visit -> list of forms) */
.forms-list{display:flex;flex-direction:column;border:1px solid var(--line);border-radius:var(--r-md);overflow:hidden}
.form-row{display:flex;align-items:center;gap:12px;padding:12px 14px;border-bottom:1px solid var(--line);cursor:pointer;transition:background .12s ease}
.form-row:last-child{border-bottom:0}
.form-row:hover{background:var(--surface-2)}
.form-dot{width:9px;height:9px;border-radius:50%;background:var(--line);flex-shrink:0}
.form-dot.done{background:var(--good)}
.form-name{flex:1;font-size:13.5px;color:var(--ink-2)}
.form-chev{color:var(--muted);font-size:16px;line-height:1}

/* generic CRF engine — schema-driven form fields */
.crf-form{display:flex;flex-direction:column;gap:12px}
.crf-row{display:grid;grid-template-columns:1fr 1fr;gap:6px 14px;align-items:center}
.crf-row .crf-lbl{font-size:12.5px;color:var(--muted);font-weight:600}
.crf-unit{font-weight:400;color:var(--muted)}
.crf-check-row{grid-template-columns:1fr}
.crf-check{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--ink-2);cursor:pointer}
.crf-multicheck{grid-template-columns:1fr}
.crf-multicheck-opts{display:flex;flex-wrap:wrap;gap:8px 18px;margin-top:2px}
.crf-heading{
  font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;
  color:var(--ink); padding-top:10px; margin-top:4px; border-top:1px solid var(--line);
}
.crf-heading:first-child{border-top:0;padding-top:0;margin-top:0}
.crf-row.invalid{background:var(--bad-soft);border-radius:var(--r-md);padding:6px 8px;margin:0 -8px}
.crf-row.invalid .crf-lbl{color:var(--bad)}
.crf-row.invalid .crf-field, .crf-row.invalid .input, .crf-row.invalid .select{border-color:var(--bad) !important}

/* per-data-point audit icon — small, quiet, doesn't compete with the input */
.crf-field-wrap{display:flex;align-items:center;gap:8px}
.crf-field-wrap .input, .crf-field-wrap .select{flex:1}
.crf-audit-btn{
  flex-shrink:0;width:32px;height:32px;border-radius:var(--r-sm,6px);border:1px solid transparent;
  background:none;color:var(--muted);display:grid;place-items:center;cursor:pointer;padding:0;
}
.crf-audit-btn:hover{background:var(--surface-2);color:var(--ink-2);border-color:var(--line)}
.crf-audit-btn .icon{width:19px;height:19px}
.crf-check-row .crf-audit-btn, .crf-multicheck .crf-lbl .crf-audit-btn{margin-left:auto}
.oct-finding{position:relative}
.oct-finding .crf-audit-btn{margin-left:auto;position:relative;z-index:1}
.oct-finding .crf-audit-btn:hover{background:var(--surface)}

/* query icon (see queryIconHtml() in app.js) — same base look as the audit
   history icon, plus a small count badge when there's an open query on
   this exact field. */
.crf-query-btn{position:relative}
.crf-query-badge{position:absolute;top:-2px;right:-2px;min-width:16px;height:16px;padding:0 3px;border-radius:8px;background:var(--bad);color:#fff;font-size:10.5px;font-weight:700;display:grid;place-items:center;line-height:1}

/* verify icon (see verifyIconHtml() in app.js) — filled green once a
   current, non-revoked verification exists on this exact field. */
.crf-verify-btn.verified{color:var(--good);background:var(--good-soft)}
.crf-verify-btn.verified:hover{background:var(--good-soft)}

/* Queries popover body (showQueryPopover() in app.js) — reuses the same
   .field-audit-* overlay/panel shell as the audit-history popover. */
.query-entry{border:1px solid var(--line);border-radius:var(--r-md);padding:12px;margin-bottom:10px}
.query-entry-head{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.query-q{font-size:13px;color:var(--ink-2);margin-bottom:4px}
.query-a{font-size:13px;color:var(--ink-2);background:var(--surface-2);border-radius:var(--r-sm);padding:8px 10px;margin-top:6px}
.query-reply{display:flex;flex-direction:column;gap:8px;margin-top:10px}
.query-compose{display:flex;flex-direction:column;gap:8px;margin-top:4px;padding-top:12px;border-top:1px solid var(--line)}

/* independent floating popover for a single field's history — appended to
   <body>, not routed through modalShell(), so it can never clobber an
   in-progress form underneath it */
.field-audit-overlay{position:fixed;inset:0;background:rgba(11,15,26,.55);backdrop-filter:blur(4px);z-index:400;display:flex;align-items:flex-start;justify-content:center;padding:64px 24px 24px;overflow-y:auto;animation:fadeIn .15s ease}
.field-audit-pop{background:var(--surface);border-radius:var(--r-lg);box-shadow:var(--shadow-lg);width:100%;max-width:560px;border:1px solid var(--line);animation:popIn .18s ease}
.field-audit-head{display:flex;align-items:center;gap:10px;padding:14px 18px;border-bottom:1px solid var(--line)}
.field-audit-head h4{margin:0;font-size:14.5px;font-weight:700;letter-spacing:-0.01em;flex:1}
.field-audit-head .close{width:28px;height:28px;border-radius:var(--r-md);display:grid;place-items:center;color:var(--muted);font-size:17px;line-height:1;flex-shrink:0}
.field-audit-head .close:hover{background:var(--bg-2);color:var(--ink)}
.field-audit-body{padding:14px 18px;max-height:50vh;overflow-y:auto}

.chart-wrap{padding:18px 0 8px;background:var(--surface)}
canvas{width:100%;height:240px;display:block}
.legend{display:flex;gap:18px;font-size:12px;color:var(--muted);padding:6px 18px 14px}
.legend i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:6px;vertical-align:middle}

/* toasts */
.toast-stack{position:fixed;bottom:24px;right:24px;display:flex;flex-direction:column;gap:8px;z-index:100}
.toast{background:var(--ink);color:#fff;padding:10px 14px;border-radius:var(--r-md);font-size:13px;box-shadow:var(--shadow-lg);display:flex;align-items:center;gap:10px;min-width:280px;animation:slideIn .25s ease}
.toast.success{background:var(--good)} .toast.error{background:var(--bad)}
@keyframes slideIn{from{transform:translateY(8px);opacity:0}to{transform:translateY(0);opacity:1}}

/* prominent save confirmation */
.save-confirm{position:fixed;top:20px;left:50%;transform:translateX(-50%) translateY(-16px);opacity:0;background:var(--good);color:#fff;padding:16px 20px;border-radius:var(--r-lg,14px);box-shadow:var(--shadow-lg);display:flex;align-items:flex-start;gap:14px;z-index:300;min-width:360px;max-width:560px;transition:transform .28s cubic-bezier(.2,.8,.2,1),opacity .28s ease;pointer-events:none}
.save-confirm.show{transform:translateX(-50%) translateY(0);opacity:1;pointer-events:auto}
.save-confirm .sc-icon{width:30px;height:30px;border-radius:50%;background:rgba(255,255,255,.22);display:flex;align-items:center;justify-content:center;font-weight:800;flex-shrink:0;font-size:16px}
.save-confirm .sc-title{font-weight:700;font-size:14.5px;line-height:1.3}
.save-confirm .sc-sub{font-size:12.5px;opacity:.92;margin-top:3px;line-height:1.4}
.save-confirm .sc-close{margin-left:auto;background:none;border:none;color:#fff;opacity:.75;cursor:pointer;font-size:17px;line-height:1;padding:2px 4px;flex-shrink:0}
.save-confirm .sc-close:hover{opacity:1}

.icon{width:16px;height:16px;display:inline-block;vertical-align:middle;stroke:currentColor;stroke-width:1.7;fill:none;stroke-linecap:round;stroke-linejoin:round}
.row{display:flex;align-items:center;gap:8px}
.spacer{flex:1}
.muted{color:var(--muted)}

/* reference-protocol ribbon (calmer than red — signals 'demo config', not danger) */
.priv-ribbon{position:fixed;top:0;left:0;right:0;background:linear-gradient(90deg,#1E1B4B,#312E81);color:#C7D2FE;text-align:center;padding:5px 12px;font-size:11px;font-weight:600;letter-spacing:.04em;z-index:200;border-bottom:1px solid #1E1B4B}
.priv-ribbon b{color:#E0E7FF}
.priv-spacer{height:25px}

/* ---------- MODAL ---------- */
.modal-overlay{position:fixed;inset:0;background:rgba(11,15,26,.55);backdrop-filter:blur(4px);z-index:300;display:flex;align-items:flex-start;justify-content:center;padding:48px 24px 24px;overflow-y:auto;animation:fadeIn .18s ease}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.modal{background:var(--surface);border-radius:var(--r-lg);box-shadow:var(--shadow-lg);width:100%;max-width:880px;display:flex;flex-direction:column;animation:popIn .2s ease;border:1px solid var(--line)}
@keyframes popIn{from{transform:translateY(8px) scale(.98);opacity:0}to{transform:none;opacity:1}}
.modal-head{display:flex;align-items:center;gap:14px;padding:18px 22px;border-bottom:1px solid var(--line)}
.modal-head .id-mark{width:38px;height:38px;border-radius:var(--r-md);background:var(--brand-soft);color:var(--brand-ink);display:grid;place-items:center;font-weight:700;font-size:13px}
.modal-head h3{margin:0;font-size:17px;font-weight:700;letter-spacing:-0.02em}
.modal-visit-tag{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:600;letter-spacing:0;color:var(--brand-ink);background:var(--brand-soft);border-radius:999px;padding:3px 10px;vertical-align:middle;margin-left:4px}
.modal-visit-tag::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--brand);display:inline-block}
.modal-head .sub{color:var(--muted);font-size:12.5px;margin-top:2px}
.modal-head .close{margin-left:auto;width:32px;height:32px;border-radius:var(--r-md);display:grid;place-items:center;color:var(--muted);font-size:18px;line-height:1}
.modal-head .close:hover{background:var(--bg-2);color:var(--ink)}
.modal-body{padding:20px 22px;max-height:70vh;overflow-y:auto}
.modal-foot{display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:14px 22px;border-top:1px solid var(--line);background:var(--surface-2);border-radius:0 0 var(--r-lg) var(--r-lg)}
.modal-foot .info{font-size:12px;color:var(--muted);margin-right:auto;display:flex;align-items:center;gap:6px}

/* shared eye toggle */
.eye-toggle{display:inline-flex;border:1px solid var(--line-2);border-radius:var(--pill);padding:3px;background:var(--bg-2);margin-bottom:14px}
.eye-toggle button{padding:6px 14px;border-radius:var(--pill);font-size:12px;font-weight:600;color:var(--muted)}
.eye-toggle button.on{background:var(--brand);color:#fff;box-shadow:var(--shadow-sm)}

/* ETDRS chart */
.etdrs{display:grid;grid-template-rows:repeat(5,1fr);gap:8px;margin:8px 0 14px;padding:14px;border:1px solid var(--line);border-radius:var(--r-md);background:#FFFEF7}
:root.dark .etdrs{background:#0F0E08}
.etdrs-row{display:grid;grid-template-columns:32px repeat(5,1fr);gap:8px;align-items:center}
.etdrs-row .row-lbl{font-family:var(--font-mono);font-size:11px;color:var(--muted);text-align:right;font-weight:600}
.etdrs-letter{aspect-ratio:1;display:grid;place-items:center;border:1px solid var(--line);border-radius:var(--r-sm);background:var(--surface);font-family:"SF Pro Display",Helvetica,Arial,sans-serif;font-weight:800;cursor:pointer;user-select:none;color:var(--ink);transition:all .12s}
.etdrs-letter:hover{border-color:var(--brand)}
.etdrs-letter.missed{background:var(--bad-soft);color:var(--bad);border-color:#FCA5A5;text-decoration:line-through}
.etdrs-row[data-row="1"] .etdrs-letter{font-size:32px}
.etdrs-row[data-row="2"] .etdrs-letter{font-size:26px}
.etdrs-row[data-row="3"] .etdrs-letter{font-size:21px}
.etdrs-row[data-row="4"] .etdrs-letter{font-size:17px}
.etdrs-row[data-row="5"] .etdrs-letter{font-size:14px}

.score-strip{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:14px}
.score-cell{padding:12px 14px;border:1px solid var(--line);border-radius:var(--r-md);background:var(--surface-2)}
.score-cell .lbl{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);font-weight:600}
.score-cell .val{font-size:24px;font-weight:700;font-family:var(--font-mono);letter-spacing:-0.01em;color:var(--ink);margin-top:4px}
.score-cell.alert .val{color:var(--bad)}
.score-cell.good  .val{color:var(--good)}

/* IOP table */
.iop-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:12px}
.iop-grid .field{margin:0}
.iop-mean{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--line);border-radius:var(--r-md);background:var(--brand-soft);color:var(--brand-ink)}
.iop-mean b{font-family:var(--font-mono);font-size:18px;font-weight:700}

/* OCT findings */
.oct-findings{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:8px 0 14px}
.oct-finding{padding:10px 12px;border:1px solid var(--line);border-radius:var(--r-md);background:var(--surface-2);display:flex;align-items:center;gap:10px;cursor:pointer;font-size:13px}
.oct-finding:hover{border-color:var(--brand)}
.oct-finding.on{background:var(--bad-soft);border-color:#FCA5A5;color:var(--bad)}
.oct-finding .check{width:18px;height:18px;border-radius:5px;border:1.5px solid var(--line-2);display:grid;place-items:center;font-size:11px;color:transparent;font-weight:800}
.oct-finding.on .check{background:var(--bad);border-color:var(--bad);color:#fff}

/* CRA read-only lockdown (see lockdownReadOnly() in app.js) — makes
   click-to-toggle custom widgets (ETDRS letters, OCT findings, attachment
   controls) fully inert for a CRA session. pointer-events:none stops the
   click from ever reaching the element, independent of when its own click
   listener was attached, so this is safe to apply before or after wiring. */
.cra-locked{pointer-events:none !important;opacity:.55;cursor:not-allowed !important}

/* image upload placeholder */
.dropzone{border:1.5px dashed var(--line-2);border-radius:var(--r-md);padding:18px;text-align:center;color:var(--muted);background:var(--surface-2);font-size:13px;margin-top:10px}
.dropzone b{color:var(--ink-2);font-weight:600;display:block;margin-bottom:4px}

/* Source document attachments (SD-OCT, etc.) */
.attach-list{display:flex;flex-direction:column;border:1px solid var(--line);border-radius:var(--r-md);background:var(--surface-2);overflow:hidden}
.attach-row{display:flex;align-items:center;gap:10px;padding:9px 12px;border-bottom:1px solid var(--line)}
.attach-row:last-child{border-bottom:none}
.attach-row .icon{width:16px;height:16px;color:var(--muted);flex-shrink:0}
.attach-name{flex:1;font-size:13px;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.attach-size{font-size:11.5px;color:var(--muted);font-family:var(--font-mono)}
.attach-empty{padding:12px;font-size:13px;color:var(--muted);text-align:center}
.attach-btn-row{display:flex;align-items:center;gap:10px;margin-top:10px}
.attach-upload-label{display:inline-flex;align-items:center;gap:6px;cursor:pointer}
.attach-upload-label .icon{width:15px;height:15px}

.attach-preview{display:none;margin-top:12px;border:1px solid var(--line);border-radius:var(--r-md);overflow:hidden;background:var(--surface)}
.attach-preview.show{display:block}
.attach-preview-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 12px;border-bottom:1px solid var(--line);background:var(--surface-2)}
.attach-preview-name{font-size:12.5px;font-weight:600;color:var(--ink-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.attach-preview-actions{display:flex;align-items:center;gap:8px;flex-shrink:0}
.attach-zoom-group{display:flex;align-items:center;gap:2px;border:1px solid var(--line-2);border-radius:var(--r-md);padding:2px;background:var(--surface)}
.attach-zoom-group button{padding:3px 9px;font-size:14px;font-weight:700;line-height:1}
.attach-zoom-pct{font-size:11px;font-family:var(--font-mono);color:var(--muted);min-width:36px;text-align:center}
/* block (not flex) so overflow:auto scrolls correctly once the image is
   zoomed past the container's width/height — flex centering clips the
   start of overflowing content in most browsers. */
.attach-preview-body{max-height:480px;overflow:auto;text-align:center;background:var(--bg-2);padding:10px}
.attach-preview-body img{max-width:100%;max-height:460px;object-fit:contain;border-radius:4px;cursor:zoom-in}
.attach-preview-body iframe{width:100%;height:460px;border:none;background:#fff}
.attach-preview-loading,.attach-preview-error{padding:24px;text-align:center;font-size:13px;color:var(--muted)}
.attach-preview-error a{color:var(--brand)}

/* exam grid (anterior/posterior) */
.exam-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.exam-section h6{margin:0 0 10px;font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--brand);font-weight:700}
.exam-row{display:grid;grid-template-columns:120px 1fr;gap:10px;align-items:center;padding:6px 0;border-bottom:1px dashed var(--line);font-size:13px}
.exam-row:last-child{border-bottom:0}
.exam-row .lbl{color:var(--ink-2);font-weight:500}
.exam-row select{padding:5px 8px;border:1px solid var(--line-2);border-radius:5px;background:var(--surface);font-size:12.5px;width:100%}

/* completion footer */
.complete-strip{display:flex;align-items:center;gap:10px;font-size:12px;color:var(--muted)}
.complete-strip .dot{width:6px;height:6px;border-radius:50%;background:var(--good)}
