/* oddsfeed console - one stylesheet for every page.
 *
 * Design read: an internal operations console for a small odds-data team.
 * Calm, dense, terminal-adjacent. Cool neutral surfaces, ONE accent (signal
 * cyan) for interactive emphasis and chart lines, status colours only where
 * they carry state and always beside an icon or a word.
 *
 * Shape rule: 8px for controls and chips, 12px for panels, full pill for
 * segmented tabs. Nothing else.
 */

@import url("./icons/phosphor.css");

@font-face {
  font-family: "Pretendard Variable";
  src: url("./fonts/PretendardVariable.woff2") format("woff2-variations");
  font-weight: 45 920;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./fonts/JetBrainsMono-Variable.woff2") format("woff2-variations");
  font-weight: 100 800;
  font-display: swap;
}

/* -- tokens: dark is the default, light follows the system ----------------- */
:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface: #14171b;
  --raised: #1a1e23;
  --hover: #21262c;
  --line: #262b32;
  --line-strong: #353c45;

  --ink: #e8ebef;
  --ink-2: #a9b0b9;
  --ink-3: #7c848e;

  /* Validated for chart use: dark lightness band, chroma, 6.0:1 on surface. */
  --accent: #35a0cd;
  --accent-ink: #06141b;
  --accent-soft: rgb(53 160 205 / 0.14);
  --focus: rgb(53 160 205 / 0.5);

  --good: #3bbf73;
  --good-soft: rgb(59 191 115 / 0.12);
  --warn: #e3a53c;
  --warn-soft: rgb(227 165 60 / 0.12);
  --bad: #e5594f;
  --bad-soft: rgb(229 89 79 / 0.12);

  --r-control: 8px;
  --r-panel: 12px;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px rgb(0 0 0 / 0.28);

  --font: "Pretendard Variable", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic",
          "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f2f4f7;
    --surface: #fcfcfd;
    --raised: #f6f7f9;
    --hover: #eceff3;
    --line: #e1e5ea;
    --line-strong: #cbd1d9;
    --ink: #14181d;
    --ink-2: #4c545e;
    --ink-3: #69717b;
    --accent: #0a78a8;
    --accent-ink: #ffffff;
    --accent-soft: rgb(10 120 168 / 0.09);
    --focus: rgb(10 120 168 / 0.35);
    --good: #13803e;
    --good-soft: rgb(19 128 62 / 0.09);
    --warn: #986000;
    --warn-soft: rgb(152 96 0 / 0.1);
    --bad: #bf3329;
    --bad-soft: rgb(191 51 41 / 0.08);
    --shadow: 0 1px 2px rgb(20 24 29 / 0.05), 0 8px 24px rgb(20 24 29 / 0.06);
  }
}

/* -- base --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  font-feature-settings: "ss06";
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
.mono, .num { font-family: var(--mono); font-feature-settings: "zero" 0; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.ph { font-size: 1.1em; line-height: 1; vertical-align: -0.14em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* -- app shell ---------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 60px;
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: var(--r-control);
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font: 700 13px/1 var(--mono);
}
.nav { display: flex; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border-radius: var(--r-control);
  color: var(--ink-2); font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.page { max-width: 1440px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }
.page-head .spacer { flex: 1; }

/* -- panels --------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.panel-head .hint { color: var(--ink-3); font-size: 12px; }
.panel-head .end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .cols-2, .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .topbar { gap: 12px; padding: 0 14px; }
  .nav a span { display: none; }
  .page { padding: 20px 14px 48px; }
}

/* -- stat tiles --------------------------------------------------------------- */
.stat { padding: 16px 18px; display: grid; gap: 6px; align-content: start; }
.stat-label { color: var(--ink-3); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; }
.stat-sub { color: var(--ink-2); font-size: 12.5px; }

