/* Meridian analyst workbench.
 *
 * LIGHT IS THE DEFAULT. The dark palette is opt-in via the rail toggle, which
 * persists to localStorage. `prefers-color-scheme` is deliberately NOT used to
 * pick the initial theme: the requirement is light by default regardless of OS
 * setting, and silently following the OS would contradict that.
 *
 * Evidence colours are the only saturated hues in the interface, and they are
 * tuned separately per theme so a modeled estimate stays visibly distinct from a
 * measurement at both light and dark contrast ratios. That distinction is the
 * product, not decoration.
 */

@font-face{font-family:GS;src:url(/fonts/google-sans-400.woff2)format("woff2");font-weight:400;font-display:swap}
@font-face{font-family:GS;src:url(/fonts/google-sans-500.woff2)format("woff2");font-weight:500;font-display:swap}
@font-face{font-family:GS;src:url(/fonts/google-sans-700.woff2)format("woff2");font-weight:700;font-display:swap}
@font-face{font-family:GSC;src:url(/fonts/google-sans-code-400.woff2)format("woff2");font-weight:400;font-display:swap}

/* ── light (default) ── */
:root{
  --bg:#ffffff; --bg2:#f7f8fa; --bg3:#eef0f4; --line:#dfe3ea; --line2:#c9cfda;
  --fg:#131720; --fg2:#4d5666; --fg3:#79839; --fg3:#798395;
  --accent:#2f6fd0; --accent2:#6a4bd8; --accent-soft:#e8f0fc;
  --ev-direct:#1a7f37;  --ev-direct-bg:#e8f5ec;  --ev-direct-bd:#b4dcc0;
  --ev-model:#9a6700;   --ev-model-bg:#fdf6e3;   --ev-model-bd:#e6d5a0;
  --ev-alloc:#a1500f;   --ev-alloc-bg:#fdf0e6;   --ev-alloc-bd:#e8c9a8;
  --ev-proxy:#9a3412;   --ev-proxy-bg:#fdeee8;   --ev-proxy-bd:#e8bda8;
  --ev-ctx:#5b6472;     --ev-ctx-bg:#f0f2f5;     --ev-ctx-bd:#d5dae2;
  --ev-unk:#6639ba;     --ev-unk-bg:#f3eefc;     --ev-unk-bd:#d3c4ef;
  --shadow:0 1px 2px rgba(16,24,40,.05),0 1px 3px rgba(16,24,40,.06);
  --radius:7px;
}
/* ── dark (opt-in) ── */
:root[data-theme="dark"]{
  --bg:#0d1017; --bg2:#141821; --bg3:#1b2130; --line:#252c3a; --line2:#353f52;
  --fg:#e7eaf0; --fg2:#9aa4b4; --fg3:#6c7686;
  --accent:#5b9dff; --accent2:#8b6dff; --accent-soft:#16233a;
  --ev-direct:#4ac26b;  --ev-direct-bg:#0f2016;  --ev-direct-bd:#1f4429;
  --ev-model:#d4a72c;   --ev-model-bg:#211b09;   --ev-model-bd:#463818;
  --ev-alloc:#e0873d;   --ev-alloc-bg:#221609;   --ev-alloc-bd:#4a2f14;
  --ev-proxy:#e07a52;   --ev-proxy-bg:#22120c;   --ev-proxy-bd:#4a281a;
  --ev-ctx:#8b95a5;     --ev-ctx-bg:#191e28;     --ev-ctx-bd:#2b3342;
  --ev-unk:#a884f3;     --ev-unk-bg:#1a1329;     --ev-unk-bd:#382a5c;
  --shadow:0 1px 2px rgba(0,0,0,.3);
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  background:var(--bg);color:var(--fg);
  font:400 14px/1.55 GS,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  -webkit-font-smoothing:antialiased;
}
code,kbd,.mono{font-family:GSC,ui-monospace,SFMono-Regular,Menlo,monospace}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer;background:none;border:0}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}
svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.7;
    stroke-linecap:round;stroke-linejoin:round}

