/* ClimbJobs admin. Desktop only. One accent, neutral greys, quiet lines.
   Tokens first; every rule below reads them, so dark mode is one block. */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #ffffff;
  --sunk: #f1f3f6;
  --fg: #16181d;
  --muted: #646b78;
  --faint: #9aa1ad;
  --line: #e5e8ed;
  --line-strong: #d3d8e0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1fe;
  --series: #257de0;
  --good: #067647;
  --good-soft: #e7f6ee;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn-soft: #fff7e6;
  --warn-line: #f2d27a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.03);
  --radius: 10px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1115;
    --card: #171a20;
    --sunk: #1d2128;
    --fg: #e8eaee;
    --muted: #9aa1ad;
    --faint: #6b7280;
    --line: #262b33;
    --line-strong: #343a44;
    --accent: #4f8ff7;
    --accent-ink: #0b0d10;
    --accent-soft: #1a2740;
    --series: #338ced;
    --good: #4ade80;
    --good-soft: #14281d;
    --bad: #f87171;
    --bad-soft: #2d1717;
    --warn-soft: #2a2312;
    --warn-line: #6b5520;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── shell: a fixed sidebar and a scrolling main column ─────────────── */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.shell.bare { grid-template-columns: minmax(0, 1fr); }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px;
  background: var(--card);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font-weight: 600; letter-spacing: -0.01em; }
