/* DontGetPlayed Analytics: Midnight transit diagram.
   Enamel ground, porcelain frames, four line inks. See DESIGN.md. */

/* ---------------------------------------------------------------- Tokens */
:root {
  --enamel: #0B1230;
  --enamel-2: #101A40;
  --enamel-3: #17224F;
  --enamel-4: #1F2C61;
  --porcelain: #F4F4F0;
  --mute: #A9B3D1;
  --dim: #8A94B8;
  --hair: rgba(244, 244, 240, .13);
  --rule: rgba(244, 244, 240, .26);
  --frame: rgba(244, 244, 240, .62);

  /* Line inks. Chart fills use the validated steps; signage uses the bright amber. */
  --red: #E31C26;
  --amber: #C48700;
  --amber-sign: #F2B10E;
  --cobalt: #3D74FF;
  --green: #22B14C;
  /* Badge fills: white or enamel text at >= 4.5:1 */
  --red-badge: #D42A22;
  --cobalt-badge: #2F62E8;
  --green-badge: #178037;

  --focus: #6F95FF;
  --danger-ink: #FF8A80;
  --ok-ink: #7EE2A4;

  --sign: "Barlow Condensed", "Changa", "Arial Narrow", sans-serif;
  --body: "Barlow", "Changa", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --r-frame: 14px;
  --r-ctl: 6px;
  --gutter: clamp(16px, 2.4vw, 28px);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--enamel);
  color: var(--porcelain);
  font: 400 16px/1.5 var(--body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--porcelain);
}
::selection { background: rgba(61, 116, 255, .5); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: rgba(244, 244, 240, .28) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(244, 244, 240, .24); border-radius: 10px; border: 3px solid var(--enamel); }
::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3, p { margin: 0; }
a { color: var(--porcelain); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--focus); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--porcelain); color: var(--enamel); padding: .5rem .9rem; border-radius: var(--r-ctl); font-weight: 600; }
.skip:focus { top: 12px; }
.noscript { padding: 2rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }

/* Signage type: the one voice for headings, labels and controls */
.sign, .panel-h, .page-title, .btn, .seg button, .field-label, .rail-h, .nav a, .tabbar a,
th, .journey, .badge, .chip, .live-chip, .lead-h, .map-cap, .auth-display, .auth-title {
  font-family: var(--sign);
  text-transform: uppercase;
  letter-spacing: .07em;
}

/* Frames: porcelain outline, the board's only elevation */
.frame { border: 1.5px solid var(--frame); border-radius: var(--r-frame); background: var(--enamel); }

