/* Dashboard (admin + website portal). Pool-hall palette: felt, brass rails, cue chalk; statuses are pool balls. */
:root {
  --felt: #0e4535;
  --felt-deep: #0a3529;
  --felt-glow: #13573f;
  --brass: #b88a2d;
  --brass-light: #e2c47c;
  --chalk: #2c6ca6;
  --ink: #15221d;
  --ink-2: #43514b;
  --muted: #6b7873;
  --paper: #eef2ef;
  --card: #ffffff;
  --line: #d8e0db;
  --line-soft: #e8edea;
  --ivory: #f4f1e6;

  /* pool balls: 1 yellow, 2 blue, 3 red, 4 purple, 6 green */
  --ball-1: #e3a400;
  --ball-2: #1f4fa3;
  --ball-3: #c42b2b;
  --ball-4: #5e3a8f;
  --ball-6: #1c7a4a;
  --ball-0: #8c9591;

  --f-display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --radius: 10px;
  --rail-w: 236px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14.5px/1.5 var(--f-body);
  font-variant-numeric: tabular-nums;
}
a { color: var(--chalk); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--chalk); outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: var(--f-mono); font-size: 0.92em; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 22px 16px 18px;
  color: var(--ivory);
  background: radial-gradient(140% 70% at 0% 0%, var(--felt-glow) 0%, var(--felt) 45%, var(--felt-deep) 100%);
  border-right: 3px solid var(--brass);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.25);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ivory); padding: 0 6px; }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.brand-name { display: block; font: 800 21px/1 var(--f-display); letter-spacing: 0.02em; }
