/* owear_style — дизайн-код Димы. Визуальный язык дашборда OpenRouter (shadcn-токены), перенесён из LOGOS
   (kentron_baza: globals.css + components/ui/*.module.css, ADR-0014/0015). Правила — RULES.md.
   Тема — атрибут data-theme="light|dark" на <html> (ставит скрипт до отрисовки; «система» разрешается через matchMedia).
   Палитры — palettes.css (data-pl / data-pd). Шрифты проект подключает сам: Manrope + Noto Sans Armenian + JetBrains Mono. */

/* ───────── 1. Токены ───────── */
:root {
  --font-sans: "Manrope", "Noto Sans Armenian", system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --radius: 0.5rem; --radius-sm: 6px; --radius-lg: 12px; --radius-full: 999px;
  --ease: cubic-bezier(.2, 0, 0, 1); --t-fast: 140ms; --t: 200ms;
  --positive: #00BF6F; --negative: #FF2D55; --warning: #E5A000; --info: #035ADE; --destructive: #E11D48;
}

/* Опорные значения. Светлая — умолчание (и на :root, чтобы страница без атрибута была светлой). */
:root, [data-theme="light"] {
  --background: #FCFCFE; --foreground: #03080A; --card: #FFFFFF; --input-bg: #FFFFFF;
  --primary: #7624F4; --primary-foreground: #FCFCFE;
  --positive-foreground: #007544; --negative-foreground: #BF0024; --warning-foreground: #8A6000; --info-foreground: #0352C9;
  --muted-mix: 69%;
  --shadow-popover: 0 1px 3px rgb(3 8 10 / .06), 0 8px 24px -4px rgb(3 8 10 / .12);
  --scrim: rgb(3 8 10 / .6);
  --chart-1: #0088FE; --chart-2: #00A586; --chart-3: #C68700; --chart-4: #FF5E0F; --chart-5: #7B68EE; --chart-other: #8395AD;
  color-scheme: light;
}
[data-theme="dark"] {
  --background: #03080A; --foreground: #FCFCFE; --card: #080C0E;
  --input-bg: color-mix(in srgb, var(--foreground) 4%, transparent);
  --primary: #C8FF00; --primary-foreground: #03080A;
  --positive-foreground: #34DFAA; --negative-foreground: #FF2D55; --warning-foreground: #FFAB00; --info-foreground: #4D8DFF;
  --muted-mix: 63%;
  --shadow-popover: 0 1px 3px rgb(0 0 0 / .5), 0 12px 32px -4px rgb(0 0 0 / .6);
  --scrim: rgb(0 0 0 / .65);
  --chart-1: #0088FE; --chart-2: #00C49F; --chart-3: #FFBB28; --chart-4: #FF8042; --chart-5: #7B68EE; --chart-other: #94A3B8;
  color-scheme: dark;
}

/* Производные — один раз для обеих тем. На :root и на любом элементе с data-theme (мини-превью палитр). */
:root, [data-theme] {
  --popover: var(--card);
  --muted: color-mix(in srgb, var(--foreground) 3%, transparent);
  --muted-foreground: color-mix(in srgb, var(--foreground) var(--muted-mix), transparent);
  --text-faint: color-mix(in srgb, var(--foreground) 44%, transparent);
  --border: color-mix(in srgb, var(--foreground) 8%, transparent);
  --border-strong: color-mix(in srgb, var(--foreground) 20%, transparent);
  --input: var(--border);
  --card-hover: color-mix(in srgb, var(--foreground) 2.5%, transparent);
  --selected-bg: color-mix(in srgb, var(--foreground) 3.5%, transparent);
  --accent: color-mix(in srgb, var(--primary) 8%, transparent);
  --accent-subtle: color-mix(in srgb, var(--primary) 3%, transparent);
  --accent-border: color-mix(in srgb, var(--primary) 12%, transparent);
  --accent-hover: color-mix(in srgb, var(--primary) 88%, var(--background));
  --ring: var(--primary);
  --focus-shadow: 0 0 0 3px color-mix(in srgb, var(--foreground) 6%, transparent);
  --positive-bg: color-mix(in srgb, var(--positive) 8%, transparent);
  --negative-bg: color-mix(in srgb, var(--negative) 8%, transparent);
  --warning-bg: color-mix(in srgb, var(--warning) 8%, transparent);
  --info-bg: color-mix(in srgb, var(--info) 8%, transparent);
  --error-shadow: 0 0 0 3px color-mix(in srgb, var(--negative) 10%, transparent);
}

