/* Hallmark · genre: modern-minimal · macrostructure: Workbench
 * nav: N3 side-rail (grouped) · design-system: design.md · designed-as-app
 * theme: Nothing-adapted · tone: industrial-precise · anchor hue: 55 (brand orange)
 * pre-emit critique: P5 H5 E4 S5 R5 V4
 *
 * THE COMPONENT SYSTEM. Every colour and every font here comes through a token
 * from tokens.css. If you reach for a raw value, add it to tokens.css first.
 *
 * Two house rules override the source design language, everywhere in this file:
 *   1. No ALL-CAPS. Labels get the mono face + 0.08em tracking + muted ink.
 *   2. No hairline frames. Separation is surface fill, spacing, or the dot rule.
 *      The focus ring is the only outline in the system.
 *
 * The previous stylesheet (admin.css) is superseded but left on disk. Rollback
 * is one line in base.templ.
 */

/* ==========================================================================
   1 · RESET AND BASE
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  overflow-x: clip;                 /* clip, not hidden — preserves sticky    */
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: clip;
  margin: 0;
  min-height: 100dvh;
  background: var(--c-page);
  color: var(--c-ink-2);
  font-family: var(--font-body);
  font-size: var(--t-base);
  font-weight: var(--w-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
}

/* Oranzy zero-radius geometry across all utility classes. */
.rounded, .rounded-xs, .rounded-sm, .rounded-md, .rounded-lg,
.rounded-xl, .rounded-2xl, .rounded-3xl, .rounded-full {
  border-radius: 0px !important;
}
.animate-spin.rounded-full {
  border-radius: 9999px !important;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-style: normal;               /* headings are roman. always.            */
  color: var(--c-ink-1);
  letter-spacing: var(--tr-tight);
  line-height: var(--lh-tight);
  margin: 0;
  /* break-word, not anywhere: `anywhere` split "Корпоративный" into
     "Корпоратив/ный" mid-word even when the card had room to reflow. This still
     prevents overflow, but only breaks a word that genuinely cannot fit. */
  overflow-wrap: break-word;
  min-width: 0;
}

a { color: inherit; text-decoration: none; }

/* The focus ring is the one permitted outline. It appears instantly — never
   transition it, or keyboard users get no indicator while it fades in. */
:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: var(--r-tech);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--c-accent-dim); color: var(--c-ink-1); }

img, svg, video, canvas { max-width: 100%; height: auto; display: block; }

/* Monoline icons only — 1.5px stroke, no fill, colour inherited. */
svg { stroke-width: 1.5; }

/* ==========================================================================
   2 · THE INSTRUMENT VOICE
   Sentence case, medium weight, light tracking, muted ink. This replaces both
   the ALL-CAPS labels of the source language AND the monospace face that first
   carried them: mono read as a code font in a UI that is not code. Hierarchy
   now comes from weight, size and colour — which is what the system says it
   should come from.
   ========================================================================== */

.label,
.form-label,
.stat-card__label,
.settings-section-h,
.empty-state__title,
.pagination__info {
  font-family: var(--font-data);
  font-size: var(--t-label);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-label);
  text-transform: none;
  color: var(--c-ink-3);
  line-height: 1.35;
}

/* Подпись поля — 13px вместо 12px. Она стоит над полем ввода и конкурирует с
   его содержимым; на 11px в тёмной теме форма рассылки читалась как сплошное
   светло-серое поле, в котором не за что зацепиться взглядом (11.09.2026). */
.form-label {
  font-size: var(--t-sm);
  color: var(--c-ink-3);
}

/* Belt and braces against the caps ban: 25 templates still carried a literal
   `uppercase` class and Tailwind's CDN defines it. Higher specificity than the
   utility, so this wins regardless of injection order. */
html .uppercase,
html [class*="uppercase"] {
  text-transform: none !important;
  letter-spacing: var(--tr-label);
}

/* The orange coin glyph. `align-middle` put it on the line box's middle, which
   on a row of digits reads as a degree sign floating above the number — and in a
   narrow column it wrapped onto its own line. Sits on the numeral baseline now,
   and the value it belongs to never breaks away from it. */
.orange-glyph {
  display: inline-block;
  flex: none;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.18em;
}
/* A number and its unit are one object. */
.stat-card__value, .stat-widget-value, .metric__value,
td .font-medium, .gen-feed-cost, .gen-lb-cost, .stat-row__value {
  white-space: nowrap;
}

/* Numbers align in columns or they aren't data. */
.tabular, td.num, .num, table td, table th,
.stat-card__value, .stat-widget-value, .metric__value {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   3 · SHELL — rail, header, worksurface
   ========================================================================== */

#sidebar {
  background: var(--c-rail);
  backdrop-filter: none;
  border: 0;
  box-shadow: none;
}

.glass-frosted {
  background: var(--c-surface);
  backdrop-filter: none;            /* no blur — flat surfaces               */
  border: 0;
  box-shadow: none;
}

/* Rail separates from canvas purely by surface fill (--c-rail vs --c-page). */
#sidebar::after {
  display: none;
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: var(--s-lg) var(--s-md) var(--s-md);
}

.rail__wordmark {
  font-family: var(--font-wordmark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase !important;
  color: var(--salt);
  line-height: 1;
}

.rail__sub {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: var(--w-med);
  letter-spacing: 0.01em;
  color: var(--c-ink-3);
  line-height: 1.2;
  margin-top: 3px;
}

.glass-header {
  background: color-mix(in srgb, var(--c-page) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 0;
  box-shadow: none;
  position: relative;
}

.glass-header::after {
  display: none;
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--t-xl);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-tight);
  color: var(--c-ink-1);
}

/* ==========================================================================
   4 · NAV
   Active state is a dot plus full-strength ink. Not a fill, not a stripe.
   ========================================================================== */

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  padding: 0.35rem 0.5rem 0.35rem 0.9rem;
  min-height: 30px;
  border-radius: var(--r-input);
  border: 0;
  font-family: var(--font-body);
  font-size: var(--t-sm);
  font-weight: var(--w-med);
  color: var(--c-ink-2);
  white-space: nowrap;
  transition:
    color var(--dur-micro) var(--ease-out),
    background-color var(--dur-micro) var(--ease-out);
}

.nav-link > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.nav-link:hover { color: var(--c-ink-1); background: var(--c-surface); }

.nav-link.active {
  color: var(--c-ink-1);
  background: var(--c-surface-2);
  font-weight: var(--w-semi);
  box-shadow: inset 2px 0 0 var(--c-accent);
}

.nav-link svg { color: currentColor; opacity: 0.65; }
.nav-link.active svg { opacity: 1; }

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 24px;
  gap: var(--s-sm);
  margin-top: 1.15rem;
  margin-bottom: 0.15rem;
  padding: 0.25rem 0.5rem;
  background: none;
  border: 0;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: var(--w-bold);
  letter-spacing: 0.09em;
  text-transform: uppercase !important;
  color: var(--c-ink-4);
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-micro) var(--ease-out);
}

.nav-group-header:first-of-type { margin-top: var(--s-xs); }
.nav-group-header:hover { color: var(--c-ink-2); }

.nav-group-chevron {
  flex: none;
  opacity: 0.5;
  transition: transform var(--dur-short) var(--ease-out);
}
.nav-group-header.nav-collapsed .nav-group-chevron { transform: rotate(-90deg); }

/* Oranzy headings stand on typography alone without vertical ticks. */
.head-tick {
  display: none;
}