.brand-area { display: block; margin-top: 3px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass-light); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px 9px 26px; border-radius: 8px;
  color: rgba(244, 241, 230, 0.78); font-weight: 500;
}
.nav a::before { /* the bead marking the current page */
  content: ""; position: absolute; left: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
  background: rgba(244, 241, 230, 0.18);
}
.nav a:hover { color: var(--ivory); background: rgba(255, 255, 255, 0.05); text-decoration: none; }
.nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav a[aria-current="page"]::before { background: radial-gradient(circle at 35% 30%, #f6e6b8 0 20%, var(--brass) 55%, #7d5a1c 100%); }
.nav .count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--ball-3); color: #fff; font-size: 12px; font-weight: 700; text-align: center; }
.nav-label { margin: 8px 12px 4px; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(244, 241, 230, 0.45); }

.rail-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(226, 196, 124, 0.18); font-size: 13px; }
.rail-foot .who { display: block; color: var(--ivory); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-foot .where { display: block; color: rgba(244, 241, 230, 0.55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-foot .links { display: flex; gap: 14px; margin-top: 10px; }
.rail-foot a, .rail-foot button { color: var(--brass-light); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.stage { --pad-top: 30px; --pad-x: clamp(16px, 3.2vw, 44px); min-width: 0; padding: var(--pad-top) var(--pad-x) 60px; }
.stage-inner { max-width: 1180px; margin: 0 auto; }

/* Website users: their credits, always in view (sticks to the top while scrolling) */
.topbar {
  position: sticky; top: 0; z-index: 5;
  margin: calc(-1 * var(--pad-top)) calc(-1 * var(--pad-x)) 20px; padding: 10px var(--pad-x);
  background: rgba(238, 242, 239, 0.9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner { max-width: 1180px; margin: 0 auto; display: flex; justify-content: flex-end; }
.wallet {
  display: inline-flex; align-items: center; gap: 10px; padding: 5px 14px 5px 6px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.wallet:hover { text-decoration: none; border-color: var(--brass); }
.wallet-coin {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f7e9bf 0 14%, #cc9d3e 48%, #82601f 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.28), 0 1px 0 rgba(0, 0, 0, 0.15);
}
.wallet-label { display: block; font-size: 10.5px; font-weight: 600; line-height: 1.1; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.wallet-amount { display: block; font: 800 21px/1.05 var(--f-display); letter-spacing: 0.01em; white-space: nowrap; }
.wallet-amount small { font: 600 12px var(--f-body); color: var(--muted); }
.wallet-flag { font-size: 12px; font-weight: 700; white-space: nowrap; }
.wallet--low { background: #fbf3df; border-color: #ead49a; }
.wallet--low .wallet-flag { color: #7a5200; }
.wallet--empty { background: #fbe9e7; border-color: #efc3bd; }
.wallet--empty .wallet-amount { color: var(--ball-3); }
.wallet--empty .wallet-flag { color: #a3231a; }
.stage-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 4px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 0; font: 800 34px/1.05 var(--f-display); letter-spacing: 0.01em; }
h2 { margin: 0 0 14px; font: 700 15px/1.3 var(--f-body); }
h2 small, .h2-note { font-weight: 400; color: var(--muted); }
.head-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ------------------------------------------------------------------ blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card, .card + .grid, .grid + .card, .scoreboard + .card, .notice + .card, .card + .scoreboard { margin-top: 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid > .card { margin-top: 0; }
.stack > * + * { margin-top: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.notice { padding: 12px 16px; border-radius: 8px; border: 1px solid; margin-bottom: 18px; }
.notice--ok { background: #e7f3ec; border-color: #b9dcc7; color: #134b31; }
.notice--error { background: #fbe9e7; border-color: #efc3bd; color: #7d1f17; }
.notice--warn { background: #fbf3df; border-color: #ead49a; color: #5f4510; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice a { color: inherit; text-decoration: underline; }

/* the scoreboard: the four numbers that matter, set like a pool-hall score sign */
.scoreboard {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  border-top: 3px solid var(--felt);
}
.score { padding: 18px 20px 16px; min-width: 0; }
.score + .score { border-left: 1px solid var(--line-soft); }
.score-label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.score-value { margin-top: 6px; font: 800 40px/1 var(--f-display); letter-spacing: 0.01em; overflow-wrap: anywhere; }
.score-value .unit { margin-left: 4px; font-size: 18px; font-weight: 600; color: var(--muted); }
.score-sub { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.score--link { color: inherit; }
.score--link:hover { text-decoration: none; background: #f7faf8; }
.score--alert .score-value { color: var(--ball-3); }

.periods { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: #e1e8e3; }
.periods a { padding: 6px 12px; border-radius: 7px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.periods a:hover { text-decoration: none; color: var(--ink); }
.periods a[aria-current="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

/* ------------------------------------------------------------------ score wire (daily chart) */
.wire-card { padding-bottom: 14px; }
.wire-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; align-items: baseline; margin-bottom: 10px; }
.wire-head h2 { margin: 0; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.wire { position: relative; display: grid; grid-template-columns: repeat(var(--days, 30), minmax(0, 1fr)); height: calc(var(--rows, 18) * 12px + 34px); }
.wire-day { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; border-radius: 6px; }
.wire-day:hover { background: #f3f7f4; }
.wire-rod { position: relative; flex: 1; width: 100%; display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; padding: 6px 0 4px; }
.wire-rod::before { content: ""; position: absolute; top: 6px; bottom: 0; left: 50%; width: 1px; background: #c3d1c8; }
.wire-day.is-today .wire-rod::before { background: var(--felt); width: 2px; margin-left: -0.5px; }
.wire-date { height: 20px; font-size: 10.5px; line-height: 20px; color: var(--muted); white-space: nowrap; }
.wire-day:not(.is-label) .wire-date { visibility: hidden; }
.wire-day.is-today .wire-date { color: var(--felt); font-weight: 700; visibility: visible; }
.wire-empty { position: absolute; inset: 0 0 20px; display: grid; place-items: center; color: var(--muted); font-size: 13.5px; pointer-events: none; }

.bead {
  position: relative; z-index: 1; display: inline-block; flex: none;
  width: min(10px, 72%); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #f7e9bf 0 16%, #cc9d3e 46%, #82601f 100%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}
.legend .bead { width: 10px; }
.wire .bead { animation: bead-in 420ms cubic-bezier(0.2, 0.8, 0.3, 1.2) both; animation-delay: calc(var(--i, 0) * 14ms); }
@keyframes bead-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ status chips (pool balls) */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 3px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; background: #eef1ef; color: var(--ink-2);
}
.chip .ball {
  position: relative; width: 15px; height: 15px; border-radius: 50%; flex: none; background: var(--ball, var(--ball-0));
  box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.25);
}
.chip .ball::after { /* the white number spot of a pool ball */
  content: ""; position: absolute; left: 4px; top: 4px; width: 7px; height: 7px; border-radius: 50%; background: #fff; opacity: 0.92;
}
.chip--settled { --ball: var(--ball-6); background: #e3f1e8; color: #135c37; }
.chip--active { --ball: var(--ball-2); background: #e4ebf7; color: #1c3f7d; }
.chip--open { --ball: var(--ball-1); background: #fbf1d6; color: #6b4d00; }
.chip--disputed { --ball: var(--ball-3); background: #f9e3e1; color: #8c1d1d; }
.chip--review { --ball: var(--ball-4); background: #ece5f5; color: #48296f; }
.chip--cancelled { --ball: var(--ball-0); }
.chip--on { --ball: var(--ball-6); background: #e3f1e8; color: #135c37; }
.chip--off { --ball: var(--ball-0); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f7faf8; }
th.num, td.num { text-align: right; white-space: nowrap; }
.vs { display: inline-flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline; }
.vs .sep { color: var(--muted); font-size: 12px; }
.vs .won { font-weight: 700; }
.vs .won::after { content: " ●"; color: var(--brass); font-size: 10px; vertical-align: 1px; }
.pid { display: block; font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); }
.empty { padding: 34px 10px; text-align: center; color: var(--muted); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.pager .links { display: flex; gap: 8px; }

/* ------------------------------------------------------------------ forms */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .error { font-size: 12.5px; color: #a3231a; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font: inherit; color: var(--ink); min-width: 0;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--chalk); outline-offset: -1px; border-color: var(--chalk); }
input[disabled] { background: #f3f5f4; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; }
.check input { margin-top: 3px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border: 1px solid var(--felt); border-radius: 8px; background: var(--felt); color: var(--ivory);
  font: 600 14px/1 var(--f-body); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--felt-glow); text-decoration: none; }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: #f4f7f5; }
.btn--danger { background: #fff; color: #a3231a; border-color: #e6bdb7; }
.btn--danger:hover { background: #fbecea; }
.btn--small { height: 32px; padding: 0 11px; font-size: 13px; }
.inline-form { display: inline; }

/* ------------------------------------------------------------------ key/value + secrets */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 22px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-weight: 500; overflow-wrap: anywhere; }

.keyline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 8px; background: #f3f6f4; border: 1px solid var(--line-soft); }
.keyline code { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.keyline--secret { background: #fbf3df; border-color: #ead49a; }
.copy { height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font: 600 12px var(--f-body); cursor: pointer; color: var(--ink-2); }
.copy:hover { background: #f4f7f5; }
.masked { letter-spacing: 0.2em; color: var(--muted); }

.endpoint { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 4px 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.endpoint:last-child { border-bottom: 0; }
.verb { font: 600 11.5px var(--f-mono); color: var(--felt); }
.endpoint code { overflow-wrap: anywhere; }
.endpoint .what { grid-column: 2; font-size: 13px; color: var(--muted); }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.log li:last-child { border-bottom: 0; }

/* ------------------------------------------------------------------ login */
.login { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.login-art {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-start; gap: clamp(40px, 9vh, 96px); padding: 40px;
  color: var(--ivory); background: radial-gradient(120% 90% at 20% 10%, var(--felt-glow) 0%, var(--felt) 45%, var(--felt-deep) 100%);
  border-right: 4px solid var(--brass);
}
.login-art .rack { position: absolute; right: -36px; bottom: -34px; width: min(400px, 58%); height: auto; }
.login-art > div { position: relative; z-index: 1; }
.login-art h1 { max-width: 13ch; font-size: clamp(38px, 4.6vw, 60px); line-height: 0.98; color: var(--ivory); }
.login-art p { max-width: 38ch; color: rgba(244, 241, 230, 0.72); }
.login-form { display: grid; place-items: center; padding: 40px 20px; }
.login-form form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-form h2 { font: 800 30px/1 var(--f-display); margin: 0 0 4px; }
.login-form .btn { width: 100%; height: 44px; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 16px; border-right: 0; border-bottom: 3px solid var(--brass); }
  .nav { flex-direction: row; overflow-x: auto; max-width: 100%; order: 3; flex-basis: 100%; }
  .nav a { padding: 8px 12px 8px 24px; white-space: nowrap; }
  .nav-label { display: none; }
  .rail-foot { margin: 0 0 0 auto; padding: 0; border: 0; text-align: right; }
  .rail-foot .where { display: none; }
  .rail-foot .links { justify-content: flex-end; margin-top: 2px; }
  .stage { --pad-top: 22px; }
  .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score:nth-child(3) { border-left: 0; }
  .score:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { min-height: 260px; gap: 28px; border-right: 0; border-bottom: 4px solid var(--brass); }
  .login-art .rack { width: 170px; right: -24px; bottom: -22px; }
  .login-art h1 { max-width: 11ch; }
}
@media (max-width: 520px) {
  h1 { font-size: 28px; }
  .score-value { font-size: 32px; }
  .wire { height: calc(var(--rows, 18) * 9px + 30px); }
  .log li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .login-art .rack { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .wire .bead { animation: none; }
}
