/* RMN Manager — "night race" design.
   Asphalt and concrete, timing-screen colours (purple = fastest, green = personal best / go,
   yellow = caution), one race red, and kerb stripes as the signature element. */
:root {
  --bg: #e6e8eb;          /* concrete */
  --paper: #ffffff;
  --paper-2: #f0f2f4;
  --ink: #11151b;
  --ink-2: #3d4552;
  --ink-3: #737d8c;
  --line: #d9dde3;
  --line-2: #c3c9d2;
  --signal: #e1261c;      /* race red */
  --signal-ink: #ffffff;
  --signal-soft: #fde3e1;
  --go: #0f9d58;          /* green flag */
  --go-soft: #d5f3e4;
  --warn: #b98900;        /* yellow flag */
  --warn-soft: #fbf0c8;
  --off: #9aa3b0;
  --purple: #8a3ffc;      /* fastest lap */
  --purple-soft: #ece1ff;
  --rail: #11151b;        /* the pit wall stays dark in both themes */
  --rail-ink: #e9edf2;
  --rail-ink-2: #8b95a5;
  --rail-line: #252b34;
  --kerb: repeating-linear-gradient(-45deg, var(--signal) 0 9px, #fff 9px 18px);
  --check: conic-gradient(#fff 25%, #11151b 0 50%, #fff 0 75%, #11151b 0) 0 0 / 12px 12px;
  --shadow: 0 1px 0 rgba(17, 21, 27, .05), 0 10px 28px -18px rgba(17, 21, 27, .35);
  --radius: 6px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Saira', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --paper: #1c2027; --paper-2: #252a33; --ink: #eef1f5; --ink-2: #b3bbc7; --ink-3: #7a8494;
    --line: #2a3039; --line-2: #3a414c; --signal: #ff3b30; --signal-soft: #3d1715; --go: #2bd17a; --go-soft: #0f2c1e;
    --warn: #f5c400; --warn-soft: #302810; --off: #59616e; --purple: #b67cff; --purple-soft: #2b1d45;
    --rail: #0e1115; --rail-line: #20252d;
    --shadow: 0 1px 0 rgba(0,0,0,.35), 0 14px 32px -18px rgba(0,0,0,.9); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --paper: #1c2027; --paper-2: #252a33; --ink: #eef1f5; --ink-2: #b3bbc7; --ink-3: #7a8494;
  --line: #2a3039; --line-2: #3a414c; --signal: #ff3b30; --signal-soft: #3d1715; --go: #2bd17a; --go-soft: #0f2c1e;
  --warn: #f5c400; --warn-soft: #302810; --off: #59616e; --purple: #b67cff; --purple-soft: #2b1d45;
  --rail: #0e1115; --rail-line: #20252d;
  --shadow: 0 1px 0 rgba(0,0,0,.35), 0 14px 32px -18px rgba(0,0,0,.9); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- shell: the pit wall ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 26px; padding: 0 14px 22px; background: var(--rail); color: var(--rail-ink); }
.rail::before { content: ''; display: block; flex: none; height: 8px; margin: 0 -14px; background: var(--kerb); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 6px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--signal); color: #fff; font-weight: 900; font-style: italic; font-stretch: 125%; font-size: 21px; clip-path: polygon(18% 0, 100% 0, 82% 100%, 0 100%); }
.brand-name { font-weight: 800; font-style: italic; font-stretch: 118%; font-size: 18px; line-height: 1.05; text-transform: uppercase; letter-spacing: .01em; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 4px; text-decoration: none; color: var(--rail-ink-2); font-weight: 600; font-size: 15px; }
.nav a:hover { background: var(--rail-line); color: var(--rail-ink); }
.nav a.active { background: var(--rail-line); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 6px; bottom: 6px; width: 4px; background: var(--signal); }
.nav a.active svg { color: var(--signal); }
.nav-sep { height: 1px; background: var(--rail-line); margin: 10px 6px; }
.theme-btn { align-self: flex-start; margin-left: 4px; background: none; border: 1px solid var(--rail-line); border-radius: 4px; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; color: var(--rail-ink-2); }
.theme-btn:hover { color: #fff; border-color: var(--rail-ink-2); }
.view { padding: 36px clamp(16px, 4vw, 52px) 80px; max-width: 1400px; width: 100%; min-width: 0; }

/* ---------- signed-in player (Steam) ---------- */
.player-box { margin: 0 -2px; }
.steam-btn { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 4px; text-decoration: none; font-weight: 700; font-size: 14px; color: #fff; background: var(--rail-line); border: 1px solid #333a45; }
.steam-btn:hover { border-color: var(--signal); }
.steam-btn svg { color: var(--signal); }
.player-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 4px; text-decoration: none; color: var(--rail-ink); min-width: 0; }
.player-card:hover { background: var(--rail-line); }
.player-card span { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.player-card b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-card small { font-size: 12px; color: var(--rail-ink-2); }
.avatar { width: 36px; height: 36px; border-radius: 4px; flex: none; object-fit: cover; box-shadow: 0 0 0 2px var(--warn); }
.avatar-fallback { display: grid; place-items: center; background: var(--warn); color: #11151b; font-weight: 900; font-style: italic; }
.avatar-lg { width: 72px; height: 72px; border-radius: 6px; flex: none; object-fit: cover; box-shadow: 0 0 0 3px var(--warn); font-size: 32px; }
.h1-avatar { display: inline-block; vertical-align: middle; margin-right: 16px; }
.h1-avatar .avatar-lg { width: .9em; height: .9em; font-size: .5em; }
.me-card { display: flex; gap: 22px; align-items: flex-start; padding: 26px; max-width: 760px; border-top: 4px solid var(--warn); }
.me-card h2 { margin-bottom: 6px; }
.me-card p { margin: 0 0 18px; max-width: 60ch; }
.me-error { color: var(--signal); font-weight: 700; }
.steam-big { height: 46px; padding: 0 22px; font-size: 16px; }
.mtop-right { display: flex; align-items: center; gap: 8px; }
.player-mini { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 4px; border: 1px solid var(--rail-line); color: var(--rail-ink-2); text-decoration: none; }
.player-mini .avatar { width: 32px; height: 32px; box-shadow: none; }
.player-mini:has(.avatar) { border-color: var(--warn); }

/* mobile top bar (hidden on desktop) */
.mtop { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .mtop { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 25; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--rail); color: var(--rail-ink); }
  .mtop::after { content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; background: var(--kerb); }
  .mtop .brand { padding: 0; gap: 10px; }
  .mtop .brand-mark { width: 30px; height: 30px; font-size: 17px; }
  .mtop .brand-name { font-size: 16px; }
  .mtop .theme-btn { width: 36px; height: 36px; margin: 0; }
  .rail { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 20; flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap: 0; border-top: 1px solid var(--rail-line); }
  .rail::before { display: none; }
  .rail .brand, .rail .theme-btn, .nav-sep, .player-box { display: none; }
  .nav { flex-direction: row; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; font-size: 11px; padding: 7px 2px; flex: 1; align-items: center; min-width: 0; }
  .nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .nav a.active { background: transparent; }
  .nav a.active::before { left: 28%; right: 28%; top: -4px; bottom: auto; width: auto; height: 3px; }
  .view { padding: 26px 16px calc(92px + env(safe-area-inset-bottom)); }
}

/* ---------- typography / page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 30px; }
.eyebrow { font-size: 13px; font-weight: 700; font-style: italic; color: var(--signal); letter-spacing: .01em; }
h1 { font-size: clamp(32px, 5vw, 58px); font-weight: 900; font-style: italic; font-stretch: 112%; text-transform: uppercase; letter-spacing: -.015em; line-height: .92; margin: 4px 0 0; }
.page-head h1::after { content: ''; display: block; width: 72px; height: 7px; margin-top: 12px; background: var(--kerb); transform: skewX(-20deg); transform-origin: left; }
h2 { font-size: 21px; font-weight: 800; font-style: italic; font-stretch: 108%; letter-spacing: -.005em; margin: 0; }
h3 { font-size: 15px; font-weight: 700; margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--paper); font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.signal { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); }
.btn.signal:hover { filter: brightness(1.08); }
.btn.go { background: var(--go); color: #fff; border-color: var(--go); }
.btn.danger { color: var(--signal); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { color: var(--signal); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12px; }
.input, select.input, textarea.input { height: 40px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--paper); width: 100%; min-width: 0; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: 2px solid var(--signal); outline-offset: -1px; border-color: transparent; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px 18px; }
.grid-form .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--signal); }
.seg { display: inline-flex; background: var(--paper-2); border: 1px solid var(--line); border-radius: 4px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 3px; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--paper); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .input { width: auto; min-width: 160px; }

/* ---------- panels ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 20px; }
.empty { padding: 52px 20px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); font-size: 18px; font-style: italic; margin-bottom: 6px; }

/* ---------- stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; box-shadow: var(--shadow); }
.stat { padding: 16px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: 34px; font-weight: 800; font-style: italic; font-stretch: 110%; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--ink-3); font-weight: 600; }

/* ---------- live server strip ---------- */
.strips { display: flex; flex-direction: column; gap: 18px; }
.strip { display: grid; grid-template-columns: 10px minmax(240px, 1.2fr) minmax(260px, 1.4fr) 210px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.strip-flag { background: var(--off); }
.strip.online .strip-flag { background: var(--go); }
.strip.race .strip-flag { background: var(--kerb); }
.strip-id { padding: 20px 22px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; font-style: italic; color: var(--ink-3); }
.online .status-line { color: var(--go); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.online .dot { background: var(--go); box-shadow: 0 0 0 4px var(--go-soft); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
.strip-track { font-size: 27px; font-weight: 900; font-style: italic; font-stretch: 110%; text-transform: uppercase; letter-spacing: -.01em; line-height: .95; }
.strip-layout { color: var(--ink-2); font-weight: 700; }
.strip-name { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 3px; background: var(--paper-2); font-size: 12.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.chip svg { width: 14px; height: 14px; }
.chip.hot { background: var(--signal-soft); color: var(--signal); }
.chip.ok { background: var(--go-soft); color: var(--go); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
button.chip { border: 0; cursor: pointer; }
button.chip:hover { color: var(--ink); }

.strip-mid { padding: 20px 22px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
/* session timeline: slanted segments like a timing banner */
.timeline { display: flex; gap: 6px; padding-left: 3px; }
.tl-seg { flex: 1; min-width: 0; }
.tl-bar { height: 10px; background: var(--paper-2); overflow: hidden; position: relative; transform: skewX(-24deg); }
.tl-bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink-3); }
.tl-seg.done .tl-bar { background: var(--line-2); }
.tl-seg.now .tl-bar i { background: var(--signal); }
.tl-label { display: flex; flex-direction: column; gap: 1px; margin-top: 7px; font-size: 12.5px; font-weight: 700; font-style: italic; color: var(--ink-3); }
.tl-seg.now .tl-label { color: var(--ink); }
.tl-label .mono { font-weight: 600; font-style: normal; }
.cond { display: grid; grid-template-columns: repeat(auto-fit, minmax(98px, 1fr)); gap: 12px; }
.cond div { min-width: 0; }
.cond small { display: block; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.cond b { font-size: 16px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* slots gauge: a tachometer */
.strip-slots { padding: 18px 20px; border-left: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(var(--paper-2), var(--paper-2)) bottom / 100% 0 no-repeat; }
.gauge { position: relative; width: 124px; height: 124px; }
.gauge svg { width: 124px; height: 124px; transform: rotate(-90deg); }
.gauge circle { stroke-width: 9; fill: none; }
.gauge .g-bg { stroke: var(--paper-2); stroke-dasharray: 3 2.2; }
.gauge .g-fg { stroke: var(--ink-3); transition: stroke-dashoffset .6s ease; }
.strip.online .gauge .g-fg { stroke: var(--go); }
.strip.race .gauge .g-fg { stroke: var(--signal); }
.gauge .g-txt { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge .g-txt b { font-size: 36px; font-weight: 800; font-style: italic; line-height: 1; display: block; font-variant-numeric: tabular-nums; }
.gauge .g-txt span { font-size: 12px; color: var(--ink-3); font-weight: 650; }
.free { font-size: 13px; font-weight: 700; color: var(--ink-2); }

.strip-drivers { grid-column: 1 / -1; border-top: 1px solid var(--line); }
.strip-drivers summary { list-style: none; cursor: pointer; padding: 12px 22px 12px 32px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.strip-drivers summary::-webkit-details-marker { display: none; }
.strip-drivers summary:hover { color: var(--ink); background: var(--paper-2); }
.strip-drivers[open] summary .caret { transform: rotate(180deg); }
.caret { transition: transform .2s; }

/* ---------- tables: timing tower ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 700; padding: 10px 14px; border-bottom: 2px solid var(--line); white-space: nowrap; background: var(--paper-2); }
.t td { padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--paper-2) 45%, transparent); }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--paper-2); }
.t .r { text-align: right; }
.t td.wrap { white-space: normal; }
.t a { text-decoration: none; font-weight: 700; }
.t a:hover { text-decoration: underline; text-decoration-color: var(--signal); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.pos { width: 56px; }
td.pos { font-family: var(--sans); font-weight: 800; font-style: italic; font-size: 15px; }
td.pos::before { content: ''; }
.pos.p1 { color: var(--signal); }
.lap { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.lap.best { color: var(--purple); font-weight: 700; }
.lap.pb { color: var(--go); }
.lap.bad { color: var(--ink-3); text-decoration: line-through; }
.gap { font-family: var(--mono); color: var(--ink-3); font-size: 13px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 800; font-style: italic; background: var(--paper-2); color: var(--ink-2); }
.badge.race { background: var(--signal); color: #fff; }
.badge.qualifying { background: var(--purple-soft); color: var(--purple); }
.badge.track { background: var(--go-soft); color: var(--go); }
.badge.pit { background: var(--warn-soft); color: var(--warn); }

/* ---------- live lap ticker ---------- */
.ticker { display: flex; gap: 10px; overflow: hidden; mask-image: linear-gradient(90deg, #000 85%, transparent); }
.tick { flex: none; display: flex; gap: 10px; align-items: center; padding: 8px 14px; border-radius: 4px; background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--purple); font-size: 13px; animation: slidein .4s ease; }
.tick b { font-family: var(--mono); }
@keyframes slidein { from { opacity: 0; transform: translateX(-12px); } }

/* ---------- track tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.tile { text-decoration: none; padding: 20px 20px 26px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--signal); }
.tile::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--kerb); opacity: .9; transform: translateY(6px); transition: transform .2s; }
.tile:hover::after { transform: none; }
.tile-track { font-weight: 900; font-style: italic; font-stretch: 110%; text-transform: uppercase; font-size: 20px; letter-spacing: -.005em; line-height: 1; }
.tile-record b { font-family: var(--mono); font-size: 26px; display: block; color: var(--purple); }
.tile-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-3); font-weight: 600; }

/* ---------- podium ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 12px; margin-bottom: 18px; align-items: end; }
.pod { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; border-top: 4px solid var(--line-2); }
.pod.p1 { order: 2; padding-top: 30px; background: var(--rail); color: #fff; border-color: var(--rail); border-top: 4px solid var(--signal); }
.pod.p2 { order: 1; border-top-color: #a9b3c1; }
.pod.p3 { order: 3; border-top-color: #c0773d; }
.pod.p1::after { content: ''; position: absolute; top: 0; right: 0; width: 72px; height: 48px; background: var(--check); opacity: .9; -webkit-mask-image: linear-gradient(225deg, #000 30%, transparent 75%); mask-image: linear-gradient(225deg, #000 30%, transparent 75%); }
.pod .place { font-size: 15px; font-weight: 900; font-style: italic; color: var(--ink-3); }
.pod.p1 .place, .pod.p1 .muted { color: var(--signal); }
.pod .who { font-size: 19px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .time { font-family: var(--mono); font-size: 22px; font-weight: 700; }
.pod.p1 .time { font-size: 26px; }
@media (max-width: 700px) { .podium { grid-template-columns: 1fr; } .pod.p1, .pod.p2, .pod.p3 { order: 0; } }

/* ---------- admin ---------- */
.login { max-width: 400px; margin: 8vh auto 0; padding: 32px; display: flex; flex-direction: column; gap: 16px; border-top: 6px solid transparent; border-image: var(--kerb) 1; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 16px; align-items: center; padding: 14px 16px 14px 0; overflow: hidden; }
.admin-row .bar { align-self: stretch; background: var(--off); margin: -14px 0; }
.admin-row.on .bar { background: var(--go); }
.admin-row .info { min-width: 0; }
.admin-row .info b { font-size: 17px; font-style: italic; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .info .small { display: flex; gap: 12px; flex-wrap: wrap; }
@media (max-width: 700px) { .admin-row { grid-template-columns: 6px 1fr; } .admin-row .btn-row { grid-column: 2; } }

.editor { display: grid; grid-template-columns: 210px 1fr; gap: 22px; align-items: start; }
.tabs { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 20px; }
.tabs button { position: relative; text-align: left; border: 0; background: none; padding: 10px 14px; border-radius: 4px; font-weight: 650; cursor: pointer; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.tabs button:hover { background: var(--paper-2); }
.tabs button.on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); border-left: 4px solid var(--signal); }
@media (max-width: 860px) { .editor { grid-template-columns: 1fr; } .tabs { flex-direction: row; overflow-x: auto; position: static; } .tabs button { white-space: nowrap; } }
.save-bar { position: sticky; bottom: 16px; margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 12px 20px; background: var(--rail); color: #fff; border-radius: 6px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); z-index: 5; border-left: 6px solid var(--warn); }
.save-bar .btn { border-color: transparent; }
@media (max-width: 860px) { .save-bar { bottom: 76px; } }
.fieldset { padding: 22px; margin-bottom: 16px; }
.fieldset > h3 { margin-bottom: 4px; font-size: 17px; font-style: italic; }
.fieldset > p.muted { margin: 0 0 16px; font-size: 13px; }
.session-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.sess { padding: 16px; border: 1px solid var(--line); border-top: 3px solid var(--go); border-radius: 4px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.sess.off { opacity: .55; border-top-color: var(--off); }
.sess .grid-form { grid-template-columns: 1fr 1fr; gap: 10px; }

.car-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; max-height: 560px; overflow: auto; padding: 4px; }
.car { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; font-size: 13.5px; background: var(--paper); }
.car:hover { border-color: var(--line-2); }
.car.on { border-color: var(--signal); background: var(--signal-soft); }
.car input { accent-color: var(--signal); width: 16px; height: 16px; flex: none; }
.car .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.car .pi { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

.console { background: #0a0c0f; color: #cfd6df; font-family: var(--mono); font-size: 12.5px; border-radius: 6px; height: 460px; overflow: auto; padding: 14px; white-space: pre-wrap; word-break: break-word; border: 1px solid #20252d; }
.console .sys { color: #ff8a7a; }
.console .err { color: #ff5a4f; }
.console .t { color: #5d6675; margin-right: 8px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--rail); color: #fff; padding: 12px 18px; border-radius: 6px; border-left: 5px solid var(--go); font-weight: 650; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-left-color: var(--signal); }
@media (max-width: 860px) { .toast { bottom: 86px; } }

.modal-bg { position: fixed; inset: 0; background: rgba(8, 10, 13, .6); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { max-width: 640px; width: 100%; max-height: 85vh; overflow: auto; padding: 24px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 13px; }

@media (max-width: 1100px) {
  .strip { grid-template-columns: 10px 1fr 190px; }
  .strip-mid { grid-column: 2 / -1; grid-row: 2; border-top: 1px solid var(--line); }
  .strip-flag { grid-row: 1 / 3; }
}
@media (max-width: 640px) {
  .strip { grid-template-columns: 6px 1fr; }
  .strip-slots { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); flex-direction: row; justify-content: flex-start; }
  .strip-flag { grid-row: 1 / 4; }
  .strip-mid { grid-row: 3; }
  .gauge, .gauge svg { width: 84px; height: 84px; }
  .gauge .g-txt b { font-size: 24px; }
}
.save-bar[hidden] { display: none; }
.save-bar .btn:not(.signal) { color: var(--ink); }
[hidden] { display: none !important; }
.tile > * { position: relative; z-index: 1; }

/* ================================================================ phone */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .page-head { margin-bottom: 20px; gap: 12px; }
  .page-head > .btn, .page-head > a.btn { align-self: flex-start; }
  h1 { font-size: 30px; }
  .page-head h1::after { width: 56px; height: 6px; margin-top: 10px; }
  .section { margin-top: 30px; }

  /* filters and tab bars scroll sideways instead of wrapping */
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button, .seg a { flex: none; }
  .toolbar { gap: 8px; }
  .toolbar .input, .page-head .input { width: 100%; min-width: 0; max-width: none !important; flex: 1 1 100%; }

  /* live strip: compact */
  .strip-id, .strip-mid { padding: 16px; }
  .strip-track { font-size: 23px; }
  .strip-slots { padding: 12px 16px; gap: 14px; }
  .gauge, .gauge svg { width: 60px; height: 60px; }
  .gauge circle { stroke-width: 12; }
  .gauge .g-txt b { font-size: 20px; }
  .gauge .g-txt span { font-size: 10px; }
  .strip-drivers summary { padding: 12px 16px; }
  .cond { grid-template-columns: 1fr 1fr; gap: 10px 14px; }

  /* tables: tighter, and drop the columns that matter least on a phone */
  table.t { font-size: 13.5px; }
  .t th, .t td { padding: 9px 10px; }
  .t th:first-child, .t td:first-child { padding-left: 14px; }
  .t th:last-child, .t td:last-child { padding-right: 14px; }
  .pos { width: 38px; }
  .t [data-col="Car"], .t [data-col="Status"], .t [data-col="Last"], .t [data-col="#"],
  .t [data-col="S1"], .t [data-col="S2"], .t [data-col="S3"], .t [data-col="Sectors"],
  .t [data-col="Session"], .t [data-col="Date"], .t [data-col="When"], .t [data-col="Lap #"],
  .t [data-col="Server"], .t [data-col="Drivers"], .t [data-col="Best lap"], .t [data-col="Total"],
  .t [data-col="Sessions"], .t [data-col="Race wins"], .t [data-col="Last seen"], .t [data-col="Last driven"],
  .t [data-col="Created"], .t [data-col="Nation"] { display: none; }
  .t:not([data-first="Driver"]) [data-col="Laps"] { display: none; }
  .t[data-first="Pos"] [data-col="Best lap"] { display: table-cell; } /* result sheet keeps its best lap */
  .t[data-first="Lap"] [data-col="Valid"] { text-align: right; }
  .t td[data-col="Driver"], .t td[data-col="Track"], .t td[data-col="Winner / P1"] { white-space: normal; min-width: 0; }
  .t td[data-col="Track"] { max-width: 150px; }

  /* podium: one compact row per place */
  .podium { gap: 8px; }
  .pod { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 12px 16px; }
  .pod.p1 { padding-top: 14px; }
  .pod .place { width: 28px; }
  .pod .who { flex: 1; font-size: 16px; }
  .pod .time, .pod.p1 .time { font-size: 18px; }
  .pod .muted { width: 100%; padding-left: 40px; }
  .pod.p1 { padding-right: 56px; }
  .pod.p1::after { width: 44px; height: 100%; }

  .stats { grid-template-columns: 1fr 1fr; }
  .stat { border-bottom: 1px solid var(--line); }
  .stat b { font-size: 28px; }
  .tiles { grid-template-columns: 1fr; gap: 10px; }
  .tile { padding: 16px 16px 20px; }

  /* admin */
  .admin-row { padding: 14px 14px 14px 0; gap: 12px; }
  .admin-row .btn-row { gap: 6px; }
  .tabs { margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button.on { border-left: 0; box-shadow: inset 0 -3px 0 var(--signal); }
  .fieldset { padding: 16px; }
  .sess .grid-form { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr; }
  .car-pick { grid-template-columns: 1fr; max-height: 60vh; }
  .console { height: 60vh; font-size: 11.5px; }
  .save-bar { bottom: calc(76px + env(safe-area-inset-bottom)); padding: 10px 10px 10px 14px; }
  .modal { padding: 18px; max-height: 90vh; }
  .login { margin-top: 4vh; padding: 24px; }
  .me-card { flex-direction: column; padding: 20px; }
}