/* ───────── 2. База ───────── */
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* классы с display не перебивают hidden */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font: 450 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
::selection { background: color-mix(in srgb, var(--primary) 24%, transparent); }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 20px; line-height: 1.3; margin: 0 0 var(--s-5); }
h2 { font-size: 16px; line-height: 1.4; margin: 0 0 var(--s-4); }
h3 { font-size: 14px; line-height: 1.4; margin: var(--s-5) 0 var(--s-2); }
p { text-wrap: pretty; }
b, strong { font-weight: 600; }
code, kbd { font-family: var(--font-mono); font-size: .9em; }
code { background: var(--muted); border-radius: var(--radius-sm); padding: 1px 6px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.mono { font-family: var(--font-mono); font-size: .9em; }
.muted { color: var(--muted-foreground); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
/* Иконки — Lucide (ISC), обводка 2, 16 px, цвет — currentColor. Декоративные — aria-hidden. */
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.i-14 { width: 14px; height: 14px; } .i-20 { width: 20px; height: 20px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ───────── 3. Каркас: верхняя полоса 48, меню 232, контент до 1100 ───────── */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; display: flex; align-items: center; gap: var(--s-3);
  height: 48px; padding: 0 var(--s-4); background: var(--background); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; gap: 6px; font: 700 14px/1 var(--font-sans); letter-spacing: .08em; color: var(--foreground); text-decoration: none; white-space: nowrap; }
.brand-sub { color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; min-width: 0; }
.who { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s-2); border-radius: var(--radius-sm);
  color: var(--foreground); text-decoration: none; font-weight: 500; }
.who:hover { background: var(--muted); }
.who svg { color: var(--muted-foreground); }
.frame { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: calc(48px + env(safe-area-inset-top, 0px)); height: calc(100dvh - 48px - env(safe-area-inset-top, 0px));
  overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-4) var(--s-3); border-right: 1px solid var(--border); background: var(--background);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-group { display: grid; gap: 4px; }
.nav-title { margin: 0; padding: 0 var(--s-3); color: var(--muted-foreground); font: 500 12px/1.6 var(--font-sans); text-transform: uppercase; letter-spacing: .04em; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 35px; padding: 6px var(--s-3); border-radius: var(--radius-sm);
  color: var(--foreground); text-decoration: none; line-height: 1.3; transition: background-color var(--t-fast) var(--ease); }
.nav-link svg { flex: none; color: var(--muted-foreground); }
.nav-link:hover { background: var(--muted); }
.nav-link[aria-current="page"] { background: var(--accent); color: var(--primary); font-weight: 500; }
.nav-link[aria-current="page"] svg { color: currentColor; }
.nav-link .badge { margin-left: auto; }
.nav-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) var(--s-1) 0; }
.logout { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s-2); border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--negative-foreground); font: 500 14px/1 var(--font-sans); cursor: pointer; }
.logout:hover { background: var(--negative-bg); }
.main { min-width: 0; width: 100%; max-width: 1100px; margin: 0 auto; padding: var(--s-5); }
.scrim { display: none; }
.topbar .menu-toggle { display: none; }
@media (max-width: 900px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .topbar .menu-toggle { display: inline-flex; }
  .sidebar { position: fixed; z-index: 50; top: calc(48px + env(safe-area-inset-top, 0px)); bottom: 0; left: 0; width: min(280px, 85vw); height: auto;
    padding-left: max(var(--s-3), env(safe-area-inset-left, 0px));
    translate: -100% 0; visibility: hidden; transition: translate var(--t) var(--ease), visibility 0s linear var(--t); }
  .sidebar[data-open] { translate: 0 0; visibility: visible; transition: translate var(--t) var(--ease); }
  .sidebar[data-open] ~ .scrim { display: block; position: fixed; z-index: 40; inset: 0; background: var(--scrim); }
  .main { padding: var(--s-4); }
}

