/* AskESIM admin/support panel — design tokens and components ported from
 * prototype/*.html (docs/02-admin-support-panel.md §6). The prototype is
 * four independent single-file pages, each with its own <style> block; this
 * file merges them into one stylesheet, so a few class names shared across
 * pages with different visual intent are resolved by scoping (.login-page
 * .btn-wave .btn) rather than renaming, and every original selector name is
 * kept wherever there was no real conflict. No inline style="" is used
 * anywhere this stylesheet is paired with (CSP style-src 'self', no
 * 'unsafe-inline'); per-instance visual state (active nav item, disabled nav
 * item, a status tag's colour) is expressed with classes.
 */

/* The panel's UI face, bundled with the binary (assets/InterVariable.woff2,
 * SIL Open Font License 1.1 — assets/InterVariable-LICENSE.txt) rather than
 * fetched from a font CDN, which the runtime is not allowed to do at all.
 * The URL is relative to THIS stylesheet, like select-arrow.svg above it, so
 * it resolves under any ADMIN_PATH_PREFIX; cmd/admin's font-src 'self' is what
 * lets it load — without that directive it inherits default-src 'none' and is
 * blocked even from our own origin. One variable file covers every weight the
 * panel uses (450/550/600/650/700), so there is one request and no synthetic
 * bolding. font-display: swap keeps the text readable during that request:
 * the system stack in --font-ui below renders first and is replaced, never
 * hidden. */
@font-face {
  font-family: 'Inter';
  src: url('InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Sidebar (dark) */
  --sidebar-bg: #1b2130;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-text: #e2e5ec;
  --sidebar-text-sec: #8b92a5;
  --sidebar-section: #505872;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-w: 224px;
  /* FR-UIA-005: the width of the icons-only rail the sidebar collapses to on
   * a wide screen. Wide enough for a 44px touch target plus the rail's own
   * padding, so the collapsed state is still usable on a touch laptop. */
  --sidebar-w-collapsed: 72px;
  /* Content (light) */
  --content-bg: #f8f9fb;
  --card-bg: #ffffff;
  --card-border: #e5e7ec;
  --card-header-bg: #fafbfc;
  --text-heading: #1b2130;
  --text-body: #4b5563;
  --text-muted: #9ca3af;
  /* Accent */
  --accent: #5b6abf;
  --accent-hover: #4a59b0;
  --accent-soft: #eef0fa;
  --accent-text: #4351a8;
  /* Status colors: base (dot/indicator) / soft (tag background) / text (tag text) */
  --green: #22c55e;
  --green-soft: #dcfce7;
  --green-text: #15803d;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --red-text: #dc2626;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --amber-text: #b45309;
  --blue: #3b82f6;
  --blue-soft: #eff6ff;
  --blue-text: #2563eb;
  /* The hairline between rows of a list — a table body, a stat list, a form's
   * fields. Deliberately lighter than --card-border, which is the edge of a
   * box: inside one, a divider as dark as the frame reads as a grid. */
  --row-divider: #eef0f3;
  /* Density scale. The panel is a reference tool an operator reads all day:
   * these are the four measurements that decide how many rows fit on a screen,
   * named once so a card, a cell and a control cannot drift apart. */
  --gap-page: 12px;
  --pad-card: 10px 12px;
  --pad-cell: 6px 10px;
  --h-control: 30px;
  --fs-body: 12.5px;
  --fs-table: 12px;
  --fs-label: 10.5px;
  /* Fonts */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-ui); background: var(--content-bg); color: var(--text-body); font-size: var(--fs-body); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Takes an element out of sight while leaving it in the accessibility tree
 * and the tab order — the opposite of display:none and visibility:hidden,
 * both of which remove it from both. FR-UIA-005 needs exactly this twice:
 * the collapsed sidebar still has to announce what each icon means, and the
 * narrow-screen drawer's checkbox still has to be reachable by keyboard while
 * the eye sees only its hamburger label. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Sidebar + shell (prototype/index.html)                                  */
/* ---------------------------------------------------------------------- */

.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; z-index: 100;
  transition: width 0.15s;
}
.sidebar-header {
  padding: 12px 12px 10px; border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 8px;
}

/* FR-UIA-005, wide screens: the collapse control is the submit button of a
 * real form (layout.templ) posting to /ui/sidebar, which writes the
 * preference cookie and redirects back. assets/app.js intercepts the submit
 * and applies the same class and the same cookie without the round trip; with
 * the script absent the form posts and everything below still holds. */
.sidebar-collapse-form { margin: 0 0 0 auto; }
.sidebar-collapse {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px; background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--sidebar-text-sec); cursor: pointer; transition: color 0.15s, background 0.15s;
}
.sidebar-collapse:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }
.sidebar-collapse svg { width: 13px; height: 13px; }

/* The button's accessible name, both directions of it. Only one is in the
 * accessibility tree at a time — display:none removes the other outright,
 * which is the point: two visually-hidden spans would both be announced and
 * the button would read "Collapse menu Expand menu". Switching them here
 * rather than in JavaScript is what keeps every translated string on the
 * server side of the panel (CLAUDE.md rule 2) while still letting the script
 * change the state without a reload. */
.sidebar-collapse-label-expand { display: none; }
body.sidebar-collapsed .sidebar-collapse-label-collapse { display: none; }
body.sidebar-collapsed .sidebar-collapse-label-expand { display: block; }

/* FR-UIA-005, narrow screens: the drawer. All three elements are inert on a
 * wide screen — display:none removes the checkbox from the tab order too, so
 * only one of the two mechanisms is ever reachable at a given width. The
 * narrow media query at the end of this file turns them on. */
.drawer-state,
.drawer-button,
.drawer-scrim { display: none; }
.sidebar-logo {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #7c8cf0);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #fff;
}
.sidebar-brand { font-weight: 600; font-size: 13px; color: var(--sidebar-text); letter-spacing: -0.3px; }
/* The sections are spaced by the nav's own gap rather than by a margin on each
 * of them: with .sidebar-section carrying no padding of its own, an item's
 * 8px and a section title's 8px measure from the same edge, so the icons and
 * the words above them line up down the whole menu. */
.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 8px 8px 4px;
  display: flex; flex-direction: column; gap: 10px;
}

/* Navigation sections (layout.templ): each one is a <details> and its title is
 * the <summary>. The element discloses natively, so a section opens and closes
 * with no script and no request; the state is [open] on the <details>, which is
 * both what the server renders and what the browser maintains, and every rule
 * below follows it rather than a class or an aria-* attribute.
 *
 * The summary shows no disclosure triangle of its own — the chevron is the
 * affordance, and two would be noise. display:flex already suppresses the
 * marker in most engines; list-style covers the standard property and the
 * -webkit- pseudo covers Safari. */
.sidebar-section { padding: 0; margin-bottom: 0; }
.sidebar-section-title {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 8px 4px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--sidebar-section);
  border-radius: 6px; cursor: pointer; list-style: none;
  transition: color 0.15s, background 0.15s;
}
.sidebar-section-title::-webkit-details-marker { display: none; }
.sidebar-section-title:hover { color: var(--sidebar-text-sec); background: var(--sidebar-hover); }
.sidebar-section-title:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* The title text, kept separate from the chevron so the collapsed rail can
 * hide the words while leaving the control itself on screen — see the
 * FR-UIA-005 block near the end of this file. */
.sidebar-section-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar-section-chevron {
  width: 12px; height: 12px; flex-shrink: 0; margin-left: auto;
  transform: rotate(-90deg); transition: transform 0.15s;
}
.sidebar-section[open] > .sidebar-section-title .sidebar-section-chevron { transform: rotate(0deg); }
.sidebar-link {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 6px; color: var(--sidebar-text-sec);
  font-size: 12.5px; line-height: 1.25; font-weight: 450; transition: all 0.15s;
  cursor: pointer; text-decoration: none;
}
.sidebar-link:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }
.sidebar-link.active {
  color: #fff; background: var(--sidebar-active-bg); font-weight: 550;
}
/* The icon's own box, fixed at its own width: an item whose label wraps to two
 * lines ("Pricing / коэффициенты") would otherwise squeeze the svg out of
 * square, since a flex item shrinks below its width by default. */
