/* Admin panel: the one place that decides page geometry and shared components.
 *
 * Why this file exists: every page used to carry its own copy of the palette,
 * the header and the card rules, and the copies had drifted. Analytics was
 * 1400px wide, posting 1500px, settings 760px; the header showed a badge on one
 * page and an "Updated" timestamp on another. Navigating between pages moved
 * the navbar and the content edges, which is exactly what makes an interface
 * feel assembled rather than designed.
 *
 * So there is one standard, and it lives here:
 *   - page container: max-width 1400px, clamped gutters, 20px top / 40px bottom
 *   - header: sticky blurred pill, brand + segmented nav + icons, always the
 *     same height and the same internals (see .appbar below)
 *   - density rules borrowed from the BasePaint dashboard standard
 *     (basepaint-market/frontend/app/dashboard/dashboard.css): hairline rules
 *     instead of borders around every card, uppercase letterspaced
 *     micro-labels, monospace tabular figures, square accent markers,
 *     segmented controls, 16px card radius
 *
 * Page-specific CSS may add sections, but it must not redeclare body, header,
 * .panel, .card, .btn, .segmented or .iconbtn. If a page needs a variant, add a
 * modifier here so the next page inherits the decision.
 */

:root {
  --bg: #0a0d13; --panel: #121722; --panel-2: #0e121b; --inset: #0e121b;
  --border: #232b3a; --border-soft: #1c2431; --rule-ink: #dde3ec;
  --text: #dfe4ec; --dim: #8b96a8; --label: #8b96a8; --faint: #6b7789;
  --blue: #4a9eff; --blue-fill: #2a75d6; --blue-fill-hover: #3183e6; --blue-dim: rgba(74,158,255,0.13); --blue-line: rgba(74,158,255,0.38);
  --blue-wash: rgba(74,158,255,0.09);
  --hover: rgba(255,255,255,0.08);
  --gold: #e8b64c; --rose: #e05c6e; --green: #3dd68c;
  --gold-wash: rgba(232,182,76,0.12); --gold-line: rgba(232,182,76,0.45);
  --rose-wash: rgba(224,92,110,0.12); --rose-line: rgba(224,92,110,0.45);
  --green-wash: rgba(61,214,140,0.12); --green-line: rgba(61,214,140,0.40);
  --chart-grid: #1c2330; --track: #1c2330;
  --topbar: rgba(18, 23, 34, 0.82); --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --radius-card: 16px; --radius-ctl: 9px; --radius-inner: 6px;
}
[data-theme="light"] {
  --bg: #f4f5f7; --panel: #ffffff; --panel-2: #ffffff; --inset: #f1f3f5;
  --border: #e2e6ec; --border-soft: #eef0f4; --rule-ink: #1a2029;
  --text: #1a2029; --dim: #636d7a; --label: #636d7a; --faint: #6b7788;
  --blue: #1d69c6; --blue-fill: #1d69c6; --blue-fill-hover: #1a63bb; --blue-dim: rgba(29,105,198,0.09); --blue-line: rgba(29,105,198,0.35);
  --blue-wash: rgba(29,105,198,0.09);
  --hover: rgba(38,49,72,0.06);
  --gold: #9a6d09; --rose: #c02f42; --green: #12734a;
  --gold-wash: rgba(176,125,16,0.10); --gold-line: rgba(176,125,16,0.35);
  --rose-wash: rgba(192,47,66,0.08); --rose-line: rgba(192,47,66,0.32);
  --green-wash: rgba(18,115,74,0.08); --green-line: rgba(18,115,74,0.30);
  --chart-grid: #dfe4ea; --track: #e8ecf1;
  --topbar: rgba(255, 255, 255, 0.85); --shadow: 0 8px 24px rgba(20,30,50,0.08);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7; --panel: #ffffff; --panel-2: #ffffff; --inset: #f1f3f5;
    --border: #e2e6ec; --border-soft: #eef0f4; --rule-ink: #1a2029;
    --text: #1a2029; --dim: #636d7a; --label: #636d7a; --faint: #6b7788;
    --blue: #1d69c6; --blue-fill: #1d69c6; --blue-fill-hover: #1a63bb; --blue-dim: rgba(29,105,198,0.09); --blue-line: rgba(29,105,198,0.35);
    --blue-wash: rgba(29,105,198,0.09);
    --hover: rgba(38,49,72,0.06);
    --gold: #9a6d09; --rose: #c02f42; --green: #12734a;
    --gold-wash: rgba(176,125,16,0.10); --gold-line: rgba(176,125,16,0.35);
    --rose-wash: rgba(192,47,66,0.08); --rose-line: rgba(192,47,66,0.32);
    --green-wash: rgba(18,115,74,0.08); --green-line: rgba(18,115,74,0.30);
    --chart-grid: #dfe4ea; --track: #e8ecf1;
    --topbar: rgba(255, 255, 255, 0.85); --shadow: 0 8px 24px rgba(20,30,50,0.08);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-monospace, 'JetBrains Mono', 'Departure Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  padding: 20px clamp(16px, 3vw, 40px) 40px;
  max-width: 1400px;
  margin: 0 auto;
}
::selection { background: var(--blue-dim); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 3px solid var(--bg); }
button, a { transition: color .15s ease, border-color .15s ease, background .15s ease, transform .1s ease; }
button:active { transform: scale(0.97); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- header: identical on every page ----------
   Markup contract (see .appbar below): brand, separator, nav, spacer, icons.
   The controls on the right may differ (a page may add a refresh or a
   timestamp), but the brand block, the separator and the nav must not. */
header.topbar {
  position: sticky; top: 12px; z-index: 20;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--topbar); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 10px 16px; margin-bottom: 28px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 30px; height: 30px; display: block; }
