/* Snack Market Radar. Semantic tokens first; components only use tokens. */
:root {
  color-scheme: light;
  /* surfaces */
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f1f2ee;
  --surface-3: #e8e9e4;
  --border: #e1e3dc;
  --border-strong: #cfd2c9;
  /* text */
  --text: #0f1411;
  --text-2: #4a524c;
  --text-3: #6b736d;
  /* brand chrome (logo, active nav). Data never uses it. */
  --brand: #166f5a;
  --brand-soft: #e3f1ec;
  --brand-ink: #0d5645;
  /* data */
  --accent: #2a78d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --pos: #2a78d6; --neg: #e34948; --mid: #c9c8c2;
  /* status */
  --good: #1a7f37; --warn: #9a6700; --bad: #cf222e;
  --warn-bg: #fff6dc; --warn-border: #f1d58a; --warn-ink: #5c4400;
  --grid: #eceee8;
  /* shape */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 18, .04), 0 1px 3px rgba(16, 24, 18, .06);
  --shadow-lift: 0 4px 16px rgba(16, 24, 18, .08);
  --focus: 0 0 0 3px rgba(42, 120, 214, .35);
  --side-w: 248px;
  --t-fast: 150ms;
  --t: 200ms;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e100f; --surface: #171a18; --surface-2: #1f2320; --surface-3: #272c28;
    --border: #2b302c; --border-strong: #3a403b;
    --text: #f4f6f3; --text-2: #c2c8c2; --text-3: #8e968f;
    --brand: #3fb893; --brand-soft: #16302a; --brand-ink: #7fd8bb;
    --accent: #3987e5; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --pos: #3987e5; --neg: #e66767; --mid: #4a4a46;
    --good: #3fb950; --warn: #d29922; --bad: #f85149;
    --warn-bg: #2e2508; --warn-border: #5c4a14; --warn-ink: #f5dc9a;
    --grid: #232724;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lift: 0 6px 20px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e100f; --surface: #171a18; --surface-2: #1f2320; --surface-3: #272c28;
  --border: #2b302c; --border-strong: #3a403b;
  --text: #f4f6f3; --text-2: #c2c8c2; --text-3: #8e968f;
  --brand: #3fb893; --brand-soft: #16302a; --brand-ink: #7fd8bb;
  --accent: #3987e5; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --pos: #3987e5; --neg: #e66767; --mid: #4a4a46;
  --good: #3fb950; --warn: #d29922; --bad: #f85149;
  --warn-bg: #2e2508; --warn-border: #5c4a14; --warn-ink: #f5dc9a;
  --grid: #232724;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lift: 0 6px 20px rgba(0, 0, 0, .4);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
h1, h2, h3 { letter-spacing: -0.015em; }
h2 { font-size: 22px; line-height: 1.3; margin: 0 0 8px; font-weight: 700; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--good); } .neg { color: var(--bad); }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
code { font-size: 13px; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 8px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.logo .ic { width: 20px; height: 20px; stroke-width: 2; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tabs button {
  display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 12px;
  font: inherit; font-size: 14.5px; font-weight: 500; color: var(--text-2); text-align: left;
  background: none; border: 0; border-radius: 10px; cursor: pointer;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.tabs button[aria-selected="true"] .ic { stroke: var(--brand); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); }
.side-foot .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.side-foot .row span:first-child { display: flex; align-items: center; gap: 8px; color: var(--text-2); }

.col { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 28px; max-width: 1280px; }
.top-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crumb { font-weight: 650; font-size: 15px; }
.updated { font-size: 12.5px; color: var(--text-3); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 10px; border-radius: 999px; background: var(--surface); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--good); } .dot.stale, .dot.partial { background: var(--warn); } .dot.err { background: var(--bad); }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; cursor: pointer;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border);
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.only-mobile { display: none; }

.wrap { width: 100%; max-width: 1280px; padding: 0 28px; }
main { padding-top: 24px; padding-bottom: 40px; }
.tab { animation: tab-in var(--t) ease both; }
@keyframes tab-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.intro { margin-bottom: 20px; max-width: 860px; }
.intro p { margin: 0; color: var(--text-2); }
.foot { color: var(--text-3); font-size: 12.5px; padding-bottom: 32px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; min-width: 0; box-shadow: var(--shadow); }
.card > h3:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.banner { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-border); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.banner::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-top: 7px; flex: none; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile .k { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.tile .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -0.02em; line-height: 1.2; }
.tile .muted.small { margin-top: 4px; line-height: 1.4; }