/* Шапка страницы: H1 + серая строка; справа действия */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-3) var(--s-4); margin-bottom: var(--s-5); }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: var(--s-2); }
.page-head p { margin: 4px 0 0; color: var(--muted-foreground); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

/* ───────── 4. Кнопки ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 var(--s-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); color: var(--foreground);
  font: 500 14px/1 var(--font-sans); white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { flex: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: color-mix(in srgb, var(--destructive) 10%, transparent); color: var(--negative-foreground);
  border-color: color-mix(in srgb, var(--destructive) 15%, transparent); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--destructive) 18%, transparent); }
.btn-ghost { border-color: transparent; background: none; }
.btn-icon { width: 32px; padding: 0; color: var(--muted-foreground); }
.btn-icon:hover:not(:disabled) { color: var(--foreground); }
.btn-lg { height: 40px; }
.btn-wide { display: flex; width: 100%; }
.btn-link { height: auto; padding: 0; border: 0; background: none; color: inherit; border-radius: 2px; font-weight: 450;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
.btn-link:hover:not(:disabled) { background: none; text-decoration-color: currentColor; }
.arrow-link { display: inline-flex; align-items: center; gap: 2px; font-weight: 500; color: var(--foreground); text-decoration: none; }
.arrow-link:hover { text-decoration: underline; }

/* ───────── 5. Бейджи ───────── */
.badge { --c: var(--muted-foreground); --bg: transparent;
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--radius-full);
  background: var(--bg); color: var(--c); font: 500 12px/1 var(--font-sans); white-space: nowrap; vertical-align: middle; }
.badge-default { --c: var(--foreground); box-shadow: inset 0 0 0 1px var(--border); }
.badge-info { --c: var(--info-foreground); --bg: color-mix(in srgb, var(--info) 12%, transparent); }
.badge-positive { --c: var(--positive-foreground); --bg: var(--positive-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--positive) 25%, transparent); }
.badge-warning { --c: var(--warning-foreground); --bg: var(--warning-bg); }
.badge-negative { --c: var(--negative-foreground); --bg: var(--negative-bg); }
.badge-accent { --c: var(--primary); --bg: var(--accent); }
.badge-solid { --c: var(--background); --bg: var(--foreground); }
.badge-pill { height: 26px; padding: 2px 10px; text-transform: uppercase; letter-spacing: .04em; box-shadow: inset 0 0 0 1px var(--border); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-dot.badge-positive::before { background: var(--positive); }
.badge-dot.badge-warning::before { background: var(--warning); }
.badge-dot.badge-negative::before { background: var(--negative); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted-foreground); flex: none; }
.dot-positive { background: var(--positive); } .dot-warning { background: var(--warning); } .dot-negative { background: var(--negative); }

/* ───────── 6. Баннер, опасная зона, пустое состояние ───────── */
.banner { --c: var(--info); --fg: var(--info-foreground);
  display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); margin: 0 0 var(--s-4);
  border: 1px solid color-mix(in srgb, var(--c) 20%, transparent); border-radius: var(--radius); background: color-mix(in srgb, var(--c) 8%, transparent); }
.banner-warning { --c: var(--warning); --fg: var(--warning-foreground); }
.banner-negative { --c: var(--negative); --fg: var(--negative-foreground); }
.banner-positive { --c: var(--positive); --fg: var(--positive-foreground); }
.banner > svg { flex: none; margin-top: 2px; color: var(--fg); }
.banner-text { flex: 1; min-width: 0; }
.banner-text p { margin: 0; }
.banner-title { font-weight: 600; }
.banner-actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }
@media (max-width: 640px) { .banner { flex-wrap: wrap; } .banner-text { flex-basis: calc(100% - 28px); } .banner-actions { margin-left: auto; } }

