/* Tariff monitor — dark only.
   Ink-blue night canvas, a lighter rail for navigation and filters, periwinkle for interaction.
   Operator colours are recognition marks next to the operator's name, never the only cue. */

@font-face {
  font-family: "Golos Text"; font-style: normal; font-display: swap; font-weight: 400 900;
  src: url("/static/vendor/fonts/golos-text-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text"; font-style: normal; font-display: swap; font-weight: 400 900;
  src: url("/static/vendor/fonts/golos-text-latin.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+20AC, U+20BD, U+2122, U+2190-2199, U+2212, U+2215, U+221E;
}
@font-face {
  font-family: "Unbounded"; font-style: normal; font-display: swap; font-weight: 200 900;
  src: url("/static/vendor/fonts/unbounded-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded"; font-style: normal; font-display: swap; font-weight: 200 900;
  src: url("/static/vendor/fonts/unbounded-latin.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+20AC, U+20BD, U+2122, U+2190-2199, U+2212, U+2215, U+221E;
}

[hidden] { display: none !important; }
[x-cloak] { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #11151f;          /* canvas */
  --rail: #161b28;        /* navigation + filters */
  --surface: #1a2030;     /* tables, panels */
  --head: #1f2638;        /* table headers */
  --raise: #252d42;       /* hover, inputs, active nav */
  --line: #2b3449;
  --line-soft: #222a3c;
  --text: #e7eaf3;
  --muted: #9aa3bc;
  --faint: #6c7590;
  --accent: #8ea6ff;
  --accent-ink: #0e1426;
  --good: #5fcf98;
  --warn: #e7b85c;
  --bad: #f2808a;
  --chip: #242c41;
  --chip-other: #2f2a22;
  --op-mts: #e04a4f; --op-beeline: #b8890a; --op-megafon: #1f9a58; --op-t2: #a95de0; --op-yota: #1b98bb;
  --radius: 8px;
  --rail-w: 288px;
  font: 400 14.5px/1.5 "Golos Text", system-ui, sans-serif;
  font-feature-settings: "tnum" 0;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: #b3c3ff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font: 600 1.55rem/1.2 "Unbounded", "Golos Text", sans-serif; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: .98rem; font-weight: 600; }
h2.section { margin: 28px 0 10px; }

/* Controls */
button, .button { font: inherit; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  border-radius: 6px; border: 1px solid var(--line); background: var(--raise); color: var(--text); cursor: pointer;
  text-decoration: none; line-height: 1.3; }
button:hover, .button:hover { border-color: #3a4560; color: var(--text); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: #a4b7ff; }
button.quiet { background: none; border-color: transparent; color: var(--muted); padding: 4px 6px; }
button.quiet:hover { color: var(--text); }
button.danger:hover { color: var(--bad); }
button.link { padding: 0; border: 0; background: none; color: var(--accent); font-size: inherit; }
button.link:hover { text-decoration: underline; }
input, select { font: inherit; font-size: .9rem; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; max-width: 100%; }
input:hover, select:hover { border-color: #3a4560; }
input::placeholder { color: var(--faint); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
input[type="date"] { color-scheme: dark; }
select[multiple] { padding: 4px; }
select[multiple] option { padding: 3px 6px; border-radius: 4px; }
select[multiple] option:checked { background: var(--raise) linear-gradient(0deg, var(--raise), var(--raise)); color: var(--text); }
form.inline { display: inline; }

/* Shell: top bar with the sections, a filter rail on pages that have filters */
.shell { min-height: 100vh; --top-h: 56px; }
header.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px 28px; min-height: var(--top-h);
  padding: 0 24px; background: var(--rail); border-bottom: 1px solid var(--line); }
.brand { font: 600 .98rem/1.25 "Unbounded", "Golos Text", sans-serif; color: var(--text); text-decoration: none;
  letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.pages { display: flex; align-self: stretch; gap: 4px; }
.pages a { display: flex; align-items: center; padding: 0 12px; color: var(--muted); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pages a:hover { color: var(--text); }
.pages a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: .85rem; }
.langs { display: flex; gap: 10px; }
.langs a { color: var(--faint); text-decoration: none; font-weight: 600; }
.langs a[aria-current="true"] { color: var(--text); }
.frame { display: block; }
.has-rail .frame { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.rail { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 18px 18px 24px;
  background: var(--rail); border-right: 1px solid var(--line); scrollbar-width: thin; }
.stage { min-width: 0; padding: 26px 40px 56px; }
.stage > * { max-width: 1480px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; min-height: 40px; margin-bottom: 22px; }
.bar h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bar-actions { margin-left: auto; display: flex; gap: 10px; }
.bar-actions:empty { display: none; }
.filters-toggle { display: none; }
.scrim { display: none; }
main.solo { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }

/* Rail filters: each group folds */
.rail-filters { display: flex; flex-direction: column; gap: 10px; }
.rail-head { display: flex; align-items: baseline; gap: 8px; padding-bottom: 6px; }
.rail-head h2 { font-size: .95rem; }
.rail-head .count { color: var(--accent); font-size: .8rem; }
.rail-head .reset { margin-left: auto; font-size: .82rem; color: var(--muted); }
.rail .filters { display: flex; flex-direction: column; }
.fgroup { border-top: 1px solid var(--line-soft); }
.fgroup:last-of-type { border-bottom: 1px solid var(--line-soft); }
.fgroup > summary { display: flex; align-items: center; gap: 8px; padding: 10px 2px; cursor: pointer; list-style: none;
  color: var(--muted); font-size: .85rem; font-weight: 600; }
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s ease-out; }
.fgroup[open] > summary { color: var(--text); }
.fgroup[open] > summary::after { transform: rotate(45deg); }
.fgroup > summary:hover { color: var(--text); }
.fbody { display: flex; flex-direction: column; gap: 7px; padding: 0 2px 14px; }
.filters fieldset { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.filters legend, .filters .field { color: var(--muted); font-size: .8rem; font-weight: 500; }
.filters legend { padding: 0; margin-bottom: 6px; }
.filters .field { display: flex; flex-direction: column; gap: 6px; }
.filters .field > input, .filters .field > select, .rail .filters select, .rail .filters input[type="date"] { width: 100%; color: var(--text); }
.filters label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; font-weight: 400; cursor: pointer; }
.filters .pair { display: flex; gap: 6px; align-items: center; color: var(--faint); }
.filters .pair input { flex: 1 1 0; min-width: 0; }
.filters .pair-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .hint { color: var(--faint); font-size: .8rem; }
.region-search { width: 100%; }
.rail .filters .apply { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); padding: 0; border: 0; }

/* Content */
#content { transition: opacity .12s ease-out; }
#content.htmx-request { opacity: .55; }
.meta { color: var(--muted); margin: 6px 0; font-size: .88rem; }
.notice { margin: 10px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--chip-other); color: #f0dcc0; font-size: .9rem; }
.notice.error, .error { color: var(--bad); }
.empty { margin: 18px 0; padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 10px; color: var(--muted); font-size: .88rem; }
.toolbar .button { font-size: .85rem; padding: 5px 12px; }

/* Headline numbers: the one loud element */
.kpis { display: flex; flex-wrap: wrap; gap: 16px 64px; padding: 4px 0 22px; margin-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.kpi { min-width: 220px; max-width: 420px; }
.kpi h2 { font-size: .85rem; font-weight: 500; color: var(--muted); }
.kpi .figure { margin: 4px 0 2px; font: 500 2.35rem/1.1 "Unbounded", "Golos Text", sans-serif; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; }
.kpi .sub { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }
.kpi .sub .op { color: var(--text); }
.delta { margin: 6px 0 0; color: var(--faint); font-size: .85rem; }
.delta .up { color: var(--bad); font-weight: 600; }
.delta .down { color: var(--good); font-weight: 600; }

/* Operator mark */
.op { white-space: nowrap; }
.op::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 2px;
  background: var(--op, var(--faint)); vertical-align: 1px; }
.op-mts { --op: var(--op-mts); }
.op-beeline { --op: var(--op-beeline); }
.op-megafon { --op: var(--op-megafon); }
.op-t2 { --op: var(--op-t2); }
.op-yota { --op: var(--op-yota); }

/* Tables */
.table-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
table.data th { background: var(--head); color: var(--muted); font-size: .8rem; font-weight: 600; white-space: nowrap;
  border-bottom-color: var(--line); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: rgba(142, 166, 255, .045); }
table.data .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data small { color: var(--muted); }
table.data a { text-decoration: none; }
table.data a:hover { text-decoration: underline; }
table.data a.out { color: var(--faint); }
table.data a.out:hover { color: var(--accent); text-decoration: none; }
table.data.compact th, table.data.compact td { padding: 5px 10px; }
.chip { display: inline-block; max-width: 100%; margin: 0 4px 4px 0; padding: 1px 7px; border-radius: 5px; background: var(--chip);
  color: #c9d0e3; font-size: .78rem; line-height: 1.55; }
td.perks { min-width: 240px; max-width: 420px; }
.chip.other { background: var(--chip-other); color: #dccfb8; }
.badge { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: .75rem; }
.unmapped { color: var(--muted); }
.kind { font-size: .82rem; font-weight: 600; }
.kind-new, .status.ok { color: var(--good); }
.kind-changed, .status.partial { color: var(--warn); }
.kind-removed, .status.failed { color: var(--bad); }
.kind-cosmetic { color: var(--faint); }
.status { font-size: .85rem; font-weight: 600; }
.status.running { color: var(--accent); }
.bar h1 .status { font: 600 .8rem/1 "Golos Text", sans-serif; padding: 5px 9px; border-radius: 999px; background: var(--raise); }

/* Dashboards */
table.grouped tr.group { cursor: pointer; }
table.grouped tr.group td { border-bottom-color: var(--line-soft); }
table.grouped tbody.open tr.group td { background: rgba(142, 166, 255, .05); }
table.grouped button.disclose { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none;
  color: var(--text); font-size: inherit; }
table.grouped button.disclose::before { content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--faint);
  border-bottom: 1.5px solid var(--faint); transform: rotate(-45deg); transition: transform .15s ease-out; }
table.grouped tbody.open button.disclose::before { transform: rotate(45deg); }
table.grouped tr.sub td { background: rgba(0, 0, 0, .12); font-size: .86rem; }
table.grouped tr.sub td:first-child { padding-left: 46px; }
.dash { margin-bottom: 8px; }
.dash > summary { cursor: pointer; font-weight: 600; margin-bottom: 12px; list-style-position: outside; width: fit-content; }
.dash > summary .meta { font-weight: 400; margin-left: 6px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.dash-card { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.dash-card .meta { font-size: .84rem; }
.dash-card table.data { margin: 8px -16px 0; width: calc(100% + 32px); border-top: 1px solid var(--line-soft); }
.dash-card table.data th { background: transparent; }
.dash-card table.data th:first-child, .dash-card table.data td:first-child { padding-left: 16px; }
.dash-card table.data th:last-child, .dash-card table.data td:last-child { padding-right: 16px; }

/* Run status strip */
.banner { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: var(--radius); font-size: .85rem; }
.banner.running { background: #1d2a4d; color: #d3dcff; }
.banner.done { background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.banner.idle { padding: 0; }
.banner.idle button { font-size: .82rem; padding: 4px 10px; }
.top .banner { max-width: 520px; }

/* Runs */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 24px; margin: 0 0 18px; }
.facts div { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }

/* Settings */
.settings-block { margin-bottom: 22px; }
.settings-block > h2 { margin-bottom: 4px; }
.settings-block > h3 { margin: 22px 0 12px; }
.list-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.list-tools input { flex: 1 1 260px; max-width: 360px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 18px; max-height: 360px;
  overflow-y: auto; margin: 10px 0 14px; padding: 10px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.checklist label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.row-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.rule-form { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 18px 32px; }
.rule-form .field.wide { flex: 1 1 100%; max-width: 420px; }
.rule-form fieldset { min-width: 180px; }
.rule-form .actions { flex: 1 1 100%; display: flex; gap: 14px; align-items: center; }

/* Trends */
.chart-panel { padding: 10px; }
#chart { width: 100%; height: 600px; color: var(--muted); }

/* Login */
.login { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; }
.login .brand { margin: 0 0 6px; color: var(--muted); font-size: .9rem; }
.login h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login .field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .85rem; }
.login button { justify-content: center; padding: 9px; margin-top: 4px; }

/* Narrow screens: the top bar wraps, the rail becomes a drawer */
@media (max-width: 960px) {
  header.top { position: static; flex-wrap: wrap; padding: 10px 16px 0; gap: 6px 16px; }
  .top-tools { margin-left: auto; }
  .pages { order: 3; flex: 1 1 100%; overflow-x: auto; margin: 0 -16px; padding: 0 4px; }
  .pages a { padding: 10px 12px; white-space: nowrap; }
  .has-rail .frame { display: block; }
  .rail { position: fixed; z-index: 40; left: 0; top: 0; height: 100vh; width: min(var(--rail-w), 86vw);
    transform: translateX(-100%); transition: transform .2s ease-out; }
  .rail.open { transform: none; box-shadow: 0 0 0 100vmax rgba(5, 8, 15, .55); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; }
  .filters-toggle { display: inline-flex; }
  .stage { padding: 16px 16px 40px; }
  .bar { margin-bottom: 16px; }
  h1 { font-size: 1.2rem; }
  .kpis { gap: 18px 32px; }
  .kpi .figure { font-size: 1.9rem; }
  #chart { height: 440px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