/* -------------------------------------------------------------- Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .7rem;
  min-height: 48px; padding: 0 1.3rem; border-radius: var(--r-ctl);
  border: 1.5px solid var(--frame); background: transparent; color: var(--porcelain);
  font-weight: 600; font-size: 1.06rem; letter-spacing: .08em; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn svg { width: 20px; height: 20px; flex: none; transition: transform .2s var(--ease-out); }
.btn:hover svg.arrow { transform: translateX(3px); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red-badge); border-color: var(--red-badge); color: #fff; }
.btn-primary:hover { background: #E3352C; border-color: #E3352C; }
.btn-primary:focus-visible { outline-color: var(--porcelain); box-shadow: inset 0 0 0 2px var(--enamel); }
.btn-outline:hover { border-color: var(--porcelain); background: rgba(244, 244, 240, .06); }
.btn-outline[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--focus); border-color: var(--focus); }
.btn-ghost { border-color: transparent; color: var(--mute); }
.btn-ghost:hover { color: var(--porcelain); border-color: var(--rule); }
.btn-danger { border-color: rgba(255, 138, 128, .7); color: var(--danger-ink); }
.btn-danger:hover { background: rgba(227, 28, 38, .14); border-color: var(--danger-ink); }
.btn-sm { min-height: 36px; padding: 0 .85rem; font-size: .92rem; gap: .45rem; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--porcelain); text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.link:hover { text-decoration-color: var(--focus); }

.field { display: grid; gap: .45rem; }
.field-label { font-size: .9rem; font-weight: 600; color: var(--mute); letter-spacing: .1em; }
.field-hint { font-size: .88rem; color: var(--dim); }
.input, .select {
  width: 100%; min-height: 48px; padding: 0 .95rem; border-radius: var(--r-ctl);
  background: var(--enamel-2); border: 1.5px solid rgba(244, 244, 240, .4); color: var(--porcelain);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--dim); }
.input:hover, .select:hover { border-color: rgba(244, 244, 240, .7); }
.input:focus, .select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(61, 116, 255, .32); }
.input[aria-invalid="true"] { border-color: var(--danger-ink); }
.select { appearance: none; padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A9B3D1' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; background-size: 18px; }
.pw { position: relative; }
.pw .input { padding-right: 5rem; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 0 .7rem;
  border: 0; border-radius: 4px; background: transparent; color: var(--mute); font: 600 .85rem var(--sign); letter-spacing: .08em; text-transform: uppercase; }
.pw-toggle:hover { color: var(--porcelain); background: rgba(244, 244, 240, .07); }

.msg { min-height: 1.4em; font-size: .95rem; display: flex; gap: .5rem; align-items: flex-start; }
.msg:empty { min-height: 0; }
.msg-error { color: var(--danger-ink); }
.msg-ok { color: var(--ok-ink); }
.msg svg { width: 18px; height: 18px; flex: none; margin-top: .15rem; }

.seg { display: inline-flex; border: 1.5px solid var(--frame); border-radius: var(--r-ctl); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--mute); min-height: 34px; padding: 0 .8rem; border-radius: 4px; font-weight: 600; font-size: .95rem; position: relative; }
.seg button:hover { color: var(--porcelain); }
.seg button[aria-pressed="true"] { color: var(--porcelain); background: var(--enamel-4); }
.seg button[aria-pressed="true"]::after { content: ""; position: absolute; left: .8rem; right: .8rem; bottom: 3px; height: 2px; background: var(--red); border-radius: 2px; }
.seg-sm button { min-height: 30px; font-size: .85rem; padding: 0 .65rem; }
.seg-sm button[aria-pressed="true"]::after { left: .65rem; right: .65rem; bottom: 2px; }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 .45rem; border-radius: 4px; font-size: .74rem; font-weight: 700; letter-spacing: .08em; white-space: nowrap; color: #fff; }
.badge-red { background: var(--red-badge); }
.badge-amber { background: var(--amber-sign); color: var(--enamel); }
.badge-cobalt { background: var(--cobalt-badge); }
.badge-green { background: var(--green-badge); }
.badge-quiet { background: transparent; color: var(--mute); box-shadow: inset 0 0 0 1.5px var(--rule); }
.badge-test { background: transparent; color: var(--porcelain); box-shadow: inset 0 0 0 1.5px var(--porcelain); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: .5rem; min-height: 32px; padding: 0 .75rem; border-radius: 999px;
  border: 1.5px solid var(--rule); background: transparent; color: var(--mute); font-weight: 600; font-size: .85rem; }
.chip:hover { color: var(--porcelain); border-color: var(--frame); }
.chip[aria-pressed="true"] { color: var(--porcelain); border-color: var(--porcelain); background: rgba(244, 244, 240, .07); }

/* A short line-ink bar: the chip that names a line beside its text */
.ink { display: inline-block; width: 22px; height: 6px; border-radius: 3px; flex: none; background: var(--line, var(--porcelain)); }
.ink-dot { width: 10px; height: 10px; border-radius: 50%; }
[data-line="red"] { --line: var(--red); }
[data-line="amber"] { --line: var(--amber-sign); }
[data-line="cobalt"] { --line: var(--cobalt); }
[data-line="green"] { --line: var(--green); }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.is-live .status-dot { background: var(--porcelain); box-shadow: 0 0 0 0 rgba(244, 244, 240, .7); animation: beacon 2.4s var(--ease-out) infinite; }
.is-stale .status-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--mute); }
.is-sample .status-dot { background: var(--amber-sign); }
.is-error .status-dot { background: var(--danger-ink); }
@keyframes beacon { 0% { box-shadow: 0 0 0 0 rgba(244, 244, 240, .55); } 70%, 100% { box-shadow: 0 0 0 8px rgba(244, 244, 240, 0); } }

.clock { display: inline-flex; flex-direction: column; gap: .1rem; color: var(--dim); font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; font-family: var(--sign); }
.clock-time { font: 600 1.35rem/1 var(--sign); color: var(--porcelain); letter-spacing: .04em; }
.clock-lg .clock-time { font-size: 2rem; }