.brand .stack { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand-sub { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--label); }
.spacer { flex: 1; }
.sep { width: 1px; height: 24px; background: var(--border); }
#updated { color: var(--faint); font-size: 11px; min-width: 104px; }

/* Segmented control, matched to the BasePaint timeframe switcher: inset track,
   3px pad, 9px track radius, 12px figures. The active segment is the blue wash
   and an inset ring rather than a filled pill, so a page can carry three of
   these (nav, range, view switcher) without turning into a wall of blue. The
   inset box-shadow draws the ring inside the segment, which keeps every segment
   the same size, so switching does not nudge the row. */
.segmented {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius-ctl);
}
.segmented > button, .segmented > a {
  font: inherit; font-size: 12px; font-weight: 500; line-height: 1; padding: 8px 12px;
  border: 0; border-radius: var(--radius-inner); background: none; color: var(--dim);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.segmented > button:hover, .segmented > a:hover { color: var(--text); }
.segmented > .on, .segmented > .on:hover {
  background: var(--blue-dim); color: var(--blue); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--blue-line);
}

.iconbtn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-ctl); border: 1px solid var(--border); background: none;
  color: var(--text); cursor: pointer;
}
.iconbtn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }
/* Bare icon button: no frame, quiet hover fill, the shape DSH uses for its own
   sidebar toggles (28px, round, --dsw-alias-label-secondary, hover
   --dsw-alias-interactive-bg-hover which resolves to #2631480f / #ffffff14).
   For controls that sit inside a panel head rather than on a toolbar. */
.iconbtn.ghost {
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  color: var(--label); background: none;
}
.iconbtn.ghost:hover { background: var(--hover); color: var(--text); border: 0; }
.iconbtn.ghost svg { width: 15px; height: 15px; }
.iconbtn.ghost.on { background: var(--hover); color: var(--text); }
.iconbtn svg { width: 17px; height: 17px; }
.iconbtn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#exit:hover { border-color: var(--rose); color: var(--rose); background: var(--rose-wash); }