/* ───────── shell: fixed 62px rail + main, matching the reference app ─────────
   No expand/collapse. The rail is one width; anything that needs room is either a
   full view in main or the slide-over panel. */
.shell{display:flex;height:100vh;overflow:hidden}

.rail{
  width:62px;flex-shrink:0;background:var(--bg2);
  border-right:1px solid var(--line);
  display:flex;flex-direction:column;align-items:center;
  padding:14px 0 18px;gap:6px;
  /* Above the panel backdrop so rail actions stay clickable while the panel is
     open -- otherwise the backdrop swallows the clicks. */
  position:relative;z-index:100;
}
.rail-logo{display:block;margin-bottom:14px;line-height:0}
.rail-logo img{width:30px;height:30px;border-radius:50%;display:block}
.rail-btn{
  background:none;border:0;cursor:pointer;color:var(--fg3);
  width:38px;height:38px;border-radius:10px;display:grid;place-items:center;
  transition:background .15s,color .15s;position:relative;
}
.rail-btn:hover{background:var(--bg3);color:var(--fg);text-decoration:none}
.rail-btn:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.rail-btn.is-active{background:var(--accent-soft);color:var(--accent)}
.rail-btn.is-active::before{
  content:"";position:absolute;left:-12px;top:8px;bottom:8px;width:2.5px;
  border-radius:0 2px 2px 0;background:var(--accent);
}
.rail-spacer{flex:1}
#theme-toggle .i-moon{display:none}
:root[data-theme="dark"] #theme-toggle .i-sun{display:none}
:root[data-theme="dark"] #theme-toggle .i-moon{display:block}

/* ───────── slide-over panel ───────── */
.panel-backdrop{display:none}
.panel-backdrop.open{
  display:block;position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:90;
}
.panel{
  position:fixed;left:62px;top:0;bottom:0;width:300px;z-index:95;
  background:var(--bg2);border-right:1px solid var(--line);
  transform:translateX(-110%);transition:transform .2s ease;
  display:flex;flex-direction:column;
}
.panel.open{transform:translateX(0)}
.panel-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:12px 10px 12px 16px;border-bottom:1px solid var(--line);min-height:59px;
}
.panel-title{font-weight:600;font-size:13.5px}
.panel-scroll{flex:1;overflow-y:auto;padding:0 16px 14px;min-height:0}
.panel-foot{
  padding:12px 16px;border-top:1px solid var(--line);
  font-size:11.5px;color:var(--fg3);line-height:1.45;
}
.panel-foot a{display:block;margin-top:6px}
.stats{display:grid;grid-template-columns:1fr 1fr;gap:6px;padding:12px 0}
.stat{
  background:var(--bg);border:1px solid var(--line);border-radius:var(--radius);
  padding:8px 10px;
}
.stat b{display:block;font:600 16px/1.15 GSC}
.stat span{color:var(--fg3);font-size:9.5px;text-transform:uppercase;letter-spacing:.07em}
.pnl-h{
  font-size:10px;text-transform:uppercase;letter-spacing:.09em;color:var(--fg3);
  margin:14px 0 6px;
}
.pnl-row{
  display:flex;justify-content:space-between;gap:8px;padding:4px 0;
  border-bottom:1px solid var(--line);font-size:12px;
}
.pnl-row:last-child{border-bottom:0}
.pnl-row span:last-child{font-family:GSC;color:var(--fg2);white-space:nowrap}
.pnl-note{color:var(--fg3);font-size:11px;line-height:1.5}

