/* Токены Bidvol: значения из превью, переменные Pico переопределены под бордовый акцент. */
:root, :root:not([data-theme=dark]) { --bg: #F3F3F5; --row-alt: #FAFAFB; --surface: #FFFFFF; --ink: #1C1C1E; --ink-2: #6E6E73; --ink-3: #A1A1A6; --ink-subtle: #606065; --hair: #D1D1D6; --tint: #A81515; --tint-soft: #FBECEC; --brand: #A81515; --ok: #34C759; --warn: #FF9500; --bad: #FF3B30; --idle: #8E8E93; --ok-ink: #1C8036; --bad-ink: #C9302C; --ex-bg: #FFF1E0; --ex-ink: #A85A00; --ex-chip: #AB5D00; --radius: 10px; --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color-scheme: light;
  --pico-font-family: var(--font); --pico-font-size: 15px; --pico-line-height: 1.4; --pico-background-color: var(--bg); --pico-color: var(--ink); --pico-muted-color: var(--ink-2); --pico-primary: var(--tint); --pico-primary-background: var(--tint); --pico-primary-border: var(--tint); --pico-primary-hover: #8C1010; --pico-primary-hover-background: #8C1010; --pico-primary-focus: rgba(168,21,21,.18); --pico-border-radius: var(--radius); --pico-form-element-background-color: var(--surface); --pico-form-element-border-color: var(--hair); --pico-form-element-focus-color: var(--tint); --pico-table-border-color: var(--hair); --pico-spacing: 1rem; }
html, body { background: var(--bg); color: var(--ink); }
body { font-family: var(--font); font-size: 15px; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
a { color: var(--tint); text-decoration: none; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
html:not(.js) .js-only { display: none !important; }
.skip-link { position: absolute; left: 12px; top: -64px; z-index: 100; background: var(--surface); color: var(--tint); padding: 10px 16px; border-radius: var(--radius); box-shadow: 0 0 0 .5px var(--hair); }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }

/* Оболочка: сайдбар, топбар, таб-бар. На планшете подписи скрываются визуально, а не display:none. */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--bg); border-right: .5px solid var(--hair); padding: 20px 12px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.side .logo { padding: 4px 12px; }
.side .logo img { height: 22px; width: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; }
.nav a { display: flex; align-items: center; gap: 14px; padding: 0 12px; height: 46px; color: var(--ink-2); border-radius: 10px; font-size: 15px; letter-spacing: .005em; transition: background .15s, color .15s; }
.nav a:hover { color: var(--ink); background: rgba(0,0,0,.035); }
.nav a:focus-visible { outline-offset: -2px; }
.mark { width: 24px; height: 26px; flex: none; overflow: visible; }
.mark .hex { fill: #C7C7CC; transition: fill .15s; }
.nav a:hover .mark .hex { fill: var(--ink-3); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); font-weight: 600; box-shadow: 0 0 0 .5px var(--hair); }
.nav a[aria-current="page"] .mark .hex, .tabbar a[aria-current="page"] .mark .hex { fill: var(--brand); }
.main { min-width: 0; padding: 28px max(16px, env(safe-area-inset-right, 0px)) 48px 36px; }
.main:focus { outline: none; }
.wrap { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head h1 { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; margin: 0; color: var(--ink); }
.head .sub { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range { font-size: 15px; color: var(--ink); font-weight: 500; }
.spacer { flex: 1 1 0; }
.stand { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #8A5A00; background: #FFF4E0; border-radius: 99px; padding: 2px 10px; }
.stand::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: -6px; }
.topbar form { margin: 0; }
.topbar .email { font-size: 14px; font-weight: 500; color: var(--ink); }
.iconbtn { all: unset; box-sizing: border-box; cursor: pointer; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-2); }
.iconbtn:hover { background: rgba(0,0,0,.05); color: var(--ink); }
.iconbtn:focus-visible { outline: 2px solid var(--tint); }
.iconbtn svg, .ic { width: 20px; height: 20px; }
.tabbar { display: none; }
.progress { position: fixed; left: 0; top: 0; height: 2px; width: 100%; background: var(--tint); transform: scaleX(0); transform-origin: left; opacity: 0; z-index: 90; pointer-events: none; }
.progress.htmx-request { opacity: 1; transform: scaleX(.85); transition: transform 8s cubic-bezier(.1,.7,.3,1); }
.flash:empty, .toast-host:empty { display: none; }
.kit-block { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.kit-block .side { position: static; height: auto; width: 248px; border: .5px solid var(--hair); border-radius: var(--radius); }
.kit-block .side.compact { width: 72px; padding: 20px 10px; align-items: center; }
.kit-block .logo-dark { background: var(--surface); padding: 12px 16px; border-radius: var(--radius); }
.kit-icons { display: flex; gap: 16px; align-items: center; color: var(--ink-2); }
.kit-block .logo-dark img { height: 22px; width: auto; display: block; }
.kit-block .errpage { align-self: stretch; }
.kit-icons svg { width: 20px; height: 20px; }
.kit-nav { display: flex; justify-content: flex-start; gap: 16px; flex-wrap: wrap; }
.kit h2 { font-size: 22px; margin: 28px 0 12px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 72px minmax(0, 1fr); }
  .app > .side { padding: 20px 10px; align-items: center; }
  .app > .side .logo img { height: 18px; width: 46px; object-fit: cover; object-position: left; }
  .app > .side .nav a { padding: 0; justify-content: center; width: 48px; }
  .app > .side .nav a .txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .main { padding-left: 24px; }
}
.compact .logo img { height: 18px; width: 46px; object-fit: cover; object-position: left; }
.compact .nav a { padding: 0; justify-content: center; width: 48px; }
.compact .nav a .txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 640px) {
  .topbar .stand, .app .spacer { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .app > .side { display: none; }
  .main { padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(84px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .head h1 { font-size: 30px; }
  .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(249,249,249,.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: .5px solid var(--hair); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--ink-2); padding: 2px 0; }
  .tabbar a[aria-current="page"] { color: var(--ink); font-weight: 600; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Таблица: inset-группа, строки 44, липкие шапка и «Итого», закреплённая первая колонка. Pico стилизует table, поэтому поля сброшены. */
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.tbl { overflow-x: auto; }
.tbl table { margin: 0; width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; background: var(--surface); color: var(--ink); }
.tbl th, .tbl td { padding: 0 14px; height: 44px; border: 0; background: var(--surface); vertical-align: middle; color: inherit; }
.tbl thead th { height: 36px; font-size: 12px; font-weight: 500; color: var(--ink-2); border-bottom: .5px solid var(--hair); position: sticky; top: 0; z-index: 1; white-space: nowrap; text-align: left; }
.tbl thead th.n { text-align: right; }
.tbl thead th a { color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.tbl thead th[aria-sort] a { color: var(--ink); }
.tbl thead th[aria-sort="ascending"] a::after, .tbl thead th[aria-sort="descending"] a::after { color: var(--tint); font-size: 10px; }
.tbl thead th[aria-sort="ascending"] a::after { content: "▲"; }
.tbl thead th[aria-sort="descending"] a::after { content: "▼"; }
.tbl tbody td { border-bottom: .5px solid var(--hair); }
.tbl tbody tr:last-child td, .tbl tbody tr:last-child th { border-bottom: 0; }
.tbl tbody th, .tbl thead tr.total th { font-weight: 400; text-align: left; white-space: nowrap; }
.tbl tbody th { padding: 0 14px 0 16px; border-bottom: .5px solid var(--hair); }
.tbl thead tr.total th, .tbl thead tr.total td { position: sticky; top: 36px; z-index: 1; height: 44px; font-weight: 600; font-size: 14px; color: var(--ink); background: var(--row-alt); border-bottom: .5px solid var(--hair); }
.tbl thead tr.total th:first-child { z-index: 3; }
.tbl thead tr.total .pc { font-weight: 400; }
.tbl tbody tr.link { cursor: pointer; }
.tbl tbody tr.link:hover td, .tbl tbody tr.link:hover th { background: #F7F7FA; }
.tbl tbody tr.link:active td, .tbl tbody tr.link:active th { background: #E9E9EE; }
.tbl tbody tr.weekend td, .tbl tbody tr.weekend th { background: var(--row-alt); }
.tbl tbody tr.top td, .tbl tbody tr.top th { vertical-align: top; padding-top: 12px; padding-bottom: 12px; height: auto; }
.tbl td.chev, .tbl th.chev { width: 28px; padding-left: 0; color: #C7C7CC; text-align: right; }
.tbl td:first-child, .tbl th:first-child { padding-left: 16px; }
.rowlink { color: inherit; }
.rowlink:focus-visible { outline-offset: 3px; border-radius: 3px; }
.pc { display: inline-block; min-width: 46px; margin-left: 8px; font-size: 12px; color: var(--ink-subtle); text-align: right; }
.tbl.wide, #sites-region .tbl:has(> table), #pl-region .tbl:has(> table) { max-height: calc(100vh - 120px); overflow: auto; }
.tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; z-index: 2; box-shadow: .5px 0 0 var(--hair); }
.tbl thead th:first-child { z-index: 4; }
.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 4px; color: var(--ink-2); font-size: 13px; flex-wrap: wrap; }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.empty .textbtn { display: block; margin: 8px auto 0; }

/* Ячейки: идентификатор, значок площадки, QPS, статус, составные значения, динамика. */
.tbl td.id { color: var(--ink-subtle); font-size: 12px; font-variant-numeric: tabular-nums; }
.qps { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 18px; padding: 0 6px; border-radius: 9px; background: #EBEBEF; color: var(--ink-subtle); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }
.qps.on { background: var(--tint-soft); color: var(--tint); }
.tbl td.kv { font-size: 13px; color: var(--ink-2); line-height: 1.5; min-width: 220px; }
.kv b { color: var(--ink); font-weight: 400; }
.tag { display: inline-block; vertical-align: 1px; font-size: 11px; font-weight: 600; letter-spacing: .03em; color: var(--ink-subtle); background: var(--bg); border-radius: 5px; padding: 1px 6px; }
.cellname b { font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cellname b a { color: inherit; }
.cellname > span { display: block; font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.site { display: flex; align-items: center; gap: 12px; min-width: 0; }
.appicon { width: 30px; height: 30px; border-radius: 7px; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; text-transform: uppercase; }
.appicon.c0 { background: #007AFF; } .appicon.c1 { background: #FF2D55; } .appicon.c2 { background: #34C759; } .appicon.c3 { background: #FF9500; }
.appicon.c4 { background: #5856D6; } .appicon.c5 { background: #5AC8FA; } .appicon.c6 { background: #8E8E93; } .appicon.c7 { background: #4CD964; }
.ext { color: var(--ink-3); display: inline-flex; padding: 4px; }
.ext:hover { color: var(--tint); }
.ext svg { width: 14px; height: 14px; }
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.status[data-s="active"] { --c: var(--ok); } .status[data-s="moderation"] { --c: var(--warn); }
.status[data-s="rejected"] { --c: var(--bad); } .status[data-s="paused"] { --c: var(--idle); }
.why { display: block; color: var(--ink-2); font-size: 12px; margin-top: 2px; }
.spark { width: 84px; height: 24px; display: block; }
.spark-line { fill: none; stroke: var(--tint); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--tint); opacity: .1; stroke: none; }
.spark-dot { fill: var(--tint); }
.spark-empty { stroke: var(--hair); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.trend { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.trend .d { font-size: 12px; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--ok-ink); } .down { color: var(--bad-ink); } .flat { color: var(--ink-subtle); }

/* Контролы: сегменты, пилюли, поиск, панель параметров. Нативные radio/checkbox скрыты визуально, но доступны с клавиатуры. */
.seg input, .pill > input, .opt > input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; appearance: none; }
fieldset.seg { display: inline-flex; width: auto; min-width: 0; margin: 0; padding: 0; border: 1px solid var(--tint); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg label { position: relative; display: block; margin: 0; flex: none; }
.seg label + label { border-left: 1px solid var(--tint); }
.seg span { display: block; padding: 5px 14px; font-size: 13px; line-height: 1.4; color: var(--tint); white-space: nowrap; cursor: pointer; user-select: none; }
.seg input:checked + span { background: var(--tint); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--tint); outline-offset: -4px; }
.seg input:checked:focus-visible + span { outline-color: #fff; }
.seg.wide { display: flex; width: 100%; }
.seg.wide label { flex: 1; }
.seg.wide span { text-align: center; padding: 6px 8px; }
.seg.scroll { max-width: 100%; overflow-x: auto; }
.toolbar { display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; }
fieldset.chips { margin: 0; padding: 0; border: 0; width: auto; min-width: 0; gap: 8px; }
div.chips:empty { display: none; }
.toolbar.filters, fieldset.chips { gap: 8px; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 5px 12px; border-radius: 99px; font-size: 13px; line-height: 1.3; color: var(--ink); background: var(--surface); border: .5px solid var(--hair); white-space: nowrap; cursor: pointer; text-decoration: none; }
.pill .c { color: var(--ink-subtle); font-variant-numeric: tabular-nums; }
.pill:has(input:checked), a.pill.x { background: var(--tint); color: #fff; border-color: var(--tint); }
.pill:has(input:checked) .c { color: rgba(255,255,255,.75); }
.pill:has(input:focus-visible), a.pill:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }
a.pill:hover { text-decoration: none; }
a.pill.x::after { content: "×"; font-size: 15px; line-height: 1; opacity: .8; }
a.pill.exc { background: var(--ex-chip); border-color: var(--ex-chip); }
.muted-in { opacity: .75; }
a.pill.exc .muted-in, a.pill.exc::after { opacity: 1; }
.search { position: relative; display: block; margin: 0; flex: 1 1 240px; max-width: 360px; }
.search input[type=search] { margin: 0; height: 36px; padding: 0 12px 0 34px; border: 0; border-radius: 10px; background: #E3E3E8; background-image: none; font-size: 15px; box-shadow: none; }
.search input[type=search]:focus { background: #E3E3E8; box-shadow: 0 0 0 3px var(--pico-primary-focus); }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-2); pointer-events: none; }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
kbd { font-family: inherit; font-size: 11px; padding: 1px 5px; background: #E3E3E8; color: var(--ink-2); border-radius: 4px; box-shadow: none; }
.textbtn { all: unset; cursor: pointer; color: var(--tint); font-size: 15px; }
.textbtn.small { font-size: 13px; }
.textbtn.strong { font-weight: 600; }
.textbtn:focus-visible { outline: 2px solid var(--tint); outline-offset: 3px; border-radius: 3px; }
.panel { padding: 4px 0; background: var(--surface); border-radius: var(--radius); overflow: visible; }
.prow { position: relative; display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px 16px; }
.prow + .prow::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--hair); }
.plabel { padding-top: 6px; font-size: 13px; color: var(--ink-2); }
.pbody { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.pbody.toolbar { flex-direction: row; }
@media (max-width: 640px) {
  .prow { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .plabel { padding-top: 0; }
  .search { max-width: none; flex-basis: 100%; }
  div.chips, fieldset.chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
}
@media (prefers-reduced-motion: reduce) { .seg span, .pill { transition: none; } }
.kit-tall { min-height: 440px; }
.kit-form { margin: 0; }
.pbody:not(.toolbar) .search { flex: none; width: 100%; }

.controls-toast { position: fixed; z-index: 60; inset: auto 16px calc(76px + env(safe-area-inset-bottom, 0px)); width: fit-content; max-width: calc(100% - 32px); margin: auto; padding: 8px 14px; border-radius: var(--radius); background: var(--ink); color: white; font-size: 14px; }

#pl-form { display: flex; flex-direction: column; gap: 22px; }
#pl-form > .chips { align-self: flex-start; }
#sites-form + .region, #pl-form + .region { display: grid; gap: 22px; min-width: 0; }
#sites-table tbody th, #pl-table tbody th { color: var(--ink-subtle); font-size: 12px; font-variant-numeric: tabular-nums; }
#pl-table tbody tr.top .n, #pl-table tbody tr.top td:nth-child(8), #pl-table tbody tr.top .chev { vertical-align: middle; }
@media (max-width: 640px) { #pl-form .head > .period { width: 100%; } }

#stats-form { display: flex; flex-direction: column; gap: 22px; margin: 0; }
#stats-form .pbody > .seg, #stats-form .pbody > .period { margin-bottom: 1rem; }
#stats-state { display: none; }
#stats-region { display: flex; flex-direction: column; gap: 22px; }

/* Поповеры <details>: сброс стилей Pico для summary, список вариантов, нижний лист на телефоне. */
details.dd { position: relative; display: block; margin: 0; padding: 0; border: 0; }
details.dd[open] > summary { margin: 0; }
details.dd > summary { --dd-ink: var(--ink); --pico-accordion-close-summary-color: var(--dd-ink); --pico-accordion-open-summary-color: var(--dd-ink); --pico-accordion-active-summary-color: var(--dd-ink); color: var(--dd-ink); list-style: none; }
details.dd > summary::-webkit-details-marker { display: none; }
details.dd > summary::marker { content: none; }
details.dd > summary::after { content: none; display: none; }
details.dd > summary:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; color: var(--dd-ink); }
.ddbtn { padding: 6px 10px 6px 14px; font-size: 14px; width: auto; }
.ddbtn .caret { width: 12px; height: 12px; color: var(--ink-2); }
.ddbtn .ic { width: 16px; height: 16px; color: var(--ink-2); }
.ddbtn.on { --dd-ink: var(--tint); background: var(--tint-soft); border-color: transparent; font-weight: 500; }
.ddbtn.on .caret { color: var(--tint); }
.ddbtn.ex { --dd-ink: var(--ex-ink); background: var(--ex-bg); border-color: transparent; }
.ddbtn.ex .caret { color: var(--ex-ink); }
.dd[open] > .ddbtn { border-color: var(--tint); }
.pop { position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; width: 320px; background: var(--surface); border-radius: 13px; box-shadow: 0 12px 32px rgba(0,0,0,.14), 0 0 0 .5px rgba(0,0,0,.08); overflow: hidden; }
.pop.right, .pop-end > .pop { left: auto; right: 0; }
.pop .ps { padding: 10px; border-bottom: .5px solid var(--hair); }
.pop .ps .search { max-width: none; }
.pop .ps .search input[type=search] { height: 34px; font-size: 14px; }
.pop .opts { display: block; width: auto; max-height: 308px; overflow-y: auto; overscroll-behavior: contain; }
.opts > .opt, .opt { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; margin: 0; padding: 6px 16px; cursor: pointer; }
.opt + .opt::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--hair); }
.opts > .opt { width: 100%; flex: none; }
.opt:hover { background: #F7F7FA; }
.opt:has(input:focus-visible) { outline: 2px solid var(--tint); outline-offset: -2px; }
.opt .ot { min-width: 0; line-height: 1.25; }
.opt .ot b { display: block; font-weight: 400; font-size: 15px; }
.opt .ot small { display: block; font-size: 12px; color: var(--ink-2); }
.opt .chk { margin-left: auto; width: 20px; height: 20px; color: var(--tint); visibility: hidden; flex: none; }
.opt:has(input:checked) .chk { visibility: visible; }
.opt:has(input:checked) .ot b { font-weight: 500; }
.pop .pf { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: .5px solid var(--hair); font-size: 13px; background: var(--row-alt); }
.pop .empty { margin: 0; padding: 20px; font-size: 14px; }
@media (max-width: 640px) {
  .pop, .pop.right, .pop-end > .pop { position: fixed; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); top: auto; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); width: auto; z-index: 45; }
  .pop .opts { max-height: min(308px, 45vh); }
}
.opt[hidden], .pop .empty[hidden] { display: none; }

/* Выбор периода: пресеты, свой диапазон и ошибка проверки. */
.period { display: flex; align-items: stretch; max-width: 100%; }
.period > .seg { border-radius: 7px 0 0 7px; overflow-x: auto; }
.period details.period-custom > summary { display: flex; height: 100%; margin-left: -1px; padding: 5px 14px; border: 1px solid var(--tint); border-radius: 0 7px 7px 0; --dd-ink: var(--tint); font-size: 13px; line-height: 1.4; }
.period .period-custom > summary.on { --dd-ink: #fff; background: var(--tint); }
@media (max-width: 640px) { .period .seg span, .period details.period-custom > summary { padding-inline: 5px; } .head .period .seg { flex: 1; } .head .period .seg label { flex: 1 0 auto; text-align: center; } }
.period .pf button[type=submit] { width: auto; margin-inline-start: auto; }
.dates { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 12px; padding: 16px; }
.dates label { margin: 0; font-size: 14px; color: var(--ink-2); }
.dates input { margin: 0; height: 40px; font-size: 15px; }
.perr { margin: -6px 16px 12px; color: var(--bad-ink); font-size: 13px; }
.range { font-size: 15px; font-weight: 500; color: var(--ink); }
.range .muted { font-weight: 400; }

/* KPI: одна inset-группа с волосяными разделителями; значения подстраиваются под ширину карточки и не выходят за неё. */
.kpis { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(4, minmax(0, 1fr)); }
.kpi { padding: 16px 18px 14px; position: relative; min-width: 0; container-type: inline-size; }
.kpi + .kpi::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; border-left: .5px solid var(--hair); }
.kpi .t { font-size: 13px; color: var(--ink-2); }
.kpi .v { font-size: clamp(17px, 13.5cqi, 24px); font-weight: 600; letter-spacing: -.015em; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.main .v { font-size: clamp(22px, 12cqi, 32px); }
.kpi .d { font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 3px; white-space: nowrap; min-height: 18px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi.main { grid-column: span 3; }
  .kpi:nth-child(2)::before, .kpi:nth-child(5)::before { display: none; }
  .kpi:nth-child(n+2) { border-top: .5px solid var(--hair); }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi.main { grid-column: span 2; }
  .kpi:nth-child(n)::before { display: none; }
  .kpi:nth-child(odd):not(.main)::before { display: block; }
}

/* Загрузка и обратная связь: полупрозрачный регион, флеш с повтором, тост. Полоса #progress — в 10-shell.css. */
.region { transition: opacity .15s; }
/* После смешения с фоном страницы тексту таблицы и подвала нужен полный тональный диапазон. */
.region.htmx-request { opacity: .55; transition-delay: .3s; --ink: #000; --ink-2: #000; --ink-3: #000; --ink-subtle: #000; --tint: #000; --ok-ink: #000; --bad-ink: #000; }
.region.htmx-request :is(.qps, .tag, kbd) { color: var(--ink); background: var(--surface); }
.region.htmx-request :is(.textbtn, .rowlink) { text-decoration: underline; }
.region.htmx-request .tbl tbody tr.link:active :is(td, th) { background: var(--row-alt); }
.flash { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 16px; max-width: calc(100vw - 32px); padding: 10px 16px; background: var(--surface); color: var(--ink); border-radius: var(--radius); border-left: 3px solid var(--bad); box-shadow: 0 0 0 .5px var(--hair); font-size: 14px; }
.flash.flash-static { position: static; transform: none; width: fit-content; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: rgba(28,28,30,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; }
@media (max-width: 640px) { .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); width: max-content; max-width: calc(100% - 32px); } }
@media (prefers-reduced-motion: reduce) { .region, .progress.htmx-request { transition: none; } }
.flash button { all: unset; cursor: pointer; color: var(--tint); font-size: 14px; }
.flash button:focus-visible { outline: 2px solid var(--tint); outline-offset: 3px; border-radius: 3px; }

/* Страница входа: bare-раскладка, одна колонка 380 px. */
.login { min-height: 100vh; display: grid; place-items: center; padding: 32px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); }
.login .box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; margin: 0; }
.login .logo { display: flex; justify-content: center; padding-bottom: 6px; }
.login .logo img { height: 30px; width: auto; }
.login h1 { text-align: center; font-size: 22px; font-weight: 600; margin: 0; color: var(--ink); }
.login .form-group { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.login .fld { display: flex; align-items: center; padding: 0 16px; height: 48px; position: relative; }
.login .fld + .fld::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--hair); }
.login .form-group .fld input, .login .form-group .fld input:focus { margin: 0; border: 0; padding: 0; height: 46px; background: transparent; box-shadow: none; outline: 0; font-size: 16px; }
.login .form-group:focus-within { box-shadow: 0 0 0 3px var(--pico-primary-focus); }
.login .fld:focus-within { box-shadow: inset 0 0 0 2px var(--tint); }
.login .eye { all: unset; cursor: pointer; color: var(--tint); font-size: 14px; padding-left: 8px; }
.login .eye:focus-visible { outline: 2px solid var(--tint); }
.login .opts { display: flex; justify-content: space-between; align-items: center; font-size: 14px; padding: 0 4px; }
.login .opts label { margin: 0; display: flex; gap: 8px; align-items: center; }
.login .opts input[type=checkbox] { margin: 0; }
.login .forgot summary { cursor: pointer; color: var(--tint); list-style: none; }
.login .forgot summary::-webkit-details-marker { display: none; }
.login .forgot summary::after { display: none; }
.login .forgot { margin: 0; text-align: right; }
.login button.primary { width: 100%; height: 48px; border-radius: 12px; font-size: 17px; font-weight: 600; margin: 0; padding: 0; }
.login .err { background: #FFEBEA; color: var(--bad-ink); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; }
.login .hint { text-align: center; font-size: 13px; color: var(--ink-2); margin: 8px 0 0; }
.login .stand { align-self: center; }
.kit .login { min-height: 0; padding: 24px 0; }

/* Страницы ошибок: bare-раскладка по центру. */
.errfull { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 0; }
.errpage { margin: 0; display: grid; justify-items: center; gap: 12px; text-align: center; padding: 32px 16px; }
.errpage img { height: 26px; width: auto; margin-bottom: 18px; }
.errpage .code { margin: 0; font-size: 64px; line-height: 1; font-weight: 700; letter-spacing: -.03em; color: var(--tint); font-variant-numeric: tabular-nums; }
.errpage h1 { margin: 0; font-size: 22px; font-weight: 600; }
.errpage p { margin: 0; color: var(--ink-2); max-width: 420px; }
.errpage .reqid { font-size: 12px; color: var(--ink-subtle); }
.errpage .act { display: inline-flex; align-items: center; height: 44px; padding: 0 22px; margin-top: 10px; background: var(--tint); color: #fff; border-radius: 12px; font-weight: 600; }
.errpage .act:hover { background: #8C1010; }
.kit .errpage { padding: 24px 16px; background: var(--surface); border-radius: var(--radius); flex: 1 1 280px; }
