/* dashboard/public/assets/style.css — Crab Stats. Colours are the validated
   dataviz palette (light + dark): slot 1 blue = Crab Race For It, slot 2
   orange = Crab Race Royale, slot 3 aqua for a third part. Text never wears
   a series colour; identity rides on a swatch or line key beside it. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --raised: #ffffff;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11,11,11,0.10);
  --free: #2a78d6; --royale: #eb6834; --third: #1baf7a;
  --wash: rgba(42,120,214,0.10);
  --good: #006300; --bad: #d03b3b;
  --brand: #ff5a3c;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --raised: #222221;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,0.10);
    --free: #3987e5; --royale: #d95926; --third: #199e70;
    --good: #0ca30c; --bad: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --raised: #222221;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,0.10);
  --free: #3987e5; --royale: #d95926; --third: #199e70;
  --good: #0ca30c; --bad: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: inherit; }

/* ── Header, tabs, filters ─────────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--page) 88%, transparent);
       backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
       border-bottom: 1px solid var(--ring); }
.top-inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 60px; height: 60px; display: block; flex: none; }
.brand h1 { font-size: 24px; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
.brand .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand > div:nth-child(2) { min-width: 0; }
@media (max-width: 480px) { .brand .sub { display: none; } }
.brand .spacer { flex: 1; }
.icon-btn { border: 1px solid var(--ring); background: var(--surface); border-radius: 10px; height: 34px; min-width: 34px;
            padding: 0 10px; cursor: pointer; font-size: 13px; color: var(--ink-2); white-space: nowrap; flex: none; }
.icon-btn:hover { background: var(--raised); }

.tabs { display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 10px 12px; font-size: 14px; font-weight: 600; color: var(--muted);
       border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 7px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab .key { width: 8px; height: 8px; border-radius: 50%; }

.filters { max-width: 1180px; margin: 0 auto; padding: 14px 16px 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.range { display: inline-flex; background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 3px; }
.range button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.range button:hover { background: var(--ring); }
.range button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.updated { font-size: 12px; color: var(--muted); }
.demo-flag { font-size: 12px; font-weight: 600; color: var(--ink-2); border: 1px dashed var(--axis); padding: 3px 8px; border-radius: 99px; }

/* ── Layout ────────────────────────────────────────────────────────────── */
main { max-width: 1180px; margin: 0 auto; padding: 8px 16px 64px; transition: opacity .2s; }
main.loading { opacity: .55; }
.section-title { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 2px 10px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(12, 1fr); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
@media (max-width: 900px) { .span-8, .span-6, .span-4 { grid-column: span 12; } .span-3 { grid-column: span 6; } }

.card { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card .hint { margin: 3px 0 12px; font-size: 12px; color: var(--muted); }
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-head .grow { flex: 1; min-width: 0; }

/* ── Hero + tiles ──────────────────────────────────────────────────────── */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 28px; }
.hero .big { font-size: 56px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; }
.hero .label { font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.tile .label { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.1; }
.tile .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; min-height: 22px; }
.delta { font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.delta.up.good, .delta.down.bad-is-good { color: var(--good); }
.delta.down.good, .delta.up.bad-is-good { color: var(--bad); }
.delta .vs { color: var(--muted); font-weight: 500; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ── Charts ────────────────────────────────────────────────────────────── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .end-label { font-size: 12px; font-weight: 650; fill: var(--ink); }
.chart .bar:hover, .chart .bar:focus { opacity: .8; outline: none; }
.chart:focus-visible { outline: 2px solid var(--axis); outline-offset: 4px; border-radius: 6px; }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--raised); border: 1px solid var(--ring);
           box-shadow: 0 6px 24px rgba(0,0,0,.12); border-radius: 10px; padding: 8px 10px; font-size: 12px; min-width: 120px;
           opacity: 0; transition: opacity .08s; }
.tooltip.on { opacity: 1; }
.tooltip .t-title { color: var(--muted); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row b { font-size: 14px; font-variant-numeric: tabular-nums; }
.tooltip .t-row span { color: var(--ink-2); }
.tooltip .lkey { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin: 0 0 10px; }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .lkey { width: 14px; height: 2px; border-radius: 1px; }

.big-single { font-size: 40px; font-weight: 650; padding: 24px 0 8px; }
.big-single small { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 4px; }

/* Ranked bars: label over a thin bar, value at the tip */
.ranks { display: flex; flex-direction: column; gap: 10px; }
.rank { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; font-size: 13px; }
.rank .name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .num { color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.rank .track { grid-column: 1 / -1; height: 8px; }
.rank .fill { height: 8px; border-radius: 0 4px 4px 0; min-width: 2px; }
.rank .sub { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.empty { font-size: 13px; color: var(--muted); padding: 18px 0; text-align: center; }

/* Segmented bar (one whole, split into parts) */
.seg { display: flex; gap: 2px; height: 28px; }
.seg .part { border-radius: 4px; display: flex; align-items: center; padding: 0 8px; color: #fff; font-size: 12px; font-weight: 650;
             overflow: hidden; white-space: nowrap; min-width: 0; }
.seg-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.seg-legend .item { display: flex; align-items: center; gap: 6px; }
.seg-legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Table view under a chart */
details.table-view { margin-top: 10px; }
details.table-view summary { font-size: 12px; color: var(--muted); cursor: pointer; list-style: none; display: inline-block; }
details.table-view summary::before { content: "▸ "; }
details.table-view[open] summary::before { content: "▾ "; }
.tbl-wrap { max-height: 260px; overflow: auto; margin-top: 8px; border: 1px solid var(--ring); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--ring); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
tr:last-child td { border-bottom: 0; }
.wide-table td:first-child { white-space: normal; }

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel .step { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.funnel .bar { grid-column: 1 / -1; height: 24px; border-radius: 0 4px 4px 0; background: var(--royale); min-width: 2px; }
.funnel .pct { color: var(--muted); font-size: 12px; }

/* Setup steps for Search Console */
.steps { margin: 6px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.steps b { color: var(--ink); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--ring); padding: 1px 5px; border-radius: 5px; }

.error { background: var(--surface); border: 1px solid var(--bad); color: var(--ink); border-radius: var(--radius); padding: 16px; margin-top: 16px; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--ring); border-radius: 20px; padding: 28px 24px; }
.login .logo { width: 96px; height: 96px; display: block; margin: -4px 0 14px; }
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login p { font-size: 14px; color: var(--ink-2); margin: 0 0 20px; }
.login input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--axis); background: var(--page); color: var(--ink);
               padding: 0 14px; font-size: 16px; }
.login input:focus { outline: 2px solid var(--free); outline-offset: 1px; }
.login button { width: 100%; height: 46px; margin-top: 12px; border: 0; border-radius: 12px; background: var(--ink); color: var(--surface);
                font-size: 15px; font-weight: 650; cursor: pointer; }
.login .msg { min-height: 20px; margin-top: 10px; font-size: 13px; color: var(--bad); }