/* ───────── main / views ───────── */
#main{display:flex;flex-direction:column;min-height:0;overflow:hidden}
.view{display:none;flex-direction:column;min-height:0;flex:1}
.view.is-active{display:flex}
.view-head{
  display:flex;justify-content:space-between;align-items:center;gap:14px;
  padding:15px 22px;border-bottom:1px solid var(--line);flex-wrap:wrap;
}
.view-head h2{font-size:18px;font-weight:600;letter-spacing:-.01em}
.view-sub{color:var(--fg3);font-size:11.5px;margin-top:2px;max-width:640px}
.view-sub em{color:var(--fg2);font-style:normal;font-weight:500}
.view-tools{display:flex;gap:7px;align-items:center;flex-wrap:wrap}
.view-tools input,.view-tools select{
  background:var(--bg);border:1px solid var(--line);border-radius:var(--radius);
  padding:6px 10px;font-size:12.5px;min-width:130px;
}
.view-tools input:focus,.view-tools select:focus{outline:0;border-color:var(--accent)}
.back{color:var(--fg2);font-size:13px}
.back:hover{color:var(--fg)}
.primary{
  background:var(--accent);color:#fff;padding:7px 15px;border-radius:var(--radius);
  font-size:12.5px;font-weight:500;
}
.primary:hover{filter:brightness(1.07)}
.table-scroll{flex:1;overflow:auto;min-height:0}

/* ───────── data tables ───────── */
.grid-tbl{width:100%;border-collapse:collapse;font-size:12.5px}
.grid-tbl thead th{
  position:sticky;top:0;z-index:2;background:var(--bg2);
  text-align:left;padding:8px 12px;font-size:10px;text-transform:uppercase;
  letter-spacing:.07em;color:var(--fg3);border-bottom:1px solid var(--line);
  white-space:nowrap;
}
.grid-tbl td{padding:8px 12px;border-bottom:1px solid var(--line);vertical-align:top}
.grid-tbl tbody tr:hover{background:var(--bg2)}
.grid-tbl tbody tr.clickable{cursor:pointer}
.grid-tbl td.mono{font-family:GSC;font-size:11.5px;color:var(--fg2);white-space:nowrap}
.grid-tbl td.num{font-family:GSC;text-align:right;white-space:nowrap}
.grid-tbl td.name{max-width:330px}
.more{
  width:100%;padding:11px;color:var(--accent);font-size:12.5px;
  border-top:1px solid var(--line);
}
.empty{padding:34px 22px;color:var(--fg3);text-align:center;font-size:13px}

.chip{
  display:inline-block;font-family:GSC;font-size:9.5px;padding:1.5px 6px;
  border-radius:4px;background:var(--bg3);border:1px solid var(--line);
  color:var(--fg2);white-space:nowrap;
}
.chip.on{color:var(--ev-direct);background:var(--ev-direct-bg);border-color:var(--ev-direct-bd)}
.chip.auto{color:var(--accent);background:var(--accent-soft);border-color:var(--accent)}
.chip.blocked{color:var(--ev-proxy);background:var(--ev-proxy-bg);border-color:var(--ev-proxy-bd)}
.ev{
  display:inline-block;font-family:GSC;font-size:9.5px;padding:1.5px 6px;
  border-radius:4px;border:1px solid;white-space:nowrap;
}
.ev-direct_reported{color:var(--ev-direct);background:var(--ev-direct-bg);border-color:var(--ev-direct-bd)}
.ev-modeled_estimate{color:var(--ev-model);background:var(--ev-model-bg);border-color:var(--ev-model-bd)}
.ev-allocated_estimate{color:var(--ev-alloc);background:var(--ev-alloc-bg);border-color:var(--ev-alloc-bd)}
.ev-regional_proxy{color:var(--ev-proxy);background:var(--ev-proxy-bg);border-color:var(--ev-proxy-bd)}
.ev-context_only{color:var(--ev-ctx);background:var(--ev-ctx-bg);border-color:var(--ev-ctx-bd)}
.ev-unknown_pending_review{color:var(--ev-unk);background:var(--ev-unk-bg);border-color:var(--ev-unk-bd)}