.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-5);
  padding: var(--s-4) var(--s-5); margin: 0 0 var(--s-4); border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--destructive) 30%, transparent); background: color-mix(in srgb, var(--destructive) 8%, transparent); }
.danger-zone h2 { margin: 0; color: var(--negative-foreground); }
.danger-zone p { margin: 4px 0 0; color: var(--muted-foreground); }
.danger-zone > div { flex: 1 1 260px; min-width: 0; }

.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-2); padding: var(--s-7) var(--s-4); }
.empty-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--muted); border: 1px solid var(--border); color: var(--muted-foreground); }
.empty-title { margin: var(--s-2) 0 0; font-weight: 600; }
.empty p { margin: 0; max-width: 420px; color: var(--muted-foreground); }

/* ───────── 7. Карточки и секции ───────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-4) var(--s-5); margin: 0 0 var(--s-4); min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-3); }
.card-flush > .card-head { padding: var(--s-4) var(--s-5) 0; }
.card-title { margin: 0; font-size: 16px; font-weight: 600; }
.card-sub { margin: 4px 0 0; color: var(--muted-foreground); }
.section-two { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s-6); margin: 0 0 var(--s-6); }
.section-two > .card { margin: 0; }
.section-two h2 { display: flex; align-items: center; gap: var(--s-2); margin: 0; }
.section-two p { margin: 4px 0 0; color: var(--muted-foreground); }
@media (max-width: 760px) { .section-two { grid-template-columns: 1fr; gap: var(--s-3); } .card:not(.card-flush) { padding: var(--s-4); } }

/* ───────── 8. Поля ───────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field-head { display: flex; align-items: center; gap: 6px; }
.label { font-weight: 500; }
.req { color: var(--negative-foreground); }
.help { margin: 0; color: var(--muted-foreground); font-size: 13px; }
.field-error { margin: 0; color: var(--negative-foreground); font-size: 13px; }
.control {
  width: 100%; height: 40px; padding: 8px var(--s-3); margin: 0; border: 1px solid var(--input); border-radius: var(--radius-sm);
  background: var(--input-bg); color: var(--foreground); font: inherit; font-variant-numeric: tabular-nums;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.control::placeholder { color: var(--text-faint); opacity: 1; }
.control:hover:not(:disabled):not([readonly]) { border-color: var(--border-strong); }
.control:focus-visible { outline: none; border-color: var(--ring); box-shadow: var(--focus-shadow); }
.control[aria-invalid="true"] { border-color: var(--negative); box-shadow: var(--error-shadow); }
.control:disabled { opacity: .5; cursor: not-allowed; }
.control[readonly] { background: var(--muted); }
textarea.control { height: auto; min-height: 80px; resize: vertical; line-height: 1.5; }
.control-sm { height: 32px; padding: 0 var(--s-2); }
.search, .select { position: relative; display: block; }
.search .control { padding-left: 36px; }
.search > svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--text-faint); pointer-events: none; }
.select .control { appearance: none; padding-right: 36px; cursor: pointer; }
.select > svg { position: absolute; right: 12px; top: 50%; translate: 0 -50%; color: var(--muted-foreground); pointer-events: none; }
.input-group { display: flex; gap: var(--s-2); }
.input-group .control { flex: 1; min-width: 0; }
.fieldset { display: grid; gap: var(--s-3); margin: 0; padding: var(--s-3) var(--s-4) var(--s-4); border: 1px solid var(--border); border-radius: var(--radius); }
.fieldset { background: var(--card); }
.fieldset legend { float: left; width: 100%; padding: 0; font-weight: 500; }   /* float — заголовок внутри рамки, а не на ней */

