/* ОКК — общий стиль. Токены в :root, компоненты ниже. Без сборки и CDN.
   Палитра — как у «JS Бронь» (EKB): тёплая гамма и янтарный акцент; тема по системе (prefers-color-scheme),
   переключатель в меню ставит <html data-theme="light|dark"> (web/static/js/theme.js). */
@font-face { font-family: Manrope; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("../fonts/manrope-cyrillic-ext.28f2a82ccec8.woff2") format("woff2"); unicode-range: U+460-52F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: Manrope; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("../fonts/manrope-cyrillic.8fc0aa17e129.woff2") format("woff2"); unicode-range: U+301, U+400-45F, U+490-491, U+4B0-4B1, U+2116; }
@font-face { font-family: Manrope; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("../fonts/manrope-latin.101877a7a906.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 {
  color-scheme: light;
  /* цвета — светлая тема */
  --bg: #f6f3ef;
  --surface: #ffffff;
  --surface-2: #faf7f3;
  --surface-3: #f1ece6;
  --border: #e9e2da;
  --border-strong: #d9d0c6;
  --text: #1f1a16;
  --text-2: #3d352e;
  --muted: #6d645b;
  --faint: #786d63;         /* подписи третьего плана: читаются на белом (4.5:1) */
  --primary: #c77d12;         /* акцент: кнопки, отметки, активное */
  --primary-hover: #b06c0c;
  --primary-soft: #fbefdc;
  --primary-ring: rgba(199, 125, 18, .25);
  --on-primary: #1f1407;      /* текст на акценте: тёмный на янтаре (5.5:1), как в тёмной теме */
  --on-danger: #ffffff;
  --link: #9a5c06;            /* акцент текстом: ссылки и подписи — темнее, чтобы читался на белом */
  --success: #28693f;
  --success-soft: #e7f4eb;
  --success-border: #bcdfc8;
  --warning: #9a5a06;
  --warning-soft: #fdf3e1;
  --warning-border: #f1d39a;
  --danger: #b4372a;
  --danger-strong: #b3341f;
  --danger-soft: #fcebe7;
  --danger-border: #f2c3ba;
  --info: #2f6497;
  --info-soft: #e9f1f9;
  --info-border: #bfd4ea;
  --demo-bg: #f1e9fb; --demo-text: #6b3fb8; --demo-border: #e1d1f6;
  --wa-bg: #e5f5ea; --wa-text: #23703f; --ig-bg: #fbeaf3; --ig-text: #a8266a;
  --cell-manual: #fdf1cf;
  --chart-bar: #ecd7b3; --chart-bar-weekend: #dcb46e;
  /* баллы: высокий / средний / низкий */
  --score-high: #28693f;
  --score-high-bg: #dcf1e2;
  --score-mid: #9a5a06;
  --score-mid-bg: #fbe8c6;
  --score-low: #ad2f20;
  --score-low-bg: #f9ddd7;
  /* отступы */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  /* радиусы и тени — мягче, «по-дружески» */
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, .05);
  --shadow: 0 1px 3px rgba(60, 40, 20, .08), 0 1px 2px rgba(60, 40, 20, .04);
  --shadow-lg: 0 14px 34px -10px rgba(60, 40, 20, .2), 0 4px 10px -4px rgba(60, 40, 20, .08);
  /* шрифт */
  --font: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs: 14px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 26px;
  --page-max: 1560px;
  --side-w: 236px;
  --topbar-h: 0px;  /* шапки над страницей нет; на узком экране — 52px (.mobilebar) */
}
/* тёмная тема — как основной вид «Брони» */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #14110f; --surface: #1c1815; --surface-2: #211c18; --surface-3: #2a241f;
  --border: #2f2822; --border-strong: #433a31;
  --text: #f3ede6; --text-2: #dcd3c9; --muted: #a59b90; --faint: #948a7f;
  --primary: #e8a33d; --primary-hover: #f0b354; --primary-soft: rgba(232, 163, 61, .14); --primary-ring: rgba(232, 163, 61, .32);
  --on-primary: #1a1206; --on-danger: #2a0d08; --link: #f0b354;
  --success: #6cc58e; --success-soft: rgba(92, 184, 122, .13); --success-border: rgba(92, 184, 122, .34);
  --warning: #f0b354; --warning-soft: rgba(232, 163, 61, .12); --warning-border: rgba(232, 163, 61, .34);
  --danger: #f08070; --danger-strong: #f08070; --danger-soft: rgba(229, 96, 79, .13); --danger-border: rgba(229, 96, 79, .38);
  --info: #8db8e8; --info-soft: rgba(111, 154, 209, .13); --info-border: rgba(111, 154, 209, .34);
  --demo-bg: rgba(160, 120, 230, .16); --demo-text: #c9adf5; --demo-border: rgba(160, 120, 230, .35);
  --wa-bg: rgba(92, 184, 122, .15); --wa-text: #7fd39f; --ig-bg: rgba(225, 90, 160, .15); --ig-text: #f08cc0;
  --cell-manual: rgba(232, 163, 61, .16);
  --chart-bar: #4a3d2c; --chart-bar-weekend: #8a6a38;
  --score-high: #7fd39f; --score-high-bg: rgba(92, 184, 122, .18);
  --score-mid: #f0b354; --score-mid-bg: rgba(232, 163, 61, .18);
  --score-low: #f4897a; --score-low-bg: rgba(229, 96, 79, .2);
  --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .6);
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14110f; --surface: #1c1815; --surface-2: #211c18; --surface-3: #2a241f;
  --border: #2f2822; --border-strong: #433a31;
  --text: #f3ede6; --text-2: #dcd3c9; --muted: #a59b90; --faint: #948a7f;
  --primary: #e8a33d; --primary-hover: #f0b354; --primary-soft: rgba(232, 163, 61, .14); --primary-ring: rgba(232, 163, 61, .32);
  --on-primary: #1a1206; --on-danger: #2a0d08; --link: #f0b354;
  --success: #6cc58e; --success-soft: rgba(92, 184, 122, .13); --success-border: rgba(92, 184, 122, .34);
  --warning: #f0b354; --warning-soft: rgba(232, 163, 61, .12); --warning-border: rgba(232, 163, 61, .34);
  --danger: #f08070; --danger-strong: #f08070; --danger-soft: rgba(229, 96, 79, .13); --danger-border: rgba(229, 96, 79, .38);
  --info: #8db8e8; --info-soft: rgba(111, 154, 209, .13); --info-border: rgba(111, 154, 209, .34);
  --demo-bg: rgba(160, 120, 230, .16); --demo-text: #c9adf5; --demo-border: rgba(160, 120, 230, .35);
  --wa-bg: rgba(92, 184, 122, .15); --wa-text: #7fd39f; --ig-bg: rgba(225, 90, 160, .15); --ig-text: #f08cc0;
  --cell-manual: rgba(232, 163, 61, .16);
  --chart-bar: #4a3d2c; --chart-bar-weekend: #8a6a38;
  --score-high: #7fd39f; --score-high-bg: rgba(92, 184, 122, .18);
  --score-mid: #f0b354; --score-mid-bg: rgba(232, 163, 61, .18);
  --score-low: #f4897a; --score-low-bg: rgba(229, 96, 79, .2);
  --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .6);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.015em; }