/* ------------------------------------------------------------------ Metro */
.metro { display: block; width: 100%; height: auto; overflow: visible; }
.metro .river { fill: none; stroke: rgba(61, 116, 255, .08); stroke-width: 46; stroke-linecap: round; }
.metro .street { fill: none; stroke: rgba(244, 244, 240, .045); stroke-width: 1.5; }
.metro .line { fill: none; stroke: var(--line); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; transition: opacity .35s var(--ease-out); }
.metro .line-hit { fill: none; stroke: transparent; stroke-width: 30; cursor: pointer; pointer-events: stroke; }
.metro .stop { fill: var(--enamel); stroke: var(--porcelain); stroke-width: 3; transition: r .3s var(--ease-out); }
.metro .stop.pulse { animation: stop-pulse .9s var(--ease-out); }
@keyframes stop-pulse { 0% { stroke-width: 7; } 100% { stroke-width: 3; } }
.metro .leader { stroke: rgba(244, 244, 240, .35); stroke-width: 1.5; }
.metro .terminal { stroke: var(--porcelain); stroke-width: 3; stroke-linecap: round; }
.metro .hub-ring { fill: var(--enamel); stroke: var(--porcelain); stroke-width: 5; }
.metro .hub-core { fill: var(--porcelain); opacity: 0; transition: opacity .3s; }
.metro .hub-core.on { opacity: 1; }
.metro .label { fill: var(--porcelain); font: 600 18px var(--sign); letter-spacing: .05em; text-transform: uppercase; }
.metro .count { fill: #D2D7E8; font: 600 16px var(--body); }
.metro .hub-label { fill: var(--porcelain); font: 700 14px var(--sign); letter-spacing: .1em; }
.metro .hub-count { fill: var(--mute); font: 500 13px var(--body); }
.metro .train { fill: var(--line); stroke: var(--porcelain); stroke-width: 2.5; }
.metro .group { transition: opacity .35s var(--ease-out); }
.metro.has-focus .group { opacity: .16; }
.metro.has-focus .group.is-focus { opacity: 1; }
.metro.has-focus .group.is-focus .line { stroke-width: 12; }
.metro .empty-label { fill: var(--dim); font: 500 13px var(--body); }

/* ---------------------------------------------------------------- Sign-in */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 460px) 1fr; gap: var(--gutter); padding: var(--gutter); }
.auth-rail { display: flex; flex-direction: column; gap: 1.6rem; padding: clamp(22px, 2.6vw, 34px); min-height: calc(100vh - 2 * var(--gutter)); }
.lockup { display: block; width: min(300px, 100%); height: auto; }
.lockup-sm { width: 180px; }
.auth-intro { display: grid; gap: .6rem; }
.auth-title { font-size: clamp(1.8rem, 2.4vw, 2.2rem); font-weight: 700; line-height: 1.05; letter-spacing: .04em; }
.auth-lede { color: var(--mute); max-width: 42ch; font-size: .98rem; }

/* The journey line: sign-in steps drawn as stations */
.journey { list-style: none; margin: 0; padding: 0 0 .2rem; display: flex; position: relative; font-size: .8rem; font-weight: 600; letter-spacing: .09em; }
.journey li { flex: 1; position: relative; display: grid; justify-items: center; gap: .55rem; color: var(--dim); text-align: center; min-width: 0; }
.journey li::before { content: ""; position: absolute; top: 9px; left: -50%; right: 50%; height: 6px; margin-top: -3px; background: var(--enamel-4); border-radius: 3px; }
.journey li:first-child::before { display: none; }
.journey li.done::before, .journey li.current::before { background: var(--red); }
.journey .j-stop { position: relative; z-index: 1; width: 18px; height: 18px; border-radius: 50%; background: var(--enamel); border: 3px solid var(--enamel-4); transition: border-color .3s, transform .4s var(--ease-out); }
.journey li.done .j-stop { border-color: var(--porcelain); background: var(--porcelain); }
.journey li.current { color: var(--porcelain); }
.journey li.current .j-stop { border-color: var(--porcelain); border-width: 4px; transform: scale(1.35); }
.journey .j-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; padding: 0 2px; }

.auth-stage { display: grid; gap: 1.1rem; outline: none; }
.auth-stage h2 { font: 700 1.4rem/1.1 var(--sign); text-transform: uppercase; letter-spacing: .06em; }
.auth-stage .stage-lede { color: var(--mute); font-size: .95rem; max-width: 44ch; }
.auth-form { display: grid; gap: 1.1rem; }
.stage-enter { animation: stage-in .5s var(--ease-out); }
@keyframes stage-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.auth-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; padding-top: 1.1rem; border-top: 1px solid var(--hair); color: var(--dim); font-size: .85rem; }
.auth-foot > span:last-child { text-align: right; max-width: 22ch; }

.auth-map { position: relative; display: grid; grid-template-rows: auto 1fr auto; min-width: 0; padding: clamp(8px, 2vw, 24px) clamp(8px, 2vw, 32px); }
.auth-display { font-size: clamp(3rem, 7.4vw, 6rem); font-weight: 700; line-height: .92; letter-spacing: .015em; color: var(--porcelain); }
.auth-map .metro { align-self: center; max-height: calc(100vh - 260px); }
.auth-map-note { display: flex; align-items: center; gap: .6rem; color: var(--dim); font-size: .85rem; justify-self: end; }
.auth-map-note .tick { width: 18px; height: 2px; background: var(--dim); }