.sidebar-link-icon {
  flex: 0 0 14px; display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-link svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.6; }
.sidebar-link.active svg { opacity: 1; }
/* The item's own text, kept as a separate element so the collapsed state can
 * hide it from sight without removing it from the accessibility tree. It takes
 * the rest of the row and may shrink to nothing (min-width: 0) — the icon
 * beside it may not. */
.sidebar-link-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Not yet implemented in this work package (AP1+): no href, not clickable. */
.sidebar-link.disabled { color: var(--sidebar-section); cursor: default; }
.sidebar-link.disabled:hover { background: none; color: var(--sidebar-section); }
.sidebar-link-soon {
  margin-left: auto; flex-shrink: 0; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px;
  background: rgba(255,255,255,0.08); color: var(--sidebar-text-sec);
}
.sidebar-footer {
  padding: 8px 10px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 8px;
}
.sidebar-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(91,106,191,0.2); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 10px; flex-shrink: 0;
}
.sidebar-user { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 11.5px; font-weight: 550; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-family: var(--font-mono); font-size: 10px; color: var(--sidebar-section); }
.sidebar-logout-form { margin: 0; }
.sidebar-logout {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px; border: none; background: transparent;
  color: var(--sidebar-text-sec); cursor: pointer; transition: color 0.15s;
}
.sidebar-logout:hover { color: var(--red); background: var(--sidebar-hover); }
.sidebar-logout svg { width: 16px; height: 16px; }

/* Main content area. No padding at the top: the page header below is the first
 * child of .main on every screen and brings its own. */
.main { margin-left: var(--sidebar-w); min-height: 100vh; padding: 0 20px 32px; }
/* The title bar stays in sight while a long table scrolls under it — which is
 * what makes the screen's identity, and the actions beside it, reachable from
 * row 400 without scrolling back. It is translucent and blurred rather than
 * opaque so the content reads as passing beneath it.
 *
 * The negative side margins break it out of .main's padding to the full width
 * of the content area; they must therefore always match that padding, which is
 * why both narrow branches below restate them.
 *
 * The z-index is above EVERYTHING the content area can put on screen and below
 * the navigation: over an ordinary sticky `thead th` (10), over the catalogue's
 * sticky pagination bar (20), over a header cell holding an open filter (30)
 * and the dropdown trapped in its stacking context (40), under the drawer
 * button (80), the scrim (90) and the sidebar (100). 20 was not enough for the
 * third of those: .table-wrap creates no stacking context (overflow-x: auto
 * does not), so a header cell lifted to 30 while its filter is open compared
 * directly against this bar and painted its grey over the title — visible on
 * any width where the page itself is the scroller, i.e. every screen below
 * 900px, where .catalogue-form .table-wrap drops its max-height.
 *
 * What that costs, deliberately: an open dropdown is z-index 40 INSIDE the
 * stacking context its sticky <th> creates, so it cannot be ordered separately
 * from the cell it hangs from — lifting this bar above the cell puts the top of
 * an open dropdown under it too, in the ~48px band it occupies, if the operator
 * scrolls the page far enough with the dropdown open. That is the smaller
 * damage: the dropdown is one scroll gesture away from being whole again and
 * carries its own apply button (.col-apply) so it need not be scrolled to at
 * all, while a title bar painted over by a table cell is wrong on every screen
 * at once and stays wrong. */
.page-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 -20px var(--gap-page); padding: 10px 20px 8px;
  background: rgba(248,249,251,0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}
.page-title { font-size: 20px; font-weight: 650; color: var(--text-heading); letter-spacing: -0.3px; }
.page-subtitle { font-size: 12px; color: var(--text-muted); }

/* Cards */
.card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
/* The gap is for the headers that carry more than a title — a note beside it
 * (the tariff card's identity card), or a submit button for the form in the
 * body below. A header with one child is unaffected by it. */
.card-header {
  padding: 9px 12px; border-bottom: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-heading);
  background: var(--card-header-bg);
}
/* A second line in the header, saying what the card expects rather than what
 * it is: pushed against the title (margin-right: auto) so that whatever comes
 * after it — a button — still lands on the far right. */
.card-header-note { margin-right: auto; font-size: 11px; font-weight: 450; color: var(--text-muted); }
.card-body { padding: var(--pad-card); }
.card-body-tight { padding: 8px 12px; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-page); margin-bottom: var(--gap-page); }

/* Stat row */
.stat-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12.5px; border-bottom: 1px solid var(--row-divider); }
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text-muted); font-size: 12px; }
.stat-value { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-heading); }

/* Tags */
.tag {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 550; gap: 4px;
}
.tag-green { background: var(--green-soft); color: var(--green-text); }
.tag-red { background: var(--red-soft); color: var(--red-text); }
.tag-blue { background: var(--blue-soft); color: var(--blue-text); }
.tag-amber { background: var(--amber-soft); color: var(--amber-text); }
.tag-accent { background: var(--accent-soft); color: var(--accent-text); }
.tag-gray { background: #f3f4f6; color: #6b7280; }

/* Dots */
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.dot-red { background: var(--red); }
.dot-gray { background: var(--text-muted); }

/* Activity feed */
.activity-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid #f0f1f3; font-size: 12px;
}
.activity-item:last-child { border-bottom: none; }
.activity-time { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; flex-shrink: 0; }
/* An event line is a row of pieces — an actor tag, an id, an action, a target,
 * a result tag — and inline elements emitted by a template carry no whitespace
 * between them to space them out. The gap is stated here rather than as
 * separators in the markup, which would be untranslatable punctuation inside a
 * template. Wrapping, because a long target must fall onto a second line
 * instead of pushing the card sideways. */
.activity-text {
  color: var(--text-body);
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0;
}
.activity-text strong { color: var(--text-heading); font-weight: 550; }
.activity-empty { padding: 18px 0; text-align: center; color: var(--text-muted); font-size: 12px; }

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 14px; font-weight: 600; color: var(--text-heading); }