h2 { font-size: var(--fs-lg); font-weight: 700; }
h3 { font-size: var(--fs-md); font-weight: 600; }
p { margin: 0 0 var(--s3); }
code { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
::selection { background: var(--primary); color: var(--on-primary); }
html { scrollbar-color: var(--border-strong) transparent; accent-color: var(--primary); }
a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
h1, h2, h3 { text-wrap: balance; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; } }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

/* --- каркас: меню слева ------------------------------------------------------ */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.shell-main { min-width: 0; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s1); padding: var(--s4) var(--s3); background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: var(--s2); color: var(--text); font-weight: 800; font-size: 17px; letter-spacing: .02em; flex-shrink: 0; }
.sidebar > .brand { padding: 0 var(--s2) var(--s3); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; box-shadow: 0 2px 8px var(--primary-ring); }
.brand-mark svg { width: 18px; height: 18px; fill: none; stroke: var(--on-primary); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark-lg { width: 44px; height: 44px; border-radius: 12px; }
.brand-mark-lg svg { width: 26px; height: 26px; }
.side-branch { margin: 0 var(--s1) var(--s2); padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 500; transition: background .15s, color .15s; }
.side-nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.side-nav a.active { background: var(--primary-soft); color: var(--text); font-weight: 700; box-shadow: inset 3px 0 0 var(--primary); }
.side-nav a.active .side-icon { color: var(--primary); }
.side-count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: 12px; font-weight: 700; text-align: center; line-height: 18px; }
.side-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-dot { width: 18px; flex: none; display: grid; place-items: center; }
.side-dot::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.side-group summary { list-style: none; cursor: pointer; padding: var(--s3) 10px var(--s1); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); display: flex; justify-content: space-between; }
.side-group summary::-webkit-details-marker { display: none; }
.side-group summary::after { content: "▾"; }
.side-group:not([open]) summary::after { content: "▸"; }
.userbox { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--border); display: flex; align-items: center; gap: var(--s1); }
.user-meta { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s2); color: var(--text); padding: 4px 6px 4px 4px; border-radius: var(--r-sm); }
.user-meta:hover { background: var(--surface-3); text-decoration: none; }
.avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--primary-soft); color: var(--link); font-weight: 650; display: grid; place-items: center; font-size: var(--fs-sm); }
.user-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-name { font-weight: 550; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }
.mobilebar { display: none; }
.userbox .icon-btn { width: 32px; height: 32px; padding: 0; flex: none; }
/* значки без текста: контур 1.8, цвет наследуется (маска) */
.ic { display: inline-block; width: 18px; height: 18px; flex: none; background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
.ic-menu { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E"); }
.ic-logout { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h3M15 8l4 4-4 4M19 12H9'/%3E%3C/svg%3E"); }
.ic-theme { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 3.5v17a8.5 8.5 0 0 0 0-17z' fill='%23000'/%3E%3C/svg%3E"); }
[data-theme-state="light"] .ic-theme { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2.5v2.5M12 19v2.5M2.5 12H5M19 12h2.5M5.3 5.3l1.8 1.8M16.9 16.9l1.8 1.8M5.3 18.7l1.8-1.8M16.9 7.1l1.8-1.8'/%3E%3C/svg%3E"); }
[data-theme-state="dark"] .ic-theme { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 14.5A8.5 8.5 0 0 1 9.5 4a8.5 8.5 0 1 0 10.5 10.5z'/%3E%3C/svg%3E"); }
.ic-flag { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 21V4M5 4h11l-2 4.5 2 4.5H5' fill='%23000'/%3E%3C/svg%3E"); width: 15px; height: 15px; vertical-align: -2px; }

/* переключатель-сегменты: период дашборда, «Смотреть / Заполнить» недельных отчётов */
.seg-links { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; }
.seg-links a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; }
.seg-links a:hover { color: var(--text); text-decoration: none; }
.seg-links a.is-active { background: var(--surface); color: var(--text); box-shadow: inset 0 -2px 0 var(--primary), var(--shadow-sm); }

/* --- страница ------------------------------------------------------------- */
.page { max-width: var(--page-max); margin: 0 auto; padding: var(--s5) var(--s6) var(--s7); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-header > div:first-child { flex: 1 1 320px; min-width: 0; }
.page-subtitle { color: var(--muted); margin: var(--s1) 0 0; max-width: 78ch; }
.page-actions { flex: none; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
main > section.card + section.card { margin-top: var(--s4); }
.breadcrumbs { font-size: var(--fs-sm); color: var(--muted); margin: 0 0 var(--s1); }
.breadcrumbs a { color: var(--muted); }
.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.card.narrow { max-width: 560px; margin-top: var(--s6); }
.section { margin-top: var(--s6); }
.section-title { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--s3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.stack > * + * { margin-top: var(--s4); }

/* --- карточки ------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: var(--s5); }
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.card-title { font-size: var(--fs-md); font-weight: 600; }

/* KPI-показатель */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s4); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s4) var(--s5); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-unit { font-size: var(--fs-md); color: var(--muted); font-weight: 500; margin-left: 2px; }
.kpi-delta { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger-strong); }
.kpi-period { font-size: var(--fs-xs); color: var(--muted); margin-top: auto; }
.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid { gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.kpi-grid > .kpi { border: 0; border-radius: 0; box-shadow: none; background: none; box-shadow: -1px 0 0 var(--border), 0 -1px 0 var(--border); }
.kpi-grid > .kpi-accent { background: var(--danger-soft); }
.kpi-grid > .kpi-filter.is-active { box-shadow: inset 0 -3px 0 var(--primary), -1px 0 0 var(--border), 0 -1px 0 var(--border); }
.kpi-grid > a.kpi:hover { background: var(--surface-2); box-shadow: -1px 0 0 var(--border), 0 -1px 0 var(--border); }
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow); }

/* --- таблицы -------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.table th, .table td { padding: 10px var(--s3); text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: var(--s4); }
.table th:last-child, .table td:last-child { padding-right: var(--s4); }
/* шапка: длинный заголовок переносится, а не раздвигает таблицу за край экрана */
.table thead th { background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; line-height: 1.3; vertical-align: bottom; text-wrap: balance; }
.table tbody th { font-weight: 500; color: var(--text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.text-right, .table td.text-right { text-align: right; }
.row-total td { background: var(--surface-2); border-top: 2px solid var(--border-strong); }
.row-muted td { color: var(--faint); }
.row-muted .cell-title { color: var(--muted); }
.cell-title { font-weight: 550; color: var(--text); }
.cell-sub { font-size: var(--fs-xs); color: var(--muted); }
/* сортируемые заголовки: <th class="sortable" aria-sort="ascending|descending"><a href="?sort=...">…</a></th> */
.table th.sortable a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th.sortable a:hover { color: var(--text); text-decoration: none; }
.table th.sortable a::after { content: "↕"; font-size: 11px; opacity: .45; }
.table th[aria-sort="ascending"] a::after { content: "↑"; opacity: 1; color: var(--link); }
.table th[aria-sort="descending"] a::after { content: "↓"; opacity: 1; color: var(--link); }
.table th[aria-sort] { color: var(--text); }
.pagination { display: flex; gap: var(--s2); align-items: center; justify-content: flex-end; padding: var(--s3) var(--s4); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); }

/* --- фильтры ------------------------------------------------------------ */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2) var(--s3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s3) var(--s4); margin-bottom: var(--s4); box-shadow: var(--shadow-sm); }
.filters .field { margin: 0; min-width: 150px; flex: 0 1 190px; }
.filters .field label { font-size: var(--fs-xs); }
.filters-actions { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.filters-hint { margin: 0; white-space: nowrap; }  /* подсказка про начало суток — рядом с кнопками */
.filters .field-presets { flex: 0 0 auto; min-width: 0; }
/* «Ещё фильтры»: редко нужные поля свёрнуты; открыты сами, если в них что-то выбрано (web.reports.panel.filter_panel) */
.filters-more { flex: 1 1 100%; order: 10; }
.filters-more > summary { cursor: pointer; display: inline-block; color: var(--link); font-weight: 600; font-size: var(--fs-sm); padding: 2px 0; }
.filters-more[open] > summary { margin-bottom: var(--s3); }
.filters-more-body { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); }
.filters .filters-actions { order: 9; }
.btn.filters-toggle { display: none; }
.presets-label { display: block; font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
/* быстрый период — сегменты, как на «Сегодня» */
.presets { display: inline-flex; gap: 2px; padding: 3px; height: 36px; background: var(--surface-3); border-radius: 10px; }
.preset { display: inline-flex; align-items: center; padding: 0 12px; border-radius: 8px; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.preset:hover { color: var(--text); text-decoration: none; }
.preset.is-active { background: var(--surface); color: var(--text); box-shadow: inset 0 -2px 0 var(--primary), var(--shadow-sm); }

/* --- бейджи и баллы --------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 18px; white-space: nowrap; border: 1px solid transparent; background: var(--surface-3); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-plain::before { display: none; }
.badge-neutral { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger-strong); border-color: var(--danger-border); }
.badge-demo { background: var(--demo-bg); color: var(--demo-text); border-color: var(--demo-border); }
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 3px 8px; border-radius: var(--r-sm); font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.score-high { background: var(--score-high-bg); color: var(--score-high); }
.score-mid { background: var(--score-mid-bg); color: var(--score-mid); }
.score-low { background: var(--score-low-bg); color: var(--score-low); }
.score-none { background: var(--surface-3); color: var(--muted); }

/* --- кнопки ---------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: 650 var(--fs)/1 var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-strong); color: var(--on-danger); }
.btn-danger:hover { filter: brightness(.92); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-ghost-danger { background: transparent; color: var(--danger-strong); }
.btn-ghost-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
form.inline { display: inline; margin: 0; }

/* --- формы ------------------------------------------------------------------ */
.form { display: flex; flex-direction: column; gap: var(--s4); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.form-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-top: var(--s2); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-weight: 550; font-size: var(--fs-sm); color: var(--text-2); }
.field .req { color: var(--danger-strong); }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea,
.filters input, .filters select, .dash-branch select {
  width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: var(--fs) var(--font); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.field select, .filters select, .dash-branch select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%23667085' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.field select[multiple] { height: auto; min-height: 96px; padding: 6px; background-image: none; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px var(--primary-ring); }
.field-check label { display: flex; align-items: center; gap: var(--s2); font-weight: 500; color: var(--text); cursor: pointer; }
.field-check input { width: 18px; height: 18px; accent-color: var(--link); }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s1) var(--s3); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger-strong); }
.field.has-error input:focus, .field.has-error select:focus { box-shadow: 0 0 0 3px var(--danger-border); }
.field-error { color: var(--danger-strong); font-size: var(--fs-sm); margin: 0; }
.help { color: var(--muted); font-size: var(--fs-xs); margin: 0; }
.help ul { margin: 2px 0 0; padding-left: 16px; }
.help li + li { margin-top: 1px; }
.narrow > .alert, .page > .alert { margin-bottom: var(--s4); }

/* --- плашки ----------------------------------------------------------------- */
.messages { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.alert { padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-size: var(--fs); }
.alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
/* красная плашка-предупреждение: сбой источника, неоценённые, стерео < 100% */
.alert-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.alert-banner { display: flex; align-items: center; gap: var(--s3); border-left: 4px solid var(--danger-strong); font-weight: 500; }
.alert a { color: inherit; text-decoration: underline; }

/* --- пустое состояние ---------------------------------------------------------- */
.empty { text-align: center; padding: var(--s7) var(--s5); display: flex; flex-direction: column; align-items: center; }
.empty-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--primary-soft); display: grid; place-items: center; margin-bottom: var(--s4); }
.empty-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty-icon.danger { background: var(--danger-soft); }
.empty-icon.danger svg { stroke: var(--danger-strong); }
.empty-title { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--s1); }
.empty-text { color: var(--muted); max-width: 420px; margin: 0 auto; }
.empty-actions { display: flex; gap: var(--s2); justify-content: center; margin-top: var(--s4); flex-wrap: wrap; }

/* --- пары «ключ — значение» -------------------------------------------------------- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: var(--s3) var(--s4); margin: var(--s4) 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.copyable { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px 8px; user-select: all; }
.copyable.secret { font-size: var(--fs-md); letter-spacing: .04em; }

/* --- вход ------------------------------------------------------------------ */
.auth-body { background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft) 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, var(--surface-3) 0%, transparent 55%), var(--bg); }
.auth-layout { min-height: 100vh; display: grid; place-items: center; padding: var(--s5) var(--s4); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: var(--s6); }
.auth-brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.auth-title { font-weight: 750; font-size: 20px; letter-spacing: .03em; }
.auth-subtitle { color: var(--muted); font-size: var(--fs-sm); }
.auth-heading { font-size: var(--fs-lg); margin-bottom: var(--s4); }
.auth-card .alert { margin-bottom: var(--s4); }
.auth-card .btn-block { height: 42px; margin-top: var(--s1); }
.auth-note { color: var(--muted); font-size: var(--fs-sm); text-align: center; margin: var(--s5) 0 0; }
.auth-remember { display: flex; align-items: center; gap: var(--s2); margin: 0 0 var(--s3); color: var(--text-2); font-size: var(--fs-sm); cursor: pointer; }
.auth-remember input { width: 16px; height: 16px; accent-color: var(--link); }