/* ---------- the section bar under the header ----------
   One bar per page for the controls that belong to the page as a whole
   (site list and range, posting views). Same height and alignment everywhere,
   so the first row of content starts at the same y on every page. */
.secbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.secbar h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.secbar .slug { color: var(--faint); font-size: 12px; }

/* ---------- cards and panels ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 14px; margin-bottom: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 18px 20px;
}
.card .label, .panel h3, .panel h2, .card h3 {
  color: var(--label); font-size: 10px; font-weight: 500; letter-spacing: 0.13em;
  text-transform: uppercase;
}
.card .label { display: block; }
/* The micro-label as a utility, for page markup that is not a card head (a row
   label in a form, a group heading in a toolbar). Pages used to declare their own
   copy of exactly this rule. */
.label {
  color: var(--label); font-size: 10px; font-weight: 500; letter-spacing: 0.13em;
  text-transform: uppercase;
}
.panel h3, .panel h2, .card h3 { margin-bottom: 16px; }
.panel h3 span, .panel h2 span { color: var(--faint); }
.card .value { font-size: 30px; font-weight: 650; margin-top: 10px; letter-spacing: -0.02em; line-height: 1; }
.card .sub { color: var(--faint); font-size: 11px; margin-top: 6px; }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 22px 24px;
}
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1050px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- controls ---------- */
.btn {
  font: inherit; font-size: 12px; padding: 9px 14px; border-radius: var(--radius-ctl);
  border: 1px solid var(--border); background: none; color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }
.btn.primary { background: var(--blue-fill); border-color: var(--blue-fill); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue-fill-hover); border-color: var(--blue-fill-hover); color: #fff; }
.btn.warn:hover, .btn.warn-btn:hover { border-color: var(--rose); color: var(--rose); background: var(--rose-wash); }
.btn.warn-btn { border-color: var(--rose-line); color: var(--rose); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* Legacy button markup still resolves to the standard look. */
button.primary { background: var(--blue-fill); border-color: var(--blue-fill); color: #fff; font-weight: 600; }

label { display: block; color: var(--label); font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase; margin: 14px 0 6px; }
input, textarea, select {
  width: 100%; background: var(--inset); border: 1px solid var(--border); color: var(--text);
  font: inherit; font-size: 13px; padding: 9px 11px; border-radius: var(--radius-inner); outline: none;
}
textarea { min-height: 190px; resize: vertical; line-height: 1.55; }
textarea.short { min-height: 70px; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-dim); }

/* ---------- text ---------- */
.hint { color: var(--faint); font-size: 12px; }
::placeholder { color: var(--faint); opacity: 1; }
.meta { color: var(--dim); font-size: 12px; }
.meta b { color: var(--text); font-weight: 600; }
.msg { font-size: 12px; margin-top: 10px; min-height: 16px; }
.msg.err { color: var(--rose); }
.msg.ok { color: var(--green); }
.dim { color: var(--dim); }
/* A change reads by direction-that-is-good, not by sign: a bounce rate going up
   is not progress. Green means better, rose means worse, and gold is reserved for
   status (a live pill, a gate, a score badge) so it stops meaning two things. */
.up, .good { color: var(--green); }
.down, .bad, .err { color: var(--rose); }
.flat { color: var(--faint); }
.live { color: var(--green); font-weight: 600; }
.ok { color: var(--green); } .skip { color: var(--gold); } .bad { color: var(--rose); }
.tag { display: inline-block; font-size: 10px; color: var(--label); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.pill {
  font-size: 10px; color: var(--label); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px; letter-spacing: 0.13em; text-transform: uppercase;
}
.pill.live { color: var(--green); border-color: var(--green-line); background: var(--green-wash); }
.pill.gate { color: var(--gold); border-color: var(--gold-line); background: var(--gold-wash); }
.pill.done { color: var(--green); border-color: var(--green-line); background: var(--green-wash); }

footer { color: var(--faint); font-size: 11px; margin-top: 28px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
footer a { color: var(--faint); }
footer a:hover { color: var(--blue); }
