/* SmeargleScope design system.
   Tokens follow the validated dataviz reference palette: series colors are the
   categorical slots (us=blue, competitor 1=orange, 2=aqua) — 3 series passes
   all-pairs CVD checks in both modes. Ink/surface/hairline from the same sheet.
   Brand navy #1c1f3a carried over from SmeargleMetrics. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --baseline: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --brand: #1c1f3a;
  --brand-hover: #2a2e57;
  --brand-ink: #ffffff;
  --us: #2a78d6;
  --shop-1: #eb6834;
  --shop-2: #1baf7a;
  --shop-3: #eda100;
  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;
  --wash-us: rgba(42, 120, 214, 0.10);
  --wash-gap: rgba(208, 59, 59, 0.06);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --baseline: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --brand: #3987e5;
    --brand-hover: #5598e7;
    --brand-ink: #0b0b0b;
    --us: #3987e5;
    --shop-1: #d95926;
    --shop-2: #199e70;
    --shop-3: #c98500;
    --good-text: #0ca30c;
    --wash-us: rgba(57, 135, 229, 0.14);
    --wash-gap: rgba(230, 103, 103, 0.08);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
a.plain { text-decoration: none; }
a.plain:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 2px; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 10px; display: flex; align-items: center; gap: 7px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }

/* --- nav --- */
.topnav {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.topnav-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 14px;
}
.brand { font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--us); }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tabs a {
  padding: 6px 12px; border-radius: 8px; text-decoration: none;
  font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.tabs a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.tabs a.active { background: var(--brand); color: var(--brand-ink); }
.logout { font-size: 13px; color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--ink); }