/* --- адаптив ------------------------------------------------------------------ */
@media (max-width: 1024px) {
  .page { padding: var(--s5) var(--s4) var(--s7); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* узкий экран: меню — выезжающая панель по кнопке «Меню» (web/static/js/menu.js) */
@media (max-width: 900px) {
  :root { --topbar-h: 52px; }
  .shell { display: block; }
  .mobilebar { display: flex; align-items: center; gap: var(--s3); position: sticky; top: 0; z-index: 30; height: 52px; padding: 0 var(--s4); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: min(280px, 86vw); transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar.open ~ .shell-main::before { content: ""; position: fixed; inset: 0; z-index: 35; background: rgba(20, 14, 8, .45); }
  html:has(.sidebar.open) { overflow: hidden; }
  .menu-toggle { gap: 8px; height: 36px; }
}
@media (max-width: 760px) {
  h1 { font-size: 22px; }
  .page-header { align-items: flex-start; }
  .page-actions { width: 100%; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: var(--s3) var(--s4); }
  .kpi-value { font-size: 22px; }
  .card { padding: var(--s4); border-radius: var(--r); }
  .card-flush { padding: 0; }
  .filters { padding: var(--s3); }
  .filters .field { flex: 1 1 140px; }
  .filters .field-presets { flex: 1 1 100%; order: -2; }  /* быстрый период — первой строкой во всю ширину */
  .filters .presets-label { display: none; }
  .presets { display: flex; }
  .preset { flex: 1; justify-content: center; padding: 0 6px; }
  /* телефон: под периодом — кнопка «Фильтры», поля раскрываются по ней (web/static/js/filters.js) */
  .btn.filters-toggle { display: flex; order: -1; flex: 1 1 100%; justify-content: space-between; }
  .filters[data-fold]:not(.is-open) > :not(.field-presets):not(.filters-toggle) { display: none; }
  .filters-actions { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .filters-hint { flex: 1 1 100%; white-space: normal; }
  .filters-actions .btn { flex: 1; }
  .table th, .table td { padding: 10px var(--s3); }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: var(--s2); }
  .auth-card { padding: var(--s5); }
}
/* слабый канал и слабый шаг вкладки «Каналы» */
.is-weak td, td.is-weak { background: var(--danger-soft); color: var(--danger-strong); }
