/* ============================================================
   usual.pnesolutions.ca — the admin room.
   The tokens are usualapp.ca's own (usual-landing/src/styles/
   tokens.css): same grounds, same navy, same pill buttons, so
   the tool reads as family. One deliberate light look; the data
   tables and the sidebar are this file's only inventions.
   ============================================================ */
:root {
  /* grounds */
  --edge: #E8ECEF;
  --ground: #F4F5F7;
  --sheet: #FFFFFF;
  --card: #EBF0F8;
  --tint: #ECF1FA;
  --tint-border: #B7C6E8;

  /* ink */
  --ink: #0F1419;
  --muted: #5D646E;
  --label: #626873;
  --line: #E2E5EA;

  /* the one accent, and the brand navy */
  --accent: #1B3F9C;
  --accent-down: #16337F;
  --on-accent: #FFFFFF;
  --brand: #152A5E;

  /* the black pill (bevel anatomy) */
  --pill: #17181B;
  --pill-hover: #2C2E33;
  --on-pill: #FFFFFF;

  /* verdict tints, AA on their grounds */
  --ok-bg: #E3F2E8;    --ok-ink: #175B33;
  --warn-bg: #FBEFD8;  --warn-ink: #7A4E10;
  --bad-bg: #FBE3E1;   --bad-ink: #8C231B;
  --error: #B3261E;

  --font-sans: -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r-card: 24px;
  --r-panel: 32px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; color: var(--ink); }
p { margin: 0; }
button { font: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.kicker {
  font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--label);
}
.wordmark { font-family: var(--font-serif); font-weight: 600; color: var(--brand); letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); font-size: 0.8rem; }
.muted { color: var(--muted); }