/* ==========================================================================
   5 · SURFACES
   Fill and spacing carry separation. No outline, no shadow, no blur, no glow.
   ========================================================================== */

.glass,
.glass-thin,
.glass-elevated,
.glass-intense,
.glass-card,
.glass-card-static,
.card {
  background: var(--c-surface);
  border: 0;
  border-radius: var(--r-card);
  box-shadow: none;
  backdrop-filter: none;
}

/* Cards breathe at 24px; stat cards run tighter at 16px because a dashboard
   shows eight of them at once. Uniform padding everywhere is what makes a
   layout read flat. */
.glass-card, .glass-card-static, .card { padding: var(--s-md); }

/* Distill filter toolbars and table wrappers globally: no box-in-box nesting. */
.glass-card-static:has(> form.flex),
.glass-card-static:has(> form.gl-filters),
.glass-card:has(> select#log-container) {
  background: transparent;
  padding: 0;
  margin-bottom: var(--s-md);
}
.glass-card-static:not(:has(> .card-title)):has(> .table-container),
.glass-card-static:not(:has(> .card-title)):has(> div > .table-container) {
  background: transparent;
  padding: 0;
}
.flex > .glass-input,
.flex > .glass-select,
form.flex .glass-input,
form.flex .glass-select {
  min-height: 34px;
  padding-block: 0.35rem;
  font-size: var(--t-caption);
}
.flex > .glass-input:not([class*="w-"]):not(.flex-1),
.flex > .glass-select:not([class*="w-"]):not(.flex-1) {
  width: auto;
}
form.flex .form-label {
  font-size: 11px;
  margin-bottom: 2px;
  color: var(--c-ink-3);
  font-weight: var(--w-med);
}

/* The card title. One tick, one line of display type — no accent bar, because
   32 accent bars is not an accent. */
.card-title {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  margin-bottom: var(--s-md);
  font-family: var(--font-display);
  font-size: var(--t-md);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-tight);
  color: var(--c-ink-1);
  min-width: 0;
}

/* Zero 1px rules — sections separate via surface fill and spacing alone. */
.rule-dot {
  display: none !important;
  height: 0;
  background: none;
}

/* The old system drew a light-refraction highlight across the top of every
   card. Cut — it was the glassmorphism tell. */
.glass-card::before,
.glass-card-static::before,
.stat-card::before { content: none; display: none; }

.glass-card {
  transition: background-color var(--dur-short) var(--ease-out);
}
.glass-card:hover { background: var(--c-surface-2); transform: none; }

.glass-elevated, .glass-intense { background: var(--c-surface-2); }

/* Spectrum 2 ("Solar & Glacier") 2px top bars on tariff cards. */
[data-tariff] {
  position: relative;
}
[data-tariff="mini"] { box-shadow: inset 0 2px 0 var(--tier-mini-bar); }
[data-tariff="lite"] { box-shadow: inset 0 2px 0 var(--tier-lite-bar); }
[data-tariff="pro"]  { box-shadow: inset 0 2px 0 var(--tier-pro-bar); }
[data-tariff="maxi"] { box-shadow: inset 0 2px 0 var(--tier-maxi-bar); }

/* Cut outright — ambient orbs, grain, and glow borders were decoration with no
   semantic role, and all three are banned by the system. */
.ambient-orb, .grain-overlay, .glow-border::after, .glow-border::before {
  display: none !important;
  content: none !important;
}
.glow-border { box-shadow: none; }

.hover-lift:hover, .hover-scale:hover { transform: none; }
.hover-glow, .hover-glow:hover { box-shadow: none; }

.dot-field {
  background: none;
}

/* ==========================================================================
   6 · BUTTONS
   Primary is an inverted fill — ink background, page-coloured text. That is
   both the source language's rule and the only way this brand orange clears AA
   on a filled control: white on #e67a1a measures 2.93:1.
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xs);
  min-height: 40px;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: var(--r-input);
  font-family: var(--font-body);
  font-size: var(--t-sm);
  font-weight: var(--w-med);
  letter-spacing: 0.005em;
  text-transform: none;
  white-space: nowrap;              /* affordances never wrap to two lines    */
  cursor: pointer;
  transition:
    background-color var(--dur-micro) var(--ease-out),
    color var(--dur-micro) var(--ease-out),
    opacity var(--dur-micro) var(--ease-out);
}

.btn:disabled, .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--c-ink-1);
  color: var(--c-page);
}
.btn-primary:hover { background: var(--c-ink-2); }
.btn-primary:active { background: var(--c-ink-3); }

.btn-secondary, .btn-glass {
  background: var(--c-surface-2);
  color: var(--c-ink-2);
}
.btn-secondary:hover, .btn-glass:hover {
  background: var(--c-surface-3);
  color: var(--c-ink-1);
}
.btn-secondary:active, .btn-glass:active { background: var(--c-surface-2); }

/* Destructive stays quiet until it is reached for. */
.btn-danger {
  background: transparent;
  color: var(--c-bad);
}
.btn-danger:hover { background: var(--c-bad-dim); color: var(--c-bad); }
.btn-danger:active { background: var(--c-bad-dim); }

.btn-success {
  background: transparent;
  color: var(--c-ok);
}
.btn-success:hover { background: var(--c-ok-dim); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-input);
  background: transparent;
  color: var(--c-ink-3);
  cursor: pointer;
  transition:
    background-color var(--dur-micro) var(--ease-out),
    color var(--dur-micro) var(--ease-out);
}
.btn-icon:hover { background: var(--c-surface-2); color: var(--c-ink-1); }
/* Destructive row actions keep their signal colour — that is a defined status,
   not decoration. Edit/open actions do NOT: they were blue, which is not a
   colour this system defines, and they repeated on every row of every table. */
.btn-icon.is-danger { color: var(--c-bad); }
.btn-icon.is-danger:hover { background: var(--c-bad-dim); color: var(--c-bad); }

.btn-sm { min-height: 34px; padding: 0.35rem 0.75rem; font-size: var(--t-label); }
.btn-lg { min-height: 46px; padding: 0.7rem 1.4rem; font-size: var(--t-sm); }

.btn.is-choice-on, .choice-on {
  background: var(--c-surface);
  color: var(--c-ink-1);
  box-shadow: inset 0 0 0 2px var(--c-accent);
  font-weight: var(--w-semi);
}
.btn.is-choice-on:hover, .choice-on:hover {
  background: var(--c-surface-3);
  color: var(--c-ink-1);
}
html.light .btn.is-choice-on, html.light .choice-on {
  background: var(--c-ink-1);
  color: var(--c-page);
  box-shadow: none;
}
html.light .btn.is-choice-on:hover, html.light .choice-on:hover {
  background: var(--c-ink-2);
  color: var(--c-page);
}

@media (pointer: coarse) {
  .btn, .btn-sm, .nav-group-header, .gl-viewtoggle__btn, .gen-live__btn { min-height: 44px; }
  .btn-icon { width: 44px; height: 44px; }
}

/* ==========================================================================
   7 · FORMS
   Underline-free, frame-free. The field is a raised surface; focus lifts it and
   adds the ring.
   ========================================================================== */

:where(.glass-input, .glass-select, textarea.glass-input, .form-control) {
  width: 100%;
}
.glass-input, .glass-select, textarea.glass-input, .form-control {
  padding: 0.55rem 0.75rem;
  border: 0;
  border-radius: var(--r-input);
  background: var(--c-surface-2);
  color: var(--c-ink-1);
  font-family: var(--font-body);
  font-size: var(--t-sm);
  line-height: 1.4;
  transition: background-color var(--dur-micro) var(--ease-out);
}