/* ---------------------------------------------------------------------- */
/* Buttons (shared shape from settings/virtual-machines; login overrides    */
/* below for its own gradient "wave" submit button)                        */
/* ---------------------------------------------------------------------- */
/* The shared control height, not vertical padding: the class is worn by
 * <button>, by <a> and by <summary> (the column menu), and only a stated height
 * makes those three the same size in a row beside an <input>. inline-flex with
 * a centred cross axis is what keeps the text in the middle of that box on the
 * elements that are not buttons — a link with a fixed height would otherwise
 * hang its text from the top. */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--h-control); padding: 0 12px;
  border-radius: 8px; font-size: 12px; font-weight: 550; cursor: pointer;
  border: 1px solid var(--card-border); background: var(--card-bg); color: var(--text-body);
  transition: all 0.15s; font-family: var(--font-ui);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn:hover { border-color: #d1d5db; color: var(--text-heading); }
.btn-primary { padding: 0 14px; background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 3px rgba(91,106,191,0.3); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { border-color: rgba(239,68,68,0.3); color: var(--red-text); background: var(--red-soft); }
.btn-danger:hover { background: #fde8e8; border-color: var(--red); }
.btn svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------------------- */
/* Tabs, collapsible sections, fields, toggle (prototype/settings.html)     */
/* ---------------------------------------------------------------------- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--card-border); margin-bottom: var(--gap-page); }
.tab {
  padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s;
  background: none; border-top: none; border-left: none; border-right: none;
  font-family: var(--font-ui);
}
.tab:hover { color: var(--text-heading); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.settings-section {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 10px; margin-bottom: var(--gap-page); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.settings-section .section-header {
  padding: 14px 16px; margin-bottom: 0; cursor: pointer; user-select: none; transition: background 0.15s;
}
.settings-section .section-header:hover { background: #fafafc; }
.section-chevron {
  width: 16px; height: 16px; color: var(--text-muted);
  transition: transform 0.2s; flex-shrink: 0;
}
.section-header.open .section-chevron { transform: rotate(90deg); }
.section-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  font-weight: 600;
}
.section-body { display: none; padding: 0 16px 16px; }
.section-body.open { display: block; }

.field { display: flex; align-items: center; padding: 10px 0; font-size: 12.5px; border-bottom: 1px solid var(--row-divider); gap: 16px; }
.field:last-child { border-bottom: none; }
.field-label { width: 200px; flex-shrink: 0; }
/* The form label reads as a label, not as a small heading: the value beside it
 * is what the eye is looking for on these screens, so the name of the field is
 * set in the muted uppercase of a column header. */
.field-name {
  font-size: var(--fs-label); font-weight: 550; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.field-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.field-hint-danger { color: var(--red-text); }
/* flex-wrap is here for .field-error below and changes nothing else: every
 * .field-control in the panel holds exactly one control, and a single item
 * never wraps. */
.field-control { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; }

/* A field the tariff group modal's own pre-check refused, and the reason under
 * it (assets/app.js). Both appear only with the script loaded: without it the
 * server refuses the same input on the next screen, as it always has.
 *
 * The note reuses .field-hint-danger — the colour a refusal is already written
 * in on this panel — and only adds where it sits. Inside a .field it is given a
 * full basis so it wraps under the input instead of squeezing in beside it, and
 * is aligned with the control above it rather than with the label opposite; in
 * a channel table's cell it is an ordinary block under the input. */
.input-danger { border-color: var(--red); }
.input-danger:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,0.12); }
.field-error { margin-top: 4px; }
.field-control .field-error { flex-basis: 100%; text-align: right; }

.input {
  height: var(--h-control); padding: 0 10px; border-radius: 8px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  color: var(--text-heading); font-family: var(--font-ui); font-size: 12px;
  outline: none; transition: border-color 0.15s; width: 280px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,106,191,0.1); }
.input::placeholder { color: var(--text-muted); }
/* A multi-line field is the one control the shared height is wrong for: fixed
 * at 30px it would show one line of a three-line description and scroll the
 * rest. It keeps the horizontal metrics and takes its height from its rows. */
textarea.input { height: auto; padding: 6px 10px; }
.input-mono { font-family: var(--font-mono); font-size: 12px; }
.input-narrow { width: 100px; }
.input-medium { width: 160px; }
/* A field whose whole value is two digits — the showcase position, bounded at 1
 * to 10 by migration 025's range CHECK. 64px is 10px+10px of .input's own
 * padding, 2px of border, two mono digits and the browser's spinner: enough to
 * type in and to step with the arrows, and small enough that the column reads as
 * a column of numbers rather than a row of empty boxes.
 *
 * Below 900px the media query's `.input { width: 100% }` takes it over, as it
 * already does .input-narrow and .input-medium: on a phone every control is one
 * full-width row with a 44px touch target, and a 64px box in a table cell is not
 * a thing a thumb hits. */
.input-tiny { width: 64px; }

select.input {
  appearance: none; cursor: pointer;
  /* Relative to this stylesheet's own URL, not the page's: resolves to
     <ADMIN_PATH_PREFIX>/assets/select-arrow.svg under any prefix. An inline
     data URI here is blocked by the panel's img-src 'self' CSP. */
  background-image: url("select-arrow.svg");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px;
}

.toggle { position: relative; width: 40px; height: 22px; cursor: pointer; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 11px;
  background: #d1d5db; transition: background 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(18px); }

/* Flash banner for /security/* GET screens after a POST-redirect (PRG,
 * WP-AP1 §3/§6, adminui.Flash) — distinct from .flash-alert above, which is
 * scoped to the dark login page and has no success variant (login has none
 * to show). */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: var(--gap-page); font-size: 13px; }
.flash-success { background: var(--green-soft); border: 1px solid rgba(34,197,94,0.3); color: var(--green-text); }
.flash-error { background: var(--red-soft); border: 1px solid rgba(239,68,68,0.3); color: var(--red-text); }

/* Warning banner */
.warning-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--amber-soft); border: 1px solid #fde68a;
  border-radius: 10px; margin-bottom: var(--gap-page); font-size: 12px; color: var(--amber-text);
}
.warning-banner svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--amber); }
.warning-banner-text { flex: 1; }
.warning-banner .btn { margin-left: auto; flex-shrink: 0; }

/* ---------------------------------------------------------------------- */
/* Stats bar, toolbar, table, pagination (prototype/virtual-machines.html) */
/* ---------------------------------------------------------------------- */
.stats-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--gap-page); }
.stat-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px;
  font-size: 12px; color: var(--text-body); cursor: default;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); transition: border-color 0.15s;
}
.stat-chip:hover { border-color: #d1d5db; }
.stat-chip-value { font-family: var(--font-mono); font-weight: 600; color: var(--text-heading); }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: var(--gap-page); flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-icon svg { width: 14px; height: 14px; }
.search-input {
  width: 100%; padding: 8px 12px 8px 34px;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px;
  color: var(--text-heading); font-family: var(--font-ui); font-size: 13px;
  outline: none; transition: border-color 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,106,191,0.1); }
.search-input::placeholder { color: var(--text-muted); }

/* The vertical axis is deliberately NOT `hidden` (it was until this batch, and
 * that was the defect recorded in Part 47): with overflow-y: hidden the wrap is
 * a scrollport that can never be scrolled, so the sticky `thead th` below stuck
 * to a box that does not move and the header scrolled off with the page. A
 * non-visible overflow-x already clips both axes to the rounded corners, so
 * dropping it changes nothing visually here — what it changes is that a wrap
 * with a bounded height (.table-tall) becomes a real vertical scroller, which
 * is the only arrangement where a sticky header and a horizontally scrolling
 * table can both work without script. */
.table-wrap {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 10px; overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 7px 10px; text-align: left; font-size: var(--fs-label); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  background: var(--card-header-bg); border-bottom: 1px solid var(--card-border);
  white-space: nowrap; position: sticky; top: 0; z-index: 10;
}
tbody td {
  padding: var(--pad-cell); border-bottom: 1px solid var(--row-divider);
  font-size: var(--fs-table); white-space: nowrap;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--card-header-bg); }
tbody tr:last-child td { border-bottom: none; }

.row-title { color: var(--text-heading); font-weight: 550; }
.row-title:hover { color: var(--accent); }
.text-mono { font-family: var(--font-mono); font-size: 11px; }
.text-sec { color: var(--text-muted); }

.actions-cell { display: flex; gap: 4px; }
.action-btn {
  width: 28px; height: 28px; border-radius: 6px; border: none;
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.action-btn:hover { background: var(--accent-soft); color: var(--accent); }
.action-btn svg { width: 14px; height: 14px; }
.checkbox { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-top: 1px solid var(--card-border);
  font-size: 12px; color: var(--text-muted);
}
.page-btns { display: flex; gap: 2px; }
/* A 26x26 square — min-width rather than width, so a three-digit page number
 * (the catalogue runs to a hundred pages and more) widens the button instead of
 * being clipped by it. */
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 4px;
  border-radius: 6px; border: 1px solid var(--card-border);
  background: transparent; color: var(--text-muted); font-size: 12px;
  cursor: pointer; font-family: var(--font-ui); transition: all 0.15s;
}
.page-btn:hover { border-color: #d1d5db; color: var(--text-heading); }
/* The page being read is stated in full accent, not a tint of it: in a footer
 * of a dozen identical squares the soft background was easy to lose. */
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
/* WP-AP2: pagination links (audit.templ) reuse .page-btn as an <a>, not
 * just a <button> — strip the browser's default link underline. */
a.page-btn { text-decoration: none; }
.page-ellipsis { padding: 4px 6px; color: var(--text-muted); }

/* ---------------------------------------------------------------------- */
/* Login (prototype/login.html) — OIDC-only per docs/02 §6.5: the           */
/* login/password form and "remember me" are not ported, only the visual   */
/* shell (waves, card, flash, "wave" button) around a single SSO button.   */
/* Reuses the shell's dark sidebar palette instead of introducing separate */
/* --bg-dark/--text-primary tokens, so :root above stays the single        */
/* source of truth (docs/02 §6.1) with no duplicate/conflicting variables. */
/* ---------------------------------------------------------------------- */
.login-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background: var(--sidebar-bg); color: var(--sidebar-text);
}

