:root {
  color-scheme: light;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --line: #e1dfd7;
  --text: #1c1c1a;
  --text-2: #55554f;
  --muted: #85847c;
  --accent: #b4232a;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e8;
  --good: #0f7a3d;
  --warn: #a15c00;
  --bad: #b42318;
  --focus: #2a78d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  --s-redstar: #8f8e86; --s-entrants: #6250d6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #33332f;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #e5484d; --accent-ink: #ffffff; --accent-soft: #3a1a1b;
    --good: #3fb871; --warn: #e0a033; --bad: #f2645c;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
    --s-redstar: #8f8e86; --s-entrants: #9085e9;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #33332f;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #e5484d; --accent-ink: #ffffff; --accent-soft: #3a1a1b;
  --good: #3fb871; --warn: #e0a033; --bad: #f2645c;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --s-redstar: #8f8e86; --s-entrants: #9085e9;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 16px; } h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.num, td.n, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* layout */
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand .mark { width: 28px; height: 20px; border-radius: 4px; background: var(--accent); position: relative; flex: none; }
.brand .mark::after { content: ""; position: absolute; left: 4px; top: 6px; width: 7px; height: 5px; border-radius: 1.5px; background: #f4d27a; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.side { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .cols-3 { grid-template-columns: minmax(0, 1fr); } .side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.pad-lg { padding: 22px; }
.card h3 + * { margin-top: 10px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 10px; }

/* controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { min-height: 52px; font-size: 17px; padding: 0 24px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], input[type=number], select {
  min-height: 40px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); width: 100%;
}
input[type=number] { font-variant-numeric: tabular-nums; }
label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--text); color: var(--bg); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.timer { font: 700 28px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer.low { color: var(--bad); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
tr.sub td { color: var(--text-2); }
tr.me td { background: var(--accent-soft); }
.neg { color: var(--bad); }
.pos { color: var(--good); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .delta { font-size: 12px; margin-top: 2px; color: var(--text-2); }

/* bars */
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--text-2); }
.capbar { display: grid; grid-template-columns: 1fr 44px; gap: 4px 10px; align-items: center; font-size: 13px; }

/* events */
.event { border-left: 4px solid var(--accent); padding: 10px 14px; background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.event .kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.event h3 { margin: 4px 0; }
.event.macro { border-left-color: var(--s1); } .event.macro .kind { color: var(--s1); }
.event.reg { border-left-color: var(--s7, #6250d6); } .event.reg .kind { color: var(--s-entrants); }
.event.entrant { border-left-color: var(--s2); } .event.entrant .kind { color: var(--s2); }
.event.innovation { border-left-color: var(--s3); } .event.innovation .kind { color: var(--s3); }
.event.risk { border-left-color: var(--bad); } .event.risk .kind { color: var(--bad); }
.event.info { border-left-color: var(--muted); } .event.info .kind { color: var(--muted); }

/* product cards */
.product { display: flex; flex-direction: column; gap: 12px; }
.product.off { background: var(--surface-2); }
.product .head { display: flex; align-items: center; gap: 10px; }
.product .head h3 { flex: 1; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.fields .full { grid-column: 1 / -1; }
.slider { display: grid; grid-template-columns: 1fr 86px; gap: 8px; align-items: center; }
.slider input[type=number] { min-height: 34px; padding: 0 6px; text-align: right; }
.hint { font-size: 12px; color: var(--muted); }
.ref { font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 6px; padding: 6px 8px; }
.product.off .ref { background: var(--surface); }

.sticky-foot { position: sticky; bottom: 0; z-index: 15; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line); margin-top: 16px; }
.sticky-foot .wrap { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }

/* logos */
.logo { display: inline-block; flex: none; }
.logo svg { display: block; width: 100%; height: 100%; }
.team-chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* logo builder */
.builder { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: start; }
@media (max-width: 640px) { .builder { grid-template-columns: 1fr; } }
.pick { display: flex; flex-wrap: wrap; gap: 6px; }
.pick button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; padding: 6px; display: grid; place-items: center; }
.pick button.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--text) inset; }
.pick button svg { width: 24px; height: 24px; }
.pick.colours button { padding: 0; width: 32px; height: 32px; border-radius: 50%; }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); min-width: 140px; z-index: 5; }
.chart .tip .r { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart .tip .r span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 100; max-width: calc(100% - 32px); }
.banner { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.banner.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }

.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.join-card { width: 100%; max-width: 440px; }

/* info tooltips */
.tip-i { position: relative; width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); font: 700 11px/1 Georgia, serif; font-style: italic; cursor: help; padding: 0; display: inline-grid; place-items: center; }
.tip-i::after { content: attr(data-tip); position: absolute; left: -10px; bottom: calc(100% + 8px); width: max-content; max-width: 280px; padding: 8px 10px; border-radius: 8px; background: var(--text); color: var(--bg); font: 400 12.5px/1.4 Inter, ui-sans-serif, system-ui, sans-serif; font-style: normal; text-align: left; white-space: normal; box-shadow: 0 6px 20px rgba(0,0,0,.18); display: none; z-index: 30; pointer-events: none; }
.tip-i.left::after { left: auto; right: -10px; }
.tip-i:hover::after, .tip-i:focus-visible::after { display: block; }
.mode-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.mode-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.mode-opt input { margin-top: 3px; accent-color: var(--accent); }