/* One-time code cells over a single real input (paste and autofill keep working) */
.otp { position: relative; display: grid; grid-template-columns: repeat(3, 1fr) 4px repeat(3, 1fr); gap: 8px; }
.otp input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; font-size: 16px; cursor: text; }
.otp .cell { height: 60px; border: 1.5px solid rgba(244, 244, 240, .4); border-radius: var(--r-ctl); display: grid; place-items: center; font: 600 2rem/1 var(--sign); background: var(--enamel-2); transition: border-color .15s, box-shadow .15s; }
.otp .cell:nth-of-type(4) { grid-column: 5; }
.otp.focused .cell.active { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(61, 116, 255, .32); }
.otp.focused .cell.active:empty::after { content: ""; width: 2px; height: 26px; background: var(--porcelain); animation: caret 1s steps(1) infinite; }
.otp.invalid .cell { border-color: var(--danger-ink); }
@keyframes caret { 50% { opacity: 0; } }
.period { display: flex; align-items: center; gap: .7rem; color: var(--dim); font-size: .85rem; }
.period-track { flex: 1; height: 4px; background: var(--enamel-4); border-radius: 2px; overflow: hidden; }
.period-track i { display: block; height: 100%; background: var(--porcelain); transform-origin: left; }

.qr-row { display: grid; grid-template-columns: 148px 1fr; gap: 1rem; align-items: start; }
.qr { width: 148px; height: 148px; background: #fff; border-radius: 10px; padding: 10px; }
.qr svg { display: block; width: 100%; height: 100%; }
.secret { font: 500 .95rem/1.6 var(--mono); letter-spacing: .04em; word-break: break-all; color: var(--porcelain); background: var(--enamel-2); border: 1px solid var(--hair); border-radius: var(--r-ctl); padding: .5rem .7rem; }
.steps-mini { margin: 0; padding-left: 1.1rem; color: var(--mute); font-size: .92rem; display: grid; gap: .35rem; }

.codes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; font: 500 1rem/1.9 var(--mono); }
.codes li { border-bottom: 1px solid var(--hair); }
.check { display: flex; gap: .7rem; align-items: flex-start; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin: .1rem 0 0; accent-color: var(--red); flex: none; }

.pw-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .88rem; color: var(--dim); }
.pw-rules li { display: flex; gap: .55rem; align-items: center; }
.pw-rules li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--dim); flex: none; transition: background .2s, border-color .2s; }
.pw-rules li.ok { color: var(--porcelain); }
.pw-rules li.ok::before { background: var(--porcelain); border-color: var(--porcelain); }

@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; padding: 12px; }
  .auth-map { order: -1; padding: 8px 4px 0; grid-template-rows: auto auto; }
  .auth-display { font-size: clamp(2.4rem, 11vw, 3.6rem); }
  .auth-map .metro { max-height: 34vh; }
  .auth-map-note { display: none; }
  .auth-rail { min-height: 0; }
}

/* ------------------------------------------------------------- App shell */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: var(--gutter); padding: var(--gutter); min-height: 100vh; }
.rail { position: sticky; top: var(--gutter); align-self: start; height: calc(100vh - 2 * var(--gutter)); display: flex; flex-direction: column; gap: 1.2rem; padding: 22px 18px; overflow: auto; }
.rail-product { font: 600 .9rem var(--sign); letter-spacing: .3em; text-transform: uppercase; color: var(--mute); margin-top: -.6rem; padding-bottom: 1rem; border-bottom: 1px solid var(--hair); }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: .85rem; min-height: 44px; padding: 0 .6rem; border-radius: var(--r-ctl); color: var(--mute); text-decoration: none; font-weight: 600; font-size: 1.05rem; position: relative; }
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { color: var(--porcelain); background: rgba(244, 244, 240, .05); }
.nav a[aria-current="page"] { color: var(--porcelain); }
.nav a[aria-current="page"]::after { content: ""; position: absolute; left: .6rem; width: 96px; bottom: 4px; height: 3px; background: var(--red); border-radius: 2px; }
.rail-block { padding-top: 1rem; border-top: 1px solid var(--hair); display: grid; gap: .4rem; }
.rail-block:first-of-type { margin-top: auto; }
.rail-h { font-size: .85rem; font-weight: 600; color: var(--mute); letter-spacing: .12em; }
.status-line { display: flex; align-items: center; gap: .55rem; font-weight: 500; }
.rail-sub { font-size: .85rem; color: var(--dim); }
.rail-user { display: grid; gap: .7rem; padding-top: 1rem; border-top: 1px solid var(--hair); }
.user-btn { display: flex; align-items: center; gap: .7rem; min-width: 0; background: transparent; border: 0; padding: .3rem; border-radius: var(--r-ctl); text-align: left; }
.user-btn:hover { background: rgba(244, 244, 240, .05); }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--porcelain); display: grid; place-items: center; font: 700 .9rem var(--sign); letter-spacing: .05em; flex: none; }
.user-meta { display: grid; min-width: 0; }
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: .82rem; color: var(--mute); font-family: var(--sign); text-transform: uppercase; letter-spacing: .1em; }