/* Data-entry fields take the mono face — you are reading values, not prose. */
input[type="number"].glass-input,
input[type="date"].glass-input,
input[type="datetime-local"].glass-input,
.glass-input.is-data {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.glass-input::placeholder { color: var(--c-ink-4); }
.glass-input:hover:not(:focus), .glass-select:hover:not(:focus) {
  background: var(--c-surface-3);
}
.glass-input:focus, .glass-select:focus, textarea.glass-input:focus {
  background: var(--c-surface-3);
  outline: 2px solid var(--c-focus);
  outline-offset: 1px;
}
.glass-input:disabled, .glass-select:disabled, textarea.glass-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.glass-select {
  appearance: none;
  padding-inline-end: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

textarea.glass-input { min-height: 96px; resize: vertical; }

.form-label { display: block; margin-bottom: var(--s-xs); }

.input-group { display: flex; align-items: stretch; gap: var(--s-2xs); }
.input-group .glass-input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group__suffix {
  display: inline-flex;
  align-items: center;
  padding-inline: 0.65rem;
  border-radius: 0 var(--r-input) var(--r-input) 0;
  background: var(--c-surface-3);
  color: var(--c-ink-3);
  font-family: var(--font-data);
  font-size: var(--t-label);
  letter-spacing: var(--tr-label);
  white-space: nowrap;
}

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--c-accent); }

/* ==========================================================================
   8 · TABLES
   The core of this panel. Rows separated by the dot rule, numbers right and
   tabular, no zebra striping, no cell backgrounds. Alignment comes from Onest's
   tabular figures, not from a monospace face.
   ========================================================================== */

.table-container {
  position: relative;
  width: 100%;
  overflow-x: auto;
  border-radius: var(--r-card);
  background: var(--c-surface);
  -webkit-overflow-scrolling: touch;

  /* Scroll affordance. Several tables are wider than 1440px, so the last column
     (usually the row's action) sat past the edge with nothing to suggest it was
     there — readers took the cut-off header for broken layout. The two `local`
     layers are painted with the surface colour and travel WITH the content, so
     they mask the hint at whichever end is fully scrolled; the two `scroll`
     layers stay pinned to the container and show a fade only while there is
     more to reach. No shadow involved. */
  background-image:
    linear-gradient(to right, var(--c-surface), var(--c-surface)),
    linear-gradient(to left,  var(--c-surface), var(--c-surface)),
    linear-gradient(to right, var(--c-page), transparent),
    linear-gradient(to left,  var(--c-page), transparent);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 22px 100%, 22px 100%, 22px 100%, 22px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* NOTE — pinning the action column was tried and REVERTED. Making the last
   column sticky did keep the row action reachable, but on /users the
   "Регистрация" column then rendered on top of it and rows read as garbled
   text-over-text: strictly worse than the problem it solved. The horizontal
   scroll stays, and the fade on .table-container is what tells the reader
   there is more to the right. Do not re-add sticky columns without checking
   /users at 1440px first. */

/* An empty state inside a table sits in a colspan cell as wide as the TABLE,
   not the viewport — so on a narrow screen its centred message was centred
   off-screen and had to be scrolled to. Pin it to the visible edge instead. */
.table-container .empty-state,
.table td .empty-state {
  position: sticky;
  left: 0;
  max-width: min(100%, calc(100vw - 2rem));
  /* NOT margin-inline: auto — auto re-centres the block inside a cell that is
     as wide as the whole table, which is exactly how the message ended up
     off-screen. Pinned to the left edge, it is visible at scroll 0 and stays
     put while the table scrolls. */
  margin-inline-start: 0;
  margin-inline-end: auto;
}

.table, .glass-table, .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}

.table thead, .glass-table thead, .data-table thead { background: var(--c-surface-2); }

.table th, .glass-table th, .data-table th, .data-table__th {
  padding: 0.6rem 0.75rem;
  border: 0;
  text-align: left;
  font-family: var(--font-data);
  font-size: var(--t-label);
  font-weight: var(--w-med);
  letter-spacing: var(--tr-label);
  text-transform: none;
  color: var(--c-ink-3);
  white-space: nowrap;
}

.table td, .glass-table td, .data-table td, .data-table__td {
  padding: 0.65rem 0.75rem;
  border: 0;
  color: var(--c-ink-2);
  vertical-align: middle;
}

/* Rows separated by 2px canvas gap, never a dotted or 1px hairline border. */
.table tbody tr, .glass-table tbody tr, .data-table tbody tr {
  border-bottom: 2px solid var(--c-page);
  transition: background-color var(--dur-micro) var(--ease-out);
}
.table tbody tr:last-child,
.glass-table tbody tr:last-child,
.data-table tbody tr:last-child { border-bottom: 0; }

.table tbody tr:hover,
.glass-table tbody tr:hover,
.data-table tbody tr:hover { background-color: var(--c-surface-2); }

/* Zebra striping is banned — the previous system had it on even rows. */
.data-table tbody tr:nth-child(even) > td,
.table tbody tr:nth-child(even) > td { background: none; }

/* Active row: raised fill plus an accent tick in the leading cell. */
.data-table tbody tr.is-active,
.table tbody tr.is-active { background-color: var(--c-surface-3); }
.data-table tbody tr.is-active > td:first-child,
.table tbody tr.is-active > td:first-child {
  box-shadow: inset 2px 0 0 var(--c-accent);
}

/* Numbers right and mono; text left and body face. */
.table td.num, .table th.num,
.glass-table td.num, .data-table td.num,
.table td.text-right, .table th.text-right,
.glass-table td.text-right, .glass-table th.text-right,
.data-table td.text-right, .data-table__th.text-right {
  text-align: right;
}
.table td.num, .glass-table td.num, .data-table td.num, .tabular {
  font-family: var(--font-data);
}
.table th.text-center, .glass-table th.text-center,
.data-table__th.text-center, .table td.text-center { text-align: center; }
.table th.text-left, .glass-table th.text-left,
.data-table__th.text-left { text-align: left; }

.fit-table { table-layout: auto; }
.fit-table th, .fit-table td { white-space: nowrap; }

/* ==========================================================================
   9 · BADGES AND CHIPS
   Dim fill plus coloured text. No outline, no pill borders.
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  padding: 0.15rem 0.5rem;
  border: 0;
  border-radius: var(--r-tech);
  background: var(--c-surface-2);
  color: var(--c-ink-3);
  font-family: var(--font-data);
  font-size: var(--t-label);
  font-weight: var(--w-med);
  letter-spacing: 0.04em;
  text-transform: none;
  white-space: nowrap;
  line-height: 1.5;
}

.badge-green  { background: var(--c-ok-dim);   color: var(--c-ok);   }
.badge-red    { background: var(--c-bad-dim);  color: var(--c-bad);  }
.badge-blue   { background: var(--c-info-dim); color: var(--c-info); }
.badge-cyan   { background: var(--c-info-dim); color: var(--c-info); }
.badge-orange { background: var(--c-accent-dim); color: var(--c-accent); }
.badge-yellow { background: var(--c-warn-dim); color: var(--c-warn); }
.badge-purple { background: var(--c-surface-3); color: var(--c-ink-2); }
.badge-gray   { background: var(--c-surface-2); color: var(--c-ink-3); }

/* Тариф рядом с именем пользователя. Отступ живёт здесь, а не на месте
   вызова: подпись стоит в полутора десятках таблиц, и один класс держит
   расстояние одинаковым во всех. */