/* -- controls ----------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--raised); color: var(--ink);
  font-weight: 550; white-space: nowrap; cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.icon-btn { width: 34px; padding: 0; }

.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.input, .select {
  height: 36px; width: 100%; padding: 0 11px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-control);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input::placeholder { color: var(--ink-3); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search { position: relative; }
.search .ph { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 34px; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
}
.segmented button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2); font-weight: 550; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }
.segmented .count { font: 500 11.5px var(--mono); color: var(--ink-3); }

.check { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-control); cursor: pointer; }
.check:hover { background: var(--hover); }
.check input { appearance: none; width: 16px; height: 16px; margin: 0; flex: none;
  border: 1.5px solid var(--line-strong); border-radius: 5px; display: grid; place-items: center; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; width: 8px; height: 4px; margin-top: -2px;
  border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg); }
.check .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.check .meta { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* -- chips (pattern editor) --------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px;
  min-height: 44px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-control); }
.chips:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 9px;
  border-radius: var(--r-control); background: var(--raised); border: 1px solid var(--line); font-size: 12.5px; }
.chip.id { font-family: var(--mono); font-size: 12px; }
.chip button { width: 18px; height: 18px; border: 0; border-radius: 5px; background: transparent;
  color: var(--ink-3); cursor: pointer; display: grid; place-items: center; padding: 0; }
.chip button:hover { background: var(--hover); color: var(--ink); }
.chips input { flex: 1; min-width: 120px; border: 0; background: transparent; outline: none; height: 26px; padding: 0 4px; }

/* -- badges & status ---------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--raised); color: var(--ink-2); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.live-pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
@media (prefers-reduced-motion: no-preference) {
  .live-pulse { animation: pulse 1.6s var(--ease) infinite; }
  @keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
                     70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
}

/* -- tables ------------------------------------------------------------------- */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left;
  font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data .r { text-align: right; }
table.data tbody tr.clickable { cursor: pointer; transition: background 0.12s var(--ease); }
table.data tbody tr.clickable:hover { background: var(--hover); }
table.data tbody tr[aria-selected="true"] { background: var(--accent-soft); }

/* -- states --------------------------------------------------------------------- */
.empty { display: grid; place-items: center; gap: 8px; text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .ph { font-size: 28px; color: var(--ink-3); }
.empty strong { color: var(--ink-2); font-weight: 600; }
.error-line { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-control);
  background: var(--bad-soft); color: var(--bad); font-size: 13px; }
.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--raised), var(--hover), var(--raised)); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: shimmer 1.4s linear infinite; } @keyframes shimmer { to { background-position: -200% 0; } } }
.is-refreshing { opacity: 0.55; transition: opacity 0.2s var(--ease); }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--r-control); background: var(--raised); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); font-size: 13px; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise 0.25s var(--ease); } @keyframes rise { from { transform: translateY(8px); opacity: 0; } } }

/* -- chart ---------------------------------------------------------------------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--ink-3); font: 11px var(--mono); }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); fill-opacity: 0.1; stroke: none; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--line-strong); stroke-width: 1; }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; padding: 8px 10px; border-radius: var(--r-control);
  background: var(--raised); border: 1px solid var(--line-strong); box-shadow: var(--shadow); white-space: nowrap; }
.chart-tip .v { font: 650 15px var(--mono); }
.chart-tip .t { color: var(--ink-3); font-size: 12px; }

/* Odds moving is neither good nor bad news, so direction is an arrow in
   neutral ink - status colours stay reserved for real state. */
.move { display: inline-flex; align-items: center; gap: 2px; color: var(--ink-2); font: 500 11.5px var(--mono); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* page-level alert under the header */
.note-banner { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; padding: 12px 14px;
  border: 1px solid var(--warn, #c98a00); border-radius: 10px; background: color-mix(in srgb, var(--warn, #c98a00) 12%, var(--surface));
  color: var(--ink); font-size: 13px; line-height: 1.5; }
.note-banner[hidden] { display: none; }
.note-banner > i { font-size: 18px; color: var(--warn, #c98a00); margin-top: 1px; }
