/*
  Вид приложения — образец дизайна для приложений на Vow (как у приложения-эталона accounting-ai-vow): тёмная боковая панель с разделами,
  белая шапка с заголовком страницы, серый фон рабочей области, белые карточки и таблицы, основной цвет #2ED38A, шрифт Inter.

  Как менять:
  - цвет приложения — одна строка: --primary (и --primary-hover, --primary-soft рядом);
  - тёмная тема — блок html.dark (класс ставит assets/js/theme.js до отрисовки, переключатель — store app в app.js);
  - направление RTL — <html dir="rtl">: отступы и края — логическими свойствами (inset-inline-*, margin-inline-*, padding-inline-*).

  Шрифт Inter 4.1 (вариативный, вес 100–900, кириллица; OFL 1.1 — assets/fonts/inter/LICENSE.txt) — файлом сайта, без внешних
  запросов (CSP: font-src 'self'). Курсива в файле нет — браузер наклоняет сам. Пока файл грузится — системный шрифт (font-display: swap).

  Разделы: 1 токены · 2 основа · 3 кнопки · 4 поля · 5 оболочка (панель, шапка, меню пользователя) · 6 уведомления · 7 карточки ·
  8 списки и таблицы · 9 окна · 10 страницы входа · 11 совместимость с заготовками модулей · 12 телефон и печать.
*/

@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/inter/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- 1. Токены ---------- */
:root {
  --primary: #2ed38a;
  --primary-hover: #26bd7b;
  --primary-soft: rgba(46, 211, 138, .14);
  --on-primary: #ffffff;       /* текст на основном цвете */
  --fg: #111827;               /* заголовки, основной текст */
  --text: #374151;             /* текст абзацев */
  --muted: #6b7280;            /* подписи, вторичное */
  --line: #e5e7eb;             /* рамки карточек и таблиц */
  --line-strong: #d1d5db;
  --field-line: #cad5e2;       /* рамка полей и вторичных кнопок */
  --surface: #ffffff;          /* карточки, таблицы, шапка, окна */
  --canvas: #f9fafb;           /* фон рабочей области */
  --panel: #f3f4f6;            /* заливка: строки через одну, поиск, бейджи */
  --hover: #e5e7eb;
  --accent: #059669;           /* ссылки: зелёный темнее основного — читается на белом */
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: .5rem;
  --radius-sm: .375rem;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1);
  --shadow-pop: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .1);
  --sidebar-w: 16rem;
  --topbar-h: 3.5rem;
  /* старые имена (заготовки модулей Vow.Chat, Vow.Mcp и страницы до этого вида читают их) */
  --bg: var(--surface);

  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

html.sidebar-collapsed { --sidebar-w: 4rem; }

/* тёмная тема: фон slate-900, карточки slate-800, линии slate-700 — как у эталона */
html.dark {
  --fg: #f8fafc;
  --text: #cad5e2;
  --muted: #90a1b9;
  --line: #314158;
  --line-strong: #45556c;
  --field-line: #45556c;
  --surface: #1d293d;
  --canvas: #0f172b;
  --panel: #263449;
  --hover: #314158;
  --accent: #34d399;
  --danger: #f87171;
  --danger-soft: rgba(127, 29, 29, .45);
  --ok: #4ade80;
  --on-primary: #052e1b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, .35);
  --shadow-pop: 0 10px 15px -3px rgba(0, 0, 0, .45), 0 0 0 1px #314158;
  color-scheme: dark;
}