.user-tariff {
  display: inline-flex;
  align-items: center;
  margin-left: var(--s-sm);
  vertical-align: middle;
}
/* Ника у строки нет — значок начинает строку сам, и отступ от левого края
   выглядел бы случайным сдвигом. .copy-id блочный, поэтому это тот случай. */
.copy-id + .user-tariff { margin-left: 0; }

.settings-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  padding: 0.3rem 0.65rem;
  border: 0;
  border-radius: var(--r-tech);
  background: var(--c-surface-2);
  color: var(--c-ink-2);
  font-family: var(--font-body);
  font-size: var(--t-caption);
  font-weight: var(--w-med);
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.settings-chip:hover { background: var(--c-surface-3); }
.settings-chip--danger { color: var(--c-bad); }
.settings-chip--danger:hover { background: var(--c-bad-dim); }

.settings-section-h { margin: var(--s-xl) 0 var(--s-sm); }

/* ==========================================================================
   10 · ALERTS AND INLINE STATUS
   No alert banners with coloured backgrounds. A dim fill, the status colour on
   the text, and a square status mark.
   ========================================================================== */

.alert-box {
  display: flex;
  align-items: flex-start;
  gap: var(--s-sm);
  padding: var(--s-sm) var(--s-md);
  border: 0;
  border-radius: var(--r-input);
  background: var(--c-surface-2);
  color: var(--c-ink-2);
  font-size: var(--t-sm);
}
.alert-box svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }

.alert-info    { background: var(--c-info-dim); }
.alert-info    svg { color: var(--c-info); }
.alert-warning { background: var(--c-warn-dim); }
.alert-warning svg { color: var(--c-warn); }
.alert-success { background: var(--c-ok-dim); }
.alert-success svg { color: var(--c-ok); }
.alert-danger  { background: var(--c-bad-dim); }
.alert-danger  svg { color: var(--c-bad); }

/* Inline status — the replacement for celebratory success toasts. Sits next to
   the trigger, says what happened, and goes away. */
.status-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  font-family: var(--font-data);
  font-size: var(--t-label);
  letter-spacing: var(--tr-label);
  color: var(--c-ink-3);
}
.status-inline::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 0px;
  background: currentColor;
}
.status-inline.is-ok  { color: var(--c-ok); }
.status-inline.is-bad { color: var(--c-bad); }

/* ==========================================================================
   11 · MODAL
   Layering through background contrast, not shadow.
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-md);
  background: var(--c-backdrop);
  backdrop-filter: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-long) var(--ease-out);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-overlay.hidden { display: none; }

.modal-content {
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  overflow-y: auto;
  border: 0;
  border-radius: var(--r-panel);
  background: var(--c-surface);
  box-shadow: none;
  opacity: 0;
  transform: scale(0.97);
  transition:
    opacity var(--dur-long) var(--ease-out),
    transform var(--dur-long) var(--ease-out);
}
.modal-overlay.active .modal-content { opacity: 1; transform: scale(1); }

.modal-header { padding: var(--s-lg) var(--s-lg) var(--s-sm); }
.modal-title {
  font-family: var(--font-display);
  font-size: var(--t-lg);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-tight);
  color: var(--c-ink-1);
}
.modal-body { padding: var(--s-sm) var(--s-lg) var(--s-lg); }
.modal-footer {
  display: flex;
  gap: var(--s-sm);
  padding: var(--s-md) var(--s-lg) var(--s-lg);
  border: 0;
  background: none;
}

/* ==========================================================================
   12 · TOAST
   Failures and async results only. Fixed to a corner so an arriving toast never
   pushes layout, and existing toasts never move.
   ========================================================================== */

.toast-container {
  position: fixed;
  inset-block-end: var(--s-md);
  inset-inline-end: var(--s-md);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  max-width: min(380px, calc(100vw - 2rem));
  padding: 0.65rem var(--s-md);
  border: 0;
  border-radius: var(--r-input);
  background: var(--c-surface-3);
  color: var(--c-ink-1);
  font-family: var(--font-data);
  font-size: var(--t-caption);
  letter-spacing: 0.02em;
  box-shadow: none;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: auto;
  transition:
    opacity var(--dur-short) var(--ease-out),
    transform var(--dur-short) var(--ease-out);
}
.toast.show { opacity: 1; transform: none; }

.toast__icon { flex: none; display: inline-flex; }
.toast__message { min-width: 0; }
.toast-success .toast__icon { color: var(--c-ok); }
.toast-error   .toast__icon { color: var(--c-bad); }

/* ==========================================================================
   13 · INSTRUMENT WIDGETS
   The hero metric, the stat row, the segmented bar. Doto carries the numerals;
   Onest carries the label and the unit.
   ========================================================================== */

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.75rem 0.9rem;
  border: 0;
  border-radius: var(--r-card);
  background: var(--c-surface);
  box-shadow: none;
  transition: background-color var(--dur-short) var(--ease-out);
}
.stat-card:hover { background: var(--c-surface-2); transform: none; }

.stat-card__icon {
  display: none;
}

/* Stat cards are the SECONDARY layer, so they take Onest, not Doto.
   Two reasons, both learned from looking at the rendered page:
   (a) Doto has no rouble glyph, so "119 883 ₽" fell back mid-value to a mono
       face at Doto's 32px and wrapped the ₽ onto its own line;
   (b) the dot-matrix face is the one moment of surprise per screen. Eight of
       them on a dashboard is a texture, not a moment.
   Doto survives on .metric__value — the single hero number, where the markup
   splits the unit out into its own span. */
.stat-card__value, .stat-widget-value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0;
  font-family: var(--font-data);
  font-size: var(--t-lg);
  font-weight: var(--w-med);
  letter-spacing: var(--tr-tight);
  line-height: 1.15;
  color: var(--c-ink-1);
  overflow-wrap: anywhere;
  min-width: 0;
}

/* Opt-in dot matrix, for a number that is genuinely the hero of its block. */
.is-doto {
  font-family: var(--font-numeral);
  font-stretch: normal;
  letter-spacing: var(--tr-display);
}

/* The unit rides beside the number, sized RELATIVE to it and optically raised to
   the cap height. Absolute sizing was the bug: an 11px rouble sign pinned to the
   baseline of a 72px dot-matrix number read as a detached, crooked speck. Ems
   keep the pairing proportional at every metric size. */
.stat-card__value span, .stat-widget-value span, .metric__unit {
  font-family: var(--font-data);
  /* Relative sizing keeps the pairing proportional, but a bare em put the
     rouble sign at 8.4px on a 20px stat value — legible only if you lean in.
     max() sets an 11px floor so the unit never drops below label size. */
  font-size: max(0.75rem, 0.7em);
  font-weight: var(--w-base);
  letter-spacing: 0.02em;
  color: var(--c-ink-3);
  margin-inline-start: 0.22em;
  line-height: 1;
  white-space: nowrap;
}

.stat-card__label { margin: 0; }

.stat-card__change {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  font-family: var(--font-data);
  font-size: var(--t-label);
  letter-spacing: 0.02em;
  color: var(--c-ink-3);
}
.stat-card__change--positive { color: var(--c-ok); }
.stat-card__change--negative { color: var(--c-bad); }