.brand .mark {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--fg); color: var(--card); font-size: 13px; font-weight: 700;
}
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; line-height: 1.2; }
nav { display: grid; gap: 2px; }
nav a {
  display: block; padding: 7px 10px; border-radius: 7px;
  color: var(--muted); font-weight: 500;
}
nav a:hover { background: var(--sunk); color: var(--fg); text-decoration: none; }
nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.signout { margin-top: auto; display: grid; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.who { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.who strong { display: block; color: var(--fg); font-weight: 500; font-size: 13px; }
.who .pill { margin-top: 4px; }

main { width: 100%; max-width: 1360px; padding: 28px 36px 24px; }
.shell.bare main { max-width: 440px; margin: 10vh auto 0; }
footer { color: var(--faint); font-size: 12px; padding: 8px 36px 28px; }
.shell.bare footer { text-align: center; }

/* ── type ───────────────────────────────────────────────────────────── */
h1 { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 32px 0 12px; }
h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0; }
.card h2 { margin-top: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
.ok { color: var(--good); }
strong { font-weight: 600; }

/* ── surfaces ───────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card > :last-child { margin-bottom: 0; }
.card > table { border: 0; border-radius: 0; box-shadow: none; table-layout: fixed; }
.card > table td { overflow-wrap: anywhere; }
.card > table tr > :first-child { padding-left: 0; }
.card > table tr > :last-child { padding-right: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.grid > .card { margin-bottom: 0; }
.notice { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 8px; padding: 10px 14px; }
.stack.card { max-width: 520px; }

/* ── tables ─────────────────────────────────────────────────────────── */
table {
  border-collapse: separate; border-spacing: 0; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; font-size: 13.5px;
}
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tr:last-child > td, tr:last-child > th { border-bottom: 0; }
th {
  background: var(--sunk); color: var(--muted); font-weight: 500; font-size: 12px;
  white-space: nowrap;
}
tbody tr:hover td, tr:hover > td { background: color-mix(in srgb, var(--sunk) 55%, transparent); }
td.delta.good { color: var(--good); }
td.delta.bad { color: var(--bad); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card table th { background: transparent; }
/* a key and value table, as on the person page */
.card table tr > th:first-child:not(:only-child) { width: 42%; }

/* ── forms and buttons ──────────────────────────────────────────────── */
form.stack .actions { display: flex; gap: 10px; flex-wrap: wrap; }
form.stack { display: grid; gap: 14px; max-width: 520px; }
form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--fg); }
input, select, textarea {
  font: inherit; font-weight: 400; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--card); color: var(--fg);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input, select, textarea { max-width: 100%; }
form.stack textarea, form.stack input:not([type="checkbox"]):not([type="radio"]), form.stack select { width: 100%; }
input[type="checkbox"], input[type="radio"] { min-height: 0; margin: 0; accent-color: var(--accent); }
fieldset { margin: 0; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 8px; display: grid; gap: 8px; }
legend { padding: 0 6px; font-size: 13px; font-weight: 500; }
fieldset label, fieldset label > span { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
button, a.button, span.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; min-height: 36px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
  cursor: pointer; text-decoration: none; transition: filter 0.12s, background 0.12s;
}
button:hover, a.button:hover { filter: brightness(1.07); text-decoration: none; }
button.quiet, .signout button {
  background: var(--card); color: var(--fg); border-color: var(--line-strong);
}
button.quiet:hover, .signout button:hover { background: var(--sunk); filter: none; }
button.danger { border-color: var(--bad); background: var(--bad); color: #fff; }
.signout button { min-height: 32px; font-size: 13px; }

/* ── small pieces ───────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--sunk); color: var(--muted);
  white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pager { display: flex; gap: 16px; margin-top: 14px; }
/* a list paged 10 at a time: where you are, then Newer and Older */
.pager.paged { justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; }
.pager.paged .muted { margin-right: 6px; font-variant-numeric: tabular-nums; }
a.button.quiet, span.button.quiet {
  min-height: 30px; padding: 0 12px; font-size: 13px;
  background: var(--card); color: var(--fg); border-color: var(--line-strong);
}
a.button.quiet:hover { background: var(--sunk); filter: none; }
span.button.quiet.off { opacity: 0.45; cursor: default; }
h2 .pill { margin-left: 6px; vertical-align: 1px; }
h2[id] { scroll-margin-top: 16px; }

/* ── dashboard ──────────────────────────────────────────────────────── */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.head p { margin: 0; max-width: 720px; font-size: 13px; }
.range { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--sunk); border: 1px solid var(--line); }
.seg a { padding: 5px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; font-size: 13px; }
.seg a:hover { color: var(--fg); text-decoration: none; }
.seg a.on { background: var(--card); color: var(--fg); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
.export { display: inline-flex; gap: 10px; font-size: 13px; color: var(--muted); }

.lead { margin: 0 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 14px; }
.tile { margin: 0; display: grid; gap: 6px; padding: 16px 18px; }
.tile .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile .foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.tile .sub { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--line); }
.tile .sub b { color: var(--fg); font-weight: 500; font-variant-numeric: tabular-nums; }

.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 16px; }
.chart { margin: 0; padding: 16px 18px 10px; }
.chart header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.chart .total { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.chart .total small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.plot { position: relative; height: 180px; }
.plot > svg.bars { height: 100%; }

/* server-drawn bars: shown only when the script did not run */
svg.bars { width: 100%; display: block; }
svg.bars rect { fill: var(--series); }
svg.bars rect.zero { fill: var(--line); }
svg.bars text { fill: var(--muted); font-size: 10px; }
.js .plot > svg.bars { display: none; }

/* uPlot, restyled to the tokens */
.uplot { font-family: var(--font); }
.u-axis { color: var(--faint); }
.u-cursor-pt { border-width: 2px !important; }
.tip {
  position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none;
  padding: 7px 10px; border-radius: 8px; white-space: nowrap;
  background: var(--fg); color: var(--card);
  font-size: 12px; line-height: 1.35; box-shadow: 0 6px 16px rgba(16, 24, 40, 0.18);
  opacity: 0; transition: opacity 0.08s;
}
.tip.on { opacity: 1; }
.tip b { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tip span { opacity: 0.7; }

/* AI cost table: a share bar per operation (SVG attributes, no inline style) */
td.num.bad { color: var(--bad); }
th.share, td.share { width: 160px; }
td.share svg { display: block; width: 100%; height: 6px; margin-top: 7px; }
td.share rect { fill: var(--series); }
td.share rect.track { fill: var(--sunk); }
code { font: 12px var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--sunk); }

/* loading: a shimmer where a chart will be, until uPlot has drawn it */
.plot::after {
  content: ""; position: absolute; inset: 6px 0 24px 44px; border-radius: 8px;
  background: linear-gradient(90deg, var(--sunk) 25%, var(--line) 50%, var(--sunk) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.js .plot:not(.ready)::after, .busy .plot::after { opacity: 1; }
.busy .plot > .uplot { opacity: 0.25; }
/* a range or link clicked: a thin bar on top while the next page is built */
.busy > body::before {
  content: ""; position: fixed; z-index: 50; top: 0; left: 0; height: 2px; width: 40%;
  background: var(--accent); animation: progress 1.1s ease-in-out infinite;
}
.busy .tiles, .busy table { opacity: 0.55; transition: opacity 0.2s; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@keyframes progress { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) {
  .plot::after, .busy > body::before { animation: none; }
}

/* five tiles in a row: every tile has the same shape, whatever its numbers */
.tile .value { font-size: 24px; }
.tile .foot { flex-direction: column; align-items: flex-start; gap: 4px; }
.tile .sub { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile .sub b { display: block; white-space: nowrap; }

/* the "?" beside each number (ticket 25): a native <details>, no script needed */
.tile-head, .chart-title { display: flex; align-items: center; gap: 6px; }
.tile-head { justify-content: space-between; }
.tile-head h3, .chart-title h3 { margin: 0; }
.help { position: relative; display: inline-block; vertical-align: middle; font-size: 12px; font-weight: 400; letter-spacing: 0; text-align: left; text-transform: none; }
.help > summary {
  list-style: none; cursor: pointer; display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-strong);
  color: var(--muted); font-size: 11px; font-weight: 600; line-height: 1; user-select: none;
  outline-offset: 2px;
}
.help > summary::-webkit-details-marker { display: none; }
.help > summary::after { content: ""; position: absolute; inset: -4px; } /* 26px tap target */
.help > summary:hover, .help[open] > summary { color: var(--accent); border-color: var(--accent); }
.help > summary:focus-visible { outline: 2px solid var(--accent); }
.help > p {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: max-content; max-width: min(280px, 80vw);
  margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--card); color: var(--fg);
  border: 1px solid var(--line-strong); box-shadow: 0 6px 20px rgba(16, 24, 40, 0.14);
  font-size: 13px; line-height: 1.45; white-space: normal;
}
.help.end > p { left: auto; right: 0; }
@media (max-width: 640px) {
  /* a phone: the text sits fixed along the bottom, so it is never cut off */
  .help > p, .help.end > p {
    position: fixed; top: auto; left: 16px; right: 16px; bottom: 16px; width: auto; max-width: none;
  }
}

/* operators and setup (ticket 26) */
.acts a + a { margin-left: 12px; }
.qr-box { display: inline-block; padding: 8px; background: #fff; border-radius: 8px; border: 1px solid var(--line); line-height: 0; }
.qr-box svg { width: 200px; height: 200px; }
code.key { font-family: var(--mono); font-size: 15px; letter-spacing: 0.04em; word-break: break-all; padding: 4px 8px; background: var(--sunk); border-radius: 6px; }
.join h2 { font-size: 15px; margin: 8px 0 0; }

/* tickets (support-tickets 05, 06) */
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
@media (max-width: 960px) { .split { grid-template-columns: minmax(0, 1fr); } }
.split h2 { margin-top: 24px; }
.split > :first-child h2 { margin-top: 12px; }
/* a customer's or operator's own words: line breaks kept by CSS, never by markup */
.msg { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.message .meta { margin: 0 0 8px; font-size: 13px; }
.message.support { border-left: 3px solid var(--accent); }
.message.note { background: var(--warn-soft); border-color: var(--warn-line); }
.event { margin: 0 0 16px; font-size: 13px; text-align: center; }
