/* Holy Grail admin. Calm, dense, readable. Light by default, dark follows the system. */
:root {
  --bg: #f7f3ee; --panel: #fffdfa; --sunk: #f0e9e1; --line: #e3d8cc; --fg: #22160f; --mute: #7b685b; --faint: #a8968a;
  --accent: #8a5a2b; --accent-fg: #fff; --accent-soft: #f2e4d2;
  --ok: #2c7a4b; --ok-soft: #e1f1e6; --warn: #9a6400; --warn-soft: #fbefd6; --bad: #b0392a; --bad-soft: #f8e1dd; --info: #2d62a3; --info-soft: #e1ebf7;
  --display: 'Didot', 'Bodoni 72', 'Bodoni MT', Georgia, serif;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r: 10px; color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #120c09; --panel: #1b1310; --sunk: #241a15; --line: #36281f; --fg: #f6ece2; --mute: #b39e8e; --faint: #7f6c5f;
  --accent: #e2b27a; --accent-fg: #1b1006; --accent-soft: #3a2918;
  --ok: #6fd09a; --ok-soft: #173325; --warn: #f0c060; --warn-soft: #3a2c10; --bad: #f08b7a; --bad-soft: #3c1a15; --info: #8fb8ef; --info-soft: #172a42;
  color-scheme: dark; } }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 400 14px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--mute); }

/* shell */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { font: 500 24px/1 var(--display); letter-spacing: .06em; padding: 0 10px 18px; }
.brand small { display: block; font: 600 10px var(--body); letter-spacing: .2em; color: var(--mute); margin-top: 6px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--fg); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--sunk); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--fg); font-weight: 650; }
.nav .count { font-size: 11px; font-weight: 700; background: var(--bad); color: #fff; border-radius: 999px; padding: 1px 7px; }
.nav .group { font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); padding: 14px 10px 4px; }
.me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--mute); }
.me b { display: block; color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
main { padding: 26px 32px 60px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
h1 { font: 500 30px/1.1 var(--display); margin: 0; letter-spacing: .01em; }
h2 { font: 650 15px var(--body); margin: 26px 0 10px; }
.sub { color: var(--mute); margin: 4px 0 0; }
.crumb { font-size: 12px; margin-bottom: 6px; }
.crumb a { text-decoration: none; }

/* pieces */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.card small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.card b { display: block; font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card span { font-size: 12px; color: var(--mute); }
a.card { text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); }
a.card.hot b { color: var(--bad); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--sunk); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { font: 12px var(--mono); }
.empty { padding: 28px; text-align: center; color: var(--mute); }
.thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--sunk); display: block; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--sunk); color: var(--mute); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.info { background: var(--info-soft); color: var(--info); }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: 13px; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* forms */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--mute); }
label.f input, label.f select, label.f textarea, .in { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 14px; font-weight: 400; color: var(--fg); min-width: 0; }
label.f .hint { font-weight: 400; color: var(--faint); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 13px; }
.err { color: var(--bad); font-size: 13px; margin: 8px 0 0; min-height: 1em; }
.money { position: relative; }
.in.w-num { width: 110px; text-align: right; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px 28px; }
.auth .brand { padding: 0 0 22px; text-align: center; }
.auth form { display: grid; gap: 12px; }
.auth .btn { justify-content: center; padding: 11px; }
.code { font: 600 26px var(--mono); letter-spacing: .3em; text-align: center; }
.qr { background: #fff; border-radius: 10px; padding: 10px; width: 200px; height: 200px; margin: 4px auto 0; display: block; }
.secret { font: 13px var(--mono); word-break: break-all; text-align: center; color: var(--mute); }

/* odds editor */
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.sticky { position: sticky; top: 16px; }
.stat { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.stat:last-child { border-bottom: 0; }
.stat span { color: var(--mute); }
.problems { margin: 10px 0 0; padding: 10px 12px 10px 28px; background: var(--bad-soft); color: var(--bad); border-radius: 8px; font-size: 13px; }
.good { margin: 10px 0 0; padding: 10px 12px; background: var(--ok-soft); color: var(--ok); border-radius: 8px; font-size: 13px; font-weight: 600; }

/* dialog + toast */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--fg); padding: 22px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h3 { margin: 0 0 6px; font: 500 22px var(--display); }
dialog p { color: var(--mute); margin: 0 0 14px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; pointer-events: none; z-index: 10; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px 16px; gap: 4px; align-items: center; }
  .brand { padding: 0 8px 0 0; font-size: 20px; } .brand small { display: none; }
  .nav { display: flex; gap: 2px; overflow-x: auto; width: 100%; }
  .nav .group { display: none; }
  .nav a { white-space: nowrap; padding: 6px 10px; }
  .me { display: none; }
  main { padding: 18px 16px 50px; }
  .split, .form { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
.mt0 { margin-top: 0; } .mt10 { margin-top: 10px; } .mt14 { margin-top: 14px; } .mb6 { margin-bottom: 6px; } .mb12 { margin-bottom: 12px; }
.nowrap { white-space: nowrap; }

/* history views (Oct 27) */
.mono { font: 12px var(--mono); }
.panel .stat b { font-weight: 600; text-align: right; }
.tone-ok { color: var(--ok); } .tone-bad { color: var(--bad); }
