/* Тема по «Стандарту дизайна и структуры корпоративного веб-приложения» v1.0.
   Цвета и размеры — только через токены :root. Новые страницы собираются из классов ниже. */

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter-4/inter-cyrillic.fdccea76ce7e.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter-4/inter-latin.30a274cd01b6.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #17211b;
  --color-text: #17211b;
  --color-muted: #68756d;
  --color-page: #f2f4f1;
  --color-surface: #ffffff;
  --color-border: #dce2dd;
  --color-control-border: #cfd7d1;
  --color-control-text: #344139;
  --color-primary: #175f46;
  --color-primary-hover: #22815f;
  --color-lime: #dbe8a9;
  --color-sidebar: #112e24;
  --color-sidebar-active: #214b3b;
  --color-sidebar-sub-active: #1d4335;
  --color-sidebar-text: #b8c9c2;
  --color-sidebar-section: #8da99b;
  --color-table-head: #f6f8f6;
  --color-group: #e9efeb;
  --color-group-text: #173f30;
  --color-detail: #f7faf8;
  --color-selected: #eef5ef;
  --color-icon-bg: #e7eee9;
  --color-focus-border: #6c9984;
  --color-focus-ring: #d9e7dd;
  --color-required: #a33429;
  --color-positive: #17613f;
  --color-negative: #a33a31;

  /* Семантические состояния: фон и текст */
  --state-draft-bg: #fff0c8;      --state-draft-text: #765a0a;
  --state-active-bg: #dceee4;     --state-active-text: #185e43;
  --state-error-bg: #fde2df;      --state-error-text: #9a3028;
  --state-inactive-bg: #e8e9e8;   --state-inactive-text: #5e6660;
  --state-review-bg: #e8eefb;     --state-review-text: #31558e;
  --state-returned-bg: #fff0df;   --state-returned-text: #9a5118;

  --radius-control: 6px;
  --radius-panel: 7px;
  --sidebar-width: 236px;
  --topbar-height: 68px;
  --page-padding: 26px;
  --transition: 150ms ease;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--color-page); color: var(--color-text); font-size: 13px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }
