/* EdgeLab dashboard — light/dark via prefers-color-scheme, no build step. */
:root {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f8fafb; --border: #e2e6ea; --border-strong: #cfd6dd;
  --text: #15202b; --muted: #5d6b79; --faint: #8a97a3;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e3f4f1; --accent-text: #0b5f58;
  --pos: #137a3c; --pos-soft: #e5f5eb; --neg: #b42318; --neg-soft: #fdecea; --warn: #a15c00; --warn-soft: #fdf3e1;
  --info: #1d5fbf; --info-soft: #e7effb;
  --z-research: #5b6bd6; --z-validation: #0f8f84; --z-holdout: #c2410c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1217; --surface: #161b22; --surface-2: #1b2129; --border: #29313b; --border-strong: #3a4450;
    --text: #e6ebf0; --muted: #9aa7b4; --faint: #6f7c89;
    --accent: #2bb3a3; --accent-ink: #04201d; --accent-soft: #123430; --accent-text: #5fd4c5;
    --pos: #4ccb7f; --pos-soft: #12301f; --neg: #ff7a6e; --neg-soft: #3a1714; --warn: #f0b259; --warn-soft: #36270f;
    --info: #7aa9f5; --info-soft: #15243d;
    --z-research: #8c99f0; --z-validation: #2bb3a3; --z-holdout: #f08a4b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-variant-numeric: tabular-nums; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-head > h2 { white-space: nowrap; }
.card-head > .muted { text-align: right; }
h3.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.minw0 { min-width: 0; } .wrap-text { overflow-wrap: anywhere; }
.show-sm { display: none; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .gap-s { gap: 6px; } .wrap { flex-wrap: wrap; }

/* top bar + tabs */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 10px 20px 0; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 22px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 11l3-4 3 2 4-5' stroke='white' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; }
.logout { margin: 0; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs-in { max-width: 1240px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; }
.tabs a { padding: 10px 10px 9px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }

.main-wrap { max-width: 1240px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.crumbs { margin-bottom: 6px; color: var(--muted); }

/* cards + layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-height: 24px; }
.card.narrow { max-width: 560px; margin: 24px auto; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cols > .card { margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tiles.small-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; color: inherit; }
a.tile:hover { border-color: var(--border-strong); text-decoration: none; }
.tile-label { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 22px; font-weight: 650; margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; white-space: nowrap; }
.small-tiles .tile-value { font-size: 20px; }
.tile-value .of { font-size: 13px; color: var(--muted); font-weight: 500; }
.tile-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.dot.pos { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); } .dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.neg { background: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.meter { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.warn span { background: var(--warn); } .meter.neg span { background: var(--neg); }

/* pills, banners, flash */
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; line-height: 18px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.pill.pos { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.pill.neg { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.pill.muted { opacity: .85; }
.pill.z-research { color: var(--z-research); } .pill.z-validation { color: var(--z-validation); } .pill.z-holdout { color: var(--z-holdout); }
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.banner.neg { background: var(--neg-soft); color: var(--neg); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--pos-soft); color: var(--pos); } .flash.err { background: var(--neg-soft); color: var(--neg); }
.empty { color: var(--muted); padding: 18px 12px; text-align: center; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 8px; font-size: 13px; }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--neg); color: #fff; border-color: var(--neg); }
@media (prefers-color-scheme: dark) { .btn.danger { color: #2a0b08; } }
.btn.danger-ghost { color: var(--neg); border-color: var(--border-strong); }
.btn.danger-ghost:hover { background: var(--neg-soft); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tier { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; line-height: 15px; background: rgba(127, 127, 127, .18); letter-spacing: .02em; }
.tier.t3 { background: var(--neg-soft); color: var(--neg); }
.btn.danger .tier.t3, .btn.danger .tier { background: rgba(255, 255, 255, .25); color: inherit; }
.act-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; flex-wrap: wrap; }
.card > .act-form, .card .act-form:has(.form-grid), .card .act-form:has(textarea) { display: block; }
.card > .act-form > .btn, .act-form:has(textarea) > .btn { margin-top: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 7px 9px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input.prio { width: 64px; padding: 4px 6px; text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.form-grid .span2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 12px 16px; }
.filters label { min-width: 140px; }
.filters .grow { flex: 1; min-width: 180px; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.table-wrap.scroll-y { max-height: 420px; overflow-y: auto; }
.table-wrap.scroll-y.short { max-height: 300px; }
table { border-collapse: collapse; width: 100%; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.data thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data.compact th, table.data.compact td { padding: 6px 8px; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: 0; }
.title-cell { min-width: 220px; }
.title-cell a { font-weight: 550; }
td.reason { min-width: 220px; max-width: 420px; color: var(--muted); }
td.detail { max-width: 440px; overflow-wrap: anywhere; color: var(--muted); font-family: var(--mono); font-size: 12px; }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 5px 12px 5px 0; white-space: nowrap; vertical-align: top; width: 1%; }
table.kv td { padding: 5px 0; overflow-wrap: anywhere; }
table.kv.compact th, table.kv.compact td { padding: 3px 12px 3px 0; font-size: 13px; }
.corr-cell.hi { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.corr-cell.lo { background: var(--info-soft); color: var(--info); }

/* events list */
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--border); }
.events li:last-child { border-bottom: 0; }
.ev-ts { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.ev-msg { overflow-wrap: anywhere; }
.events .pill { justify-self: start; }

/* pipeline funnel */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.f-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 64px; gap: 10px; align-items: center; }
.f-label { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-label b { color: var(--text); display: inline-block; width: 24px; }
.f-bar { height: 18px; background: var(--surface-2); border-radius: 5px; position: relative; overflow: hidden; display: flex; }
.f-bar .reach { background: var(--accent); opacity: .85; height: 100%; border-radius: 5px 0 0 5px; }
.f-bar .died { background: var(--neg); opacity: .55; height: 100%; }
.f-num { text-align: right; font-weight: 600; white-space: nowrap; }
.legend { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.reach { background: var(--accent); } .sw.died { background: var(--neg); opacity: .6; margin-left: 6px; }
.status-strip { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.status-strip.card-like { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; margin: 0 0 16px; }
.status-strip .sc { white-space: nowrap; color: inherit; }
.big-number { display: flex; flex-direction: column; justify-content: center; }
.huge { font-size: 52px; font-weight: 700; letter-spacing: -.03em; line-height: 1.05; margin: 6px 0 8px; }

/* strategy detail */
.prose { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; max-height: 360px; margin: 0; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; tab-size: 4; }
pre.code.tall { max-height: 520px; }
.chart-box { position: relative; height: 300px; margin-bottom: 10px; }
.chart-box.short { height: 200px; }
.chart-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
details.verdict { border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; margin-bottom: 8px; }
details.verdict summary { cursor: pointer; padding: 10px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details.verdict[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
details.verdict[open] { padding-bottom: 10px; }
.actions-right { justify-content: flex-end; }

/* paper & live */
.strat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; margin-bottom: 16px; }
.strat-grid .card { margin: 0; display: flex; flex-direction: column; }
.strat.mode-live { border-top: 3px solid var(--pos); }
.strat.mode-paper { border-top: 3px solid var(--info); }
.strat.mode-paused { border-top: 3px solid var(--warn); }
.strat h2 { font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 10px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.kpis .tile-label { font-size: 11px; }
.kpi { font-size: 17px; font-weight: 650; white-space: nowrap; margin-top: 2px; }
.kpi .unit { font-size: 12px; color: var(--muted); font-weight: 500; }
.strat-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 12px; }

/* login + tier 3 */
.login { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-card .muted { margin: 4px 0 18px; }
.t3 { border-top: 3px solid var(--neg); }
.eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--neg); font-weight: 700; margin-bottom: 4px; }
code.phrase { background: var(--neg-soft); color: var(--neg); padding: 1px 6px; border-radius: 4px; font-size: 13px; user-select: all; }

/* responsive */
@media (max-width: 1100px) {
  .tiles.small-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .cols, .cols.wide-left { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .main-wrap { padding: 14px 12px; }
  .topbar-in { padding: 8px 14px 0; }
  .tabs-in { padding: 0 6px; }
  h1 { font-size: 19px; }
  .card { padding: 14px; border-radius: 9px; }
  .tiles, .tiles.small-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px; }
  .tile-value { font-size: 18px; }
  .small-tiles .tile-value { font-size: 18px; }
  .f-row { grid-template-columns: 112px minmax(0, 1fr) 52px; gap: 8px; }
  .f-label { font-size: 12px; }
  .huge { font-size: 42px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span2 { grid-column: auto; }
  .strat-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .events li { grid-template-columns: auto minmax(0, 1fr); }
  .events li .ev-msg { grid-column: 1 / -1; }
  .events li .pill { justify-self: start; }
  .hide-sm { display: none; } .show-sm { display: inline; }
  table.stack-sm thead { display: none; }
  table.stack-sm tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.stack-sm tbody tr:last-child { border-bottom: 0; }
  table.stack-sm tbody tr:hover { background: none; }
  table.stack-sm td { border: 0 !important; padding: 0 !important; }
  table.stack-sm td.hide-sm { display: none; }
  table.stack-sm td.title-cell { flex: 1 1 100%; min-width: 0; }
  table.stack-sm td.prio-cell { margin-left: auto; }
  .small-tiles .tile:last-child:nth-child(odd) { grid-column: span 2; }
  .tabs { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .filters label { min-width: 0; flex: 1 1 140px; }
  .page-head { margin-bottom: 12px; }
  .chart-box { height: 240px; }
}
@media (max-width: 600px) {
  table.stack-sm td.reason { flex: 1 1 0; min-width: 0; max-width: none; }
}