.checkbox, .radio { appearance: none; position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; margin: 0; flex: none;
  border: 1px solid var(--border-strong); border-radius: 4px; background: var(--input-bg); cursor: pointer; vertical-align: middle;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.radio { border-radius: 50%; }
.checkbox:hover:not(:disabled), .radio:hover:not(:disabled) { border-color: color-mix(in srgb, var(--foreground) 40%, transparent); }
.checkbox:checked, .radio:checked { background: var(--primary); border-color: var(--primary); }
.checkbox::before { content: ""; width: 10px; height: 10px; background: var(--primary-foreground); scale: 0; transition: scale var(--t-fast) var(--ease);
  clip-path: polygon(14% 44%, 0 59%, 39% 96%, 100% 22%, 86% 8%, 38% 66%); }   /* галочка */
.radio::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--primary-foreground); scale: 0; transition: scale var(--t-fast) var(--ease); }
.checkbox:checked::before, .radio:checked::before { scale: 1; }
.checkbox:focus-visible, .radio:focus-visible { outline-offset: 1px; }
.checkbox:disabled, .radio:disabled { opacity: .5; cursor: not-allowed; }
.check-line { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; }
.switch { appearance: none; position: relative; flex: none; width: 36px; height: 20px; margin: 0; border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--foreground) 12%, transparent); cursor: pointer; vertical-align: middle; transition: background-color var(--t-fast) var(--ease); }
.switch::before { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: color-mix(in srgb, var(--foreground) 40%, var(--background)); transition: translate var(--t-fast) var(--ease); }
.switch:checked { background: var(--primary); }
.switch:checked::before { translate: 16px 0; background: var(--background); }
.switch:disabled { opacity: .5; cursor: not-allowed; }

/* Сегментированный выбор (новое) */
.segmented { display: inline-flex; width: fit-content; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--muted); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 var(--s-3); border-radius: 4px; color: var(--muted-foreground); font-weight: 500; }
.segmented span { transition: color var(--t-fast) var(--ease); }
.segmented label:hover span { color: var(--foreground); }
.segmented input:checked + span { background: var(--card); color: var(--foreground); box-shadow: 0 0 0 1px var(--border); }
.segmented input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 1px; }

/* Форма «подпись слева — поле справа» */
.form-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--s-2) var(--s-6); align-items: start; padding: var(--s-4) 0; }
.form-row + .form-row { border-top: 1px solid var(--border); }
.form-row:first-child { padding-top: 0; }
.form-row:last-child { padding-bottom: 0; }
.form-row > div { display: grid; gap: 4px; min-width: 0; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s-2); }

/* ───────── 9. Вкладки ───────── */
.tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--border); margin: 0 0 var(--s-5); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0; border: 0; background: none;
  color: var(--muted-foreground); font: 450 14px/1 var(--font-sans); white-space: nowrap; cursor: pointer; text-decoration: none; }
.tab:hover { color: var(--foreground); }
.tab[aria-selected="true"] { color: var(--primary); font-weight: 500; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.tab:focus-visible { outline-offset: -2px; }
.tabs-sm { gap: var(--s-4); margin-bottom: var(--s-4); }
.tabs-sm .tab { height: 34px; font-size: 13px; }

/* ───────── 10. Всплывающее: поповер, меню, подсказка ───────── */
.pop-root { position: relative; display: inline-flex; }
.popover { position: absolute; z-index: 40; top: calc(100% + 4px); right: 0; width: max-content; min-width: 200px; max-width: calc(100vw - 32px);
  display: grid; padding: 4px; background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-popover); }
.popover:not([hidden]) { animation: pop-in var(--t-fast) var(--ease); transform-origin: top right; }
.popover-left { right: auto; left: 0; transform-origin: top left; }
@keyframes pop-in { from { opacity: 0; scale: .96; } }
.popover-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 6px var(--s-2) var(--s-2);
  border-bottom: 1px solid var(--border); margin-bottom: 4px; font-weight: 600; }