/* --- page scaffold --- */
.page { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.panel {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: 14px; padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

/* --- KPI tiles --- */
.tiles {
  display: grid; gap: 10px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.tile {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 14px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.tile-us { background: var(--wash-us); }
.tile-gap { background: var(--wash-gap); }
.tile-label {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--ink-2);
  display: flex; align-items: center; gap: 6px;
}
.tile-value { margin: 2px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.tile-sub { margin: 0; font-size: 12.5px; color: var(--muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-us { background: var(--us); }
.dot-shop-1 { background: var(--shop-1); }
.dot-shop-2 { background: var(--shop-2); }
.dot-shop-3 { background: var(--shop-3); }

/* --- filter pills + controls --- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill {
  padding: 5px 12px; border-radius: 999px; text-decoration: none; font-size: 13.5px;
  font-weight: 500; color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--hairline);
}
.pill:hover { border-color: var(--baseline); color: var(--ink); }
.pill.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pill-n { margin-left: 6px; opacity: 0.6; font-variant-numeric: tabular-nums; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.input {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 9px;
  padding: 7px 10px; font-size: 14px; font-family: inherit;
}
.input:focus { outline: 2px solid var(--us); outline-offset: -1px; border-color: transparent; }
.input[type="search"] { flex: 1; min-width: 180px; }

/* --- card grid --- */
.card-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card-tile {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.card-tile.is-gap { outline: 2px solid color-mix(in srgb, var(--critical) 45%, transparent); outline-offset: -2px; }
.card-img { position: relative; background: color-mix(in srgb, var(--ink) 4%, var(--surface)); }
.card-img img { display: block; width: 100%; aspect-ratio: 63 / 88; object-fit: contain; }
.cover-chips {
  position: absolute; left: 6px; top: 6px; right: 6px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.chip {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.01em;
  padding: 2px 7px; border-radius: 999px; color: #fff;
  background: var(--muted);
}
.chip-us { background: var(--us); }
.chip-shop-1 { background: var(--shop-1); }
.chip-shop-2 { background: var(--shop-2); }
.chip-shop-3 { background: var(--shop-3); }
.chip-done { background: var(--good); }
.chip-wip { background: var(--shop-3); }
.card-meta { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 3px; }
.card-title { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-size: 13.5px; }
.card-title strong { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title .muted { font-size: 12px; flex: none; }
.card-meta .small { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- buttons --- */
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 9px; font-size: 14px;
  font-weight: 550; text-decoration: none; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--hairline);
  font-family: inherit;
}
.btn:hover { border-color: var(--baseline); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.chipbtn {
  font-size: 12.5px; font-weight: 550; padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--hairline); background: transparent; color: var(--ink-2);
  cursor: pointer; font-family: inherit; margin-top: 3px;
}
.chipbtn:hover { border-color: var(--baseline); color: var(--ink); }
.chipbtn-on { background: var(--wash-us); border-color: var(--us); color: var(--us); }
.chipbtn-danger:hover { border-color: var(--critical); color: var(--critical); }
.inline-form { display: inline; }

/* --- table --- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.02em; color: var(--ink-2); padding: 6px 10px;
  border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
th .dot { margin-right: 5px; }
td { padding: 7px 10px; border-bottom: 1px solid var(--hairline); }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- pager --- */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.pager .muted { flex: 1; font-size: 13px; }

/* --- to-do rows --- */
.todo-row {
  display: flex; gap: 12px; padding: 12px 0; align-items: flex-start;
  border-bottom: 1px solid var(--hairline);
}
.todo-row:last-child { border-bottom: none; }
.todo-done { opacity: 0.55; }
.todo-thumb { width: 58px; border-radius: 6px; flex: none; }
.todo-body { flex: 1; min-width: 0; }
.todo-body .card-title { justify-content: flex-start; }
.todo-actions { display: flex; flex-direction: column; gap: 4px; flex: none; }
.note-form { margin-top: 5px; }
.input-note { width: 100%; max-width: 420px; font-size: 13px; padding: 5px 9px; }

/* --- shops --- */
.chart-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.chart-panel h2 { margin-bottom: 4px; }
.chart { min-height: 180px; }
.shop-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.shop-card { margin-bottom: 0; }
.shop-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.shop-icon { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; }
.tag {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--wash-us); color: var(--us); border-radius: 5px; padding: 2px 6px;
}
.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px; margin-bottom: 8px;
}
.stat { margin: 0; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.unmatched summary { cursor: pointer; font-size: 13.5px; color: var(--ink-2); padding: 6px 0; }
.unmatched-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px solid var(--hairline); font-size: 13px;
}
.unmatched-row:last-child { border-bottom: none; }
.pin-form { display: flex; gap: 5px; flex: none; }
.input-pin { width: 150px; font-size: 12.5px; padding: 4px 8px; }

/* --- login --- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 18px;
  padding: 34px 30px; width: 100%; max-width: 360px; display: flex;
  flex-direction: column; gap: 12px; box-shadow: 0 10px 40px rgba(11, 11, 11, 0.08);
}
.login-brand { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
.login-brand span { color: var(--us); }
.login-sub { margin: -8px 0 8px; color: var(--muted); font-size: 14px; }
.login-error { margin: 0; color: var(--critical); font-size: 13.5px; }

/* --- chart internals (used by chart.js) --- */
.chart svg { display: block; width: 100%; height: auto; }
.chart .gridline { stroke: var(--hairline); stroke-width: 1; }
.chart .axisline { stroke: var(--baseline); stroke-width: 1; }
.chart .ticklabel { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .serieslabel { font-size: 11.5px; font-weight: 600; }
.chart-tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface); border: 1px solid var(--ring); border-radius: 9px;
  box-shadow: 0 4px 18px rgba(11, 11, 11, 0.12); padding: 8px 10px; font-size: 12.5px;
}
.chart-tip .tip-day { color: var(--muted); margin-bottom: 3px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip .tip-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.chart-note { color: var(--muted); font-size: 13px; padding: 30px 0; text-align: center; }

@media (max-width: 640px) {
  .page { padding: 14px 10px 50px; }
  .panel { padding: 12px; border-radius: 12px; }
  .tile-value { font-size: 22px; }
  .todo-actions { flex-direction: row; }
  .todo-row { flex-wrap: wrap; }
}