.main { min-width: 0; outline: none; display: flex; flex-direction: column; gap: var(--gutter); }
.topbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; min-height: 56px; }
.page-title { font-size: clamp(1.9rem, 3vw, 2.6rem); font-weight: 700; letter-spacing: .05em; margin-right: auto; line-height: 1; }
.topbar-tools { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.live-chip { display: inline-flex; align-items: center; gap: .55rem; min-height: 40px; padding: .5rem .9rem; border: 1.5px solid var(--frame); border-radius: var(--r-ctl); font-weight: 600; font-size: .9rem; }
.view { display: flex; flex-direction: column; gap: var(--gutter); }
.view.entering { animation: view-in .45s var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tabbar { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); gap: 14px; }
  .rail { display: none; }
  .tabbar { display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
    background: var(--enamel); border: 1.5px solid var(--frame); border-radius: var(--r-frame); padding: 4px; justify-content: space-around; }
  .tabbar a, .tabbar button { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 8px 2px 6px; color: var(--mute); text-decoration: none; font: 600 .72rem var(--sign); letter-spacing: .08em; text-transform: uppercase; position: relative; background: none; border: 0; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--porcelain); }
  .tabbar a[aria-current="page"]::after { content: ""; position: absolute; bottom: 1px; width: 34px; height: 3px; background: var(--red); border-radius: 2px; }
  .topbar { min-height: 0; }
  .topbar-tools { width: 100%; }
  .topbar-tools .seg { flex: 1 1 auto; }
  .topbar-tools .seg button { flex: 1; padding: 0 .4rem; }
}

/* ------------------------------------------------------------ Dashboard */
.sample-banner { border: 1.5px dashed var(--amber-sign); border-radius: var(--r-ctl); padding: .7rem 1rem; color: var(--porcelain); font-size: .95rem; }
.sample-banner b { font-family: var(--sign); text-transform: uppercase; letter-spacing: .08em; }

.hero-row { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: var(--gutter); }
.lead { padding: 22px 22px 20px; display: flex; flex-direction: column; gap: .55rem; }
.lead-h { font-size: 1.05rem; font-weight: 600; color: var(--mute); letter-spacing: .12em; }
.lead-num { font: 700 clamp(3.6rem, 6vw, 5.2rem)/.95 var(--sign); letter-spacing: .01em; }
.lead-ctx { color: var(--mute); font-size: .95rem; }
.lead-ctx b { color: var(--porcelain); font-weight: 600; }
.delta { font-weight: 600; color: var(--porcelain); white-space: nowrap; }
.delta svg { width: 14px; height: 14px; vertical-align: -1px; }

.panel-h { font-size: 1.12rem; font-weight: 600; letter-spacing: .09em; }
.panel-h-sm { font-size: .95rem; color: var(--mute); padding-bottom: .5rem; border-bottom: 1px solid var(--hair); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; }
.legend button { position: relative; width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .75rem; min-height: 46px; padding: 0 .3rem;
  border: 0; border-bottom: 1px solid var(--hair); background: transparent; text-align: left; border-radius: 0; }
.legend button:hover { background: rgba(244, 244, 240, .04); }
.legend .l-name { display: grid; font-weight: 500; line-height: 1.2; padding: .45rem 0; }
.legend .l-line { font: 600 .78rem var(--sign); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.legend .l-num { font-weight: 600; }
.legend .l-share { color: var(--dim); font-size: .85rem; width: 3.2em; text-align: right; }
.legend button[aria-pressed="true"] { background: rgba(244, 244, 240, .08); }
.legend button[aria-pressed="true"] .ink { height: 10px; border-radius: 5px; box-shadow: 0 0 0 2px var(--enamel), 0 0 0 3.5px var(--porcelain); }
.legend .dim, .dim { color: var(--mute); }
.lead .panel-h-sm { margin-top: 1rem; }
.legend-hint { color: var(--dim); font-size: .82rem; margin-top: .3rem; }

.map { margin: 0; padding: 18px 20px 14px; display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.map-cap { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; font-size: 1.05rem; font-weight: 600; }
.map-sub { font-family: var(--body); text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--dim); font-size: .88rem; }
.map .metro { flex: 1; max-height: 470px; }
.map-hint { display: none; color: var(--dim); font-size: .85rem; padding: 0 6px; }

.boards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gutter); }
.board { padding: 16px 18px 14px; display: grid; align-content: start; grid-template-columns: 6px 1fr; gap: 0 14px; position: relative; transition: opacity .3s var(--ease-out), border-color .3s; }
.board::before { content: ""; grid-row: 1 / span 3; background: var(--line); border-radius: 3px; }
.board-head { display: grid; justify-items: start; gap: .5rem; }
.board-metric { margin: 0; font: 600 1.1rem var(--sign); letter-spacing: .08em; text-transform: uppercase; color: var(--porcelain); }
.board-num { font: 700 2.6rem/1.05 var(--sign); margin: .2rem 0 .4rem; letter-spacing: .02em; }
.board-stops { list-style: none; margin: 0; padding: 0; display: grid; }
.board-stops li { position: relative; display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; padding: .42rem 0; border-top: 1px solid var(--hair); font-size: .92rem; align-items: center; }
.board-stops li::before { content: ""; position: absolute; left: -23px; top: .62rem; width: 12px; height: 12px; border-radius: 50%; background: var(--enamel); border: 3px solid var(--porcelain); }
.board-stops .s-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-stops .s-num { font-weight: 600; }
.board-stops .s-bar { grid-column: 1 / -1; height: 3px; background: var(--enamel-3); border-radius: 2px; overflow: hidden; }
.board-stops .s-bar i { display: block; height: 100%; background: var(--line); border-radius: 2px; transform-origin: left; transition: transform .6s var(--ease-out); }
.board-empty { color: var(--dim); font-size: .9rem; padding: .5rem 0; border-top: 1px solid var(--hair); }
.boards.has-focus .board { opacity: .4; }
.boards.has-focus .board.is-focus { opacity: 1; border-color: var(--porcelain); }