.menu-item { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 32px; padding: 0 var(--s-2); border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--foreground); font: 450 14px/1 var(--font-sans); text-align: left; white-space: nowrap; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--muted); outline: none; }
.menu-item[aria-checked="true"], .menu-item[aria-pressed="true"] { color: var(--primary); background: var(--accent); }
.menu-item[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.menu-item svg { flex: none; color: var(--muted-foreground); }
.menu-item[aria-checked="true"] svg, .menu-item[aria-pressed="true"] svg { color: currentColor; }
.menu-item .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.menu-item-danger, .menu-item-danger svg { color: var(--negative-foreground); }
.menu-sep { height: 1px; margin: 4px -4px; background: var(--border); }
.menu-label { padding: 6px var(--s-2) 4px; color: var(--muted-foreground); font: 500 12px/1.4 var(--font-sans); text-transform: uppercase; letter-spacing: .04em; }
.short { display: inline-block; min-width: 2.6em; padding: 2px 4px; border-radius: 4px; background: var(--muted); color: var(--muted-foreground);
  font: 500 12px/1.2 var(--font-mono); text-align: center; }

.tip { position: relative; display: inline-flex; vertical-align: middle; }
.tip-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--muted-foreground); cursor: help; }
.tip-btn:hover { color: var(--foreground); }
.tip-bubble { position: absolute; z-index: 30; left: 50%; bottom: calc(100% + 6px); translate: -50% 0; width: max-content; max-width: min(260px, 70vw);
  padding: 6px 10px; border-radius: var(--radius-sm); background: var(--foreground); color: var(--background); font: 450 12px/1.4 var(--font-sans);
  box-shadow: var(--shadow-popover); display: none; pointer-events: none; }
.tip:hover .tip-bubble, .tip-btn:focus-visible + .tip-bubble { display: block; }

/* ───────── 11. Модальное окно и боковая панель (<dialog>) ───────── */
.dialog { padding: 0; border: 1px solid var(--border); background: var(--popover); color: var(--foreground); box-shadow: var(--shadow-popover); max-height: calc(100dvh - 32px); }
.dialog::backdrop { background: var(--scrim); }
.dialog[open]::backdrop { animation: fade-in var(--t) var(--ease); }
.dialog-modal[open] { animation: pop-in var(--t) var(--ease); }
.dialog-panel[open] { animation: panel-in var(--t) var(--ease); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes panel-in { from { translate: 24px 0; opacity: 0; } }
.dialog-modal { width: min(440px, calc(100vw - 32px)); border-radius: var(--radius); }
.dialog-panel { margin: 0 0 0 auto; width: min(45vw, 720px); min-width: min(440px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  border-width: 0 0 0 1px; border-radius: 0; }
@media (max-width: 640px) { .dialog-panel { width: 100vw; } }
.dialog-inner { display: flex; flex-direction: column; height: 100%; max-height: inherit; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5) 0; }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: var(--s-4) var(--s-5); overflow-y: auto; display: grid; gap: var(--s-4); align-content: start; flex: 1; }
.dialog-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-2); padding: 0 var(--s-5) var(--s-4); }
.dialog-foot-split { justify-content: space-between; padding-top: var(--s-3); border-top: 1px solid var(--border); }