h1, h2, h3 { color: var(--color-text); }
.icon { flex: none; display: inline-block; vertical-align: middle; }
.muted { color: var(--color-muted); }
.nowrap { white-space: nowrap; }
.numeric { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--color-primary-hover);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Каркас ---------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--color-sidebar); color: var(--color-sidebar-text);
  padding: 0 12px 18px;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  height: var(--topbar-height); padding: 0 6px; margin-bottom: 14px;
  color: #fff; text-decoration: none;
}
.brand:hover { color: #fff; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-control);
  background: var(--color-lime); color: var(--color-sidebar);
}
.brand-name { display: block; font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-sub { display: block; font-size: 11px; color: var(--color-sidebar-section); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-admin { margin-top: auto; padding-top: 18px; }
.nav-section {
  margin: 16px 12px 6px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-sidebar-section);
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-control);
  color: var(--color-sidebar-text); text-decoration: none; font-size: 15px; font-weight: 400;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: var(--color-sidebar-active); color: #fff; font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 2px;
  background: var(--color-lime);
}
.nav-item .chevron { margin-left: auto; opacity: 0.7; }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px; }
.nav-sub a {
  display: block; padding: 7px 12px 7px 41px; border-radius: var(--radius-control);
  color: var(--color-sidebar-text); text-decoration: none; font-size: 12px;
}
.nav-sub a:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.nav-sub a.active { background: var(--color-sidebar-sub-active); color: #fff; font-weight: 600; }
.sidebar a:focus-visible { outline-color: var(--color-lime); }

.workspace { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: var(--topbar-height); padding: 0 var(--page-padding);
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.topbar-context { display: flex; align-items: center; gap: 10px; min-width: 0; }
.context-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  border: 1px solid var(--color-control-border); border-radius: var(--radius-control); background: var(--color-surface);
  white-space: nowrap;
}
.context-chip .icon { color: var(--color-primary); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user form { margin: 0; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-icon-bg); color: var(--color-group-text); font-size: 12px; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta b { font-size: 12px; }
.user-meta span { font-size: 11px; color: var(--color-muted); }

.content { padding: var(--page-padding); display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- Заголовок страницы ---------- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 25px; font-weight: 700; line-height: 1.25; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-sub { margin: 4px 0 0; font-size: 13px; color: var(--color-muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; text-decoration: none; margin-bottom: 6px; }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 8px 13px; border-radius: var(--radius-control); border: 1px solid transparent;
  font-size: 13px; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: #fff; }
.btn-secondary { background: var(--color-surface); border-color: var(--color-control-border); color: var(--color-control-text); padding: 8px 10px; font-weight: 500; }
.btn-secondary:hover { border-color: var(--color-focus-border); color: var(--color-text); background: var(--color-detail); }
.btn-danger { background: var(--color-surface); border-color: #e7b9b3; color: var(--state-error-text); font-weight: 500; }
.btn-danger:hover { background: var(--state-error-bg); color: var(--state-error-text); }
.btn-danger-solid { background: var(--state-error-text); border-color: var(--state-error-text); color: #fff; }
.btn-danger-solid:hover { background: var(--color-negative); color: #fff; }
.btn-row {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; min-height: 0;
  border: 1px solid var(--color-control-border); border-radius: 5px; background: var(--color-surface);
  color: var(--color-primary); font-size: 12px; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-row:hover { border-color: var(--color-focus-border); background: var(--color-selected); }
.btn-row.danger { color: var(--state-error-text); }
.btn-row.danger:hover { background: var(--state-error-bg); border-color: #e7b9b3; }
.btn-text {
  border: 0; background: none; padding: 0; color: var(--color-primary); cursor: pointer; font-weight: 500; text-decoration: none;
}
.btn-text:hover { color: var(--color-primary-hover); text-decoration: underline; }
form.inline { display: inline; margin: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }

/* Сегментированный выбор (срок бюджета) */
.segmented { display: inline-flex; border: 1px solid var(--color-control-border); border-radius: var(--radius-control); overflow: hidden; background: var(--color-surface); }
.segmented a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  color: var(--color-control-text); text-decoration: none; border-left: 1px solid var(--color-control-border);
}
.segmented a:first-child { border-left: 0; }
.segmented a:hover { background: var(--color-selected); }
.segmented a.current { background: var(--color-primary); color: #fff; font-weight: 600; }

/* ---------- Панели, вкладки, сообщения ---------- */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  padding: 18px;
  min-width: 0;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2, .panel-title { margin: 0; font-size: 15px; font-weight: 700; }
.panel-head p { margin: 2px 0 0; color: var(--color-muted); font-size: 12px; }
.panel.flush > .panel-head { padding: 16px 18px 0; }
.panel-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 14px 18px; border-bottom: 1px solid var(--color-border);
}
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--color-border); color: var(--color-muted); font-size: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.narrow { max-width: 760px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); }
.tabs a {
  padding: 10px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  color: var(--color-muted); text-decoration: none; font-weight: 500;
}
.tabs a:hover { color: var(--color-text); }
.tabs a.current { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.panel.flush > .tabs { padding: 0 18px; }

.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--radius-panel); border: 1px solid transparent;
  background: var(--state-active-bg); color: var(--state-active-text);
}
.alert .icon { margin-top: 1px; }
.alert.error { background: var(--state-error-bg); color: var(--state-error-text); }
.alert.warning { background: var(--state-draft-bg); color: var(--state-draft-text); }
.alert.info { background: var(--state-review-bg); color: var(--state-review-text); }
.alert a { color: inherit; font-weight: 600; }
.alert p { margin: 0; }
.alert-details summary { cursor: pointer; list-style: none; }
.alert-details summary::-webkit-details-marker { display: none; }
.alert-details summary .btn-text { color: inherit; text-decoration: underline; margin-left: 4px; }
.alert-details[open] summary .btn-text { display: none; }
.alert-details p { margin-top: 8px; line-height: 1.7; }

/* ---------- Карточки показателей ---------- */

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.budget-metrics { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); }
.metrics.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.metric {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px; border-radius: var(--radius-panel); border: 1px solid var(--color-border);
  background: var(--color-surface); color: inherit; text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
}
a.metric:hover { border-color: var(--color-focus-border); color: inherit; }
.metric.selected { border-color: var(--color-primary); background: var(--color-selected); box-shadow: inset 0 0 0 1px var(--color-primary); }
.metric-icon {
  display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: var(--radius-panel);
  background: var(--color-icon-bg); color: var(--color-primary);
}
.metric-body { min-width: 0; }
.metric-label { display: block; font-size: 11px; color: var(--color-muted); }
.metric-value { display: block; overflow-wrap: anywhere; font-size: 21px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.metric-note { display: block; font-size: 11px; color: var(--color-muted); }

/* ---------- Разводящая страница: карточки реестров ---------- */

.registry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 13px; max-width: 1000px; }
.registry-card { align-items: center; padding: 20px; }
.registry-card .metric-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; flex: 1; }
.registry-card .metric-note { font-size: 12px; }
.registry-title { font-size: 16px; font-weight: 700; }
.registry-go { color: var(--color-muted); flex: none; }
a.registry-card:hover .registry-go { color: var(--color-primary); }

/* ---------- Доступ пользователей по реестрам ---------- */

.access-list { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Таблицы ---------- */

.table-scroll { overflow: auto; min-width: 0; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td { padding: 11px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--color-border); }
.table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--color-table-head); color: var(--color-muted);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap;
}
.table th a { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.table th a:hover { color: var(--color-text); }
.table th.sorted { color: var(--color-group-text); }
.table td { background: var(--color-surface); }
.table tbody tr:hover td { background: var(--color-selected); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.name { font-weight: 600; }
.table td.name a { color: var(--color-text); text-decoration: none; }
.table td.name a:hover { color: var(--color-primary); text-decoration: underline; }
.table td.comment { min-width: 220px; max-width: 320px; white-space: pre-line; color: var(--color-muted); }
.table td.owner { min-width: 180px; }
.table td.empty { padding: 28px 18px; text-align: center; color: var(--color-muted); }
.table .sticky-col { position: sticky; left: 0; z-index: 1; box-shadow: inset -1px 0 0 var(--color-border); }
.table th.sticky-col { z-index: 3; }
/* Копия шапки таблицы под верхней панелью (domains/static/domains/sticky-head.js). */
.sticky-head { position: fixed; z-index: 15; overflow: hidden; }
.sticky-head .table { table-layout: fixed; }
.table tr.total td {
  background: var(--color-group-text); color: #fff; font-weight: 700; border-bottom: 0;
}
.table tr.total:hover td { background: var(--color-group-text); }
.table tr.group td { background: var(--color-group); color: var(--color-group-text); font-weight: 700; }
tr.inactive td, tr.dont-renew td { color: #8a948e; }
tr.dont-renew td.name a, tr.inactive td a { color: #6f7a73; }
.panel > .table-scroll { margin: 0 -18px -18px; border-top: 1px solid var(--color-border); }
.panel > .panel-head + .table-scroll { margin-top: 0; }
.panel.flush .table-scroll { margin: 0; border-top: 0; }

.pagination { display: flex; gap: 12px; align-items: center; }

/* ---------- Метки ---------- */

.status {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 13px;
  font-size: 11px; font-weight: 600; line-height: 1.2; white-space: nowrap;
}
.status-active { background: var(--state-active-bg); color: var(--state-active-text); }
.status-inactive { background: var(--state-inactive-bg); color: var(--state-inactive-text); }
.status-error { background: var(--state-error-bg); color: var(--state-error-text); }
.status-draft { background: var(--state-draft-bg); color: var(--state-draft-text); }
.status-review { background: var(--state-review-bg); color: var(--state-review-text); }
.status-returned { background: var(--state-returned-bg); color: var(--state-returned-text); }

.badge {
  display: inline-block; min-width: 2.6em; padding: 4px 8px; border-radius: 13px;
  font-size: 12px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; line-height: 1.2;
}
.badge.gray { background: var(--state-inactive-bg); color: var(--state-inactive-text); }

/* Срочность по days_left (только активные домены). Те же цвета — в URGENCY_STYLES письма
   (domains/services/notify_email.py): меняете одно — меняйте и другое. */
.urgency-expired { background: #7a0b0b; color: #fff; }
.urgency-d7 { background: #cf222e; color: #fff; }
.urgency-d30 { background: #fb8f44; color: #1f2328; }
.urgency-d60 { background: #f5d90a; color: #1f2328; }
.urgency-later { background: #2da44e; color: #fff; }
.urgency-nodate { background: #eaeef2; color: #1f2328; }

/* ---------- Формы ---------- */

.field label, .filter label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 500; color: var(--color-control-text); }
.req { color: var(--color-required); font-weight: 700; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea,
.filter input, .filter select {
  width: 100%; min-height: 38px; padding: 8px 10px;
  border: 1px solid var(--color-control-border); border-radius: var(--radius-control);
  background: var(--color-surface); color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .filter input:focus, .filter select:focus {
  border-color: var(--color-focus-border); box-shadow: 0 0 0 2px var(--color-focus-ring); outline: none;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
.filter input:focus-visible, .filter select:focus-visible { outline: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea, .filter.has-error input {
  border-color: var(--color-required);
}
.field input[type=checkbox], .check input { width: 16px; height: 16px; accent-color: var(--color-primary); margin: 0; }
.check { display: inline-flex !important; align-items: center; gap: 8px; min-height: 38px; font-size: 13px !important; color: var(--color-text) !important; cursor: pointer; }
.field > .check { margin-top: 18px; }
.helptext { margin-top: 5px; font-size: 12px; color: var(--color-muted); }
.helptext ul { margin: 4px 0 0; padding-left: 18px; }
.field-error, .filter .field-error { margin-top: 5px; font-size: 12px; color: var(--state-error-text); font-weight: 500; }
.errorlist { margin: 0; padding: 0; list-style: none; }

.form-section + .form-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--color-border); }
.form-section h2 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.form-actions .muted { font-size: 12px; margin-left: 4px; }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; align-items: end; width: 100%; }
.filters .filter-search { grid-column: span 2; }
.filters .filter-actions { display: flex; gap: 8px; }
.filters .filter-actions .btn { min-height: 38px; }
.filter select, .filter input { font-size: 13px; }
.filter-label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 500; color: var(--color-control-text); }
/* Мультивыбор в фильтрах (виджет MultiSelectDropdown) */
.multiselect { position: relative; }
.multiselect summary {
  display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 8px 10px; cursor: pointer; list-style: none;
  border: 1px solid var(--color-control-border); border-radius: var(--radius-control); background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.multiselect summary::-webkit-details-marker { display: none; }
.multiselect summary:focus-visible, .multiselect[open] summary {
  border-color: var(--color-focus-border); box-shadow: 0 0 0 2px var(--color-focus-ring); outline: none;
}
.multiselect summary svg { flex: none; margin-left: auto; color: var(--color-muted); }
.multiselect-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect-menu {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 100%; max-width: 320px; max-height: 280px;
  overflow-y: auto; padding: 4px 0; border: 1px solid var(--color-border); border-radius: var(--radius-control);
  background: var(--color-surface); box-shadow: 0 6px 18px rgba(17, 46, 36, 0.12);
}
.multiselect-menu .check { display: flex !important; min-height: 32px; margin: 0; padding: 0 10px; }
.multiselect-menu .check input { flex: none; width: 16px; min-height: 0; padding: 0; }
.multiselect-menu .check:hover { background: var(--color-selected); }
.budget-filters { grid-template-columns: auto repeat(3, minmax(150px, 200px)) auto; justify-content: start; }

/* Карточка записи: строки «подпись — значение» по секциям */
.record { padding: 6px 18px 18px; max-width: 880px; }
.record-section { padding-top: 14px; }
.record-section h2 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
dl.rows { margin: 0; }
dl.rows > div {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--color-border);
}
dl.rows > div:last-child { border-bottom: 0; }
dl.rows dt { color: var(--color-muted); font-size: 13px; }
dl.rows dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
dl.rows dd .badge { margin-left: 8px; }
dl.rows dd.multiline { white-space: pre-line; }

.changes { margin: 0; padding-left: 16px; }
.changes li + li { margin-top: 2px; }
.changes .old { color: var(--color-negative); text-decoration: line-through; text-decoration-color: rgba(163, 58, 49, 0.4); }
.changes .new { color: var(--color-positive); font-weight: 500; }

/* ---------- Вход ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.auth-brand .brand-mark { background: var(--color-sidebar); color: var(--color-lime); }
.auth-brand b { display: block; font-size: 16px; }
.auth-brand span { display: block; font-size: 12px; color: var(--color-muted); }
.auth h1 { margin: 0 0 14px; font-size: 21px; }
.auth .btn { width: 100%; }

/* ---------- Инструкция ---------- */

.help-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.help-toc { position: sticky; top: calc(var(--topbar-height) + 16px); }
.help-toc ol { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.help-toc a { display: block; padding: 6px 8px; border-radius: 5px; color: var(--color-control-text); text-decoration: none; font-size: 13px; }
.help-toc a:hover { background: var(--color-selected); color: var(--color-primary); }
.help-body { display: flex; flex-direction: column; gap: 14px; }
.help-section { font-size: 16px; line-height: 1.65; scroll-margin-top: calc(var(--topbar-height) + 16px); }
.help-section h2 { margin: 0 0 6px; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.help-section p { margin: 0 0 10px; }
.help-section ol, .help-section ul { margin: 0 0 10px; padding-left: 22px; }
.help-section li + li { margin-top: 4px; }
.help-section :last-child { margin-bottom: 0; }
.help-section .table { font-size: 13px; line-height: 1.45; margin: 4px 0 10px; border: 1px solid var(--color-border); border-radius: var(--radius-panel); overflow: hidden; }
.help-section .table td, .help-section .table th { text-align: center; }
.help-section .table td:first-child, .help-section .table th:first-child { text-align: left; }
.help-empty { display: none; }
kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid var(--color-control-border); border-bottom-width: 2px;
  border-radius: 4px; background: var(--color-table-head); font: 600 12px/1.4 Inter, "Segoe UI", Arial, sans-serif;
}

/* ---------- Календарь flatpickr в цветах темы ---------- */

.flatpickr-calendar { font-family: inherit; border-radius: var(--radius-panel); }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--color-primary); border-color: var(--color-primary); }
.flatpickr-day.today { border-color: var(--color-focus-border); }

/* ---------- Узкие экраны ---------- */

@media (max-width: 1439px) {
  .metrics.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1179px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .budget-filters { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .help-layout { grid-template-columns: minmax(0, 1fr); }
  .help-toc { position: static; }
  .user-meta { display: none; }
}
@media (max-width: 860px) {
  :root { --page-padding: 16px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; }
  .nav-admin { margin-top: 0; }
  .topbar { position: static; height: auto; min-height: var(--topbar-height); flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .form-grid, .form-grid.cols-2, .metrics, .metrics.six { grid-template-columns: minmax(0, 1fr); }
  .filters .filter-search { grid-column: auto; }
  dl.rows > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