.stat-accent { color: var(--c-accent); }

/* The one number. Primary layer of the three-layer rule — used once per page,
   never twice. */
.metric {
  display: flex;
  flex-direction: column;
  gap: var(--s-xs);
}
.metric__label {
  font-family: var(--font-data);
  font-size: var(--t-label);
  font-weight: var(--w-med);
  letter-spacing: var(--tr-label);
  color: var(--c-ink-3);
}
.metric__value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.18em;
  font-family: var(--font-numeral);
  font-size: var(--t-4xl);
  font-weight: var(--w-bold);
  letter-spacing: var(--tr-display);
  line-height: var(--lh-display);
  color: var(--c-ink-1);
  overflow-wrap: anywhere;
  min-width: 0;
}

/* Currency/unit rides on the numeral baseline at proportional scale. */
.metric__unit {
  font-family: var(--font-numeral);
  font-size: 0.62em;
  font-weight: var(--w-semi);
  margin-top: 0;
  margin-inline-start: 0;
  color: var(--c-ink-3);
  line-height: 1;
}
.metric__value.is-ok   { color: var(--c-ok); }
.metric__value.is-warn { color: var(--c-warn); }
.metric__value.is-bad  { color: var(--c-bad); }
.metric__value.is-accent { color: var(--c-accent); }

.metric__foot {
  display: flex;
  align-items: baseline;
  gap: var(--s-sm);
  font-family: var(--font-data);
  font-size: var(--t-label);
  letter-spacing: 0.02em;
  color: var(--c-ink-3);
}

/* --- The segmented bar. The signature data form. ------------------------- */

.segbar {
  display: flex;
  gap: 2px;
  height: 8px;
  width: 100%;
  background: var(--c-surface-3);
  --seg-track: repeating-linear-gradient(90deg,
    #000 0 calc(var(--seg-w, 14px) - 2px), transparent calc(var(--seg-w, 14px) - 2px) var(--seg-w, 14px));
  -webkit-mask-image: var(--seg-track);
  mask-image: var(--seg-track);
}
.segbar--hero { height: 16px; }
.segbar--compact { height: 5px; }

.segbar__seg {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 0px;
  background: var(--c-surface-3);
}
.segbar__seg.is-on   { background: var(--c-ink-1); }
.segbar__seg.is-ok   { background: var(--c-ok); }
.segbar__seg.is-warn { background: var(--c-warn); }
.segbar__seg.is-bad  { background: var(--c-bad); }
.segbar__seg.is-accent { background: var(--c-accent); }

/* A proportional segmented bar. The blocks are drawn as a repeating mask over a
   solid fill, so an arbitrary percentage width still reads as discrete
   square-ended segments with 2px gaps — the signature form from design.md,
   rather than a solid rounded pill. */
.segbar__fill {
  height: 100%;
  min-width: 0;
  overflow: hidden;
}
.segbar__fill-inner {
  height: 100%;
  background: var(--c-ink-1);
  --seg-mask: repeating-linear-gradient(90deg,
    #000 0 calc(var(--seg-w, 14px) - 2px), transparent calc(var(--seg-w, 14px) - 2px) var(--seg-w, 14px));
  -webkit-mask-image: var(--seg-mask);
  mask-image: var(--seg-mask);
}
.segbar__fill-inner.is-accent { background: var(--c-accent); }
.segbar__fill-inner.is-ok     { background: var(--c-ok); }
.segbar__fill-inner.is-warn   { background: var(--c-warn); }
.segbar__fill-inner.is-bad    { background: var(--c-bad); }

.segbar-row {
  display: flex;
  flex-direction: column;
  gap: var(--s-xs);
}
.segbar-row__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-sm);
}
.segbar-row__value {
  font-family: var(--font-data);
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
  color: var(--c-ink-1);
}

/* --- Stat rows: label left, value right, no divider ---------------------- */

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-md);
  padding-block: 0.45rem;
}
.stat-row__label {
  font-family: var(--font-data);
  font-size: var(--t-label);
  letter-spacing: var(--tr-label);
  color: var(--c-ink-3);
  min-width: 0;
}
.stat-row__value {
  font-family: var(--font-data);
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
  color: var(--c-ink-1);
  white-space: nowrap;
}

/* ==========================================================================
   14 · PAGINATION
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  flex-wrap: wrap;
}
.pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  padding-inline: 0.5rem;
  border: 0;
  border-radius: var(--r-tech);
  background: var(--c-surface-2);
  color: var(--c-ink-3);
  font-family: var(--font-body);
  font-size: var(--t-caption);
  font-weight: var(--w-med);
  cursor: pointer;
  transition:
    background-color var(--dur-micro) var(--ease-out),
    color var(--dur-micro) var(--ease-out);
}
.pagination__btn:hover:not(:disabled) { background: var(--c-surface-3); color: var(--c-ink-1); }
.pagination__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination__btn--active {
  background: var(--c-surface);
  color: var(--c-ink-1);
  box-shadow: inset 0 0 0 2px var(--c-accent);
  font-weight: var(--w-semi);
}
html.light .pagination__btn--active {
  background: var(--c-ink-1);
  color: var(--c-page);
  box-shadow: none;
}
.pagination__info { white-space: nowrap; }

/* ==========================================================================
   15 · EMPTY AND LOADING
   No skeletons, no mascots, no multi-paragraph apologies.
   ========================================================================== */

.empty-state {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-xs);
  padding: var(--s-xl) var(--s-md);
  text-align: center;
  border-radius: var(--r-card);
  background: var(--c-surface-2);
  isolation: isolate;
}
.empty-state::before {
  display: none;
}
.empty-state__icon { display: none; }
.empty-state__title { color: var(--c-ink-3); }
.empty-state__description {
  max-width: 46ch;
  font-size: var(--t-sm);
  color: var(--c-ink-4);
}

/* A segmented loader, not a spinner. Reads as hardware. */
.loading-spinner {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}
/* htmx indicators stay hidden until htmx marks the request in flight. */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-flex; gap: 2px; align-items: center; }

.loading-spinner::before,
.loading-spinner::after,
.loading-spinner > i {
  content: "";
  width: 4px;
  height: 12px;
  border-radius: 1px;
  background: var(--c-ink-3);
  animation: seg-tick 900ms steps(1, end) infinite;
}
.loading-spinner::after { animation-delay: 300ms; }
.loading-spinner > i    { animation-delay: 600ms; }

@keyframes seg-tick {
  0%, 33%  { opacity: 1; }
  34%, 100%{ opacity: 0.25; }
}

.htmx-request { position: relative; }
.htmx-request::after { content: none; }

/* A field that IS the htmx trigger has no children to dim, so a search box gave
   no feedback at all while the request was in flight. Mark the field itself
   with a travelling bar along its lower edge — it occupies no layout, so the
   page cannot shift while it runs. */
input.htmx-request,
select.htmx-request,
textarea.htmx-request {
  background-image: linear-gradient(90deg, transparent, var(--c-accent), transparent);
  background-size: 40% 2px;
  background-repeat: no-repeat;
  background-position: -40% 100%;
  animation: htmx-scan 900ms linear infinite;
}
@keyframes htmx-scan {
  to { background-position: 140% 100%; }
}
/* Zero-blink HTMX swaps: never dim or blank out containers during polling or filtering. */
.htmx-swapping,
.htmx-settling,
.htmx-added {
  opacity: 1;
  transition: none;
}

