/* Taksi boshqaruv — web admin panel.
   Identity: the road. Asphalt rail on the left, one yellow lane marking (active place, route band).
   Everything else stays quiet so the numbers can be loud. */

@font-face { font-family: "Onest"; font-weight: 400; font-display: swap; src: url("fonts/onest-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Onest"; font-weight: 500; font-display: swap; src: url("fonts/onest-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Onest"; font-weight: 600; font-display: swap; src: url("fonts/onest-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap; src: url("fonts/onest-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Onest"; font-weight: 400; font-display: swap; src: url("fonts/onest-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 500; font-display: swap; src: url("fonts/onest-cyrillic-500-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 600; font-display: swap; src: url("fonts/onest-cyrillic-600-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap; src: url("fonts/onest-cyrillic-700-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

:root {
  color-scheme: light;
  --page: #eceeec;
  --surface: #fbfbfa;
  --surface-2: #f3f4f2;
  --ink: #161a1f;
  --ink-2: #4b535c;
  --muted: #737a82;
  --line: #dcdfdc;
  --line-strong: #c4c8c4;
  --rail: #1c2229;
  --rail-2: #262e37;
  --rail-ink: #c3c9cf;
  --rail-ink-strong: #ffffff;
  --signal: #f4b400;
  --signal-ink: #161a1f;
  --focus: #2a78d6;
  --link: #1f63b8;

  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --seq-0: #e8eef6;
  --seq-1: #b7d3f6;
  --seq-2: #86b6ef;
  --seq-3: #5598e7;
  --seq-4: #2a78d6;
  --seq-5: #1c5cab;
  --seq-6: #0d366b;
  --ord-1: #86b6ef;
  --ord-2: #3987e5;
  --ord-3: #1c5cab;

  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-ink: #b42323;
  --grid: #e3e5e1;
  --axis: #c4c8c4;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-pop: 0 10px 30px rgba(22, 26, 31, 0.16), 0 1px 0 rgba(22, 26, 31, 0.04);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f1215; --surface: #171b20; --surface-2: #1d2228; --ink: #eceff1; --ink-2: #b4bbc2; --muted: #8a9199;
    --line: #2a3037; --line-strong: #3a424b; --rail: #0a0d10; --rail-2: #161b21; --rail-ink: #a9b0b7;
    --focus: #5598e7; --link: #6da7ec;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --seq-0: #1b2330; --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #86b6ef; --seq-6: #cde2fb;
    --ord-1: #184f95; --ord-2: #2a78d6; --ord-3: #6da7ec;
    --good-ink: #0ca30c; --critical-ink: #e66767; --grid: #252b31; --axis: #3a424b;
    --shadow-pop: 0 12px 34px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1215; --surface: #171b20; --surface-2: #1d2228; --ink: #eceff1; --ink-2: #b4bbc2; --muted: #8a9199;
  --line: #2a3037; --line-strong: #3a424b; --rail: #0a0d10; --rail-2: #161b21; --rail-ink: #a9b0b7;
  --focus: #5598e7; --link: #6da7ec;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --seq-0: #1b2330; --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #86b6ef; --seq-6: #cde2fb;
  --ord-1: #184f95; --ord-2: #2a78d6; --ord-3: #6da7ec;
  --good-ink: #0ca30c; --critical-ink: #e66767; --grid: #252b31; --axis: #3a424b;
  --shadow-pop: 0 12px 34px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 400 14px/1.5 var(--font); font-feature-settings: "cv01";
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-note { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.shell > * { min-width: 0; }
.rail {
  background: var(--rail); color: var(--rail-ink); padding: 20px 12px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; gap: 20px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--rail-ink-strong); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.brand-sub { display: block; font-weight: 400; font-size: 12px; color: var(--rail-ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: 14px 8px 4px; font-size: 12px; color: #7f8891; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px;
  color: var(--rail-ink); text-decoration: none; border-radius: var(--radius-sm); font-weight: 500;
}
.nav a:hover { background: var(--rail-2); color: var(--rail-ink-strong); }
.nav a[aria-current="page"] { background: var(--rail-2); color: var(--rail-ink-strong); }
/* The lane marking: a dashed yellow line beside the current page. */
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 3px; top: 7px; bottom: 7px; width: 3px; border-radius: 2px;
  background: repeating-linear-gradient(to bottom, var(--signal) 0 6px, transparent 6px 10px);
}
.nav svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.rail-foot { margin-top: auto; padding: 0 8px; font-size: 12px; display: grid; gap: 10px; }
.status-line { display: flex; gap: 8px; align-items: flex-start; line-height: 1.35; }
.rail-foot button {
  background: none; border: 1px solid #3a434d; color: var(--rail-ink); border-radius: var(--radius-sm);
  padding: 6px 10px; cursor: pointer; text-align: left;
}
.rail-foot button:hover { color: var(--rail-ink-strong); border-color: #56616c; }

.main { padding: 28px 32px 64px; min-width: 0; }
.page { max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; }
.page-head p { color: var(--ink-2); margin-top: 6px; max-width: 64ch; }
.section { margin-top: 36px; }
.section > h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.005em; }
.section > .section-lead { color: var(--ink-2); margin: 4px 0 14px; max-width: 70ch; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--ink-2); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn-primary:hover { border-color: var(--ink); }
.btn-danger { color: var(--critical-ink); }
.btn-danger:hover { border-color: var(--critical); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.segmented button {
  border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-weight: 500;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 26, 31, 0.12); }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 500; font-size: 13px; }
.field small { color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input { max-width: 320px; }
.toolbar .grow { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 4px 12px;
  cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

.switch { position: relative; display: inline-flex; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ route band (signature) */
.route-band {
  position: relative; background: var(--rail); color: #fff; border-radius: 14px; padding: 22px 26px 20px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px 22px; align-items: center; overflow: hidden;
}
.route-end { min-width: 0; }
.route-end b { display: block; font-size: 30px; line-height: 1.05; font-weight: 700; letter-spacing: -0.015em; }
.route-end span { font-size: 13px; color: var(--rail-ink); }
.route-end.right { text-align: right; }
.route-road { position: relative; height: 96px; }
.route-road::before { /* the asphalt lane */
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 30px; margin-top: -15px; border-radius: 15px; background: #2b333c;
}
.route-road::after { /* the yellow centre line */
  content: ""; position: absolute; left: 14px; right: 14px; top: 50%; height: 3px; margin-top: -1.5px;
  background: repeating-linear-gradient(to right, var(--signal) 0 16px, transparent 16px 28px);
}
.route-flow { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--rail-ink); }
.route-flow.top { top: 0; }
.route-flow.bottom { bottom: 0; justify-content: flex-end; }
.route-flow b { color: #fff; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.route-meter { height: 8px; border-radius: 4px; flex: none; min-width: 4px; }
.route-meter.ab { background: var(--s1); }
.route-meter.ba { background: var(--s2); }
.route-note { grid-column: 1 / -1; display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; color: var(--rail-ink); border-top: 1px solid #2f3842; padding-top: 14px; }
.route-note b { color: #fff; font-weight: 600; }
.route-empty { grid-column: 1 / -1; color: var(--rail-ink); }

/* ------------------------------------------------------------------ KPI strip */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 16px; }
.kpi { padding: 16px 18px; min-width: 0; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 13px; color: var(--ink-2); }
.kpi-value { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; margin-top: 4px; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); min-height: 24px; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--critical-ink); }
.delta.flat { color: var(--muted); }

/* ------------------------------------------------------------------ panels & charts */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-head p { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.panel-head .btn { flex: none; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 400 11px var(--font); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 3px; width: 14px; border-radius: 2px; vertical-align: 3px; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-pop); padding: 8px 10px; font-size: 12px;
  min-width: 120px; white-space: nowrap; opacity: 0; transition: opacity 0.08s;
}
.tooltip.on { opacity: 1; }
.tooltip b { display: block; font-weight: 600; margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.tooltip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.bar-row .bar-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.bar-row .bar-value small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.bar-track { grid-column: 1 / -1; height: 8px; border-radius: 0 4px 4px 0; background: transparent; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }
.bar-row.is-unknown .bar-fill { background: var(--line-strong); }
.bar-row:hover .bar-label { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); }

.segbar { display: flex; height: 16px; gap: 2px; margin: 4px 0 12px; }
.segbar span { min-width: 3px; border-radius: 3px; }
.seg-legend { display: grid; gap: 6px; font-size: 13px; }
.seg-legend div { display: flex; justify-content: space-between; gap: 10px; }
.seg-legend span:first-child { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); }
.seg-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.funnel { display: grid; gap: 12px; }
.funnel-step { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.funnel-step .bar-track { height: 22px; }
.funnel-step .bar-fill { border-radius: 0 4px 4px 0; }
.funnel-step small { color: var(--muted); font-weight: 400; }

.heat-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.heat-legend span.scale { display: inline-flex; gap: 2px; }
.heat-legend span.scale i { width: 16px; height: 10px; border-radius: 2px; display: inline-block; }

.table-wrap { overflow-x: auto; position: relative; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .actions { white-space: nowrap; text-align: right; }
.list-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list-panel .data-table th:first-child, .list-panel .data-table td:first-child { padding-left: 16px; }
.list-panel .data-table th:last-child, .list-panel .data-table td:last-child { padding-right: 16px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; line-height: 1; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.pro { background: #fff4d1; border-color: #f2d27a; color: #6b4d00; }
.tag.good { color: var(--good-ink); }
.tag.bad { color: var(--critical-ink); }
.tag.neg { color: var(--critical-ink); }
:root[data-theme="dark"] .tag.pro { background: #3a2f0c; border-color: #6b5413; color: #ffd76a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag.pro { background: #3a2f0c; border-color: #6b5413; color: #ffd76a; } }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.good { background: var(--good); }
.dot.critical { background: var(--critical); }
.dot.serious { background: var(--serious); }
.dot.warning { background: var(--warning); }
.dot.muted { background: var(--line-strong); }

.msg-text { max-width: 62ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { display: flex; gap: 6px 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 4px; }
.route-cell { font-weight: 600; white-space: nowrap; }
.who { display: grid; }
.who small { color: var(--muted); }

/* ------------------------------------------------------------------ telegram-like preview */
.tg-preview { background: #d5dfe8; border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
:root[data-theme="dark"] .tg-preview { background: #0e1621; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tg-preview { background: #0e1621; } }
.tg-bubble { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: #fff; color: #0f1419; border-radius: 12px 12px 12px 4px; padding: 9px 12px; max-width: 440px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.42; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12); }
:root[data-theme="dark"] .tg-bubble { background: #182533; color: #f2f5f8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tg-bubble { background: #182533; color: #f2f5f8; } }
.tg-bubble blockquote { margin: 4px 0; padding: 2px 0 2px 9px; border-left: 3px solid #3a8bd7; background: rgba(58, 139, 215, 0.08); border-radius: 0 6px 6px 0; }
.tg-buttons { display: grid; gap: 4px; max-width: 440px; margin-top: 4px; }
.tg-buttons span { background: rgba(255, 255, 255, 0.55); color: #10314f; text-align: center; padding: 7px; border-radius: 8px; font-size: 13px; font-weight: 500; }
:root[data-theme="dark"] .tg-buttons span { background: rgba(24, 37, 51, 0.9); color: #e1ecf6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tg-buttons span { background: rgba(24, 37, 51, 0.9); color: #e1ecf6; } }
.tg-caption { font-size: 12px; color: #4f6475; }
:root[data-theme="dark"] .tg-caption { color: #8ea4b8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tg-caption { color: #8ea4b8; } }

/* ------------------------------------------------------------------ settings rows */
.settings { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px; padding: 18px 20px; border-top: 1px solid var(--line); align-items: center; }
.setting:first-child { border-top: 0; }
.setting h3 { font-size: 15px; font-weight: 600; }
.setting p { color: var(--ink-2); margin-top: 3px; max-width: 70ch; }
.setting .wide { grid-column: 1 / -1; }
.mode-card { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; cursor: pointer; background: var(--surface); text-align: left; }
.mode-card[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mode-card b { font-size: 15px; }
.mode-card span { color: var(--ink-2); font-size: 13px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ------------------------------------------------------------------ test page */
.result-banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.result-banner b { font-size: 16px; display: block; }
.result-banner .dot { margin-top: 7px; width: 10px; height: 10px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ overlays */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 13, 16, 0.42); z-index: 40; }
.drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface);
  box-shadow: var(--shadow-pop); padding: 20px 22px 28px; overflow-y: auto; display: grid; gap: 16px; align-content: start;
  animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.drawer-head h2 { font-size: 18px; font-weight: 600; }
.dialog-backdrop { position: fixed; inset: 0; background: rgba(10, 13, 16, 0.42); z-index: 50; display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-pop); width: min(460px, 100%); padding: 20px 22px; display: grid; gap: 14px; }
.dialog h2 { font-size: 18px; font-weight: 600; }
.dialog p { color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toasts { position: fixed; z-index: 60; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-pop); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.toast.error { background: var(--critical); color: #fff; }
.menu { position: absolute; z-index: 30; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-pop); padding: 4px; min-width: 190px; display: grid; }
.menu button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.rel { position: relative; display: inline-block; }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--surface); }
.login-road { background: var(--rail); color: #fff; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 40px; }
.login-road::after { content: ""; position: absolute; left: 82%; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: repeating-linear-gradient(to bottom, var(--signal) 0 34px, transparent 34px 60px); opacity: 0.9; }
.login-road .brand { padding: 0; position: relative; z-index: 1; }
.login-places { position: relative; z-index: 1; display: grid; gap: 0; font-size: 44px; line-height: 1.02; font-weight: 700; letter-spacing: -0.02em; }
.login-places b { font-weight: 700; }
.login-places span { color: var(--rail-ink); font-size: 15px; font-weight: 400; letter-spacing: 0; margin-top: 10px; }
.login-form { display: grid; align-content: center; justify-items: start; padding: 40px; gap: 18px; max-width: 460px; }
.login-form h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.login-form ol { margin: 0; padding-left: 20px; color: var(--ink-2); display: grid; gap: 4px; }
.code-input { font-size: 28px; letter-spacing: 0.35em; font-variant-numeric: tabular-nums; text-align: center; height: 56px; width: 240px; }
.form-error { color: var(--critical-ink); font-size: 13px; min-height: 20px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px 6px; gap: 8px 10px; overflow: visible; }
  .rail .brand { flex: 1; }
  .rail .nav { order: 3; flex: 0 0 100%; }
  .route-flow span:not(.route-meter) { display: none; }
  .brand-sub, .nav-group, .rail-foot .status-line { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; scrollbar-width: none; margin: 0 -12px; padding: 0 8px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 8px 10px; white-space: nowrap; }
  .nav a[aria-current="page"]::before { left: 10px; right: 10px; top: auto; bottom: 2px; width: auto; height: 3px; background: repeating-linear-gradient(to right, var(--signal) 0 6px, transparent 6px 10px); }
  .nav svg { display: none; }
  .rail-foot { margin: 0; padding: 0; display: flex; }
  .rail-foot .theme-btn { display: none; }
  .main { padding: 20px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .route-band { grid-template-columns: 1fr 1fr; padding: 18px; }
  .route-road { grid-column: 1 / -1; grid-row: 2; }
  .route-end b { font-size: 24px; }
  .kpi { border-left: 0; border-top: 1px solid var(--line); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--line); }
  .login { grid-template-columns: 1fr; }
  .login-road { min-height: 220px; padding: 24px; }
  .login-places { font-size: 32px; }
  .login-form { padding: 28px 16px; }
  .mode-grid { grid-template-columns: 1fr; }
  .setting { grid-template-columns: 1fr; }
  .data-table .hide-sm { display: none; }
}
