/* CECadence — brand system per compoundingenergy.com styles.css */
:root {
  --brand: #0B2545; --brand-500: #1E3A6A; --brand-100: #C3CCD9;
  --brand-50: #E6EAF0; --brand-25: #F4F6FA;
  --accent: #13C2C2; --accent-400: #3FDADA; --accent-600: #0F9A9A; --accent-50: #E1F8F8;
  --gold: #FFD166; --gold-50: #FFF7E1;
  --copper: #B45A2A;
  --paper: #FAFAF7; --ink-soft: #4A5A78; --ink-mute: #8593AA;
  --ff-display: 'Space Grotesk', system-ui, sans-serif;
  --ff-sans: 'Inter', system-ui, sans-serif;
  --ff-mono: 'JetBrains Mono', ui-monospace, monospace;
  --max: 1200px; --gutter: 28px;
  --ease: cubic-bezier(.2,.8,.2,1);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--brand);
  font-family: var(--ff-sans); font-size: 14.5px; line-height: 1.55;
}
h2 { font-family: var(--ff-display); font-size: 17px; margin: 0 0 10px; letter-spacing: .01em; }
h3 { font-family: var(--ff-display); font-size: 14.5px; margin: 18px 0 6px; }
.mono { font-family: var(--ff-mono); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- header ---------- */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 30; }
.topbar-inner {
  max-width: var(--max); margin: 0 auto; padding: 14px var(--gutter) 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand-name { font-family: var(--ff-display); font-weight: 700; font-size: 20px; letter-spacing: .02em; }
.badge {
  font-family: var(--ff-mono); font-size: 10.5px; letter-spacing: .08em;
  padding: 3px 8px; border-radius: 4px;
}
.badge-gold { background: var(--gold); color: var(--brand); font-weight: 600; }
.badge-warn { background: var(--gold-50); color: #9a7a1e; font-weight: 600; }
.health { font-family: var(--ff-mono); font-size: 12px; display: flex; align-items: center; gap: 7px; color: var(--brand-100); }
/* multi-tenancy v1: signed-in chip (hidden in single-tenant OFF mode) */
.tenant-chip {
  font-family: var(--ff-mono); font-size: 11px; color: var(--brand);
  background: var(--gold); font-weight: 600; padding: 3px 9px;
  border-radius: 4px; letter-spacing: .04em;
}
/* viewers are read-only: every write/compute control is shown but DISABLED
   (greyed, non-interactive) so a viewer can see the action exists and that
   their role cannot perform it — clearer than hiding. Covers the primary
   submit/demo/delete controls AND the secondary compute buttons
   (sensitivities, Monte Carlo, sweep, candidate tornado, backtest, anchor
   refresh). Keys off a body class set by loadPrincipal(). The server-side
   RBAC gate is authoritative (403 on every write); this is defence-in-depth
   + UX only. */
body.role-viewer .btn-primary,
body.role-viewer [data-del],
body.role-viewer #run-submit,
body.role-viewer #site-submit,
body.role-viewer #demo-run-btn,
body.role-viewer #sens-btn,
body.role-viewer #mc-btn,
body.role-viewer #sweep-btn,
body.role-viewer #site-tornado-btn,
body.role-viewer #bt-btn,
body.role-viewer #anchor-refresh-btn {
  opacity: .4 !important; pointer-events: none !important;
  cursor: not-allowed !important;
}
/* read-only notice for viewers (informational, gold accent — not an error).
   Revealed by loadPrincipal() only when the signed-in role is viewer. */
.viewer-banner { border-left: 3px solid var(--gold); }
/* tenant-admin API key management (iteration 60) */
.key-create { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin: 12px 0; }
.key-create label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-soft); }
.key-new { background: var(--gold); border-radius: 6px; padding: 10px 12px; margin: 8px 0; font-size: 13px; }
.key-new code { display: inline-block; margin: 0 8px; font-family: var(--ff-mono); word-break: break-all; user-select: all; }
#keys-table tr.key-revoked { opacity: .5; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot-warn { background: var(--gold); }
.dot-wait { background: var(--ink-mute); }
.tabs { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); display: flex; gap: 4px; }
.tab {
  font-family: var(--ff-display); font-size: 13px; letter-spacing: .04em;
  background: none; border: none; color: var(--brand-100); padding: 10px 14px;
  cursor: pointer; border-bottom: 2.5px solid transparent; transition: all .2s var(--ease);
}
.tab:hover { color: #fff; }
.tab.active { color: var(--accent-400); border-bottom-color: var(--accent); }
/* external link styled to sit in the tab row, pushed right (not an SPA tab) */
.tab-ext {
  margin-left: auto; align-self: center; font-family: var(--ff-display);
  font-size: 12.5px; letter-spacing: .04em; color: var(--accent-400);
  text-decoration: none; padding: 6px 12px; border: 1px solid var(--accent-600);
  border-radius: 6px; transition: all .2s var(--ease);
}
.tab-ext:hover { background: var(--accent-600); color: #fff; }

/* ---------- layout ---------- */
.content { max-width: var(--max); margin: 0 auto; padding: 22px var(--gutter) 60px; }
.panel { display: none; }
.panel.active { display: block; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.card {
  background: #fff; border: 1px solid var(--brand-50); border-radius: 8px;
  padding: 18px 20px; margin-bottom: 18px;
}
.hint { color: var(--ink-soft); font-size: 12.5px; margin: 4px 0 12px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.empty {
  text-align: center; color: var(--ink-mute); padding: 70px 0;
  border: 1.5px dashed var(--brand-100); border-radius: 8px; font-size: 15px;
}
.empty h2 { color: var(--brand); }
.empty .empty-copy {
  max-width: 540px; margin: 0 auto 18px; padding: 0 var(--gutter);
  font-size: 13.5px; color: var(--ink-soft);
}

/* ---------- getting-started hint card (Run tab) ---------- */
.hint-card { position: relative; padding: 12px 38px 12px 18px; font-size: 13px; color: var(--ink-soft); }
.hint-card b { color: var(--brand); font-family: var(--ff-display); }
.hint-card ol { margin: 4px 0 0; padding-left: 20px; }
.hint-card li { margin: 2px 0; }
.hint-dismiss {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: var(--ink-mute); font-size: 16px; line-height: 1; cursor: pointer;
  padding: 3px 7px; border-radius: 4px; transition: all .2s var(--ease);
}
.hint-dismiss:hover { color: var(--copper); background: var(--brand-25); }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 10px; }
input, select {
  font-family: var(--ff-sans); font-size: 14px; color: var(--brand);
  border: 1px solid var(--brand-100); border-radius: 6px; padding: 7px 9px; background: var(--brand-25);
  min-width: 110px;
}
input:focus, select:focus { outline: 2px solid var(--accent-50); border-color: var(--accent-600); }
.checks { display: flex; gap: 6px; flex-wrap: wrap; }
.checks label {
  flex-direction: row; align-items: center; gap: 5px; font-weight: 500;
  background: var(--brand-25); border: 1px solid var(--brand-50); border-radius: 6px;
  padding: 4px 9px; cursor: pointer; margin: 0; font-family: var(--ff-mono); font-size: 12px;
}
.checks label:has(input:checked) { background: var(--accent-50); border-color: var(--accent-600); }
/* custom-scenario fieldset (revealed by "Custom — define your own…") */
.custom-scenario-fields {
  border: 1px dashed var(--accent-600); border-radius: 8px;
  background: var(--accent-50); padding: 10px 14px 2px; margin: 0 0 12px;
}
.custom-scenario-fields legend {
  font-family: var(--ff-display); font-size: 12px; font-weight: 600;
  letter-spacing: .04em; color: var(--accent-600); padding: 0 6px;
}
.custom-scenario-fields input { min-width: 88px; background: #fff; }
.custom-scenario-fields .hint { margin: 0 0 8px; font-size: 11.5px; }

.btn-primary, .btn-secondary {
  font-family: var(--ff-display); font-size: 14px; font-weight: 600; letter-spacing: .03em;
  border: none; border-radius: 6px; padding: 10px 22px; cursor: pointer; transition: all .2s var(--ease);
}
.btn-primary { background: var(--accent); color: var(--brand); }
.btn-primary:hover { background: var(--accent-400); }
.btn-primary:disabled { background: var(--brand-100); cursor: wait; }
.btn-secondary { background: var(--brand-25); color: var(--brand); border: 1px solid var(--brand-100); }
.btn-secondary:hover { border-color: var(--accent-600); }

/* ---------- stats & cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff; border: 1px solid var(--brand-50); border-radius: 8px; padding: 14px 16px;
}
.stat .v { font-family: var(--ff-mono); font-size: 24px; font-weight: 600; color: var(--brand); }
.stat .k { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-mute); }
.hero-card {
  background: var(--brand); color: #fff; border-radius: 8px; padding: 20px 24px; margin-bottom: 18px;
  display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
}
.hero-card .big { font-family: var(--ff-mono); font-size: 40px; font-weight: 600; color: var(--gold); }
.hero-card .label { font-family: var(--ff-display); font-size: 15px; max-width: 540px; }
.hero-card .sub { color: var(--brand-100); font-size: 12.5px; width: 100%; }

/* ---------- tables ---------- */
.table-wrap { max-height: 430px; overflow: auto; border: 1px solid var(--brand-50); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  position: sticky; top: 0; background: var(--brand-25); text-align: left; padding: 8px 10px;
  font-family: var(--ff-display); font-size: 11.5px; letter-spacing: .05em; cursor: pointer;
  border-bottom: 1px solid var(--brand-100); white-space: nowrap;
}
td { padding: 6px 10px; border-bottom: 1px solid var(--brand-25); }
td.num, th.num { text-align: right; font-family: var(--ff-mono); }
tr:hover td { background: var(--accent-50); }
.status-pill { font-family: var(--ff-mono); font-size: 10px; letter-spacing: .05em; padding: 2px 7px; border-radius: 10px; }
.st-operational { background: var(--accent-50); color: var(--accent-600); }
.st-construction { background: var(--gold-50); color: #9a7a1e; }
.st-consented { background: var(--brand-25); color: var(--ink-soft); border: 1px solid var(--brand-100); }

/* ---------- charts / map ---------- */
.chart-wrap { position: relative; height: 280px; }
#gb-map { width: 100%; }
#gb-map svg { display: block; margin: 0 auto; }
.key { font-size: 11px; font-family: var(--ff-mono); padding: 1px 7px; border-radius: 9px; margin-left: 5px; }
.key-teal { background: var(--accent-50); color: var(--accent-600); }
.key-gold { background: var(--gold-50); color: #9a7a1e; }
.key-outline { border: 1px solid var(--brand-100); color: var(--ink-soft); }
.map-tip {
  position: fixed; pointer-events: none; background: var(--brand); color: #fff;
  font-family: var(--ff-mono); font-size: 11.5px; padding: 6px 9px; border-radius: 5px;
  z-index: 50; max-width: 240px; box-shadow: 0 4px 14px rgba(11,37,69,.35);
}

/* ---------- zone revenue overlay (Fleet map) ---------- */
#zone-overlay-controls { margin-bottom: 4px; }
#zone-overlay-controls select { min-width: 78px; }
#zone-overlay-controls input[type="checkbox"] { min-width: 0; width: auto; }
#zov-note { margin-top: 10px; font-size: 11px; }
.gbmap-zones text {
  font-family: var(--ff-mono); font-size: 9px; font-weight: 600; fill: var(--brand);
  paint-order: stroke; stroke: var(--paper); stroke-width: 2.5px; stroke-linejoin: round;
  pointer-events: none; user-select: none;
}
.gbmap-zones .gbmap-legend-label { font-size: 8px; font-weight: 400; fill: var(--ink-soft); }

/* ---------- run status / badges ---------- */
.run-status { font-family: var(--ff-mono); font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; min-height: 18px; }
.conv-badge { font-family: var(--ff-mono); font-size: 10.5px; letter-spacing: .05em; padding: 3px 8px; border-radius: 4px; margin-left: 6px; }
.cb-ok { background: var(--accent-50); color: var(--accent-600); }
.cb-warn { background: var(--gold-50); color: #9a7a1e; }
.cb-bad { background: #fbe9e7; color: var(--copper); }
/* in-sample fit (iteration 41): epistemically distinct from a pass —
   neutral slate pill + dashed outline so a fitted line never reads as
   independent validation at a glance */
.cb-fit { background: #EDF0F5; color: var(--ink-soft);
          outline: 1px dashed var(--ink-mute); outline-offset: -1px; }
.results-picker { margin-bottom: 16px; align-items: center; }

/* ---------- finance / atlas detail ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-family: var(--ff-mono); text-align: right; }
.verdict { font-family: var(--ff-display); font-weight: 600; padding: 8px 12px; border-radius: 6px; margin-top: 10px; text-align: center; }
.v-pass { background: var(--accent-50); color: var(--accent-600); }
.v-fail { background: #fbe9e7; color: var(--copper); }

/* ---------- methodology ---------- */
.method p, .method li { color: var(--ink-soft); font-size: 13.5px; }
.method b { color: var(--brand); }
pre { background: var(--brand-25); border: 1px solid var(--brand-50); border-radius: 6px; padding: 12px; overflow: auto; max-height: 320px; }
.footer-line { border-top: 1px solid var(--brand-50); padding-top: 14px; margin-top: 22px; color: var(--ink-mute) !important; }

/* ---------- portfolio head-to-head ---------- */
.pf-cmp { min-width: 0; padding: 0; margin: 0; cursor: pointer; accent-color: var(--accent-600); }
#pf-compare-table td.best { background: var(--accent-50); box-shadow: inset 2px 0 0 var(--accent); }
#pf-compare-table th { cursor: default; }
.banner-warn {
  background: #fbe9e7; color: var(--copper); border: 1px solid var(--copper);
  border-left-width: 4px; border-radius: 6px; padding: 9px 13px;
  font-family: var(--ff-display); font-weight: 600; font-size: 13px; margin: 0 0 12px;
}

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--brand); color: #fff; border-left: 4px solid var(--copper);
  padding: 10px 14px; border-radius: 6px; font-size: 13px; max-width: 360px;
  box-shadow: 0 6px 18px rgba(11,37,69,.3); animation: slidein .25s var(--ease);
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------ manage runs */
.mg-btn { background: none; border: none; cursor: pointer; padding: 0 4px;
  font-size: 14px; line-height: 1; }
.mg-btn:hover { transform: scale(1.15); }
#mg-table td { white-space: nowrap; }
#mg-card summary { cursor: pointer; }