/* ==========================================================================
   16 · CHARTS
   Line and axis colours are handed to Chart.js from JS; this only frames them.
   ========================================================================== */

.chart-container {
  position: relative;
  width: 100%;
  min-height: 220px;
  padding: var(--s-sm);
  border-radius: var(--r-card);
  background: var(--c-surface);
}

/* ==========================================================================
   17 · SMALL PARTS
   ========================================================================== */

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  z-index: var(--z-toast);
  padding: var(--s-sm) var(--s-md);
  border-radius: var(--r-input);
  background: var(--c-ink-1);
  color: var(--c-page);
  font-family: var(--font-data);
  font-size: var(--t-caption);
}
.skip-link:focus { inset-inline-start: var(--s-md); top: var(--s-md); }

.copy-id {
  font-family: var(--font-data);
  font-size: var(--t-label);
  color: var(--c-ink-3);
  cursor: pointer;
  border-radius: var(--r-tech);
  padding: 0.1rem 0.3rem;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.copy-id:hover { background: var(--c-surface-2); color: var(--c-ink-1); }
.copy-id:active { background: var(--c-surface-3); }

kbd {
  font-family: var(--font-data);
  font-size: var(--t-label);
  padding: 0.15rem 0.4rem;
  border: 0;
  border-radius: var(--r-tech);
  background: var(--c-surface-2);
  color: var(--c-ink-2);
}

/* --- Generation feed ------------------------------------------------------ */

.gl-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-sm);
}
.gl-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-xs);
  flex: 1 1 auto;
  min-width: 0;
}
.gl-filters .glass-input,
.gl-filters .glass-select {
  width: auto;
  min-height: 34px;
  padding-block: 0.35rem;
  font-size: var(--t-caption);
}
.gl-filters input[name="chat_id"] { width: 136px; }
.gl-filters input[name="model"] { width: 128px; }
.gl-filters input[type="date"] { width: 132px; }
@media (max-width: 640px) {
  .gl-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .gl-filters .glass-input,
  .gl-filters .glass-select,
  .gl-filters input[name="chat_id"],
  .gl-filters input[name="model"],
  .gl-filters input[type="date"] {
    width: 100%;
  }
}
.gl-toolbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  margin-inline-start: auto;
}
.gl-meta-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-sm);
}
.gl-total {
  color: var(--c-ink-4);
  font-size: var(--t-caption);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 28px;
  padding: 0.2rem 0.55rem;
  border: 0;
  border-radius: 0px;
  background: transparent;
  color: var(--c-ink-3);
  font-family: var(--font-data);
  font-size: var(--t-caption);
  font-weight: var(--w-med);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
.btn-export:hover {
  color: var(--c-ink-1);
  background: var(--c-surface-2);
}

.gl-viewtoggle { display: inline-flex; gap: 2px; padding: 2px; border-radius: 0px; background: var(--c-surface-2); }
.gl-viewtoggle__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0.25rem 0.65rem;
  border: 0;
  border-radius: 0px;
  background: transparent;
  color: var(--c-ink-3);
  font-family: var(--font-body);
  font-size: var(--t-caption);
  font-weight: var(--w-med);
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.gl-viewtoggle__btn:hover { color: var(--c-ink-1); }
.gl-viewtoggle__btn.is-active {
  background: var(--c-surface);
  color: var(--c-ink-1);
  box-shadow: inset 0 0 0 2px var(--c-accent);
  font-weight: var(--w-semi);
}
html.light .gl-viewtoggle__btn.is-active {
  background: var(--c-ink-1);
  color: var(--c-page);
  box-shadow: none;
}

.gen-feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 2px;
  overflow-anchor: none;
}
.gen-feed-date {
  grid-column: 1 / -1;
  margin: var(--s-lg) 0 var(--s-sm);
}
.gen-feed-date:first-child { margin-top: 0; }
.gen-feed-empty {
  grid-column: 1 / -1;
  color: var(--c-ink-4);
  font-size: var(--t-sm);
}
.gen-feed-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-input);
  background: var(--c-surface-2);
  cursor: pointer;
  transition:
    background-color var(--dur-micro) var(--ease-out),
    opacity var(--dur-long) var(--ease-out),
    transform var(--dur-long) var(--ease-out);
}
.gen-feed-tile:hover { background: var(--c-surface-3); }

/* Прибытие в живом режиме. Переход, а не @keyframes: у плиток с картинкой уже
   висит анимация мерцания, и вторая анимация на том же элементе её бы стёрла.
   Класс снимает JS на следующем кадре после вставки. */
.gen-feed-tile.is-enter { opacity: 0; transform: translateY(-8px); }

/* Засечка «только что пришло» — та же акцентная метка, что помечает активную
   строку таблицы. Три пикселя на плитку в 140: акцент остаётся сигналом, а не
   заливкой. Живёт на каждой плитке с opacity: 0, чтобы гаснуть переходом, а не
   исчезать вместе с удалённым псевдоэлементом. */
.gen-feed-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px var(--c-accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-long) var(--ease-out);
}
.gen-feed-tile.is-fresh::after { opacity: 1; }
.gen-feed-media { width: 100%; height: 100%; object-fit: cover; }
.gen-feed-play {
  position: absolute;
  inset-block-end: var(--s-xs);
  inset-inline-end: var(--s-xs);
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-tech);
  background: var(--c-page);
  color: var(--c-ink-1);
}
/* Text/audio tiles have no thumbnail, so the message itself fills the tile.
   The caption bar is absolutely positioned at the bottom, so the message needs
   room reserved for it — without the padding the last line ran underneath the
   model name and cost. */
.gen-feed-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-xs);
  height: 100%;
  padding: 24px var(--s-sm) 26px;
  color: var(--c-ink-4);
  text-align: center;
  overflow: hidden;
}
/* Иконка-заглушка не имеет своих размеров в разметке, поэтому растягивалась
   на всю ширину плитки — 82 px из 106 доступных. Тексту оставалось 19 px,
   то есть ОДНА строка при кламе на четыре: обрезку делал родитель с
   overflow:hidden, и строка рвалась на полуслове без многоточия
   («✗ Не получилось — попробу»). Многоточие рисует сам клам, но только
   когда высота элемента равна его же кламу, а не сжата родителем. */
.gen-feed-ph svg {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}
.gen-feed-ph__text {
  font-family: var(--font-data);
  font-size: var(--t-label);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  flex: 0 0 auto;
  max-height: calc(1.35em * 3);
  overflow: hidden;
  word-break: break-word;
}
.gen-feed-scrim {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  padding: 6px 7px 5px;
  background: linear-gradient(to top, color-mix(in srgb, var(--c-page) 92%, transparent) 64%, transparent);
  font-size: var(--t-label);
  line-height: 1.3;
  color: var(--c-ink-1);
}
.gen-feed-cat {
  font-weight: var(--w-semi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.gen-feed-cat--web,
.gen-source-text--web {
  color: var(--c-source-web);
  font-weight: var(--w-semi);
}
.gen-feed-cat--bot,
.gen-source-text--bot {
  color: var(--c-source-bot);
  font-weight: var(--w-semi);
}
.gen-feed-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  margin-inline-start: auto;
  color: var(--c-ink-2);
  font-variant-numeric: tabular-nums;
}
.gen-feed-cost svg { display: none; }
/* Username chip, revealed on hover or keyboard focus. */
.gen-feed-user {
  position: absolute;
  top: 6px;
  left: 6px;
  max-width: calc(100% - 12px);
  display: flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--r-tech);
  background: var(--c-page);
  color: var(--c-ink-1);
  font-size: var(--t-label);
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-micro) var(--ease-out);
}
.gen-feed-user__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gen-feed-tile:hover .gen-feed-user,
.gen-feed-tile:focus-visible .gen-feed-user { opacity: 1; }

