/* ============================================================
   مختبر الحالات — Forest clinical ledger
   ============================================================ */
*,*::before,*::after{ box-sizing:border-box; }

:root{
  --paper:#F4EDDD;
  --paper-hi:#FBF6EA;
  --paper-lo:#EBE1CB;
  --ink:#12352A;
  --ink-2:#2C4A3E;
  --ink-3:#5E7568;
  --green:#1B4A38;
  --green-2:#12352A;
  --brass:#B08D57;
  --sage:#6E8F74;
  --clay:#A2653F;
  --stone:#D9CFB8;
  --rule:rgba(18,53,42,.14);
  --rule-soft:rgba(18,53,42,.07);
  --r-sm:8px; --r-md:14px; --r-lg:20px;
  --shadow:0 1px 2px rgba(18,53,42,.05), 0 10px 26px -20px rgba(18,53,42,.45);
  --font-h:'Amiri', Georgia, 'Times New Roman', serif;
  --font-b:'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html,body{ height:100%; }
body{
  margin:0;
  background:var(--paper);
  color:var(--ink);
  font-family:var(--font-b);
  font-size:15px;
  line-height:1.65;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
button,input,select,textarea{ font-family:inherit; font-size:inherit; color:inherit; }
button{ cursor:pointer; border:none; background:none; }
h1,h2,h3,h4{ font-family:var(--font-h); font-weight:700; margin:0; line-height:1.25; }
p{ margin:0; }
a{ color:inherit; }
.hidden{ display:none !important; }
.muted{ color:var(--ink-3); }
code{ font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:.86em; background:var(--paper-lo); padding:2px 6px; border-radius:6px; }

.grain{
  position:fixed; inset:0; pointer-events:none; z-index:1; opacity:.035;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}

/* ------------------------------ layout ------------------------------ */
.app{ display:flex; min-height:100dvh; position:relative; z-index:2; }

.rail{
  width:258px; flex:0 0 258px;
  background:var(--green);
  color:#EFE7D3;
  display:flex; flex-direction:column; gap:14px;
  padding:20px 16px 18px;
  position:sticky; top:0; height:100dvh;
  overflow-y:auto;
  border-left:1px solid rgba(0,0,0,.12);
}
.rail-brand{ display:flex; align-items:center; gap:11px; padding-bottom:14px; border-bottom:1px solid rgba(244,237,221,.16); }
.brand-mark{
  width:38px; height:38px; flex:0 0 38px; display:grid; place-items:center;
  border:1px solid rgba(176,141,87,.7); border-radius:10px; color:var(--brass);
  font-size:18px; background:rgba(176,141,87,.12);
}
.brand-txt h1{ font-size:19px; color:#F4EDDD; letter-spacing:.01em; }
.brand-txt p{ font-size:10.5px; letter-spacing:.14em; text-transform:uppercase; color:rgba(244,237,221,.55); font-weight:500; }

.rail-label{
  font-size:10.5px; letter-spacing:.16em; text-transform:uppercase;
  color:rgba(244,237,221,.45); font-weight:600;
}
.case-list{ display:flex; flex-direction:column; gap:6px; }
.case-item{
  display:flex; align-items:center; gap:10px; text-align:start;
  padding:10px 11px; border-radius:10px;
  border:1px solid transparent;
  color:rgba(244,237,221,.82);
  transition:background .16s ease, border-color .16s ease;
  user-select:none;
}
.case-item:hover{ background:rgba(244,237,221,.07); }
.case-item.is-active{ background:rgba(244,237,221,.13); border-color:rgba(176,141,87,.6); color:#FBF6EA; }
.case-item .dot{ width:9px; height:9px; border-radius:50%; flex:0 0 9px; background:var(--brass); box-shadow:0 0 0 3px rgba(0,0,0,.14); }
.case-item .ci-body{ display:flex; flex-direction:column; min-width:0; flex:1; }
.case-item .ci-name{ font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.case-item .ci-sub{ font-size:11px; color:rgba(244,237,221,.55); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.case-item .ci-count{
  font-size:11px; font-weight:600; min-width:22px; text-align:center;
  background:rgba(244,237,221,.12); border-radius:999px; padding:1px 7px;
  color:rgba(244,237,221,.8);
}
.btn-add{
  border:1px dashed rgba(176,141,87,.6); color:#EFDCB8;
  padding:10px; border-radius:10px; font-size:13.5px; font-weight:500;
  transition:background .16s ease, border-color .16s ease;
  user-select:none;
}
.btn-add:hover{ background:rgba(176,141,87,.16); border-style:solid; }

.rail-foot{ margin-top:auto; display:flex; flex-direction:column; gap:6px; padding-top:14px; border-top:1px solid rgba(244,237,221,.16); }
.rail-btn{
  text-align:start; padding:8px 11px; border-radius:9px; font-size:12.5px;
  color:rgba(244,237,221,.72); transition:background .16s ease, color .16s ease;
  user-select:none;
}
.rail-btn:hover{ background:rgba(244,237,221,.09); color:#FBF6EA; }
.rail-btn.danger:hover{ background:rgba(162,101,63,.35); color:#FAE7DA; }

/* workspace */
.workspace{ flex:1; min-width:0; display:flex; flex-direction:column; height:100dvh; }
.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:13px 24px; border-bottom:1px solid var(--rule); background:var(--paper);
  flex:0 0 auto;
}
.case-head{ display:flex; align-items:center; gap:12px; min-width:0; }
.case-dot{ width:12px; height:12px; border-radius:50%; flex:0 0 12px; background:var(--brass); box-shadow:0 0 0 4px rgba(176,141,87,.18); }
.case-head-txt{ min-width:0; }
.case-head-txt h2{ font-size:21px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.case-head-txt p{ font-size:12px; color:var(--ink-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.tabs{ display:flex; gap:2px; padding:4px; background:var(--paper-lo); border:1px solid var(--stone); border-radius:999px; flex:0 0 auto; }
.tab{
  position:relative; padding:7px 18px 9px; border-radius:999px; font-size:14px; font-weight:500;
  color:var(--ink-3); transition:color .16s ease, background .16s ease; user-select:none;
}
.tab:hover{ color:var(--ink); }
.tab.is-active{ color:var(--ink); background:var(--paper-hi); font-weight:600; }
.tab.is-active::after{
  content:''; position:absolute; inset-inline:14px; bottom:3px; height:2px;
  background:var(--brass); border-radius:2px;
}

.scroll{ flex:1; overflow-y:auto; padding:24px; scroll-behavior:smooth; }
.view{ display:block; }
.view-inner{ max-width:1180px; margin:0 auto; display:flex; flex-direction:column; gap:18px; }

/* ------------------------------ headings ------------------------------ */
.eyebrow{
  font-size:10.5px; letter-spacing:.17em; text-transform:uppercase;
  color:var(--brass); font-weight:600; margin-bottom:3px;
}
.view-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.view-head h2{ font-size:27px; }
.view-head .muted{ font-size:13px; margin-top:3px; max-width:62ch; }
.head-actions{ display:flex; gap:8px; flex-wrap:wrap; }

/* ------------------------------ cards ------------------------------ */
.card{
  background:var(--paper-hi);
  border:1px solid var(--stone);
  border-radius:var(--r-md);
  padding:18px 20px 20px;
  box-shadow:var(--shadow);
}
.card-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; padding-bottom:10px; border-bottom:1px solid var(--rule-soft); }
.card-head h3{ font-size:18px; }
.card-hint{ font-size:11.5px; color:var(--ink-3); letter-spacing:.02em; }
.count{
  font-size:12px; font-weight:600; color:var(--ink-2);
  background:var(--paper-lo); border:1px solid var(--stone); border-radius:999px; padding:1px 10px;
}
.domain-card.risk{ border-color:rgba(162,101,63,.4); }
.domain-card.risk .card-head h3{ color:var(--clay); }

/* ------------------------------ forms ------------------------------ */
.grid-form{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.field{ display:flex; flex-direction:column; gap:6px; min-width:0; }
.field > span{ font-size:12px; font-weight:600; color:var(--ink-2); letter-spacing:.01em; }
.field.span-2{ grid-column:1/-1; }
input[type=text],input[type=number],select,textarea{
  width:100%; background:#FFFDF6; border:1px solid var(--stone); border-radius:var(--r-sm);
  padding:9px 11px; font-size:14px; color:var(--ink); outline:none;
  transition:border-color .15s ease, box-shadow .15s ease;
}
textarea{ resize:vertical; line-height:1.6; min-height:44px; }
input:focus,select:focus,textarea:focus{ border-color:var(--sage); box-shadow:0 0 0 3px rgba(110,143,116,.2); }
input[type=range]{ width:100%; accent-color:var(--green); }
.range-row{ display:flex; align-items:center; gap:10px; }
.range-row output{ font-size:12.5px; font-weight:600; color:var(--ink-2); min-width:44px; text-align:center; background:var(--paper-lo); border-radius:6px; padding:2px 6px; }

/* symptoms */
.sym-grid{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:2px; margin-bottom:14px; }
.sym{
  position:relative; display:flex; align-items:flex-start; gap:10px;
  padding:9px 10px; border-radius:10px; cursor:pointer;
  transition:background .15s ease; user-select:none;
}
.sym:hover{ background:rgba(18,53,42,.04); }
.sym input{ position:absolute; opacity:0; width:1px; height:1px; }
.sym .box{
  flex:0 0 19px; width:19px; height:19px; margin-top:3px;
  border:1.5px solid rgba(18,53,42,.34); border-radius:6px;
  background:#FFFDF6; display:grid; place-items:center;
  transition:background .15s ease, border-color .15s ease;
}
.sym input:checked + .box{ background:var(--green); border-color:var(--green); }
.sym input:checked + .box::after{ content:'✓'; color:#F4EDDD; font-size:12px; line-height:1; }
.sym input:focus-visible + .box{ outline:2px solid var(--brass); outline-offset:2px; }
.sym .sym-label{ font-size:13.5px; line-height:1.45; color:var(--ink-2); }
.sym input:checked ~ .sym-label{ color:var(--ink); font-weight:500; }
.sym-risk .box{ border-color:rgba(162,101,63,.5); }
.sym-risk input:checked + .box{ background:var(--clay); border-color:var(--clay); }
.sym-risk .sym-label{ color:#7A4A2A; }
.info-tag{ font-size:10.5px; font-style:normal; color:var(--ink-3); background:var(--paper-lo); border-radius:5px; padding:1px 6px; margin-inline-start:6px; }

/* stat strip */
.stat-strip{
  display:flex; gap:10px; flex-wrap:wrap;
  background:var(--paper-lo); border:1px solid var(--stone); border-radius:var(--r-md);
  padding:14px 18px;
}
.stat{ display:flex; flex-direction:column; min-width:120px; padding-inline-end:18px; border-inline-end:1px solid rgba(18,53,42,.12); }
.stat:last-child{ border-inline-end:none; padding-inline-end:0; }
.stat-val{ font-family:var(--font-h); font-size:26px; font-weight:700; line-height:1.1; color:var(--ink); }
.stat-lbl{ font-size:11.5px; color:var(--ink-3); }

/* ------------------------------ buttons ------------------------------ */
.btn-primary{
  background:var(--green); color:#F4EDDD; padding:10px 20px; border-radius:999px;
  font-size:13.5px; font-weight:600; transition:background .16s ease, transform .12s ease;
  user-select:none;
}
.btn-primary:hover{ background:#22604A; }
.btn-primary:active{ transform:scale(.98); }
.btn-ghost{
  background:transparent; color:var(--ink-2); border:1px solid var(--stone);
  padding:9px 16px; border-radius:999px; font-size:13px; font-weight:500;
  transition:background .16s ease, border-color .16s ease; user-select:none;
}
.btn-ghost:hover{ background:rgba(18,53,42,.05); border-color:var(--sage); }
.btn-ghost.sm{ padding:6px 13px; font-size:12px; }
.btn-ghost.danger{ color:var(--clay); border-color:rgba(162,101,63,.42); }
.btn-ghost.danger:hover{ background:rgba(162,101,63,.1); border-color:var(--clay); }
.icon-btn{
  width:36px; height:36px; border-radius:50%; display:grid; place-items:center;
  border:1px solid var(--stone); color:var(--ink-2); font-size:15px;
  transition:background .15s ease; user-select:none;
}
.icon-btn:hover{ background:rgba(18,53,42,.06); }

/* ------------------------------ hypothesis list ------------------------------ */
.hyp-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:4px; }
.hyp-row details{ border-radius:10px; }
.hyp-row summary{
  display:grid; grid-template-columns:22px 1fr 86px 34px; align-items:center; gap:10px;
  padding:9px 8px; border-radius:10px; cursor:pointer; list-style:none;
  transition:background .15s ease; user-select:none;
}
.hyp-row summary::-webkit-details-marker{ display:none; }
.hyp-row summary:hover{ background:rgba(18,53,42,.045); }
.hyp-rank{ font-size:11px; font-weight:700; color:var(--ink-3); text-align:center; }
.hyp-name{ font-size:13.5px; color:var(--ink-2); display:flex; flex-direction:column; min-width:0; }
.hyp-name em{ font-style:normal; font-size:10.5px; letter-spacing:.06em; color:var(--ink-3); }
.hyp-meter{ height:7px; background:var(--paper-lo); border-radius:999px; overflow:hidden; border:1px solid rgba(18,53,42,.08); }
.hyp-meter i{ display:block; height:100%; border-radius:999px; transition:width .35s cubic-bezier(.2,.8,.3,1); }
.hyp-score{ font-family:var(--font-h); font-size:17px; font-weight:700; text-align:center; color:var(--ink); }
.hyp-body{ padding:6px 12px 14px 44px; }
.hyp-raw{ font-size:12px; color:var(--ink-3); margin-bottom:8px; }
.chips{ display:flex; flex-wrap:wrap; gap:6px; }
.chip{
  font-size:11.5px; padding:3px 9px; border-radius:999px; border:1px solid var(--stone);
  background:var(--paper-lo); color:var(--ink-2);
}
.chip b{ font-weight:700; }
.chip.pos b{ color:var(--sage); }
.chip.neg b{ color:var(--clay); }
.chip.off{ opacity:.5; }

/* ------------------------------ charts ------------------------------ */
.grid-2{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
.chart-card{ background:var(--paper-hi); border:1px solid var(--stone); border-radius:var(--r-md); padding:16px 18px 18px; box-shadow:var(--shadow); }
.chart-card h3,.chart-card h4{ font-size:16px; margin-bottom:10px; }
.chart-wrap{ position:relative; width:100%; }
.radar-wrap{ height:288px; }
.bars-wrap{ height:238px; }
canvas{ display:block; width:100%; height:100%; }
.legend{ display:flex; flex-wrap:wrap; gap:14px; margin-top:10px; padding-top:10px; border-top:1px solid var(--rule-soft); }
.lg{ display:inline-flex; align-items:center; gap:7px; font-size:12px; color:var(--ink-2); }
.lg i{ width:12px; height:12px; border-radius:3px; display:inline-block; }

/* notes */
.notes-grid{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.note-item h4{ font-size:14px; color:var(--ink-2); margin-bottom:5px; }
.note-item p{ font-size:13px; color:var(--ink-2); line-height:1.7; }
.engine-note h3{ font-size:16px; margin-bottom:8px; }
.engine-note p{ font-size:13px; color:var(--ink-2); margin-bottom:8px; line-height:1.75; }

/* ------------------------------ tables ------------------------------ */
.tbl{ width:100%; border-collapse:collapse; font-size:13px; }
.tbl th{
  text-align:start; font-size:11.5px; font-weight:600; color:var(--ink-3);
  padding:8px 10px; border-bottom:1px solid var(--rule); white-space:nowrap;
}
.tbl td{ padding:8px 10px; border-bottom:1px solid var(--rule-soft); vertical-align:middle; }
.tbl tbody tr:hover{ background:rgba(18,53,42,.03); }
.tbl .t-name{ font-weight:500; color:var(--ink); }
.col-case{ display:table-cell; }
.col-case .dot{ width:8px; height:8px; border-radius:50%; display:inline-block; margin-inline-end:6px; vertical-align:middle; }
.ck{ text-align:center; font-weight:700; color:var(--stone); }
.ck.on{ color:var(--green); }
.badge-soft{ font-size:11.5px; background:var(--paper-lo); border:1px solid var(--stone); border-radius:999px; padding:1px 9px; color:var(--ink-2); }
.badge-case{ font-size:11px; border-radius:999px; padding:1px 9px; margin-inline-end:4px; display:inline-block; background:rgba(0,0,0,.04); border:1px solid var(--cc,#ccc); color:var(--ink-2); }
.score-cell{ white-space:nowrap; }
.score-cell .mini{ display:inline-block; width:56px; height:6px; background:var(--paper-lo); border-radius:999px; overflow:hidden; vertical-align:middle; margin-inline-end:8px; border:1px solid rgba(18,53,42,.08); }
.score-cell .mini i{ display:block; height:100%; }
.score-cell b{ font-family:var(--font-h); font-size:14px; }
.delta{ font-size:12px; font-weight:600; color:var(--ink-3); white-space:nowrap; }
.delta.up{ color:var(--sage); }
.delta.down{ color:var(--clay); }

/* ------------------------------ compare / report ------------------------------ */
.compare-toolbar{ display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; }
.cmp-picker{ display:flex; gap:8px; flex-wrap:wrap; }
.chk-chip{
  display:inline-flex; align-items:center; gap:8px; font-size:12.5px; font-weight:500;
  padding:7px 14px; border-radius:999px; border:1px solid var(--stone);
  background:var(--paper-hi); color:var(--ink-3); transition:all .15s ease; user-select:none;
}
.chk-chip .dot{ width:9px; height:9px; border-radius:50%; }
.chk-chip.on{ color:var(--ink); border-color:var(--sage); background:#fff; box-shadow:0 0 0 2px rgba(110,143,116,.16); }

.report{
  background:var(--paper-hi); border:1px solid var(--stone); border-radius:var(--r-lg);
  padding:26px 28px 30px; box-shadow:var(--shadow);
  display:flex; flex-direction:column; gap:26px;
}
.report-head{
  display:flex; align-items:flex-start; justify-content:space-between; gap:20px;
  padding-bottom:16px; border-bottom:2px solid var(--green);
}
.report-head h2{ font-size:25px; }
.report-head .muted{ font-size:12.5px; margin-top:4px; }
.seal{
  width:54px; height:54px; flex:0 0 54px; display:grid; place-items:center;
  border:1.5px solid var(--brass); border-radius:50%; color:var(--brass); font-size:22px;
  background:radial-gradient(circle at 50% 30%, rgba(176,141,87,.16), transparent 70%);
}
.block-title{ font-size:16px; color:var(--green-2); display:flex; align-items:center; gap:9px; margin-bottom:12px; }
.block-title::after{ content:''; flex:1; height:1px; background:var(--rule); }
.count-pill{ font-family:var(--font-b); font-size:11px; font-weight:600; background:var(--paper-lo); border:1px solid var(--stone); border-radius:999px; padding:0 9px; color:var(--ink-2); }
.report-block{ display:flex; flex-direction:column; }

.case-cols{ display:grid; grid-template-columns:repeat(var(--cols,2),minmax(0,1fr)); gap:14px; }
.case-sum{
  border:1px solid var(--stone); border-top:3px solid var(--cc,var(--brass));
  border-radius:12px; padding:14px 15px 16px; background:#fff;
  display:flex; flex-direction:column; gap:9px;
}
.cs-head{ display:flex; align-items:center; gap:8px; }
.cs-head .dot{ width:10px; height:10px; border-radius:50%; background:var(--cc,var(--brass)); }
.cs-head h4{ font-size:16px; }
.tag{ font-size:10px; background:rgba(176,141,87,.16); color:#7A5C2E; border-radius:999px; padding:1px 8px; }
.cs-sub{ font-size:11.5px; color:var(--ink-3); }
.cs-q{ font-size:12.5px; color:var(--ink-2); line-height:1.6; }
.cs-hyps{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:3px; }
.cs-hyps li{ display:flex; justify-content:space-between; font-size:12px; color:var(--ink-2); border-bottom:1px dotted var(--rule); padding-bottom:3px; }
.cs-hyps b{ font-family:var(--font-h); font-size:14px; color:var(--ink); }
.cs-domains{ display:flex; flex-direction:column; gap:5px; margin-top:2px; }
.dbar{ display:grid; grid-template-columns:58px 1fr 26px; align-items:center; gap:8px; font-size:11px; color:var(--ink-3); }
.dbar i{ display:block; height:6px; background:var(--paper-lo); border-radius:999px; overflow:hidden; border:1px solid rgba(18,53,42,.08); }
.dbar i b{ display:block; height:100%; border-radius:999px; }
.dbar em{ font-style:normal; text-align:end; font-weight:600; color:var(--ink-2); }

.report-foot{ border-top:1px solid var(--rule); padding-top:14px; display:flex; flex-direction:column; gap:5px; }
.report-foot p{ font-size:11.5px; color:var(--ink-3); line-height:1.7; }

/* empty state */
.empty-state{
  max-width:520px; margin:8vh auto; text-align:center; display:flex; flex-direction:column; align-items:center; gap:12px;
  background:var(--paper-hi); border:1px solid var(--stone); border-radius:var(--r-lg); padding:40px 28px; box-shadow:var(--shadow);
}
.es-mark{ width:54px; height:54px; display:grid; place-items:center; border-radius:50%; border:1.5px solid var(--brass); color:var(--brass); font-size:22px; }
.empty-state h2{ font-size:21px; }
.empty-state p{ font-size:13.5px; max-width:38ch; }

/* ------------------------------ modal ------------------------------ */
.modal{
  position:fixed; inset:0; z-index:90; display:flex; align-items:center; justify-content:center;
  padding:16px; background:rgba(18,53,42,.5); backdrop-filter:blur(5px);
}
.modal-panel{
  background:var(--paper-hi); border:1px solid var(--stone); border-radius:var(--r-lg);
  width:min(1040px,100%); max-height:90dvh; display:flex; flex-direction:column; overflow:hidden;
  box-shadow:0 34px 90px -34px rgba(18,53,42,.7);
}
.modal-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding:18px 20px 14px; border-bottom:1px solid var(--rule); }
.modal-head h3{ font-size:19px; margin-bottom:4px; }
.modal-head p{ font-size:12px; color:var(--ink-3); max-width:66ch; line-height:1.6; }
.modal-body{ overflow:auto; padding:0 20px 18px; -webkit-overflow-scrolling:touch; }
.modal-foot{ display:flex; justify-content:space-between; gap:12px; padding:14px 20px; border-top:1px solid var(--rule); background:var(--paper-lo); }

.wtbl{ width:100%; border-collapse:separate; border-spacing:0; font-size:12.5px; min-width:620px; }
.wtbl th{
  position:sticky; top:0; z-index:2; background:var(--paper-lo); text-align:center;
  font-size:11px; letter-spacing:.05em; color:var(--ink-3); font-weight:600;
  padding:10px 6px; border-bottom:1px solid var(--stone);
}
.wtbl th.w-sym{ text-align:start; padding-inline-start:10px; min-width:220px; }
.wtbl td{ padding:5px 6px; border-bottom:1px solid var(--rule-soft); text-align:center; }
.wtbl td.w-sym{ text-align:start; font-size:12.5px; color:var(--ink-2); padding-inline-start:10px; line-height:1.4; }
.wtbl tr.w-domain td{
  background:var(--paper-lo); font-family:var(--font-h); font-weight:700; font-size:13.5px;
  color:var(--green-2); text-align:start; padding:7px 10px; border-bottom:1px solid var(--stone);
}
.w-input{
  width:52px; text-align:center; padding:5px 2px; font-size:13px; font-weight:600;
  border:1px solid var(--stone); border-radius:7px; background:#FFFDF6; color:var(--ink-3);
  -moz-appearance:textfield;
}
.w-input::-webkit-outer-spin-button,.w-input::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }
.w-input.pos{ color:var(--green); border-color:rgba(110,143,116,.6); background:#F4F8F2; }
.w-input.neg{ color:var(--clay); border-color:rgba(162,101,63,.5); background:#FBF1EA; }
.w-input:focus{ outline:none; box-shadow:0 0 0 3px rgba(110,143,116,.22); border-color:var(--sage); }

/* toast */
.toast{
  position:fixed; inset-inline:0; bottom:22px; margin:0 auto; width:fit-content; max-width:88vw;
  background:var(--green); color:#F4EDDD; font-size:13px; padding:10px 20px; border-radius:999px;
  box-shadow:0 18px 40px -18px rgba(0,0,0,.65); z-index:120;
  opacity:0; transform:translateY(14px); pointer-events:none;
  transition:opacity .22s ease, transform .22s ease;
}
.toast.show{ opacity:1; transform:translateY(0); }

/* ------------------------------ responsive ------------------------------ */
@media (max-width:1080px){
  .grid-2{ grid-template-columns:1fr; }
}
@media (max-width:900px){
  .app{ flex-direction:column; }
  .rail{
    position:sticky; top:0; z-index:40; width:100%; flex:0 0 auto; height:auto;
    padding:10px 12px 12px; gap:9px; overflow:visible;
    box-shadow:0 8px 22px -16px rgba(0,0,0,.7);
  }
  .rail-brand{ padding-bottom:9px; }
  .brand-mark{ width:30px; height:30px; flex:0 0 30px; font-size:14px; border-radius:8px; }
  .brand-txt h1{ font-size:16px; }
  .brand-txt p{ font-size:9px; letter-spacing:.1em; }
  .rail-label{ display:none; }
  .case-list{ flex-direction:row; overflow-x:auto; gap:7px; padding-bottom:2px; scrollbar-width:none; }
  .case-list::-webkit-scrollbar{ display:none; }
  .case-item{ min-width:146px; flex:0 0 auto; padding:7px 10px; background:rgba(244,237,221,.06); }
  .case-item .ci-count{ display:none; }
  .btn-add{ padding:7px; font-size:12.5px; }
  .rail-foot{ margin-top:0; padding-top:8px; border-top:none; flex-direction:row; gap:6px; }
  .rail-btn{ flex:1; text-align:center; font-size:11px; padding:7px 4px; background:rgba(244,237,221,.07); border-radius:8px; }
  .workspace{ height:auto; }
  .scroll{ overflow:visible; padding:16px 13px 44px; }
  .topbar{ flex-direction:column; align-items:stretch; gap:10px; padding:12px 13px; }
  .case-head-txt h2{ font-size:18px; }
  .tabs{ justify-content:stretch; }
  .tab{ flex:1; text-align:center; padding:7px 8px 9px; font-size:13px; }
  .view-inner{ gap:14px; }
  .card{ padding:15px 14px 16px; }
  .grid-form{ grid-template-columns:1fr; }
  .sym-grid{ grid-template-columns:1fr; }
  .notes-grid{ grid-template-columns:1fr; }
  .radar-wrap{ height:252px; }
  .bars-wrap{ height:212px; }
  .report{ padding:18px 14px 22px; border-radius:var(--r-md); gap:20px; }
  .report-head h2{ font-size:20px; }
  .seal{ width:42px; height:42px; flex:0 0 42px; font-size:17px; }
  .hyp-row summary{ grid-template-columns:18px 1fr 54px 30px; gap:8px; }
  .stat{ min-width:calc(50% - 10px); border-inline-end:none; padding-inline-end:0; }
  .stat-val{ font-size:22px; }
  .modal{ padding:0; align-items:flex-end; }
  .modal-panel{ max-height:92dvh; width:100%; border-radius:var(--r-lg) var(--r-lg) 0 0; }
  .tbl{ font-size:12px; }
  .tbl th,.tbl td{ padding:7px 7px; }
}
@media (max-width:430px){
  .stat{ min-width:100%; border-bottom:1px solid rgba(18,53,42,.1); padding-bottom:8px; }
  .stat:last-child{ border-bottom:none; padding-bottom:0; }
  .report-head{ flex-direction:column; }
  .seal{ display:none; }
}

/* ------------------------------ print ------------------------------ */
@media print{
  @page{ margin:14mm; }
  .grain,.rail,.topbar,.compare-toolbar,.modal,.toast,.no-print{ display:none !important; }
  .app{ display:block; min-height:0; }
  .workspace{ display:block; height:auto; }
  .scroll{ overflow:visible; height:auto; padding:0; }
  .view-inner{ max-width:none; gap:14px; }
  body{ background:#fff; font-size:11pt; color:#12352A; }
  .report{ border:none; box-shadow:none; padding:0; background:#fff; gap:18px; }
  .card,.case-sum,.chart-card{ box-shadow:none; break-inside:avoid; }
  .report-block{ break-inside:avoid; }
  tr{ break-inside:avoid; }
  *{ -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}
@media (prefers-reduced-motion:reduce){
  *{ transition-duration:.01ms !important; animation-duration:.01ms !important; scroll-behavior:auto !important; }
}