.lang-switcher {
  position: absolute; top: 16px; right: 16px; z-index: 20;
  display: flex; gap: 4px;
}
.lang-btn {
  padding: 4px 12px; font-size: 12px; font-weight: 500;
  border-radius: 4px; text-decoration: none; transition: all 0.2s;
  color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.lang-btn:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.1); }
.lang-btn.active { color: #fff; background: rgba(91,106,191,0.3); border-color: rgba(91,106,191,0.5); }

.wave-header { position: absolute; top: 0; left: 0; width: 100%; height: 45vh; }
.wave-gradient {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #232b45 0%, var(--sidebar-bg) 100%);
}
.waves {
  position: absolute; bottom: 0; left: 0; width: 100%;
  height: 15vh; min-height: 80px; max-height: 150px;
}
.waves-parallax > use { animation: wave-move 25s cubic-bezier(.55,.5,.45,.5) infinite; }
.wave-1 { fill: rgba(91,106,191,0.06); animation-delay: -2s; animation-duration: 7s; }
.wave-2 { fill: rgba(91,106,191,0.04); animation-delay: -3s; animation-duration: 10s; }
.wave-3 { fill: rgba(91,106,191,0.03); animation-delay: -4s; animation-duration: 13s; }
.wave-4 { fill: var(--sidebar-bg); animation-delay: -5s; animation-duration: 20s; }

@keyframes wave-move {
  0%   { transform: translate3d(-90px, 0, 0); }
  100% { transform: translate3d(85px, 0, 0); }
}

.card-wrapper {
  position: relative; z-index: 10; width: 100%;
  display: flex; justify-content: center; padding: 0 16px;
}
/* Renamed from the prototype's .card: the shell/content .card above (light,
 * bordered) is a different component that would otherwise collide with this
 * page's dark variant under one shared class name. */
.login-card { width: 100%; max-width: 380px; }

.headline { text-align: center; margin-bottom: 32px; }
.title { font-size: 28px; font-weight: 700; color: var(--sidebar-text); letter-spacing: -0.3px; }
.title-sub { font-size: 14px; color: var(--sidebar-text-sec); margin-top: 6px; }

.flash-alert {
  margin-bottom: 16px; padding: 10px 14px; border-radius: 8px;
  font-size: 13px;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }
.submit-wrap { display: flex; justify-content: center; padding-top: 4px; }
.btn-wave {
  position: relative; width: 100%; overflow: hidden; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
}
.btn-wave::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%); transition: transform 0.6s ease;
}
.btn-wave:hover::before { transform: translateX(100%); }
/* Scoped override of the shared .btn (light, bordered) for the login page's
 * single "Sign in with SSO" button: full-width, transparent over the
 * gradient wrapper above, white text, no border. */
/* height: auto undoes the shared control height for this one button: the login
 * screen's single call to action is sized by its own padding and 14px text,
 * and 30px would shrink it to the size of a toolbar button. */
.login-page .btn-wave .btn {
  display: flex; width: 100%; justify-content: center; height: auto; padding: 10px 16px;
  font-size: 14px; font-weight: 600;
  border-radius: 8px; background: transparent; color: #fff; border: none;
  box-shadow: none;
}
.login-page .btn-wave .btn:hover { background: rgba(255,255,255,0.05); color: #fff; border-color: transparent; }
.login-page .btn-wave .btn:active { transform: scale(0.98); }

/* Keeps the pagination bar in sight when a wide table is scrolled sideways
 * inside .table-wrap: it is a block child of the scroll container, so without
 * this it slides out of view to the left exactly when a narrow screen needs
 * it most (FR-UIA-004: pagination stays reachable). */
.table-wrap > .pagination { position: sticky; left: 0; }

/* ---------------------------------------------------------------------- */
/* Disclosures. <details> is the panel's only interactive primitive: the   */
/* CSP does allow script-src 'self' (cmd/admin/main.go) and assets/app.js  */
/* is loaded on every page, but that script is progressive enhancement     */
/* only — so every dropdown, every collapsed coverage list and every       */
/* "show the changes" on these screens has to work with it absent, and     */
/* <details> is what does. Until this batch they were rendered with the    */
/* browser default marker and no styling of any kind.                      */
/* ---------------------------------------------------------------------- */
details > summary {
  cursor: pointer; list-style: none; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
}
/* The default triangle is replaced rather than kept: it sits outside the
 * summary box and cannot be aligned with anything around it. */
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: "\25BE"; font-size: 10px; line-height: 1; color: var(--text-muted);
  transition: transform 0.15s;
}
details[open] > summary::after { transform: rotate(180deg); }
details > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------------------------------------------------------------------- */
/* The catalogue table's header tools (internal/adminui/catalogue.templ).  */
/* One <details> per column holds that column's filter; two submit buttons */
/* beside it sort by it. Everything here is inside the screen's single GET */
/* form, so opening a dropdown changes nothing until "apply" is pressed —  */
/* which is also why the mark below (.filter-mark) exists: after the page  */
/* reloads every disclosure is closed again.                              */
/* ---------------------------------------------------------------------- */
.col-tool { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.col-filter { position: relative; }
.col-summary { max-width: 100%; }
.col-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The dropdown itself. `thead th` sets uppercase small caps for the header
 * text; the panel is ordinary content and resets all of it. */
.col-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  min-width: 240px; max-width: 340px;
  max-height: 340px; overflow-y: auto;
  padding: 10px; border: 1px solid var(--card-border); border-radius: 10px;
  background: var(--card-bg); box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  font-size: 12px; font-weight: 450; line-height: 1.5;
  text-transform: none; letter-spacing: normal; white-space: normal;
  color: var(--text-body); cursor: default; text-align: left;
}
/* Sticky headers all share one z-index, so without this the NEXT column's
 * header paints over an open panel. Lifting the whole cell is the only way:
 * a child cannot escape the stacking context its sticky parent creates. 30
 * stays below the page's own sticky title bar (.page-header, 50) — see there
 * for why that order and what it costs. */
thead th:has(.col-filter[open]) { z-index: 30; }