.gen-feed-user__tariff {
  flex: 0 0 auto;
  margin-left: var(--s-xs);
  color: var(--c-ink-3);
}
.gen-feed-user__tariff::before {
  content: "·";
  margin-right: var(--s-xs);
}

/* Infinite-scroll sentinel. A loading ring is an allowed exception to the
   no-hairline rule — it is a spinner, not a frame. */
.gen-feed-more {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}
.gen-feed-more::after {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: var(--r-pill);
  border: 2px solid var(--c-surface-3);
  border-top-color: var(--c-accent);
  animation: spin 700ms linear infinite;
}
.table tbody tr.table-more-row,
.glass-table tbody tr.table-more-row,
.data-table tbody tr.table-more-row {
  border-bottom: 0;
  background: transparent !important;
}
.table tbody tr.table-more-row > td.table-more-cell {
  padding: 0;
}
.table-container .gen-feed-more,
.table td .gen-feed-more {
  position: sticky;
  left: 0;
  max-width: min(100%, calc(100vw - 2rem));
}

/* --- Живой режим --------------------------------------------------------
   Лента подтягивает новые генерации сама. Точка моргает по факту удачного
   опроса: это событие, а не фоновая пульсация — бесконечное «дыхание» в этой
   системе запрещено, и дом ловит взгляд один раз, а не держит его. */

.gen-live {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-sm);
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: var(--t-caption);
}
.gen-live__dot { display: none; }

.gen-live__label {
  flex: none;
  color: var(--c-ink-4);
  font-weight: var(--w-semi);
  white-space: nowrap;
  transition: color var(--dur-micro) var(--ease-out);
}
.gen-live[data-state="on"]    .gen-live__label { color: var(--c-ok); }
.gen-live[data-state="error"] .gen-live__label { color: var(--c-bad); }
.gen-live__meta {
  flex: none;
  color: var(--c-ink-4);
  font-size: var(--t-caption);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gen-live__right {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  margin-inline-start: auto;
}
.gen-live__count {
  color: var(--c-ink-3);
  font-size: var(--t-caption);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gen-live__count[hidden] { display: none; }
.gen-live__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0.15rem 0.55rem;
  border: 0;
  border-radius: var(--r-tech);
  background: var(--c-surface-2);
  color: var(--c-ink-3);
  font-family: var(--font-body);
  font-size: var(--t-caption);
  font-weight: var(--w-med);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-micro) var(--ease-out),
    color var(--dur-micro) var(--ease-out);
}
.gen-live__btn:hover { background: var(--c-surface-3); color: var(--c-ink-1); }

/* Плашка «новое наверху». Держится под шапкой: её реальную высоту admin.js
   кладёт в --gen-live-top, потому что шапка sticky и на разных ширинах разная. */
.gen-live-jump {
  position: fixed;
  top: var(--gen-live-top, 88px);
  inset-inline: 0;
  margin-inline: auto;
  width: fit-content;
  z-index: var(--z-sticky);
  padding: 0.45rem 0.95rem;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--c-ink-1);
  color: var(--c-page);
  font-family: var(--font-body);
  font-size: var(--t-sm);
  font-weight: var(--w-med);
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity var(--dur-short) var(--ease-out),
    transform var(--dur-short) var(--ease-out),
    background-color var(--dur-micro) var(--ease-out);
}
.gen-live-jump[hidden] { display: none; }
.gen-live-jump.is-shown { opacity: 1; transform: translateY(0); }
.gen-live-jump:hover { background: var(--c-ink-2); }
/* Контент живёт правее рельса — плашка центрируется по нему, а не по окну. */
@media (min-width: 768px) {
  .gen-live-jump { inset-inline: var(--rail-w) 0; }
}

/* Thumbnails stream in from the shared /thumb endpoint; shimmer until loaded. */
.gen-feed-tile--image,
.gen-feed-tile--video {
  background-image: linear-gradient(100deg,
    var(--c-surface-2) 25%, var(--c-surface-3) 45%, var(--c-surface-2) 65%);
  background-size: 220% 100%;
  animation: genFeedShimmer 1.3s ease-in-out infinite;
}
.gen-feed-tile.is-loaded { animation: none; background-image: none; }
.gen-feed-tile--image img.gen-feed-media,
.gen-feed-tile--video img.gen-feed-media {
  opacity: 0;
  transition: opacity var(--dur-long) var(--ease-out);
}
.gen-feed-tile.is-loaded img.gen-feed-media { opacity: 1; }

@keyframes genFeedShimmer {
  from { background-position: 130% 0; }
  to   { background-position: -30% 0; }
}

/* --- Lightbox -----------------------------------------------------------
   Also missing from the first pass. With no rules at all the overlay had no
   positioning and no display handling, so clicking a tile appeared to do
   nothing — the owner reported exactly that. No blur and no shadow here;
   layering is carried by background contrast, as everywhere else. */

.gen-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-md);
  opacity: 0;
  transition: opacity var(--dur-short) var(--ease-out);
}
.gen-lightbox[hidden] { display: none; }
.gen-lightbox.is-open { opacity: 1; }

.gen-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: var(--c-backdrop);
  backdrop-filter: none;
}

.gen-lightbox__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: min(920px, 94vw);
  max-height: 92dvh;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-panel);
  background: var(--c-surface);
  box-shadow: none;
  transform: scale(0.97);
  transition: transform var(--dur-short) var(--ease-out);
}
.gen-lightbox.is-open .gen-lightbox__dialog { transform: scale(1); }

.gen-lightbox__close {
  position: absolute;
  top: var(--s-sm);
  right: var(--s-sm);
  z-index: var(--z-raised);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  color: var(--c-ink-1);
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.gen-lightbox__close:hover { background: var(--c-ink-1); color: var(--c-page); }
.gen-lightbox__close svg { width: 18px; height: 18px; }

.gen-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--z-raised);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  color: var(--c-ink-1);
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out),
              opacity var(--dur-micro) var(--ease-out);
}
.gen-lightbox__nav:hover { background: var(--c-ink-1); color: var(--c-page); }
.gen-lightbox__nav svg { width: 20px; height: 20px; }
.gen-lightbox__nav--prev { left: var(--s-sm); }
.gen-lightbox__nav--next { right: var(--s-sm); }
.gen-lightbox__nav[disabled] { opacity: 0.25; cursor: default; pointer-events: none; }

.gen-lightbox__media {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-page);
  max-height: 74dvh;
}
.gen-lightbox__media img,
.gen-lightbox__media video,
.gen-lightbox__media audio {
  display: block;
  max-width: 100%;
  max-height: 74dvh;
}
.gen-lightbox__media audio { width: 80vw; max-width: 520px; margin: var(--s-xl); }