/* ── Shell: sidebar + content ──────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--sheet); border-right: 1px solid var(--line);
  padding: 1.6rem 1rem; display: flex; flex-direction: column; gap: 1.6rem;
  position: sticky; top: 0; height: 100vh;
}
.side__brand { display: flex; align-items: baseline; gap: 0.5rem; padding-inline: 0.55rem; }
.side__brand .wordmark { font-size: 1.5rem; line-height: 1; }
.side__nav { display: flex; flex-direction: column; gap: 2px; }
.side__nav a {
  padding: 0.55rem 0.8rem; border-radius: 12px;
  font-weight: 500; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.side__nav a:hover { background: var(--ground); color: var(--ink); }
.side__nav a[aria-current="page"] { background: var(--tint); color: var(--accent); font-weight: 600; }
.side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.6rem; padding-inline: 0.55rem; }
.side__who { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.side__row { display: flex; gap: 0.5rem; align-items: center; }

.content { padding: clamp(1.4rem, 3vw, 2.6rem); min-width: 0; max-width: 78rem; }
.page-head { margin-bottom: 1.4rem; }
.page-head .kicker { display: block; margin-bottom: 0.35rem; }
.page-head h1 { font-size: 1.7rem; }
.page-head p { margin-top: 0.4rem; color: var(--muted); max-width: 60ch; }

@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: column; padding: 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .side__nav { flex-direction: row; flex-wrap: wrap; }
  .side__foot { margin-top: 0.4rem; flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  font-weight: 600; font-size: 0.92rem; line-height: 1;
  padding: 0.7rem 1.3rem; border: 0; border-radius: 999px; cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.btn--pill { background: var(--pill); color: var(--on-pill); }
.btn--pill:hover { background: var(--pill-hover); }
.btn--pill:active { transform: scale(0.985); }
.btn--ghost { background: var(--sheet); color: var(--ink); border: 1px solid var(--line); }
.btn--ghost:hover { border-color: var(--tint-border); color: var(--accent); }
.btn--quiet { background: transparent; color: var(--accent); padding-inline: 0.4rem; }
.btn--quiet:hover { color: var(--accent-down); }
.btn--sm { font-size: 0.8rem; padding: 0.45rem 0.9rem; }
.btn[disabled] { opacity: 0.55; cursor: default; }

/* ── Fields (the landing's intake anatomy) ─────────────────── */
.field { display: grid; gap: 0.4rem; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.field input, .field select {
  font: inherit; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.65rem 0.85rem; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form-error { color: var(--error); font-size: 0.88rem; }
.form-note { color: var(--muted); font-size: 0.85rem; }

/* ── Cards ─────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.9rem; }
.stat {
  background: var(--card); border-radius: var(--r-card); padding: 1.2rem 1.3rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.stat__label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.stat__value { font-size: 2rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.stat__hint { font-size: 0.76rem; color: var(--label); }

.panel {
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 1.3rem 1.4rem; margin-top: 1.1rem;
}
.panel > h2 { font-size: 1.05rem; margin-bottom: 0.9rem; }
.panel--tint { background: var(--tint); border-color: var(--tint-border); }

/* the queue strip: label:value pills straight off admin_queue_stats() */
.strip { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.strip__item {
  display: inline-flex; align-items: baseline; gap: 0.45rem;
  background: var(--sheet); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.42rem 0.9rem; font-size: 0.82rem;
}
.strip__item b { font-weight: 600; }
.strip__item span { color: var(--muted); font-family: var(--font-mono); font-size: 0.72rem; }

/* ── Signups-by-day: plain divs, no library ────────────────── */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin-top: 0.4rem; }
.chart__col { flex: 1 1 0; min-width: 4px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; border-radius: 4px 4px 0 0; overflow: hidden; }
.chart__seg { width: 100%; }
.chart__seg--a { background: var(--accent); }
.chart__seg--b { background: var(--tint-border); }
.chart__legend { display: flex; gap: 1rem; margin-top: 0.55rem; font-size: 0.76rem; color: var(--muted); }
.chart__legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.35rem; vertical-align: -1px; }

/* ── Tables ────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; margin-top: 0.2rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--label); font-weight: 500; white-space: nowrap;
}
tbody tr:hover { background: var(--ground); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--ink); }
.cell-dim { color: var(--muted); }
.cell-wrap { max-width: 26ch; overflow-wrap: anywhere; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 0.14rem 0.6rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
  background: var(--ground); color: var(--muted); border: 1px solid var(--line);
}
.badge--pro { background: var(--brand); color: #FFFFFF; border-color: var(--brand); }
.badge--ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.badge--bad { background: var(--bad-bg); color: var(--bad-ink); border-color: transparent; }
.badge--new { background: var(--tint); color: var(--accent); border-color: var(--tint-border); }

/* ── Toolbar over a table ──────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 0.9rem; }
.toolbar .field { flex: 1 1 220px; max-width: 340px; }
.toolbar__spacer { flex: 1 1 auto; }
.tabs { display: inline-flex; background: var(--sheet); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 0.42rem 1rem; border-radius: 999px; font-weight: 600; font-size: 0.85rem;
}
.tabs button[aria-selected="true"] { background: var(--pill); color: var(--on-pill); }
.pager { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.9rem; font-size: 0.84rem; color: var(--muted); }

/* row-level status select, quieter than a .field */
select.rowselect {
  font: inherit; font-size: 0.82rem; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.28rem 0.6rem;
}

/* ── Insight bars ──────────────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.4rem; }
.bar { display: grid; grid-template-columns: minmax(140px, 30%) 1fr auto; gap: 0.8rem; align-items: center; }
.bar__label { font-weight: 500; overflow-wrap: anywhere; }
.bar__track { background: var(--ground); border-radius: 999px; height: 14px; overflow: hidden; }
.bar__fill { background: var(--accent); height: 100%; border-radius: 999px; min-width: 3px; }
.bar__n { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar__extra { grid-column: 1 / -1; font-size: 0.76rem; color: var(--label); font-family: var(--font-mono); margin-top: -0.2rem; }

/* ── States: loading, empty, error ─────────────────────────── */
.state { padding: 2.2rem 1rem; text-align: center; color: var(--muted); }
.state--error { color: var(--error); }
.state .btn { margin-top: 0.9rem; }
@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
.state--loading { animation: pulse 1.4s ease-in-out infinite; }

/* ── Sign-in / notice panels ───────────────────────────────── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.gate__panel {
  width: min(26rem, 100%); background: var(--sheet); border: 1px solid var(--line);
  border-radius: var(--r-panel); padding: 2.2rem;
  box-shadow: 0 30px 80px rgba(21, 42, 94, 0.10);
}
.gate__panel .wordmark { font-size: 1.9rem; }
.gate__panel .kicker { display: block; margin-top: 0.3rem; }
.gate__panel form { margin-top: 1.5rem; display: grid; gap: 0.9rem; }
.gate__panel p.muted { margin-top: 0.9rem; font-size: 0.9rem; }

/* ── Confirm dialog ────────────────────────────────────────── */
dialog.confirm {
  border: 0; border-radius: var(--r-card); padding: 1.6rem;
  width: min(24rem, calc(100vw - 2rem));
  box-shadow: 0 30px 80px rgba(15, 20, 25, 0.25);
}
dialog.confirm::backdrop { background: rgba(15, 20, 25, 0.45); }
dialog.confirm p { color: var(--ink); }
dialog.confirm .row { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.3rem; }