.col-find { margin-bottom: 6px; }
.col-options { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.col-option {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 6px; cursor: pointer;
}
/* A value the dropdown's "find a value" term does not select. The whole list is
 * in the markup — the server marks what its own term excludes (facetOptions)
 * and assets/app.js re-marks it on every keystroke — and this is what makes the
 * attribute mean anything: `display: flex` above beats the browser's own
 * [hidden] rule, so without this line a hidden option would still be on screen.
 * The "no values" line needs no such rule; it sets no display of its own. */
.col-option[hidden] { display: none; }
.col-option:hover { background: var(--accent-soft); }
.col-option-label { flex: 1; min-width: 0; display: inline-flex; align-items: baseline; gap: 6px; overflow-wrap: anywhere; }
.col-option-count { color: var(--text-muted); flex-shrink: 0; }
.col-empty { padding: 6px; }
.col-choice { display: flex; flex-direction: column; gap: 2px; }
.col-choice-title { margin: 8px 0 2px; }
.col-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.col-range { display: flex; gap: 8px; }
.col-range .col-field { flex: 1; }
.col-input { width: 100%; }

/* "Apply" inside the dropdown itself. The screen's other apply button is in the
 * toolbar at the top of the table, which is off screen by the time an operator
 * has scrolled sideways to the twentieth column and set a filter in it; this one
 * is where the filter was just typed. It submits the same single form, so every
 * other filter already set travels with it — which is why it is a full-width
 * button under a rule rather than a small control beside the options: it applies
 * the screen, not the column.
 *
 * It is stuck to the bottom edge of the panel, and that is not decoration: the
 * button is the LAST child of a box whose height is capped (.col-panel,
 * max-height 340px, box-sizing: border-box — 318px of content), and the taller
 * filters overrun that cap. A country dropdown is a 30px search field, 6px, the
 * 240px option list, the 26px roaming row and then this button: 342px, and 388px
 * below 900px where the option rows and the controls grow to their 44px touch
 * size. In flow the button would sit past the bottom of the panel, reachable
 * only by scrolling the panel itself — which a wheel or a thumb over the option
 * list never does, since that list is a scroller of its own and swallows the
 * gesture. Sticky puts it in sight at every content height instead of buying one
 * filter's arithmetic a few pixels of room and leaving the trap set for the next
 * one. bottom: 0 pins its bottom margin edge to the scrollport, i.e. the panel's
 * padding box, so nothing scrolls into view underneath it either.
 *
 * The rule above it is a pseudo-element rather than a border on the button:
 * .btn's border is the button's own frame, and recolouring one side of it would
 * break the shape. It is a child of the sticky button, so it travels with it
 * instead of staying behind at the flow position — and it is a 10px opaque band
 * the exact height of the button's own top margin, stretched across the panel's
 * padding on both sides, so the options passing beneath the pinned button
 * disappear under the rule rather than through the gap above it. */
.col-apply {
  display: flex; width: 100%; justify-content: center;
  position: sticky; bottom: 0; margin-top: 10px;
}
/* box-sizing is restated here because the reset above is `* { ... }`, and the
 * universal selector matches elements, not pseudo-elements: without it this
 * strip is content-box, its border adds an eleventh pixel, and — since an
 * absolutely positioned box is offset from the PADDING box of its ancestor,
 * one pixel inside .btn's own border — it lands 9px above the button instead
 * of 10 and paints two pixels over the button's top edge. That is a white line
 * across the top of a primary button and a 1px slit the option list scrolls
 * through, which is exactly what the strip exists to prevent. */
.col-apply::before {
  content: ""; position: absolute; left: -10px; right: -10px; top: -11px; height: 10px;
  box-sizing: border-box;
  background: var(--card-bg); border-top: 1px solid var(--row-divider);
}

/* The one mark a header carries, and it means one thing: this column is
 * filtered. A count for a multi-select, a dot for everything else. */
.filter-mark {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0; flex-shrink: 0;
}

.col-sort { display: inline-flex; gap: 1px; flex-shrink: 0; }
.col-sort-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 0 3px; border-radius: 4px; line-height: 1;
  color: var(--text-muted); font-family: var(--font-ui); font-size: 11px;
}
.col-sort-btn:hover { background: var(--accent-soft); color: var(--accent); }
.col-sort-btn.is-active { background: var(--accent-soft); color: var(--accent); }

/* Figures right-aligned and monospaced, so orders of magnitude read down the
 * column instead of having to be compared digit by digit. */
th.col-num { text-align: right; }
th.col-num .col-tool { justify-content: flex-end; }
td.col-num { text-align: right; font-family: var(--font-mono); font-size: 11px; }

/* The column menu, in the toolbar above the table. */
.col-menu { position: relative; }
.col-menu-panel { min-width: 320px; max-width: 420px; }
.col-menu-section { margin-bottom: 10px; }
.col-menu-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted); margin-bottom: 4px;
}
.col-menu-presets {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-top: 8px; border-top: 1px solid var(--card-border);
}

/* The mass-operation panel (internal/adminui/catalogue_bulk.go) is that same
 * menu, so it needs no box of its own — only the two things its own controls
 * add: the row-selection column, kept to the width of a checkbox so it takes
 * nothing from the twenty columns of data beside it, and the group select,
 * indented under the radio it belongs to (8px checkbox gap + the 14px box) so
 * it reads as part of that choice rather than as a fourth operation. */
.col-check { width: 1%; text-align: center; }
.bulk-group { margin: 2px 0 6px 22px; }

/* The catalogue's own table is bounded in height, which is what makes its wrap
 * a scrollport of its own — see .table-wrap above — and therefore the only
 * arrangement in which its sticky header actually sticks. It is scoped to this
 * screen rather than applied to every .table-wrap: a bounded box is right for a
 * twenty-column reference table an operator scrolls inside, and wrong for the
 * short tables the other screens carry, which the page should simply scroll.
 *
 * The pagination bar sticks to the bottom edge for the same reason the header
 * sticks to the top: inside a scrolling box it would otherwise be reachable
 * only after scrolling past every row. */
.catalogue-form .table-wrap { max-height: calc(100vh - 220px); }
.catalogue-form .table-wrap > .pagination {
  position: sticky; left: 0; bottom: 0; z-index: 20;
  background: var(--card-bg);
}
/* Room for an open header dropdown INSIDE the scrollport, which is the only
 * place it can have any: .col-panel is absolutely positioned inside a <th> of a
 * wrap whose overflow-x is not `visible`, so the computed overflow-y beside it
 * is `auto` and the wrap clips its own absolute descendants on both axes. There
 * is no arrangement without script that lifts the panel out of that box.
 *
 * Without this the panel is cut off exactly where it is needed most: with one
 * row — or none — the wrap is about a hundred pixels tall, and the checkboxes,
 * the "find a value" field and the whole bottom of the dropdown are behind the
 * edge, which is the state an operator is in while FIXING a filter.
 *
 * 420px is what the panel needs at its tallest: the header row (up to ~64px,
 * where the mobile branch below gives the sort buttons a 44px touch target),
 * the 6px gap of .col-panel's own `top`, and its 340px max-height.
 *
 * Conditioned on a panel actually being open, so an ordinary short table keeps
 * its natural height and gains no strip of empty card under it. That is the
 * same :has() the z-index rule above already depends on for the same widget: in
 * a browser without it the dropdown is painted under the next column's header
 * anyway, so this adds no failure case that was not already there.
 *
 * It applies on narrow screens too, where the branch below drops max-height:
 * the panel is no shorter there, and its bottom half would be just as cut off.
 * On a short viewport the floor wins over max-height (CSS resolves min-height
 * last), so an open dropdown can push the wrap past the bottom of the window
 * and the page scrolls — which beats a dropdown whose buttons cannot be
 * reached. */
.catalogue-form .table-wrap:has(.col-filter[open]) { min-height: 420px; }

/* ---------------------------------------------------------------------- */
/* The tariff card (internal/adminui/tariff_card.templ). One screen with a */
/* sticky header, a metrics strip and five tab panels; everything else on  */
/* it is the shared .card/.btn/.tag/.input shapes used as they are.        */
/* ---------------------------------------------------------------------- */

/* The card's header carries four rows — crumbs, title with its actions, the
 * origin line and the tab strip — where every other screen's carries one. It
 * therefore takes .page-header for what that class actually is (the sticky,
 * blurred, full-bleed bar whose break-out margins every width restates) and
 * drops only its single-row flex layout.
 *
 * padding-bottom goes to zero because the tab strip below brings its own, and
 * an active tab's underline has to meet the bar's bottom border. It is stated
 * as a longhand deliberately: the narrow branches restate .page-header's
 * padding as a shorthand to keep the drawer button's 60px of clearance, and a
 * shorthand here would take that clearance away again. */
.page-header.tariff-header { display: block; padding-bottom: 0; }

.crumbs { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); }
.crumbs a { color: var(--text-body); }
.crumbs a:hover { color: var(--accent); }