.duo { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--gutter); }
.duo-wide { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.panel { padding: 18px 20px; min-width: 0; display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-bottom: .7rem; margin-bottom: .9rem; border-bottom: 1px solid var(--hair); }
.panel-head-gap { margin-top: 1.4rem; }
.panel-note { color: var(--dim); font-size: .88rem; }
.chart-box { position: relative; height: 240px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: -.2rem 0 .8rem; font-size: .88rem; color: var(--mute); }
.chart-legend > span { display: inline-flex; align-items: center; gap: .45rem; }
.ink-sq { width: 12px; height: 12px; border-radius: 3px; }
.chart-box-sm { height: 150px; }
.chart-empty { position: absolute; inset: 0 0 24px 0; display: grid; place-items: center; color: var(--mute); font-size: .95rem; pointer-events: none; }

.stations { list-style: none; margin: 0; padding: 0; display: grid; }
.stations li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: .35rem .75rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--hair); }
.stations .st-tick { grid-row: 1 / span 2; width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--porcelain); background: var(--enamel); }
.stations .st-path { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stations .st-num { font-weight: 600; }
.stations .st-mix { grid-column: 2 / -1; display: flex; gap: 2px; height: 6px; }
.stations .st-mix i { display: block; height: 100%; background: var(--line); border-radius: 2px; min-width: 2px; }
.lang { margin-top: auto; padding-top: 1rem; display: grid; gap: .5rem; font-size: .9rem; color: var(--mute); }
.lang-bar { display: flex; height: 8px; gap: 2px; }
.lang-bar i { display: block; height: 100%; background: var(--porcelain); border-radius: 2px; }
.lang-bar i + i { background: var(--dim); }
.lang-keys { display: flex; justify-content: space-between; }
.lang-keys b { color: var(--porcelain); font-weight: 600; }

.table-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 480px; }
.table th { text-align: left; font-weight: 600; font-size: .85rem; color: var(--mute); letter-spacing: .1em; padding: 0 .5rem .6rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table th button { background: none; border: 0; padding: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; display: inline-flex; gap: .3rem; align-items: center; }
.table th button:hover, .table th[aria-sort="ascending"] button, .table th[aria-sort="descending"] button { color: var(--porcelain); }
.table th[aria-sort="ascending"] button::after, .table th[aria-sort="descending"] button::after {
  content: ""; width: 12px; height: 12px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M6 11l6-6 6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M6 11l6-6 6 6'/%3E%3C/svg%3E") center / contain no-repeat; }
.table th[aria-sort="descending"] button::after { transform: rotate(180deg); }
.table td { padding: .7rem .5rem; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .dim { color: var(--mute); }
.t-cell { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.table .t-title { font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share { display: inline-flex; align-items: center; gap: .6rem; }
.share-bar { width: 36px; height: 6px; background: var(--enamel-3); border-radius: 3px; overflow: hidden; }
.share-bar i { display: block; height: 100%; background: var(--amber-sign); border-radius: 3px; }

.log { align-self: start; }
.log .chips { margin-bottom: .6rem; }
.log-list { list-style: none; margin: 0 -8px 0 0; padding: 0 8px 0 0; overflow: auto; height: 520px; overscroll-behavior: contain; }
@media (max-width: 720px) { .log-list { height: 440px; } }
.log-list li { border-bottom: 1px solid var(--hair); }
.log-row { position: relative; width: 100%; display: grid; grid-template-columns: 54px auto minmax(0, 1fr); gap: .15rem .8rem; align-items: center; padding: .6rem .2rem; background: transparent; border: 0; text-align: left; border-radius: 4px; }
.log-row:hover { background: rgba(244, 244, 240, .04); }
.log-row time { font: 600 .95rem var(--sign); letter-spacing: .04em; color: var(--mute); grid-row: span 2; align-self: start; padding-top: .15rem; }
.log-row .ink { grid-row: span 2; align-self: start; margin-top: .55rem; }
.log-row .r-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: .5rem; align-items: center; }
.log-row .r-title span { overflow: hidden; text-overflow: ellipsis; }
.log-row .r-meta { grid-column: 3; color: var(--dim); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-list .new { animation: arrive .5s var(--ease-out); }
@keyframes arrive { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.empty { display: grid; gap: .7rem; justify-items: start; padding: 1.2rem 0; color: var(--mute); max-width: 48ch; }
.empty strong { color: var(--porcelain); font: 600 1.1rem var(--sign); text-transform: uppercase; letter-spacing: .07em; }

@media (max-width: 1320px) {
  .duo-wide { grid-template-columns: 1fr; }
}
@media (max-width: 1280px) {
  .boards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1120px) {
  .hero-row { grid-template-columns: 1fr; }
  .lead { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
  .lead > :nth-child(-n+4) { grid-column: 1; }
  .lead .panel-h-sm, .lead .legend, .lead .legend-hint { grid-column: 2; }
  .lead .panel-h-sm { grid-row: 1; }
  .lead .legend { grid-row: 2 / span 3; }
  .duo, .duo-wide { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .lead { display: flex; }
  .map { padding: 14px 10px 10px; }
  .map-cap { padding: 0 6px; }
  .map-pan { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin: 0 -10px; padding: 0 10px; }
  .map-pan::-webkit-scrollbar { display: none; }
  .map-pan .metro { width: 760px; max-height: none; }
  .map-pan { -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
  .map-hint { display: block; }
  .boards { grid-template-columns: 1fr; }
  .chart-box { height: 210px; }
  .panel { padding: 16px; }
  .table-scroll { margin: 0 -16px; padding: 0 16px; }
}

/* ------------------------------------------------- Builder, setup, admin */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--gutter); align-items: start; }
.stack { display: grid; gap: 1.5rem; }
.toggles { display: grid; gap: .2rem; }
.toggle { display: grid; grid-template-columns: auto 1fr; gap: .2rem .9rem; padding: .75rem 0; border-bottom: 1px solid var(--hair); cursor: pointer; }
.toggle input { appearance: none; width: 42px; height: 24px; border-radius: 12px; background: var(--enamel-4); position: relative; margin: 0; grid-row: span 2; cursor: pointer; transition: background .2s; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--porcelain); transition: transform .25s var(--ease-out); }
.toggle input:checked { background: var(--red-badge); }
.toggle input:checked::after { transform: translateX(18px); }
.toggle b { font-weight: 600; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.toggle > span { color: var(--mute); font-size: .9rem; }
.toggle .params { grid-column: 2; }
.params { display: flex; flex-wrap: wrap; gap: 4px; margin-top: .3rem; }
.params code { font-size: .78rem; color: var(--mute); border: 1px solid var(--hair); border-radius: 4px; padding: 0 .35rem; }
.code-panel { position: sticky; top: var(--gutter); }
pre.code { margin: 0; background: #070C22; border: 1px solid var(--hair); border-radius: 10px; padding: 16px; overflow: auto; max-height: 64vh; font: 400 .82rem/1.65 var(--mono); color: #D5DAEE; tab-size: 2; }
pre.code .c { color: #8A94B8; }
pre.code .s { color: #F2C14E; }
pre.code .k { color: #9DB6FF; }
.notes { display: grid; gap: .5rem; margin-top: 1rem; font-size: .92rem; color: var(--mute); }
.notes p { padding-left: 1rem; position: relative; }
.notes p::before { content: ""; position: absolute; left: 0; top: .55rem; width: 6px; height: 6px; border-radius: 50%; background: var(--porcelain); }
.notes b { color: var(--porcelain); font-weight: 600; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

.route { list-style: none; margin: 0; padding: 0; display: grid; position: relative; }
.route-step { display: grid; grid-template-columns: 44px 1fr; gap: 0 1rem; position: relative; padding-bottom: 1.6rem; }
.route-step::before { content: ""; position: absolute; left: 19px; top: 30px; bottom: -4px; width: 6px; background: var(--enamel-4); border-radius: 3px; }
.route-step:last-child::before { display: none; }
.route-step.done::before { background: var(--red); }
.route-stop { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--enamel-4); background: var(--enamel); display: grid; place-items: center; position: relative; z-index: 1; font: 700 1rem var(--sign); color: var(--mute); }
.route-stop:hover { border-color: var(--porcelain); }
.route-step.done .route-stop { border-color: var(--porcelain); background: var(--porcelain); color: var(--enamel); }
.route-step.done .route-stop svg { width: 20px; height: 20px; }
.route-body { padding-top: .45rem; display: grid; gap: .6rem; max-width: 76ch; color: var(--mute); }
.route-body h3 { font: 700 1.2rem var(--sign); text-transform: uppercase; letter-spacing: .06em; color: var(--porcelain); }
.route-step.done h3 { color: var(--mute); }
.route-body b { color: var(--porcelain); font-weight: 600; }
.route-body ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .3rem; }
.progress { display: flex; align-items: center; gap: 1rem; }
.progress-track { flex: 1; height: 6px; background: var(--enamel-4); border-radius: 3px; overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 100%; background: var(--red); transform-origin: left; transition: transform .5s var(--ease-out); }
.progress span { color: var(--mute); font-size: .92rem; white-space: nowrap; }

.users-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.add-user { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .8fr) auto; gap: 1rem; align-items: end; }
.select-sm { min-height: 36px; width: auto; min-width: 128px; font-size: .92rem; }
.users-table { min-width: 860px; }
.empty-li { border: 0 !important; display: block !important; }
@media (max-width: 860px) { .add-user { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .users-table { min-width: 0; }
  .users-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .users-table tr { display: grid; grid-template-columns: 1fr auto; gap: .6rem 1rem; padding: .9rem 0; border-bottom: 1px solid var(--hair); }
  .users-table td { display: block; padding: 0; border: 0; }
  .users-table td:nth-child(3), .users-table td:nth-child(5) { grid-column: 1 / -1; }
  .users-table td:nth-child(4) { grid-column: 1 / -1; font-size: .88rem; }
  .users-table td:nth-child(4)::before { content: "Last sign-in: "; }
  .users-table .u-actions { justify-content: flex-start; flex-wrap: wrap; }
  .users-table tr { padding-left: 0; padding-right: 0; }
  .users-panel .table-scroll { margin: 0; padding: 0; overflow: visible; }
}
.role-note { margin-top: .8rem; color: var(--dim); font-size: .9rem; max-width: 70ch; }
.u-name { display: grid; }
.u-name span:last-child { color: var(--dim); font-size: .85rem; }
.u-state { display: flex; gap: .35rem; flex-wrap: wrap; }
.u-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: nowrap; }
.u-actions .btn-sm { padding: 0 .6rem; font-size: .84rem; }
.ticket { border: 1.5px solid var(--porcelain); border-radius: 10px; padding: 1rem 1.1rem; display: grid; grid-template-columns: 1fr auto; gap: .4rem 1rem; background: var(--enamel-2); }
.ticket > span { grid-column: 1; }
.ticket-mark { grid-column: 2; grid-row: 1 / span 4; width: 64px; height: 64px; align-self: center; }
.ticket .t-label { font: 600 .82rem var(--sign); text-transform: uppercase; letter-spacing: .12em; color: var(--mute); }
.ticket .t-value { font: 500 1.25rem/1.4 var(--mono); letter-spacing: .03em; word-break: break-all; }
.audit-detail { color: var(--dim); font-size: .85rem; }

@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } .code-panel { position: static; } }
@media (max-width: 720px) { .qr-row { grid-template-columns: 1fr; } .codes { grid-template-columns: 1fr 1fr; font-size: .92rem; } }

/* ------------------------------------------------------ Dialog + toasts */
.dialog { padding: 0; color: var(--porcelain); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); }
.dialog::backdrop { background: rgba(5, 8, 22, .72); }
.dialog[open] { animation: dialog-in .3s var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.dialog-inner { padding: 24px 26px; display: grid; gap: 1.1rem; }
.dialog-inner h2 { font: 700 1.5rem/1.1 var(--sign); text-transform: uppercase; letter-spacing: .05em; display: flex; gap: .7rem; align-items: center; }
.dialog-inner p { color: var(--mute); }
.dialog-inner h2 svg { width: 28px; height: 28px; flex: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; padding-top: .4rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1.1rem; font-size: .93rem; margin: 0; }
.kv dt { color: var(--dim); font-family: var(--mono); font-size: .82rem; padding-top: .12rem; }
.kv dd { margin: 0; word-break: break-word; }
.account-grid { display: grid; gap: 1rem; }
.account-section { display: grid; gap: .8rem; padding-top: 1rem; border-top: 1px solid var(--hair); }
.account-section h3 { font: 600 1.05rem var(--sign); text-transform: uppercase; letter-spacing: .08em; }

.toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 80; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: grid; grid-template-columns: auto 1fr; gap: .8rem; align-items: center; padding: .85rem 1rem; border-radius: 10px; background: var(--enamel-2); border: 1.5px solid var(--frame); font-size: .95rem; box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .8); animation: toast-in .35s var(--ease-out); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 960px) { .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .frame, .btn, .input, .seg { border-color: CanvasText; }
  .metro .line { stroke: CanvasText; }
}