/* ---------- 2. Основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--fg); }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.5rem; line-height: 1.3; font-weight: 600; margin: 0 0 1.25rem; color: var(--fg); }
h2 { font-size: 1.125rem; line-height: 1.5; font-weight: 600; margin: 1.75rem 0 .75rem; color: var(--fg); }
h3 { font-size: 1rem; line-height: 1.5; font-weight: 600; margin: 1.25rem 0 .5rem; color: var(--fg); }
p { color: var(--text); margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875em; padding: .1em .35em; border-radius: .25rem; background: var(--panel); }
pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon { width: 1.25rem; height: 1.25rem; flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: .25rem 0; }
.ok { color: var(--ok); }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- 3. Кнопки ---------- */
/* вторичная — белая с рамкой; .primary — основной цвет; .danger — красная; .ghost — без рамки; .small / .wide — размер */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  font: inherit; font-size: .875rem; font-weight: 500; line-height: 1.25rem; white-space: nowrap;
  padding: .4375rem .75rem; min-height: 2.25rem; border: 1px solid var(--field-line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
button:hover, .button:hover { background: var(--panel); text-decoration: none; }
button .icon, .button .icon { width: 1rem; height: 1rem; }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.primary:hover, .button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.danger, .button.danger { background: #ef4444; border-color: #ef4444; color: #fff; }
button.danger:hover, .button.danger:hover { background: #dc2626; border-color: #dc2626; }
button.danger-outline { background: transparent; border-color: #fca5a5; color: var(--danger); }
button.danger-outline:hover { background: var(--danger-soft); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel); }
button.small, .button.small { min-height: 1.875rem; padding: .25rem .625rem; font-size: .8125rem; }
button.wide, .button.wide { width: 100%; min-height: 2.75rem; font-size: 1rem; }
button:disabled, .button[aria-disabled='true'] { opacity: .55; cursor: not-allowed; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 0; padding: .5rem;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted);
}
.icon-button:hover { background: var(--panel); color: var(--fg); }
.buttons { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.buttons .spacer { flex: 1; }

/* ---------- 4. Поля ---------- */
.field { display: flex; flex-direction: column; gap: .375rem; min-width: 0; }
label { font-size: .875rem; line-height: 1.25rem; font-weight: 500; color: var(--text); }
.hint { font-size: .8125rem; color: var(--muted); margin: 0; }
input, select, textarea {
  font: inherit; font-size: .875rem; line-height: 1.25rem; color: var(--fg);
  padding: .4375rem .75rem; border: 1px solid var(--field-line); border-radius: var(--radius-sm); background: var(--surface);
  min-width: 0; width: 100%;
}
input:not([type='checkbox']):not([type='radio']):not([type='file']):not([type='range']), select { min-height: 2.25rem; }
textarea { min-height: 7rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9ca3af; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
input[readonly] { background: var(--canvas); }
input[aria-invalid='true'], textarea[aria-invalid='true'] { border-color: var(--danger); }
html.dark input, html.dark select, html.dark textarea { background: var(--canvas); }
input[type='checkbox'], input[type='radio'] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--primary); }
.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 400; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid .wide { grid-column: 1 / -1; }
.form-stack { display: flex; flex-direction: column; gap: 1rem; }

/* ---------- 5. Оболочка: боковая панель, шапка, меню пользователя ---------- */
/* Страница приложения: <aside class="sidebar"> + <div class="shell"> (шапка .topbar и <main>). Страница без оболочки (вход, ошибки,
   публичные страницы) — просто <main>. */
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; width: var(--sidebar-w);
  display: flex; flex-direction: column; overflow: hidden; color: #fff;
  background: linear-gradient(180deg, #1f2937 0%, #111827 50%, #000 100%);
  border-inline-end: 1px solid #4b5563; transition: width .25s ease;
}
.sidebar-logo {
  display: flex; flex: none; align-items: center; gap: .75rem; height: var(--topbar-h); padding: 0 1.25rem;
  color: #fff; font-weight: 700; font-size: 1rem; text-decoration: none; white-space: nowrap;
}
.sidebar-logo img { width: 1.75rem; height: 1.75rem; flex: none; }
.sidebar-logo:hover { text-decoration: none; }
/* overflow-x: hidden обязателен: при overflow-y: auto длинный пункт иначе даёт полосу прокрутки вбок */
.sidebar nav { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: .125rem; padding: .5rem .75rem; overflow-x: hidden; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: .75rem; padding: .375rem .75rem; border-radius: var(--radius);
  color: #fff; font-size: .875rem; font-weight: 500; line-height: 1.5rem; text-decoration: none; white-space: nowrap; overflow: hidden;
}
.sidebar nav a .icon { width: 1.5rem; height: 1.5rem; padding: .125rem; }
.sidebar nav a:hover { background: rgba(75, 85, 99, .25); }
.sidebar nav a[aria-current='page'] { background: rgba(75, 85, 99, .35); border-inline-start: 4px solid #9ca3af; margin-inline-start: -.25rem; }
.sidebar .nav-title { margin: .75rem .75rem .25rem; font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #9ca3af; white-space: nowrap; }
.sidebar-foot { flex: none; padding: .75rem; border-top: 1px solid rgba(75, 85, 99, .5); }
/* свёрнута: только значки, подписи — для чтения экрана; пункт без значка (ссылку добавила заготовка модуля) обрезается */
html.sidebar-collapsed .sidebar-logo { justify-content: center; padding: 0; }
html.sidebar-collapsed .sidebar-logo span, html.sidebar-collapsed .sidebar nav a span, html.sidebar-collapsed .sidebar .nav-title {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
html.sidebar-collapsed .sidebar nav a { justify-content: center; padding-inline: 0; }
html.sidebar-collapsed .sidebar nav a[aria-current='page'] { margin-inline-start: 0; border-inline-start-width: 3px; }
/* круглая кнопка на границе панели внизу: свернуть до значков и обратно */
.sidebar-toggle {
  position: fixed; bottom: 1.25rem; inset-inline-start: calc(var(--sidebar-w) - .875rem); z-index: 50;
  width: 1.75rem; height: 1.75rem; min-height: 0; padding: 0; border-radius: 50%;
  border: 1px solid #4b5563; background: rgba(17, 24, 39, .95); color: #d1d5db; transition: inset-inline-start .25s ease;
}
.sidebar-toggle:hover { background: #374151; color: #fff; }
.sidebar-toggle .icon { width: 1rem; height: 1rem; transition: transform .25s; }
html.sidebar-collapsed .sidebar-toggle .icon, [dir='rtl'] .sidebar-toggle .icon { transform: scaleX(-1); }
html.sidebar-collapsed[dir='rtl'] .sidebar-toggle .icon { transform: none; }
.sidebar-backdrop { display: none; }

.shell { min-height: 100vh; padding-inline-start: var(--sidebar-w); transition: padding-inline-start .25s ease; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem;
  height: var(--topbar-h); padding: 0 1rem 0 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
html.dark .topbar { background: linear-gradient(90deg, #1d293d, #0f172b 50%, #000); border-color: #45556c; }
.menu-toggle { display: none; }
.page-title { display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 1; }
.page-title h1 { margin: 0; font-size: 1.25rem; line-height: 1.4; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-back { display: inline-flex; padding: .375rem; margin-inline-start: -.375rem; border-radius: var(--radius-sm); color: var(--muted); }
.title-back:hover { background: var(--panel); color: var(--fg); }
[dir='rtl'] .title-back .icon { transform: scaleX(-1); }
.title-count {
  display: inline-flex; align-items: center; min-width: 1.5rem; justify-content: center; padding: .25rem .5rem; border-radius: 9999px;
  background: var(--primary); color: var(--on-primary); font-size: .75rem; font-weight: 700; line-height: .75rem;
}
.topbar-tools { display: flex; align-items: center; gap: .25rem; margin-inline-start: auto; }
.theme-toggle .sun, html.dark .theme-toggle .moon { display: none; }
html.dark .theme-toggle .sun { display: block; }
/* меню пользователя: кружок с инициалами (и имя на широком экране) → панель с пунктами */
.user-menu { position: relative; }
.user-menu > summary {
  display: flex; align-items: center; gap: .5rem; padding: .25rem .375rem; border-radius: 9999px; cursor: pointer; list-style: none; color: var(--text);
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: var(--panel); }
.user-menu > summary .icon { width: 1rem; height: 1rem; color: var(--muted); }
.user-name { font-size: .875rem; font-weight: 500; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--primary); color: #111827; font-size: .8125rem; font-weight: 600; letter-spacing: .02em;
}
.user-panel, .menu-panel {
  position: absolute; z-index: 60; top: calc(100% + .375rem); inset-inline-end: 0; min-width: 14rem; padding: .25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
}
.user-panel-head { display: flex; flex-direction: column; margin: 0 0 .25rem; padding: .5rem .625rem; border-bottom: 1px solid var(--line); min-width: 0; }
.user-panel-head strong { font-size: .875rem; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel-head span { font-size: .8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item {
  display: flex; align-items: center; justify-content: flex-start; gap: .5rem; width: 100%; min-height: 0; padding: .5rem .625rem;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font-size: .875rem; font-weight: 400; text-align: start; text-decoration: none;
}
.menu-item:hover { background: var(--panel); color: var(--fg); text-decoration: none; }
.menu-item .icon { width: 1.125rem; height: 1.125rem; color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }

/* рабочая область */
main { display: block; width: 100%; max-width: 64rem; margin: 0 auto; padding: 1.5rem 1rem; }
.shell > main { max-width: none; margin: 0; padding: 1.25rem; flex: 1; }
.shell > main.narrow > * { max-width: 48rem; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h2 { margin: 0; }
.page-head .buttons { margin-inline-start: auto; }

/* ---------- 6. Уведомления ---------- */
/* полоса над страницей: работа от имени пользователя, нет связи */
.banner { display: flex; align-items: center; gap: .5rem; padding: .5rem 1.25rem; font-size: .875rem; font-weight: 500; }
.banner.warn { background: #fef3c7; color: #78350f; border-bottom: 1px solid #fcd34d; }
.banner.danger { background: #fee2e2; color: #7f1d1d; border-bottom: 1px solid #fca5a5; }
html.dark .banner.warn { background: rgba(120, 53, 15, .45); color: #fde68a; border-color: rgba(146, 64, 14, .6); }
html.dark .banner.danger { background: rgba(127, 29, 29, .45); color: #fecaca; border-color: rgba(153, 27, 27, .6); }
/* сообщение в странице: .alert.error (role="alert"), .alert.ok / .alert.info (role="status") */
.alert { display: flex; align-items: flex-start; gap: .5rem; margin: 0 0 1rem; padding: .625rem .875rem; border: 1px solid; border-radius: var(--radius); font-size: .875rem; line-height: 1.25rem; }
.alert .icon { width: 1.125rem; height: 1.125rem; margin-top: .0625rem; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }
html.dark .alert.error { background: rgba(127, 29, 29, .35); border-color: rgba(153, 27, 27, .7); color: #fecaca; }
html.dark .alert.ok { background: rgba(20, 83, 45, .35); border-color: rgba(22, 101, 52, .7); color: #bbf7d0; }
html.dark .alert.info { background: rgba(30, 58, 138, .35); border-color: rgba(30, 64, 175, .7); color: #bfdbfe; }
html.dark .alert.warn { background: rgba(120, 53, 15, .35); border-color: rgba(146, 64, 14, .7); color: #fde68a; }
/* всплывающие уведомления справа снизу (store app: toast) */
.toasts { position: fixed; z-index: 200; inset-inline-end: 1.5rem; bottom: 1.5rem; display: flex; flex-direction: column; gap: .5rem; width: min(24rem, calc(100vw - 2rem)); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: .625rem; padding: .75rem 1rem; pointer-events: auto;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-inline-start: 4px solid var(--primary);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); font-size: .875rem; line-height: 1.25rem; animation: toast-in .2s ease-out;
}
.toast > .icon { width: 1.25rem; height: 1.25rem; color: var(--primary); }
.toast span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast.error { border-inline-start-color: #ef4444; }
.toast.error > .icon { color: #ef4444; }
.toast-close { min-height: 0; padding: 0; border: 0; background: none; color: var(--muted); }
.toast-close:hover { background: none; color: var(--fg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(.5rem); } to { opacity: 1; transform: none; } }

/* ---------- 7. Карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-head .icon { color: var(--primary); }
.card-head .buttons { margin-inline-start: auto; }
.card-body { padding: 1.25rem; }
.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }
.card-foot { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .875rem 1.25rem; border-top: 1px solid var(--line); background: var(--canvas); border-radius: 0 0 var(--radius) var(--radius); }
.card-foot .spacer { flex: 1; }
/* свойства записи: подпись — значение */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .5rem 1.5rem; margin: 0; font-size: .875rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--fg); overflow-wrap: anywhere; }
.record { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 1rem; align-items: start; }
.codes { margin: 0; padding: .75rem 1rem; background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); font-size: 1rem; line-height: 1.6; white-space: pre-wrap; }
.secret { word-break: break-all; font-size: .8125rem; }
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; align-items: center; gap: .75rem; padding: .625rem 0; border-bottom: 1px solid var(--line); font-size: .875rem; }
.devices li:last-child { border-bottom: 0; }
.devices li button { margin-inline-start: auto; }

/* ---------- 8. Списки и таблицы ---------- */
/* Список: .list-toolbar (поиск, «Фильтры», справа «Добавить») → .list-filters (раскрываются) → .list-table-wrap с table.list-table */
.list-toolbar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; padding: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card);
}
.list-toolbar .list-tools { display: flex; align-items: center; gap: .5rem; margin-inline-start: auto; }
.list-search { position: relative; flex: 0 1 18rem; min-width: 10rem; }
.list-search .icon { position: absolute; top: 50%; inset-inline-start: .75rem; width: 1rem; height: 1rem; transform: translateY(-50%); color: #9ca3af; pointer-events: none; }
.list-search input { padding-block: .5rem; padding-inline: 2.25rem .75rem; border-color: transparent; border-radius: var(--radius); background: var(--panel); }
html.dark .list-search input { background: #314158; }
.list-tool {
  position: relative; min-height: 2.25rem; padding: .5rem .75rem; border: 0; border-radius: .25rem; background: transparent; color: var(--fg); font-weight: 500;
}
.list-tool:hover, .list-tool[aria-expanded='true'] { background: var(--primary); color: var(--on-primary); }
.list-tool .dot {
  min-width: 1.125rem; height: 1.125rem; padding: 0 .3rem; border-radius: 9999px; background: var(--primary); color: var(--on-primary);
  font-size: .6875rem; font-weight: 700; line-height: 1.125rem;
}
.list-tool:hover .dot, .list-tool[aria-expanded='true'] .dot { background: var(--surface); color: var(--fg); }
.list-filters {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: end; margin-bottom: 1rem; padding: 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.list-filters .buttons { justify-content: flex-end; }
.list-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 4px rgba(0, 0, 0, .05); }
table.list-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: .875rem; }
.list-table th {
  position: relative; padding: .6875rem .75rem; text-align: start; font-weight: 600; line-height: 1.3125rem; color: var(--fg);
  background: var(--surface); border-bottom: 2px solid var(--line); border-inline-end: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-table th:first-child { border-start-start-radius: var(--radius); }
.list-table th:last-child { border-start-end-radius: var(--radius); border-inline-end: 0; }
.list-table th[aria-sort='ascending'], .list-table th[aria-sort='descending'], .list-table th.sortable:hover { background: var(--panel); }
/* сортировка: кнопка на всю ширину заголовка, стрелка — треугольник справа (в RTL — слева) */
.list-sort {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%; min-height: 0; padding: 0;
  border: 0; border-radius: 0; background: none; color: inherit; font: inherit; text-align: start;
}
.list-sort:hover { background: none; }
.list-arrow { flex: none; width: 0; height: 0; border-inline: 5px solid transparent; border-bottom: 6px solid #9ca3af; opacity: .6; }
th[aria-sort='ascending'] .list-arrow { border-bottom-color: currentColor; opacity: 1; }
th[aria-sort='descending'] .list-arrow { border-bottom: 0; border-top: 6px solid currentColor; opacity: 1; }
.list-table td {
  padding: .5625rem .75rem; line-height: 1.3125rem; color: var(--fg); border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
/* строки через одну, как у эталона */
.list-table tbody tr.row:nth-of-type(odd) td { background: var(--panel); }
.list-table tbody tr.row:nth-of-type(even) td { background: var(--canvas); }
.list-table tbody tr.row:hover td { background: var(--hover); }
.list-table tbody:last-of-type tr:last-child td { border-bottom: 0; }
.list-table tbody:last-of-type tr:last-child td:first-child { border-end-start-radius: var(--radius); }
.list-table tbody:last-of-type tr:last-child td:last-child { border-end-end-radius: var(--radius); }
/* ширины колонок — классами на <th> (table-layout: fixed берёт их из шапки); колонка без класса делит остаток */
.list-table th.w-author { width: 10rem; }
.list-table th.w-date { width: 8.5rem; }
.list-table th.w-state { width: 8rem; }
.list-table td a { color: inherit; font-weight: 500; text-decoration: none; }
.list-table td a:hover { color: var(--accent); text-decoration: underline; }
.list-table td.muted { color: var(--muted); }
.list-table .num { text-align: end; font-variant-numeric: tabular-nums; }
/* строка-группа (например, месяц): на всю ширину, мелким жирным */
.list-table tr.list-group td {
  padding-block: .4375rem; background: var(--surface); color: var(--muted); font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
html.dark .list-table tr.list-group td { background: #18212f; }
/* колонка «⋯»: меню строки */
.list-table th.list-actions, .list-table td.list-actions { width: 3rem; padding-inline: .25rem; text-align: center; overflow: visible; }
.row-menu { position: relative; display: inline-block; }
.list-dots { width: 2rem; height: 2rem; min-height: 0; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); }
.list-dots:hover, .list-dots[aria-expanded='true'] { background: rgba(15, 23, 42, .08); color: var(--fg); }
html.dark .list-dots:hover, html.dark .list-dots[aria-expanded='true'] { background: rgba(255, 255, 255, .1); }
.row-menu .menu-panel { min-width: 11rem; top: calc(100% + .125rem); }
/* бейджи статуса */
.badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .125rem .625rem; border-radius: 9999px;
  font-size: .75rem; font-weight: 500; line-height: 1rem; white-space: nowrap; background: var(--panel); color: var(--text);
}
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }
html.dark .badge { background: #314158; color: #e2e8f0; }
html.dark .badge.ok { background: rgba(20, 83, 45, .6); color: #bbf7d0; }
html.dark .badge.warn { background: rgba(120, 53, 15, .6); color: #fde68a; }
html.dark .badge.bad { background: rgba(127, 29, 29, .6); color: #fecaca; }
html.dark .badge.info { background: rgba(30, 58, 138, .6); color: #bfdbfe; }
/* пустой список и загрузка */
.list-empty { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 3rem 1rem; text-align: center; color: var(--muted); }
.list-empty .icon { width: 2.5rem; height: 2.5rem; color: var(--line-strong); }
.list-empty strong { color: var(--fg); font-size: 1rem; font-weight: 600; }
.list-empty p { margin: 0 0 .5rem; color: var(--muted); font-size: .875rem; }
.skeleton { height: .875rem; border-radius: .25rem; background: linear-gradient(90deg, var(--panel), var(--line), var(--panel)); background-size: 200% 100%; animation: skeleton 1.2s linear infinite; }
.skeleton.short { width: 40%; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner { display: inline-block; width: 1.5rem; height: 1.5rem; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .skeleton, .spinner, .toast { animation: none; } }
/* простая таблица без панели (страницы, которые не список) — тем же видом */
table:not(.list-table) { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: .875rem; }
table:not(.list-table) th, table:not(.list-table) td { padding: .625rem .75rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
table:not(.list-table) th { font-weight: 600; background: var(--canvas); }
table:not(.list-table) tbody tr:last-child td { border-bottom: 0; }

/* ---------- 9. Окна (<dialog> с showModal(): фокус внутри, Escape закрывает, сценарии экранов ищут кнопки только в нём) ---------- */
dialog.modal {
  width: min(30.5rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-pop), 0 0 0 1px var(--line); overflow: auto;
}
dialog.modal::backdrop { background: rgba(243, 244, 246, .75); }
html.dark dialog.modal { background: #0f172a; }
html.dark dialog.modal::backdrop { background: rgba(2, 6, 23, .7); }
dialog.modal[open] { animation: modal-in .15s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(.5rem) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 4rem; padding: .75rem 1rem .75rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: 1.125rem; line-height: 1.75rem; }
.modal-head h2.danger-title { color: #ef4444; }
.modal-head h2 .icon { width: 1.25rem; height: 1.25rem; }
.modal-body { display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: .75rem; padding: .875rem 1.25rem; border-top: 1px solid var(--line); }
.modal-foot.split > button { flex: 1; }
@media (prefers-reduced-motion: reduce) { dialog.modal[open] { animation: none; } }

/* ---------- 10. Страницы входа, регистрации, ошибок: без шапки и меню — логотип над белой карточкой ---------- */
body.auth-body { background: var(--canvas); }
main.auth-page { max-width: none; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 3rem 1rem; }
.auth-wrap { width: 100%; max-width: 28rem; display: flex; flex-direction: column; gap: 1.5rem; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .75rem; color: var(--fg); font-size: 1.875rem; font-weight: 700; text-decoration: none; }
.auth-brand:hover { text-decoration: none; }
.auth-brand img { width: 2.5rem; height: 2.5rem; }
.auth-card {
  display: flex; flex-direction: column; gap: 1rem; padding: 2rem; background: var(--surface); border-radius: .75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
}
html.dark .auth-card { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .6), 0 0 0 1px var(--line); }
.auth-card h1 { margin: 0 0 .25rem; text-align: center; font-size: 1.5rem; }
.auth-card h1 + p, .auth-card .lead { margin: 0; text-align: center; color: var(--muted); font-size: .875rem; }
.auth-card input:not([type='checkbox']):not([type='radio']) { min-height: 2.75rem; padding: .625rem .875rem; font-size: 1rem; }
.auth-card .alert { margin: 0; }
.auth-card .fields { display: flex; flex-direction: column; gap: 1rem; }
.auth-card .or { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .8125rem; }
.auth-card .or::before, .auth-card .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.auth-links { display: flex; flex-direction: column; gap: .5rem; text-align: center; color: var(--muted); font-size: .875rem; }
.auth-links p { margin: 0; color: var(--muted); }
.auth-links a { color: var(--accent); }
/* итог (письмо отправлено, почта подтверждена, ссылка устарела, 404): значок, заголовок и текст по центру, действие — кнопкой */
.auth-result { text-align: center; align-items: stretch; }
.auth-result .result-icon { width: 3.5rem; height: 3.5rem; margin: 0 auto; color: var(--primary); }
.auth-result .result-icon.bad { color: #ef4444; }
.auth-result p { margin: 0; color: var(--muted); }
.auth-result .code-big { font-size: 3.5rem; font-weight: 700; line-height: 1; color: var(--primary); }

/* ---------- 11. Совместимость: заготовки модулей (Vow.Chat, Vow.Mcp) и страницы старого вида — простая верхняя полоса header.top ---------- */
header.top {
  display: flex; align-items: center; gap: 1.25rem; height: var(--topbar-h); padding: 0 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
header.top .brand { font-weight: 700; color: var(--fg); }
header.top nav { display: flex; gap: 1rem; }
header.top nav a { color: var(--muted); font-size: .875rem; font-weight: 500; text-decoration: none; }
header.top nav a:hover { color: var(--fg); }
header.top nav a[aria-current='page'] { color: var(--fg); font-weight: 600; }
header.top .who { margin-inline-start: auto; color: var(--muted); display: flex; gap: .75rem; align-items: center; }
.panel { display: flex; flex-direction: column; gap: .75rem; max-width: 36rem; margin-bottom: 1rem; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel h2 { margin: 0; }
.toolbar { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
td.actions button { margin-block: 0 .2rem; margin-inline: 0 .4rem; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin-top: 1rem; }

/* ---------- 12. Узкий экран и телефон ---------- */
/* планшет и узкое окно: таблица ещё таблицей — второстепенные колонки (.hide-narrow) прячутся, остальные уже */
@media (min-width: 768px) and (max-width: 1199px) {
  .list-table .hide-narrow { display: none; }
  .list-table th.w-author { width: 8rem; }
  .list-table th.w-date { width: 7.5rem; }
  .list-table th.w-state { width: 7rem; }
}
@media (max-width: 1023px) {
  .record { grid-template-columns: minmax(0, 1fr); }
  .list-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* телефон: панель — шторкой поверх страницы с затемнением по кнопке ☰; в шапке — меню, заголовок, тема и аватар */
@media (max-width: 767px) {
  .shell { padding-inline-start: 0; }
  .sidebar { width: min(18rem, 85vw); transform: translateX(-100%); transition: transform .25s ease; box-shadow: none; }
  [dir='rtl'] .sidebar { transform: translateX(100%); }
  html.menu-open .sidebar { transform: none; box-shadow: 0 0 2rem rgba(0, 0, 0, .45); z-index: 70; }
  html.sidebar-collapsed .sidebar-logo { justify-content: flex-start; padding: 0 1.25rem; }
  html.sidebar-collapsed .sidebar-logo span, html.sidebar-collapsed .sidebar nav a span, html.sidebar-collapsed .sidebar .nav-title {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none;
  }
  html.sidebar-collapsed .sidebar nav a { justify-content: flex-start; padding-inline: .75rem; }
  .sidebar-toggle { display: none; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, .5); }
  html.menu-open .sidebar-backdrop { display: block; }
  html.menu-open body { overflow: hidden; }
  .menu-toggle { display: inline-flex; margin-inline-start: -.25rem; }
  .topbar { padding: 0 .5rem 0 .75rem; gap: .5rem; }
  .page-title h1 { font-size: 1.0625rem; }
  .user-name, .user-menu > summary > .icon { display: none; }
  .shell > main { padding: 1rem .75rem; }
  main { padding: 1rem .75rem; }
  .form-grid, .list-filters { grid-template-columns: minmax(0, 1fr); }
  .list-search { flex: 1 1 100%; }
  .list-toolbar .list-tools { margin-inline-start: 0; flex: 1; justify-content: space-between; }
  /* таблица списка — карточками: заголовок первой колонкой, ниже «Подпись: значение» (подпись — data-label ячейки), «⋯» — в углу */
  table.list-table, .list-table tbody, .list-table tr, .list-table td { display: block; width: 100%; }
  .list-table thead, .list-table tr.list-group td + td { display: none; }
  .list-table tr.row { position: relative; padding: .75rem 3rem .75rem 1rem; border-bottom: 1px solid var(--line); }
  .list-table tbody tr.row:nth-of-type(n) td { background: none; }
  .list-table tbody tr.row:nth-of-type(odd) { background: var(--surface); }
  .list-table tbody tr.row:nth-of-type(even) { background: var(--canvas); }
  .list-table td { padding: .125rem 0; border: 0; white-space: normal; }
  .list-table td:first-child { font-size: 1rem; padding-bottom: .25rem; }
  .list-table td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); }
  .list-table td.list-actions { position: absolute; top: .5rem; inset-inline-end: .5rem; width: auto; padding: 0; }
  .list-table tr.list-group td { padding: .5rem 1rem; }
  .list-table tbody:last-of-type tr:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
  .facts { grid-template-columns: minmax(0, 1fr); gap: .125rem; }
  .facts dd { margin-bottom: .5rem; }
  .card-head, .card-body { padding: 1rem; }
  .card-foot { padding: .75rem 1rem; }
  .card-foot .buttons, .card-foot > button { flex: 1 1 auto; }
  .toasts { inset-inline: 1rem; bottom: 1rem; width: auto; }
  .auth-card { padding: 1.5rem 1.25rem; }
  .auth-brand { font-size: 1.5rem; }
}
/* ---------- vow-dev: проекты, чаты проекта, чат с агентом (макеты docs/prototypes/vow-dev-mockups.html) ---------- */
.spacer { flex: 1; }
.dev-cards { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.dev-card { display: flex; flex-direction: column; gap: .375rem; padding: 1rem; color: inherit; }
a.dev-card:hover { text-decoration: none; border-color: var(--primary); }
.dev-card-head { display: flex; align-items: center; gap: .5rem; }
.dev-card-head > :first-child:not(.dev-dot), .dev-card-head > .dev-dot + strong { flex: 1; min-width: 0; }
.dev-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted); flex: none; }
.dev-dot.ok { background: var(--ok); }
.dev-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .8125rem; }
.dev-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8125rem; }
.dev-section { font-size: .8125rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1.25rem 0 .5rem; }
.dev-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.dev-new { margin-top: 1rem; }
.dev-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.dev-row { display: flex; flex-direction: column; gap: .25rem; padding: .75rem 1rem; color: inherit; }
.dev-row + .dev-row { border-top: 1px solid var(--line); }
.dev-row:hover { text-decoration: none; background: var(--panel); }
.dev-chat { display: flex; flex-direction: column; gap: .75rem; max-width: 52rem; }
.dev-feed { display: flex; flex-direction: column; gap: .75rem; }
.dev-msg { padding: .75rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.dev-msg.user { align-self: flex-end; max-width: 85%; background: var(--primary-soft); border-color: transparent; }
.dev-text > :first-child { margin-top: 0; }
.dev-text > :last-child { margin-bottom: 0; }
.dev-text pre { overflow-x: auto; padding: .5rem .75rem; border-radius: var(--radius-sm); background: var(--panel); }
.dev-acts { margin: .5rem 0; }
.dev-acts-toggle { min-height: 0; padding: .125rem .5rem; border: 0; background: var(--panel); color: var(--muted); font-size: .8125rem; }
.dev-acts ul { margin: .375rem 0 0; padding: 0 0 0 .75rem; list-style: none; border-left: 2px solid var(--panel); font-size: .8125rem; color: var(--muted); }
.dev-acts li.app, .dev-acts li.error { color: var(--warn); }
.dev-acts li.commit, .dev-acts li.mr { color: var(--ok); }
.dev-usage { margin-top: .5rem; font-size: .75rem; }
.dev-working { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.dev-working button { margin-left: auto; }
.dev-composer { display: flex; gap: .5rem; align-items: flex-end; position: sticky; bottom: 0; padding: .5rem 0; background: var(--canvas); }
.dev-composer textarea { flex: 1; resize: vertical; }

@media print {
  .sidebar, .sidebar-toggle, .topbar-tools, .menu-toggle, .toasts, .list-toolbar, .list-actions { display: none !important; }
  .shell { padding: 0; }
  body, .shell > main { background: #fff; }
}