.tariff-headline { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.tariff-headline-main { min-width: 0; }
.tariff-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title.tariff-title { font-size: 21px; letter-spacing: -0.02em; }
.tariff-origin { margin-top: 3px; font-size: 11.5px; color: var(--text-body); }
/* Publish, unpublish and withdraw are one form each — one submit, one
 * mutation, one audit event — so this strip is a row of forms rather than a
 * row of buttons, and each form is a flex item holding its single button. */
.tariff-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* The tabs. Each one is a link to the fragment of its panel, and the panels
 * below switch on :target — with no script, deliberately: the CSP does allow
 * script-src 'self' (cmd/admin/main.go) and assets/app.js is on every page,
 * but that script is progressive enhancement only, so the tabs must switch
 * without it. A tab that cost a request would also cost the scroll position
 * and the flash banner the POST before it just produced.
 *
 * The strip scrolls sideways rather than wrapping at every width: five tabs
 * in one line is the shape an operator learns, and a second line of them
 * would move the content down by a row on the narrowest screens only. */
.tab-bar { display: flex; gap: 2px; margin-top: 10px; overflow-x: auto; }
.tab-link {
  position: relative; flex-shrink: 0; white-space: nowrap;
  padding: 7px 10px 9px; border-radius: 6px 6px 0 0;
  font-size: var(--fs-body); color: var(--text-body);
  /* Read by ::after below; the active rule sets it on the link itself, so one
   * selector list carries both halves of the state instead of two. */
  --tab-underline: transparent;
}
.tab-link:hover { color: var(--text-heading); }
.tab-link::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0;
  height: 2px; border-radius: 2px; background: var(--tab-underline);
}
/* Which tab is active is a fact about the fragment, and the links sit in the
 * header while the panels sit in the content — no combinator reaches from one
 * to the other, so this reads the document state with :has(), the same
 * selector the catalogue's header dropdowns already depend on. The last line
 * is the state the card opens in: no fragment at all means Overview. */
body:has(#tab-overview:target) .tab-link[href="#tab-overview"],
body:has(#tab-groups:target) .tab-link[href="#tab-groups"],
body:has(#tab-provider:target) .tab-link[href="#tab-provider"],
body:has(#tab-history:target) .tab-link[href="#tab-history"],
body:not(:has(.tab-panel:target)) .tab-link[href="#tab-overview"] {
  color: var(--text-heading); --tab-underline: var(--text-heading);
}

/* The panels themselves need no :has() at all, and deliberately so: with the
 * default panel LAST in the markup, "some other panel is targeted" is a
 * following-sibling relation, which every browser has always had. Only one
 * panel is ever displayed, so its position in the source is invisible on the
 * screen — and in a browser that somehow supports neither, the fallback is
 * Overview alone rather than a blank page.
 *
 * scroll-margin keeps the jump to a fragment clear of everything above the
 * panels that must stay in sight: the sticky header (four rows, ~130px) AND
 * the metrics strip, which is NOT sticky and would otherwise be pushed off
 * the top of the viewport by the jump — the strip is outside the panels
 * precisely so that it does not change with the tab, and a strip that is
 * scrolled away on the first click is no better than one that changed.
 * 220 = header + one row of metrics (~61px) + --gap-page, with slack.
 *
 * Chosen over making .metrics sticky under the header. Sticky needs a `top`
 * equal to the header's height, and that height is not a constant — the
 * crumbs, the tags and the four action buttons wrap at narrow widths — so a
 * wrong value either slides the strip under the translucent bar or leaves a
 * gap through which the content scrolls in plain sight (the same failure the
 * narrow .page-header rule below already refuses `top: 52px` over). It would
 * also cost ~70px of viewport on every scroll of a screen whose header
 * already takes 130. scroll-margin costs nothing except at the jump, and its
 * failure mode is slack above the panel rather than a hidden strip — which is
 * why the values here are rounded UP. */
.tab-panel { display: none; scroll-margin-top: 220px; }
.tab-panel:target { display: block; }
.tab-panel-default { display: block; }
.tab-panel:target ~ .tab-panel-default { display: none; }

/* ---------------------------------------------------------------------- */
/* Modals (the tariff groups screen: one per group, one for the create     */
/* form).                                                                 */
/*                                                                        */
/* Opened and closed by :target, exactly like the tariff card's tabs above */
/* and for the same reason: script-src 'self' is allowed and assets/app.js */
/* is on every page, but that script is progressive enhancement only, so a */
/* modal must open without it. Every closer — the backdrop, the cross and  */
/* the Cancel button — is a link to "#", which clears the fragment; the    */
/* browser's Back button closes it too, since opening one is a history     */
/* entry.                                                                 */
/*                                                                        */
/* The modals are rendered AFTER .table-wrap and outside it. .table-wrap is */
/* a scrollport (overflow-x: auto) and a scrollport clips on both axes, so */
/* a modal inside a row would be cut to the width of the table and would   */
/* scroll away with it — position: fixed does not escape it.               */
/*                                                                        */
/* What it costs, deliberately: Escape does not close (no script), and the */
/* page behind an open modal still scrolls — locking it needs a class on   */
/* <body>, which only script can put there. Neither loses anything: the    */
/* backdrop covers the whole viewport, so a scroll of the page behind ends */
/* on the same three closers.                                             */
/* ---------------------------------------------------------------------- */
/* Above everything the panel can put on screen: the sticky page header is
 * 50, the narrow-width drawer scrim 90 and the drawer itself 100. */
.modal { display: none; position: fixed; inset: 0; z-index: 120; }
.modal:target { display: flex; align-items: center; justify-content: center; padding: 16px; }
/* A link, not a decoration: it IS the "click outside to close" affordance, and
 * it sits under the card because the card is positioned after it. */
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,18,26,0.45); }
.modal-card {
  position: relative; width: min(760px, 92vw); max-width: 760px;
  max-height: 88vh; overflow-y: auto;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,0.22);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-bottom: 1px solid var(--card-border);
  background: var(--card-header-bg);
  font-size: 12.5px; font-weight: 600; color: var(--text-heading);
}
.modal-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.modal-close { flex-shrink: 0; font-size: 16px; line-height: 1; padding: 2px 4px; color: var(--text-muted); }
.modal-close:hover { color: var(--text-heading); }
.modal-body { padding: var(--pad-card); }
/* The fields on one side, the channel table on the other: the two are read
 * against each other (a coefficient per channel beside the box that says the
 * channel sells at all), and stacking them puts a scroll between the pair. */
.modal-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-page); align-items: start; }
.modal-col { min-width: 0; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--row-divider);
}
/* A .field inside a modal gets ~361px of track, not the width of a card body:
 * the card is 760px border to border, the body takes 2x12 of padding off it
 * and .modal-cols splits what is left into two 1fr tracks with a 12px gap.
 * The side-by-side shape does not fit that: .field-label is a hard 200px
 * (flex-shrink: 0) and .input keeps its own min-content floor (min-width is
 * auto on a flex item), so the row's minimum stands above the track whatever
 * the exact browser figure — and nothing on the chain clips or wraps it
 * (.field, .modal-col, .modal-cols and .modal-body are all overflow: visible),
 * so the excess painted straight over the channel table beside it.
 *
 * Stacking removes the sum instead of trimming it: label above, control below,
 * each bounded by the column alone at every width. It is the same shape the
 * <=900px branch already gives .field sitewide, stated here for the one place
 * a field is narrow on a WIDE screen.
 *
 * Scoped to .modal on purpose: .field is shared with settings, the pricing
 * forms and the tariff card, which sit at full card width and must keep the
 * label beside the control there. */