.gen-lightbox__meta {
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
  padding: var(--s-md) var(--s-lg) var(--s-lg);
  overflow-y: auto;
}
.gen-lb-caption {
  font-size: var(--t-sm);
  line-height: 1.5;
  color: var(--c-ink-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 22dvh;
  overflow-y: auto;
}
.gen-lb-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-sm) var(--s-md);
  font-size: var(--t-caption);
  color: var(--c-ink-3);
}
.gen-lb-facts a { color: var(--c-info); font-weight: var(--w-med); }
.gen-lb-facts a:hover { text-decoration: underline; }
.gen-lb-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--c-accent);
  font-weight: var(--w-semi);
  font-variant-numeric: tabular-nums;
}
.gen-lb-detail {
  align-self: flex-start;
  color: var(--c-info);
  font-size: var(--t-caption);
  font-weight: var(--w-med);
}
.gen-lb-detail:hover { text-decoration: underline; }
.gen-lb-pos { color: var(--c-ink-4); font-variant-numeric: tabular-nums; }

/* Live-poll indicator on the campaign-traffic dashboard. */
.campaign-poll-dot {
  width: 6px;
  height: 6px;
  border-radius: 0px;
  background: var(--c-ink-4);
  transition: background-color var(--dur-short) var(--ease-out);
}
#campaign-poll.htmx-request .campaign-poll-dot { background: var(--c-accent); }


/* --- Scrollbars ---------------------------------------------------------- */

* { scrollbar-width: thin; scrollbar-color: var(--c-surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-surface-3); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--c-ink-4); }

/* ==========================================================================
   18 · TEXT UTILITIES
   Kept because the templates reference them. Repointed at the new tokens.
   ========================================================================== */

.text-gradient {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  -webkit-text-fill-color: currentColor;
  color: var(--c-ink-1);
}

.text-primary   { color: var(--c-ink-2); }
.text-secondary { color: var(--c-ink-3); }
.text-tertiary  { color: var(--c-ink-4); }
.text-orange    { color: var(--c-accent); }
.text-success   { color: var(--c-ok); }
.text-danger    { color: var(--c-bad); }
.text-warning   { color: var(--c-warn); }
.text-info      { color: var(--c-info); }

/* .font-mono is a legacy utility name used across the templates. It no longer
   means monospace — it resolves to the one text family with tabular figures,
   which is what those call sites actually wanted (aligned numbers). */
.font-mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.font-numeral { font-family: var(--font-numeral); }

.tracking-tight  { letter-spacing: var(--tr-tight); }
.tracking-normal { letter-spacing: 0; }
.tracking-wide   { letter-spacing: var(--tr-label); }

/* Clickable text is a single-line object — a nav link, button or inline action
   that wraps to two lines reads as a styling fault, not as intent. Gate 49.
   Headings may wrap; the affordance beside them may not. */
.btn, .nav-link, .pagination__btn, .gl-viewtoggle__btn, .settings-chip,
.card-title + a, .card-title ~ a { white-space: nowrap; }

/* ==========================================================================
   19 · MOTION
   ========================================================================== */

/* Zero-blink page and HTMX rendering: cards, tables and widgets paint at full
   opacity immediately without entrance fade/translate flashes on reload or swap. */
.animate-fade-in,
.animate-fade-in-up,
.animate-slide-in,
.animate-scale-in,
.stagger-children > * {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

/* Cut. Ambient breathing and pulsing glows pull the eye and never let go. */
.animate-pulse-glow, .animate-breathe { animation: none; }
.animate-spin { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 150ms !important;
    animation-delay: 0ms !important;
    transition-duration: 150ms !important;
  }
  .animate-fade-in, .animate-fade-in-up, .animate-slide-in,
  .animate-scale-in, .stagger-children > * {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .modal-content { transform: none !important; }
  /* Functional loaders keep running — they carry information. */
  .loading-spinner::before, .loading-spinner::after, .loading-spinner > i,
  .animate-spin, .gen-feed-more::after { animation-duration: 1400ms !important; }
  input.htmx-request, select.htmx-request, textarea.htmx-request { animation-duration: 1600ms !important; }
  /* Живой режим: пространственное движение схлопывается в проявление. */
  .gen-feed-tile.is-enter { transform: none; }
  .gen-live__dot.is-beat { transform: none; }
  .gen-live-jump, .gen-live-jump.is-shown { transform: none; }
  /* Decorative shimmer is not information — cut it. */
  .gen-feed-tile--image, .gen-feed-tile--video { animation: none; background-image: none; }
  .gen-feed-tile--image img.gen-feed-media,
  .gen-feed-tile--video img.gen-feed-media { opacity: 1; transition: none; }
  .gen-lightbox__dialog { transform: none !important; }
}

/* ==========================================================================
   20 · LAYOUT AND RESPONSIVE
   Verified at 320 / 375 / 414 / 768 px.
   ========================================================================== */

main#main-content { min-width: 0; }
main#main-content > div { min-width: 0; max-width: 100%; }

/* Any grid track that can hold a table, chart or image gets minmax(0, 1fr) —
   a bare 1fr lets the content set the track's minimum and push the page wide. */
.grid { min-width: 0; }
.grid > * { min-width: 0; }

/* Preserve Tailwind display utilities against component display declarations in nothing.css. */
.hidden, [hidden] { display: none !important; }
@media (min-width: 768px) {
  .md\:hidden { display: none !important; }
  .md\:block { display: block !important; }
  .md\:flex { display: flex !important; }
}

@media (max-width: 48rem) {
  /* Long page names ("Использование моделей", "Безлимиты и очередь") were
     clipped to an ellipsis between the menu button and the theme toggle.
     Smaller and allowed two lines rather than truncated. */
  .page-title {
    font-size: var(--t-md);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.2;
  }
  .table-container { border-radius: 0; }
  .modal-content { max-width: 100%; }
  .toast-container { inset-inline: var(--s-sm); inset-inline-end: var(--s-sm); }
  .toast { max-width: 100%; }
  .metric__value { font-size: var(--t-3xl); }
}

/* ==========================================================================
   21 · PRINT & LARGE TABLE RENDERING
   ========================================================================== */

.glass-table tbody tr {
  content-visibility: auto;
  contain-intrinsic-size: auto 48px;
}

.prov-filter-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  background: var(--c-surface-2);
}
.prov-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.375rem 0.75rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--c-ink-3);
  font-family: var(--font-body);
  font-size: var(--t-caption);
  font-weight: var(--w-semi);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}
.prov-filter-btn:hover {
  color: var(--c-ink-1);
  background: var(--c-surface-3);
}
.prov-filter-btn.is-active {
  background: var(--c-surface);
  color: var(--c-ink-1);
  box-shadow: inset 0 0 0 2px var(--c-accent);
}
.prov-filter-btn:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}
.prov-action-btn {
  min-height: 38px;
  padding: 0.5rem 0.875rem;
  font-size: var(--t-caption);
  font-variant-numeric: tabular-nums;
}
.prov-well {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1rem 1.125rem;
  background: var(--c-surface-2);
}
.prov-note {
  padding: 0.625rem 0.875rem;
  background: var(--c-surface-2);
  color: var(--c-ink-2);
  font-size: var(--t-caption);
  line-height: 1.45;
}
.prov-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  background: var(--c-surface-2);
  text-align: center;
}
@media (max-width: 48rem) {
  .prov-filter-btn,
  .prov-action-btn {
    min-height: 44px;
  }
}

@media print {
  #sidebar, .glass-header, .toast-container, .modal-overlay, .btn, .pagination {
    display: none !important;
  }
  main#main-content { margin: 0 !important; }
  body { background: #fff; color: #000; }
  .glass-card, .stat-card, .table-container { background: #fff; }
}