.tag { display: inline-flex; align-items: center; font-size: 11px; font-weight: 650; letter-spacing: 0.02em; padding: 1px 8px; border-radius: 999px; vertical-align: 1px; border: 1px solid; white-space: nowrap; }
.tag-vetted { color: var(--good); background: color-mix(in srgb, var(--good) 8%, transparent); }
.tag-live { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tag-signal { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.tag-conflict { color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
td { padding: 11px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr { transition: background var(--t-fast) ease; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
th.num { text-align: right; }

/* ---------- where to play ---------- */
.rank-row {
  display: grid; grid-template-columns: 36px minmax(180px, 1.35fr) minmax(130px, .9fr) 2.2fr 24px; gap: 16px; align-items: center;
  padding: 14px 12px; margin: 0 -12px; border-radius: 10px; cursor: pointer; border-bottom: 1px solid var(--grid);
  transition: background var(--t-fast) ease;
}
.rank-row:hover { background: var(--surface-2); }
.rank-row:last-child { border-bottom: 0; }
.rank-row::after { content: ""; grid-column: 5; grid-row: 1; width: 18px; height: 18px; justify-self: end; opacity: .55;
  background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: transform var(--t) ease; }
.rank-row.open::after { transform: rotate(180deg); }
.rank-n { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 650; background: var(--surface-2); color: var(--text-2); font-variant-numeric: tabular-nums; }
.rank-row:nth-child(-n+4) .rank-n { background: var(--brand-soft); color: var(--brand-ink); }
.rank-name { font-weight: 650; font-size: 15.5px; }
.rank-why { font-size: 13px; color: var(--text-2); margin-top: 2px; line-height: 1.45; }
.score { display: flex; align-items: center; gap: 10px; }
.score b { font-size: 22px; font-variant-numeric: tabular-nums; min-width: 34px; letter-spacing: -0.02em; }
.bar { height: 8px; background: var(--surface-3); border-radius: 4px; flex: 1; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; transition: width 400ms ease; }
.comps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.comp .k { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp .bar { height: 6px; margin-top: 4px; }
.comp .bar > i { background: var(--s1); }
.comp.na .k::after { content: " n/a"; color: var(--text-3); }
.comp.na .bar { background: repeating-linear-gradient(45deg, var(--surface-3) 0 4px, transparent 4px 8px); }
.detail { display: none; grid-column: 1 / -1; background: var(--surface-2); border-radius: 10px; padding: 16px; font-size: 13.5px; cursor: default; }
.detail th { background: var(--surface-2); }
.rank-row.open .detail { display: block; animation: tab-in var(--t) ease both; }
.leaders { font-size: 13px; margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.leader { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; white-space: nowrap; color: var(--text); text-decoration: none; transition: border-color var(--t-fast) ease, background var(--t-fast) ease; }
.leader:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.leader.tracked { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }

/* ---------- controls ---------- */
.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 420px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
select, .chip, #brand-search {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; min-height: 40px; padding: 8px 12px; transition: border-color var(--t-fast) ease, background var(--t-fast) ease;
}
select { padding-right: 32px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b736d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
select:hover, #brand-search:hover { border-color: var(--text-3); }
.chip { cursor: pointer; border-radius: 999px; min-height: 36px; padding: 6px 14px; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
#brand-search { font-size: 15px; min-width: min(380px, 100%); padding-left: 38px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b736d' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center / 18px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin: 4px 0 10px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ---------- news & lists ---------- */
.news-item { padding: 14px 0; border-bottom: 1px solid var(--grid); }
.news-item:first-child { padding-top: 0; }
.news-item:last-child { border-bottom: 0; padding-bottom: 0; }
.news-item .t { font-weight: 550; line-height: 1.45; }
.news-item .t a { color: var(--text); }
.news-item .t a:hover { color: var(--accent); }
.news-item .m { font-size: 12.5px; color: var(--text-3); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.type { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); padding: 1px 7px; border-radius: 5px; background: var(--surface-2); }
.type-funding, .type-acquisition { color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }
.type-launch { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.type-regulation { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.empty { padding: 36px 24px; text-align: center; color: var(--text-2); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); margin-bottom: 16px; }
.empty b { color: var(--text); display: block; margin-bottom: 6px; font-size: 16px; }
.list { margin: 0; padding-left: 20px; }
.list li { margin-bottom: 8px; }
.list li::marker { color: var(--text-3); }
.rising { display: flex; flex-wrap: wrap; gap: 6px; }
.rising span { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; }

/* ---------- loading skeleton ---------- */
.skeleton { display: grid; gap: 14px; }
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; border-radius: 10px; animation: shimmer 1.2s linear infinite; }
.sk-title { height: 26px; width: 45%; } .sk-line { height: 14px; width: 70%; }
.sk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; } .sk-card { height: 86px; }
.sk-block { height: 320px; }
@keyframes shimmer { to { background-position: -200% 0; } }
body.loaded .skeleton { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .app { display: flex; flex-direction: column; }
  .col { display: contents; }
  .top { order: 0; } .side { order: 1; } main { order: 2; } .foot { order: 3; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .side .brand, .side-foot { display: none; }
  .tabs { flex-direction: row; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; white-space: nowrap; scroll-snap-align: start; min-height: 40px; }
  .top { position: static; }
  .only-mobile { display: grid; }
  .top-inner, .wrap { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 760px) {
  h2 { font-size: 19px; }
  .status { display: none; }
  .rank-row { grid-template-columns: 32px minmax(0, 1fr) 20px; gap: 10px; }
  .rank-row .score, .rank-row .comps { grid-column: 2 / 3; }
  .rank-row::after { grid-column: 3; }
  .comps { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .comp .k { font-size: 10.5px; }
  .card { padding: 16px; }
  .chart-box.tall { height: 320px; }
  .sk-grid { grid-template-columns: 1fr; }
  .tile .v { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media print {
  .side, .top, .skeleton { display: none !important; }
  .app { display: block; }
}