.modal .field { flex-direction: column; align-items: stretch; gap: 6px; }
.modal .field-label { width: auto; }
.modal .field-control { justify-content: flex-start; }
.modal .input { width: 100%; }
/* The heading of one form inside a modal that holds MORE than one. The groups
 * modal holds two, behind two different permissions (catalogue.manage writes
 * the fields and the channels, pricing.manage the coefficients), and they
 * cannot be merged into one submission. Two forms running together in one
 * column with both buttons in a shared row below is how a typed coefficient
 * got thrown away by the button of the OTHER form, under a "saved" flash:
 * nothing on screen said where one form ended.
 *
 * So the boundary is drawn: a name for each half and a rule between them. A
 * heading and not <fieldset>/<legend> — the pair carries its own box and
 * baseline metrics, and every one of them would have to be undone here.
 *
 * The top margin is reset for whichever half comes FIRST rather than for a
 * fixed one: an admin without catalogue.manage gets no fields form at all, and
 * the price heading is then the top of the column. The heading is not matched
 * as the form's :first-child — CSRFField renders a hidden input ahead of it —
 * so the reset asks only that the heading's FORM be first, which holds because
 * a form carries exactly one of these headings. */
.modal-section {
  margin: 14px 0 8px; padding-bottom: 4px;
  border-bottom: 1px solid var(--card-border);
  font-size: var(--fs-label); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
}
.modal-col > .modal-section:first-child,
.modal-col > :first-child > .modal-section { margin-top: 0; }
/* The channel table's coefficient cell holds a short decimal, and .input's
 * sitewide 280px alone pushes that three-column table past its own track on
 * every row. Contained rather than overlapping (.table-wrap is a scrollport),
 * so this is the inner scrollbar, not the overlap above — but a modal that
 * scrolls sideways to reach the field being typed into is the same defect one
 * step milder. 100px is .input-narrow's width, applied by context so neither
 * modal has to carry the class in markup. */
.modal-col .table-wrap .input { width: 100px; }

/* The metrics strip, on every tab: the six figures the rest of the screen is
 * read against. It is flex and not a grid with a 1px gap on a tinted
 * background — that arrangement shows the empty tracks of the last row as
 * grey holes the moment the cells do not divide evenly. */
.metrics {
  display: flex; flex-wrap: wrap; margin-bottom: var(--gap-page);
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.metric { flex: 1 1 150px; min-width: 150px; padding: 9px 12px; border-left: 1px solid var(--row-divider); }
.metric:first-child { border-left: none; }
.metric-label {
  font-size: var(--fs-label); text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
}
.metric-value {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px;
  font-size: 15px; font-weight: 600; color: var(--text-heading);
}
/* The price and margin cells are the list screen's own components, and their
 * mono spans carry that screen's 11px. Here they are the figure of the cell. */
.metric-value .text-mono { font-size: inherit; }
/* On the dashboard a cell can BE the link to the screen its figure comes from.
 * Its children keep their own colours (the label muted, the figure heading), so
 * the accent an <a> would otherwise paint the whole tile with never shows —
 * which leaves nothing at all to say the tile is clickable. This is that
 * statement, and it is a rule on the existing class rather than a second one. */
a.metric:hover { background: var(--card-header-bg); }

/* A panel's own layout: the wide column carries what is edited and counted,
 * the narrow one what is only read. */
.grid-cards { display: grid; grid-template-columns: 1.35fr 1fr; gap: var(--gap-page); align-items: start; }
.card-column { display: flex; flex-direction: column; gap: var(--gap-page); }
/* A table that IS the card's body, edge to edge: the card already draws the
 * frame and clips the corners, and a second border inside it reads as a box
 * in a box. */
.card > .table-wrap { border: none; border-radius: 0; box-shadow: none; }
/* One control and its button on one line — the code field, the group select. */
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form .input { flex: 1; width: auto; min-width: 0; }
/* Label/value pairs in two columns (the provider's full facts): the pairs are
 * .stat-row, so they keep the divider and the spacing of every other list. */
.pair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; padding: 4px 12px 8px; }
/* A hash is 64 characters of nothing to read: it is shown so that two cards
 * can be compared, and truncated so it cannot push the label off the row. */
.pair-value-clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------------- */
/* FR-UIA-005 (docs/02 §6.8) — the collapsed sidebar, wide screens only.   */
/* Scoped to min-width so a phone never gets an icons-only rail: at that   */
/* width the sidebar is a drawer (below), and the desktop preference       */
/* cookie has no say over it.                                             */
/* ---------------------------------------------------------------------- */
/* Legal documents (batch 87.1). The editor's textarea takes the card's whole
 * width — .input is a 280px control everywhere else — because it holds a
 * document, not a value. .legal-doc sets the rendered Markdown (preview, any
 * version): the panel's reset strips lists and tables of their spacing, and a
 * legal text without its paragraph gaps and its table borders is unreadable. */
.legal-textarea { width: 100%; min-height: 420px; margin: 8px 0; line-height: 1.5; resize: vertical; }
.legal-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
/* Batch 88.3: the portal languages' key editor — the English text kept as
 * written (line breaks included), the translation's box filling its cell. */
.lang-key-english { white-space: pre-wrap; max-width: 420px; }
.lang-key-textarea { width: 100%; min-width: 280px; margin: 0 0 4px; line-height: 1.4; resize: vertical; }
.legal-doc { font-size: 13px; line-height: 1.6; color: var(--text-body); max-width: 860px; }
.legal-doc h1, .legal-doc h2, .legal-doc h3, .legal-doc h4 { color: var(--text-heading); margin: 1.2em 0 0.4em; }
.legal-doc h1 { font-size: 20px; }
.legal-doc h2 { font-size: 17px; }
.legal-doc h3 { font-size: 15px; }
.legal-doc p, .legal-doc ul, .legal-doc ol, .legal-doc blockquote, .legal-doc table, .legal-doc pre { margin: 0 0 0.8em; }
.legal-doc ul { list-style: disc; padding-left: 1.6em; }
.legal-doc ol { list-style: decimal; padding-left: 1.6em; }
.legal-doc blockquote { border-left: 3px solid var(--card-border); padding-left: 12px; color: var(--text-muted); }
.legal-doc code, .legal-doc pre { font-family: var(--font-mono); font-size: 12px; }
.legal-doc table { border-collapse: collapse; }
.legal-doc th, .legal-doc td { border: 1px solid var(--card-border); padding: 4px 8px; vertical-align: top; }
.legal-doc th[align="center"], .legal-doc td[align="center"] { text-align: center; }
.legal-doc th[align="right"], .legal-doc td[align="right"] { text-align: right; }
.legal-doc hr { border: 0; border-top: 1px solid var(--card-border); margin: 1em 0; }