/* ───────── chat: hero, pills, composer -- copied from the reference app ───────── */
.main{flex:1;display:flex;flex-direction:column;min-width:0;overflow:hidden}
.view{display:none;flex-direction:column;min-height:0;flex:1}
.view.is-active{display:flex}

.chat-column{
  flex:1;overflow-y:auto;padding:28px 24px 8px;
  max-width:860px;width:100%;margin:0 auto;
  display:flex;flex-direction:column;gap:22px;
}

/* Hero: big centred logo, exactly as in the reference shell. The logo IS the
   heading -- there is deliberately no large text title above it. */
.hero{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  flex:1;min-height:340px;text-align:center;gap:18px;
}
.hero-logo{width:170px;height:170px;border-radius:50%;display:block}
.hero p{color:var(--fg3);margin:0;font-size:13.5px;max-width:520px;line-height:1.55}
.suggested{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin-top:4px}
.suggested button{
  border:1px solid var(--line2);background:var(--bg2);
  color:var(--fg2);border-radius:11px;padding:9px 13px;
  font-size:12.5px;cursor:pointer;max-width:330px;text-align:left;font-family:inherit;
}
.suggested button:hover{border-color:var(--accent);color:var(--fg)}

/* Messages */
.msg{display:flex;gap:12px}
.msg-who{
  flex:0 0 27px;width:27px;height:27px;border-radius:8px;
  display:grid;place-items:center;font:700 12px/1 GS;letter-spacing:-.02em;
}
.msg.user .msg-who{background:var(--bg3);color:var(--fg2);font-size:9.5px;font-family:GSC}
/* The assistant avatar is the brand artwork, which supplies its own background
   and circular shape -- so no background and no radius here. */
.msg-who.is-brand{border-radius:0;background:none;display:block}
.msg-body{flex:1;min-width:0;padding-top:3px;overflow-wrap:anywhere}
.msg-body p{margin:0 0 10px}
.msg-body p:last-child{margin-bottom:0}
.msg-body ul,.msg-body ol{margin:0 0 10px 20px}
.msg-body li{margin-bottom:4px}
.msg-body code{
  background:var(--bg3);padding:1px 5px;border-radius:4px;font-size:12.5px;
  border:1px solid var(--line);
}
.msg-body pre{
  background:var(--bg2);border:1px solid var(--line);border-radius:var(--radius);
  padding:11px 13px;overflow-x:auto;margin:0 0 10px;
}
.msg-body pre code{background:none;border:0;padding:0}
.msg-body table{border-collapse:collapse;margin:0 0 12px;font-size:12.5px;width:100%}
.msg-body th,.msg-body td{border:1px solid var(--line);padding:5px 9px;text-align:left}
.msg-body th{background:var(--bg2);font-weight:600;font-size:11px}
.cursor::after{
  content:"";display:inline-block;width:7px;height:15px;margin-left:2px;
  background:var(--accent);vertical-align:text-bottom;
  animation:caret 1s steps(2) infinite;
}
@keyframes caret{0%,50%{opacity:1}50.01%,100%{opacity:0}}
.tool-line{font-family:GSC;font-size:11px;color:var(--fg3);padding:3px 0;display:flex;gap:7px}
.tool-line::before{content:"⟳";color:var(--accent)}
.err{
  background:var(--ev-proxy-bg);border:1px solid var(--ev-proxy-bd);color:var(--ev-proxy);
  padding:11px 13px;border-radius:11px;font-size:13px;
}