/* ───────── 12. Таблица ───────── */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 var(--s-4); min-width: 0; container-type: inline-size; }
.table-toolbar { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 10px var(--s-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table th { height: 44px; color: var(--muted-foreground); font-weight: 500; white-space: nowrap; }
.table td { height: 53px; }
.table tbody tr { transition: background-color var(--t-fast) var(--ease); }
.table tbody tr:hover td { background: var(--card-hover); }
.table tbody tr[aria-current="true"] td { background: var(--selected-bg); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
.table .num { text-align: right; }
.table td a { font-weight: 500; text-decoration: none; }
.table td a:hover { text-decoration: underline; }
.table .cell-sub { color: var(--muted-foreground); font-size: 13px; }
.table .cell-menu { width: 1%; text-align: right; }
.table .cell-check { width: 1%; }
.table-foot { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); color: var(--muted-foreground); font-size: 13px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); }
/* Таблице тесно — строки становятся карточками (по ширине контейнера, а не окна) */
@container (max-width: 640px) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-stack, .table-stack tbody, .table-stack tfoot, .table-stack tr { display: block; width: 100%; }
  .table-stack tfoot tr { border-top: 1px solid var(--border); border-bottom: 0; }
  .table-stack tr { position: relative; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack tbody tr:hover td { background: none; }
  .table-stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 2px var(--s-3); height: auto; padding: 3px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .table-stack td::before { content: attr(data-label); flex: none; color: var(--muted-foreground); font-size: 13px; text-align: left; }
  .table-stack td:first-child, .table-stack td.cell-check + td { justify-content: flex-start; text-align: left; font-weight: 600; }
  .table-stack td:first-child::before, .table-stack td[data-label=""]::before { content: none; }
  .table-stack td.cell-check { display: none; }
  .table-stack td.cell-menu { position: absolute; top: var(--s-2); right: var(--s-2); display: block; width: auto; padding: 0; }
}

/* Пагинация (новое) */
.pager { display: inline-flex; align-items: center; gap: 4px; }
.pager .btn { min-width: 32px; padding: 0 8px; }
.pager .btn[aria-current="page"] { background: var(--accent); border-color: var(--accent-border); color: var(--primary); }

/* ───────── 13. Списки ───────── */
.nav-list { list-style: none; margin: 0 0 var(--s-5); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.nav-list > li { position: relative; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); transition: background-color var(--t-fast) var(--ease); }
.nav-list > li + li { border-top: 1px solid var(--border); }
.nav-list > li:hover { background: var(--muted); }
.nav-list > li:has(.nl-link:focus-visible) { box-shadow: inset 0 0 0 2px var(--ring); }
.letter { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--foreground); font-weight: 600; font-size: 13px; }
.nl-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.nl-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-2); min-width: 0; }
.nl-link { color: var(--foreground); font-weight: 500; text-decoration: none; overflow-wrap: anywhere; }
.nl-link:focus-visible { outline: none; }
.nl-link::after { content: ""; position: absolute; inset: 0; }
.nl-status { flex: none; color: var(--muted-foreground); font-size: 13px; text-align: right; }
.nl-control { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: var(--s-2); }
.nav-list > li > svg:last-child { flex: none; color: var(--muted-foreground); }
@media (max-width: 640px) { .nav-list > li { flex-wrap: wrap; } .nl-status { order: 5; flex-basis: 100%; padding-left: calc(28px + var(--s-3)); text-align: left; } }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-2) var(--s-5); margin: 0; }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: var(--s-3); } }

.top-list { list-style: none; margin: 0; padding: 0; display: grid; }
.top-list li { display: grid; grid-template-columns: 20px 8px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.top-list li + li { border-top: 1px solid var(--border); }
.top-list .rank { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.top-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.top-list .id { display: block; color: var(--muted-foreground); font: 12px/1.4 var(--font-mono); overflow: hidden; text-overflow: ellipsis; }
.top-list .val { font-variant-numeric: tabular-nums; font-weight: 500; }

.rec-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); align-content: start; }
.rec-list li { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-4);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.rec-list li > svg { flex: none; margin-top: 3px; color: var(--muted-foreground); }
.rec-list li > .btn { align-self: center; }
.rec-list li > div { flex: 1 1 260px; min-width: 0; }
.rec-list b { display: block; }
.rec-list p { margin: 0; color: var(--muted-foreground); }