@media (min-width: 901px) {
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

  /* §6.8's keyboard clause. A `title` tooltip answers "what is this icon?"
   * for a mouse and for nobody else, so focusing anything inside the rail
   * brings the labels back for as long as focus stays there — the sidebar is
   * position:fixed, so this overlays the content instead of reflowing it. */
  body.sidebar-collapsed .sidebar:focus-within { width: var(--sidebar-w); }

  /* Everything below is the collapsed geometry, and every rule of it is
   * switched off again by :focus-within above. */
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-header { flex-direction: column; gap: 8px; padding: 10px 6px; }
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-collapse-form { margin-left: 0; }
  /* The rail's own inset, on top of .sidebar-nav's 8px: 72 - 16 - 12 leaves a
   * 44px-wide item, which is the touch target --sidebar-w-collapsed was chosen
   * for. It is stated here and not on the expanded sidebar, where the sections
   * carry no padding of their own. */
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-section { padding: 0 6px; }
  /* 12px of vertical padding around a 14px icon, where the expanded item has
   * 6px around the same icon: the label is out of flow here (clipped below), so
   * the padding is the whole of the item's height — 38px, which is what the
   * rail measured when the icon was 18px and the padding 10px. */
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-link { justify-content: center; padding: 12px 8px; }
  /* The section header keeps its place in the rail — only its words go. It is
   * the control that reopens a closed section, and a closed section shows
   * nothing else at all: clipping the whole header would leave the operator
   * with a gap in the icon strip and no way to get the items back. What is
   * left is the chevron, centred, at the width of the rail. */
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-section-title { justify-content: center; padding: 6px 8px; }
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-section-chevron { margin-left: 0; }
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-footer { flex-direction: column; gap: 8px; padding: 10px 6px; }
  /* "Активный пункт различим и без подписи": the shared active background
   * plus a solid accent edge, which reads at rail width where a background
   * tint alone is easy to miss. */
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-link.active { box-shadow: inset 3px 0 0 var(--accent); }
  /* Clipped, never display:none — the brand, the section titles and every
   * item's name stay in the accessibility tree, which is what makes the
   * collapsed rail usable with a screen reader at all. */
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-brand,
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-section-name,
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-link-label,
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-link-soon,
  body.sidebar-collapsed .sidebar:not(:focus-within) .sidebar-user {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

/* ---------------------------------------------------------------------- */
/* FR-UIA-004 (docs/02 §6.7) — tablet and phone. Lower bound is 360px:     */
/* no page-level horizontal scroll at any width, wide content scrolls      */
/* inside its own container, toolbars wrap instead of shrinking, touch     */
/* targets are at least 44x44, and forms fall to one column with the label */
/* above the control.                                                     */
/* Also FR-UIA-005's narrow half: the sidebar stops occupying width and    */
/* becomes a drawer over the content, opened by the checkbox and closed by */
/* choosing an item (the next page renders with the checkbox back at its   */
/* unchecked default) or by tapping the scrim behind it.                  */
/* ---------------------------------------------------------------------- */
@media (max-width: 900px) {
  /* visibility, not just the transform: a panel parked off-screen is still
   * focusable, and tabbing into links nobody can see is worse than not having
   * them. visibility:hidden takes the closed drawer out of the tab order and
   * the accessibility tree both, and the checkbox above it is the entry point
   * that brings it back. */
  .sidebar {
    width: min(280px, 84vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.15s ease;
  }
  .drawer-state:checked ~ .sidebar {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 0 0 24px rgba(0,0,0,0.35);
  }
  /* Visible to the accessibility tree and to the tab order, invisible to the
   * eye; the focus ring is drawn on the label it names, below. */
  .drawer-state {
    display: block;
    position: fixed; top: 8px; left: 8px;
    width: 1px; height: 1px; margin: 0; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%);
  }
  .drawer-button {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 8px; left: 8px; z-index: 80;
    width: 44px; height: 44px; border-radius: 8px;
    background: var(--card-bg); border: 1px solid var(--card-border);
    color: var(--text-body); cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }
  .drawer-button svg { width: 20px; height: 20px; }
  .drawer-state:focus-visible + .drawer-button { outline: 2px solid var(--accent); outline-offset: 2px; }
  .drawer-label { display: none; }
  .drawer-state:checked ~ .drawer-button .drawer-label-close,
  .drawer-state:not(:checked) ~ .drawer-button .drawer-label-open {
    display: block;
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .drawer-state:checked ~ .drawer-scrim {
    display: block; position: fixed; inset: 0; z-index: 90;
    background: rgba(15,18,26,0.45);
  }
  /* The wide-screen collapse form is meaningless here (the drawer is not a
   * width the panel occupies), so exactly one mechanism is visible at a
   * time. */
  .sidebar-collapse-form { display: none; }

  .main { margin-left: 0; padding: 60px 16px 24px; }
  /* The header's break-out margins follow .main's padding at every width, or it
   * would stand 4px past the content area on both sides — and 4px past the
   * right edge is a horizontal scrollbar on the whole page, which is the one
   * thing FR-UIA-004 forbids outright.
   *
   * The left padding is the drawer button's room. That button is fixed at
   * 8px/8px, 44x44, over everything (z-index 80), while .main's padding-top only
   * holds the header clear of it BEFORE the page is scrolled; once the header
   * pins to the top the button lands on top of it. Padding, not `top: 52px`:
   * moving the bar down the viewport leaves a strip above it through which the
   * content scrolls in plain sight, which is worse than an indent. At 60px the
   * title clears the button's right edge (52px) by 8px, and the button reads as
   * sitting in the bar — which, once the bar is pinned, is where it is. */
  .page-header {
    flex-wrap: wrap; gap: 8px;
    margin: 0 -16px var(--gap-page); padding: 10px 16px 8px 60px;
  }
  .grid-2 { grid-template-columns: 1fr; }
  /* A modal at this width is one column, and it may take the whole screen:
   * two columns of 46vw each would leave the channel table narrower than its
   * own three cells. */
  .modal-cols { grid-template-columns: 1fr; }
  .modal:target { padding: 8px; }
  .modal-card { width: min(760px, 96vw); max-height: 92vh; }
  /* The tariff card at tablet width: both two-column layouts fall to one. */
  .grid-cards { grid-template-columns: 1fr; }
  .pair-grid { grid-template-columns: 1fr; }
  .card-body { padding: 12px; }
  .stat-row { flex-wrap: wrap; gap: 2px 12px; }
  .warning-banner { flex-wrap: wrap; }
  .warning-banner .btn { margin-left: 0; }
  .pagination { flex-wrap: wrap; gap: 8px; }

  /* Forms: one column, label above the control (§6.7). */
  .field { flex-direction: column; align-items: stretch; gap: 6px; }
  .field-label { width: auto; }
  .field-control { justify-content: flex-start; }
  .input, .input-narrow, .input-medium { width: 100%; min-height: 44px; }
  .search-input { min-height: 44px; }

  /* Touch targets (§6.7): 44x44 for anything a finger has to hit. The drawer's
   * own items are the first of them: the sidebar IS the navigation on this
   * width, and 8px+18px+8px of icon and padding is not a target a thumb hits
   * reliably. */
  .sidebar-link { min-height: 44px; }
  /* The section header opens and closes its section, so on this width it is
   * a target for a thumb like every item under it. */
  .sidebar-section-title { min-height: 44px; }
  .btn { min-height: 44px; }
  /* The tariff card's tabs are what an operator navigates that screen with,
   * so they are a target for a thumb like every other control here. */
  .tab-link { display: inline-flex; align-items: center; min-height: 44px; }
  /* Both halves of .tab-panel's scroll-margin grow at this width: the header
   * takes a second row for its action buttons and a 44px tab strip, and the
   * metrics strip wraps its six cells (min-width 150px) onto two rows. 340 is
   * that geometry rounded up, for the reason stated at .tab-panel — too much
   * leaves slack above the panel, too little hides the strip the jump is
   * meant to keep. */
  .tab-panel { scroll-margin-top: 340px; }
  .action-btn { width: 44px; height: 44px; }
  .page-btn, a.page-btn { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }

  /* The catalogue table's own scroll box is wrong on a phone: the viewport is
   * short, so a bounded box inside a scrolling page means two scrollbars and a
   * sticky header eating a third of the screen. The page scrolls instead, and
   * the table keeps its horizontal scroll, which is expected at this width. */
  .catalogue-form .table-wrap { max-height: none; }
  /* Header dropdowns: a finger-sized row, and a panel that fits the screen. */
  .col-option { min-height: 44px; }
  .col-sort-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .col-panel, .col-menu-panel { min-width: 0; max-width: min(340px, 84vw); }
  .lang-btn { min-height: 44px; display: inline-flex; align-items: center; }
  .sidebar-logout { width: 44px; height: 44px; }
  .toggle { width: 44px; height: 44px; }
  .toggle-track { top: 11px; bottom: 11px; }
  .toggle-thumb { top: 13px; }
  .toggle input:checked ~ .toggle-thumb { transform: translateX(22px); }
}

@media (max-width: 560px) {
  .main { padding: 60px 12px 20px; }
  /* Same two rules as the branch above, at this branch's padding: the side
   * margins follow it, the left padding keeps clearing the drawer button, whose
   * position does not change with the width. */
  .page-header { margin: 0 -12px var(--gap-page); padding: 10px 12px 8px 60px; }
  .card-header { padding: 10px 12px; }
}