/* Composer: send button and status line live INSIDE the box. */
.composer-wrap{padding:10px 24px 22px}
.composer{
  max-width:860px;margin:0 auto;background:var(--bg2);
  border:1px solid var(--line2);border-radius:18px;
  padding:14px 16px 10px;box-shadow:var(--shadow);
}
.composer:focus-within{border-color:var(--accent)}
.composer textarea{
  width:100%;border:0;outline:0;resize:none;background:none;
  color:var(--fg);font-size:15px;font-family:inherit;
  max-height:190px;padding:0;line-height:1.5;display:block;
}
.composer textarea::placeholder{color:var(--fg3)}
.composer-row{display:flex;align-items:center;justify-content:space-between;margin-top:10px}
.composer-meta{display:flex;align-items:center;gap:7px;font-size:11.5px;color:var(--fg3)}
.composer-meta .dot{width:6px;height:6px;border-radius:50%;background:var(--accent);flex:0 0 6px}
.send-btn{
  background:var(--accent);color:#fff;border:0;border-radius:50%;
  width:38px;height:38px;cursor:pointer;display:grid;place-items:center;flex:0 0 38px;
}
.send-btn:hover{filter:brightness(1.08)}
.send-btn:disabled{opacity:.45;cursor:not-allowed}
.send-btn svg{stroke-width:2}
.composer-notice{
  max-width:860px;margin:9px auto 0;font-size:11px;color:var(--fg3);
  text-align:center;line-height:1.5;
}

/* Sources legend: the acquisition-route vocabulary, stated once. */
.legend{
  display:flex;flex-wrap:wrap;gap:14px;padding:9px 22px;
  border-bottom:1px solid var(--line);font-size:11px;color:var(--fg3);
}
.legend b{color:var(--fg2);font-weight:500}

/* ───────── county profile ───────── */
.prof-head{max-width:1020px;margin:0 auto;padding:22px 22px 0}
.prof-head h2{font-size:22px;font-weight:600}
.prof-sub{color:var(--fg3);font-size:11.5px;font-family:GSC;margin-top:3px}
.cov-bar{height:5px;background:var(--bg3);border-radius:3px;margin-top:13px;overflow:hidden}
.cov-bar div{height:100%;background:var(--ev-direct)}
.sect{max-width:1020px;margin:0 auto;padding:20px 22px 0}
.sect h3{
  font-size:10.5px;text-transform:uppercase;letter-spacing:.09em;color:var(--fg3);
  margin-bottom:9px;padding-bottom:5px;border-bottom:1px solid var(--line);
}
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(238px,1fr));gap:9px}
.card{
  background:var(--bg2);border:1px solid var(--line);border-radius:var(--radius);
  padding:11px 13px;
}
.card.nodata{background:var(--bg);border-style:dashed}
.card-k{color:var(--fg3);font-size:10px;text-transform:uppercase;letter-spacing:.05em}
.card-v{font:600 20px/1.15 GSC;margin-top:3px}
.card-v.none{font:400 13px/1.4 GS;color:var(--fg3)}
.card-u{color:var(--fg2);font-size:11px;margin-left:4px;font-weight:400}
.card-f{margin-top:7px;display:flex;gap:5px;flex-wrap:wrap;align-items:center}
.card-why{color:var(--fg3);font-size:10.5px;margin-top:6px;line-height:1.42}
.caveats{
  max-width:1020px;margin:20px auto 0;background:var(--ev-model-bg);
  border:1px solid var(--ev-model-bd);border-radius:var(--radius);padding:13px 15px;
}
.caveats h4{color:var(--ev-model);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}
.caveats ul{margin:8px 0 0 18px;color:var(--fg2);font-size:12.5px}
.caveats li{margin-bottom:5px}
.spin{color:var(--fg3);font-size:13px;padding:30px 22px;text-align:center}

::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--line2);border-radius:5px;border:2px solid var(--bg)}
::-webkit-scrollbar-thumb:hover{background:var(--fg3)}

/* ─── utility classes replacing inline styles ───
   The CSP sets `style-src 'self'` with no 'unsafe-inline', which blocks style
   attributes in markup. These exist so the policy can stay strict; the one
   genuinely dynamic value (coverage width) is set through the CSSOM instead. */
.pnl-note{color:var(--fg3);font-size:11px;line-height:1.5}
.grid-tbl td.link{color:var(--accent)}
.muted{color:var(--fg3)}
.tail-space{height:28px}
.answer-foot{margin-top:12px}
.cov-fill{width:0}