/* ───────── 14. Плитки ───────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-3); margin: 0 0 var(--s-4); }
.stat { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px var(--s-3); min-width: 0;
  padding: var(--s-3) var(--s-4); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); transition: background-color var(--t-fast) var(--ease); }
.stat[data-active] { background: color-mix(in srgb, var(--foreground) 3.5%, var(--card)); }
.stat-label { color: var(--muted-foreground); font-size: 13px; }
.stat > .stat-label, .stat > .stat-value { grid-column: 1; }
.stat > .spark { grid-column: 2; grid-row: 1 / 3; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat svg.spark { width: 80px; height: 32px; overflow: visible; }
.stat-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 var(--s-2); font-size: 13px; color: var(--muted-foreground); }
.up { color: var(--positive-foreground); font-weight: 500; } .down { color: var(--negative-foreground); font-weight: 500; } .flat { color: var(--muted-foreground); font-weight: 500; }
.sec-tile { display: grid; gap: var(--s-2); align-content: start; padding: var(--s-4); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.sec-tile .stat-label { display: flex; align-items: center; gap: 6px; }
.sec-tile a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted-foreground); font-size: 13px; text-decoration: none; width: fit-content; }
.sec-tile a:hover { color: var(--foreground); }
.balance-label { color: var(--muted-foreground); font: 500 12px/1.4 var(--font-sans); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 4px; }
.balance-value { font-size: 32px; font-weight: 700; line-height: 1.2; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }

/* ───────── 15. Графики (свои SVG, цвета — токены) ───────── */
.chart { margin: 0; position: relative; min-width: 0; }
.chart svg { display: block; overflow: visible; }
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius); }
.axis { fill: var(--muted-foreground); font-size: 12px; font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--border); stroke-dasharray: 3 3; }
.day-hit { fill: transparent; }
.day-hit[data-active] { fill: var(--muted-foreground); fill-opacity: .12; }
.series { transition: opacity .15s; }
.series[data-dim] { opacity: .2; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted-foreground); }
.legend li { display: flex; align-items: center; gap: 6px; min-width: 0; cursor: default; transition: opacity .15s; }
.legend li[data-dim] { opacity: .35; }
.legend i, .swatch-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.legend b { color: var(--foreground); font-weight: 450; font-variant-numeric: tabular-nums; }
.chart-tip { position: absolute; top: 0; pointer-events: none; z-index: 2; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.chart-tip-date { background: var(--foreground); color: var(--card); padding: 2px 6px; border-radius: 4px; white-space: nowrap; width: fit-content; }
.chart-tip-card { background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-popover); padding: 8px 10px; min-width: 180px; }
.chart-tip-row { display: grid; grid-template-columns: 3px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 3px 0; }
.chart-tip-row > i { align-self: stretch; border-radius: 2px; }
.chart-tip-row > span:last-child, .chart-tip-total > span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
.chart-tip-total { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }
.share-bar { display: flex; height: 12px; border-radius: var(--radius); overflow: hidden; background: var(--border); }
.share-bar > span, .mini-bar > span { display: block; height: 100%; }
.mini { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.mini-bar { display: flex; flex: none; width: 60px; height: 6px; border-radius: 999px; overflow: hidden; background: var(--border); }

/* ───────── 16. Мелочи (новое, в LOGOS не было) ───────── */
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--foreground); font: 600 12px/1 var(--font-sans); }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.progress { height: 6px; border-radius: var(--radius-full); background: var(--border); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.skeleton { display: block; height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--muted) 25%, var(--border) 50%, var(--muted) 75%) 0 0 / 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite; }
@keyframes skeleton { to { background-position: -200% 0; } }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
  background: var(--card); color: var(--muted-foreground); font: 500 12px/1 var(--font-mono); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 var(--s-2); padding: 0; list-style: none; color: var(--muted-foreground); font-size: 13px; }
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--foreground); }
.crumbs li + li::before { content: "/"; margin-right: 4px; color: var(--text-faint); }
.crumbs [aria-current] { color: var(--foreground); font-weight: 500; }
.toast { display: flex; align-items: center; gap: var(--s-3); width: min(380px, calc(100vw - 32px)); padding: var(--s-3) var(--s-4);
  background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-popover); }
.toast > svg { flex: none; color: var(--positive-foreground); }
.toast > div { flex: 1; min-width: 0; }
.toast-stack { position: fixed; z-index: 60; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: var(--s-2); }
.toast-stack .toast { animation: toast-in var(--t) var(--ease); }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }
pre.code { margin: 0; padding: var(--s-3) var(--s-4); overflow-x: auto; background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius);
  font: 13px/1.6 var(--font-mono); }

/* ───────── 17. Карточка входа ───────── */
.auth { width: 100%; max-width: 400px; padding: var(--s-6); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-popover); }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-6); }
.auth h2 { margin: 0 0 var(--s-5); font-size: 22px; font-weight: 700; }
.auth form { display: grid; gap: var(--s-4); }
@media (max-width: 480px) { .auth { padding: var(--s-5) var(--s-4); box-shadow: none; } }
