/* Панель StroyMir (задача 2.5): вид как у нынешней админки — токены и элементы sm-* из ../site/sm-panel-7jqrx/view/stylesheet/stroymir-admin.css
   (те же значения, что у сайта; меняются вместе). Bootstrap не нужен: шапка, меню, формы, кнопки, таблицы — здесь. Цвета — только var(--…). */
:root {
  color-scheme: light;
  --brand: #006dff; --brand-d: #0057cc; --brand-l: #e8f1ff; --brand-l2: #d6e6ff; --btn: #006dff; --btn-h: #0057cc;
  --text: #1d2433; --muted: #5b6577; --line: #e3e7ee; --soft: #f4f6fa; --bg: #fff;
  --card: #fff; --field: #fff; --hover: #f7f9fc; --img: #fff;
  --ok: #1a7f37; --ok-l: #e9f6ee; --err: #c62828; --err-l: #fdecec; --warn: #b54708; --warn-l: #fff4e5;
  --dark: #151b26; --side: #151b26; --side-2: #0f141d; --side-text: #c4cad6; --side-line: rgba(255, 255, 255, .06);   /* боковая панель тёмная в обеих темах */
  --r: 10px; --shadow: 0 8px 28px rgba(21, 27, 38, .14); --shadow-s: 0 1px 2px rgba(21, 27, 38, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --hdr: 56px; --menu: 260px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #5c9dff; --brand-d: #8ab8ff; --brand-l: rgba(92, 157, 255, .16); --brand-l2: rgba(92, 157, 255, .26); --btn: #2f78ee; --btn-h: #1f66db;
  --text: #e7eaf0; --muted: #9aa4b5; --line: #2b3544; --soft: #121822; --bg: #0e131b;
  --card: #18202b; --field: #121822; --hover: #1e2733; --img: #fff;
  --ok: #3fb96b; --ok-l: rgba(63, 185, 107, .14); --err: #ff6b6b; --err-l: rgba(255, 107, 107, .14); --warn: #f5a623; --warn-l: rgba(245, 166, 35, .14);
  --dark: #0a0e14; --side: #0b1017; --side-2: #080c12; --side-text: #b3bac6;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5); --shadow-s: 0 1px 2px rgba(0, 0, 0, .4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #5c9dff; --brand-d: #8ab8ff; --brand-l: rgba(92, 157, 255, .16); --brand-l2: rgba(92, 157, 255, .26); --btn: #2f78ee; --btn-h: #1f66db;
    --text: #e7eaf0; --muted: #9aa4b5; --line: #2b3544; --soft: #121822; --bg: #0e131b;
    --card: #18202b; --field: #121822; --hover: #1e2733; --img: #fff;
    --ok: #3fb96b; --ok-l: rgba(63, 185, 107, .14); --err: #ff6b6b; --err-l: rgba(255, 107, 107, .14); --warn: #f5a623; --warn-l: rgba(245, 166, 35, .14);
    --dark: #0a0e14; --side: #0b1017; --side-2: #080c12; --side-text: #b3bac6;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5); --shadow-s: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

/* ---------- основа */
* { box-sizing: border-box; }
html, body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--soft); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); } a:hover { color: var(--brand-d); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::selection { background: var(--brand-l); }
code { color: var(--brand-d); background: var(--brand-l); border-radius: 5px; padding: 0 4px; }
h1, h2, h3 { color: var(--text); }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
[hidden] { display: none !important; }
.htmx-request { opacity: .6; transition: opacity .2s; }

/* ---------- шапка (закреплена): меню на телефоне, логотип текстом как на сайте; справа — тема, язык, сайт, сотрудник, выход */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; align-items: center; height: var(--hdr); background: var(--card); border-bottom: 1px solid var(--line); }
.top__brand { display: flex; align-items: center; width: var(--menu); height: 100%; padding: 0 18px; border-right: 1px solid var(--line); text-decoration: none; }
.logo { display: flex; flex-direction: column; line-height: 1.1; }
.logo b { font-size: 21px; font-weight: 800; letter-spacing: -.4px; color: var(--text); } .logo b span { color: var(--brand); }
.logo small { margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.top__tools { display: flex; align-items: center; gap: 6px; margin-left: auto; padding: 0 12px; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; transition: border-color .15s, color .15s; }
.btn-icon:hover, .btn-icon:focus-visible { border-color: var(--brand); color: var(--brand); }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { height: 34px; padding: 0 10px; border: 0; background: var(--card); color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--brand-l); color: var(--brand); }
.who { display: flex; align-items: center; gap: 8px; padding-left: 6px; color: var(--text); font-weight: 600; }
.who form { margin: 0; }
.menu-toggle { display: none; }

/* ---------- левое меню (тёмное в обеих темах, закреплено, своя прокрутка); на телефоне выезжает по кнопке */
.side { position: fixed; top: var(--hdr); bottom: 0; left: 0; z-index: 20; display: flex; flex-direction: column; width: var(--menu); padding: 10px 0 0; overflow-y: auto; overscroll-behavior: contain; background: var(--side); }
.side__title { padding: 8px 18px; color: #8b95a7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.side a.item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--side-text); text-decoration: none; border-left: 3px solid transparent; }
.side a.item .ic { color: #8b95a7; }
.side a.item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.side a.item[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .04); border-left-color: var(--brand); }
.side a.item[aria-current="page"] .ic { color: var(--brand); }
.side__site { margin-top: auto; padding: 12px 14px 16px; border-top: 1px solid var(--side-line); }
.side__site a { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 12px; border-radius: 8px; background: var(--btn); color: #fff; font-weight: 600; text-decoration: none; }
.side__site a:hover { background: var(--btn-h); color: #fff; }

/* ---------- страница */
main { min-height: 100vh; padding: calc(var(--hdr) + 18px) 24px 32px calc(var(--menu) + 24px); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; }
.crumbs { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.crumbs li + li::before { content: "\203A"; padding-right: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--brand); }
.page-head__actions { display: flex; gap: 6px; margin-left: auto; }

/* ---------- кнопки, поля, таблицы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 14px; border: 1px solid var(--btn); border-radius: 8px; background: var(--btn); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--btn-h); border-color: var(--btn-h); color: #fff; }
.btn--ghost { background: var(--card); border-color: var(--line); color: var(--text); } .btn--ghost:hover { background: var(--hover); border-color: var(--brand); color: var(--brand); }
.btn--danger { background: var(--err); border-color: var(--err); } .btn--danger:hover { filter: brightness(.92); background: var(--err); border-color: var(--err); }
.btn--sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.field small { font-weight: 400; }
input:not([type=checkbox], [type=radio]), select, textarea { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); font: inherit; font-weight: 400; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; }
table.sm-table { width: 100%; border-collapse: collapse; }
.sm-table th, .sm-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.sm-table th { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sm-table tbody tr:hover td { background: var(--hover); }
.table-wrap { overflow-x: auto; }
.alert { margin: 0 0 12px; padding: 9px 12px; border-radius: 8px; background: var(--err-l); color: var(--err); }

/* ================= Готовые элементы для экранов (sm-*) — макросы templates/panel/ui.twig, образец — «Елементи панелі» (/ui) */
/* карточка: .sm-card > .sm-card__head (заголовок h3, справа .sm-card__actions) + .sm-card__body; .sm-card--flat — без тени */
.sm-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-s); margin-bottom: 18px; }
.sm-card--flat { box-shadow: none; }
.sm-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sm-card__head h3, .sm-card__title { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.sm-card__head h3 .ic { color: var(--brand); margin-right: 6px; }
.sm-card__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.sm-card__body { padding: 16px; }
.sm-card__foot { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--soft); border-radius: 0 0 var(--r) var(--r); }
/* сетка: .sm-grid (авто, от 220 px), .sm-grid--2 / --3 / --4 — колонки; на телефоне — одна */
.sm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.sm-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sm-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sm-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 991px) { .sm-grid--3, .sm-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 599px) { .sm-grid--2, .sm-grid--3, .sm-grid--4 { grid-template-columns: 1fr; } }
/* показатель: .sm-stat > .sm-stat__label, .sm-stat__value, .sm-stat__delta (.is-up / .is-down) */
.sm-stat { padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.sm-stat__label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sm-stat__value { margin-top: 2px; font-size: 26px; font-weight: 700; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; }
.sm-stat__delta { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.sm-stat__delta.is-up { color: var(--ok); }
.sm-stat__delta.is-down { color: var(--err); }
/* статус: .sm-badge + --ok / --warn / --err / --info / --muted */
.sm-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.sm-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sm-badge--ok { background: var(--ok-l); color: var(--ok); border-color: transparent; }
.sm-badge--warn { background: var(--warn-l); color: var(--warn); border-color: transparent; }
.sm-badge--err { background: var(--err-l); color: var(--err); border-color: transparent; }
.sm-badge--info { background: var(--brand-l); color: var(--brand); border-color: transparent; }
.sm-badge--plain::before { display: none; }
/* пояснение: .sm-note (+ --ok / --warn / --err) — блок с полосой слева */
.sm-note { margin: 0 0 14px; padding: 10px 14px; border-left: 4px solid var(--brand); border-radius: 8px; background: var(--brand-l); color: var(--text); font-size: 13.5px; }
.sm-note--ok { border-color: var(--ok); background: var(--ok-l); }
.sm-note--warn { border-color: var(--warn); background: var(--warn-l); }
.sm-note--err { border-color: var(--err); background: var(--err-l); }
/* пусто: .sm-empty > .sm-empty__icon (svg или .fa), .sm-empty__title, p, кнопка */
.sm-empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.sm-empty__icon { color: var(--muted); margin-bottom: 8px; } .sm-empty__icon .ic { width: 34px; height: 34px; }
.sm-empty__title { margin-bottom: 4px; font-size: 15px; font-weight: 600; color: var(--text); }
.sm-empty p { margin: 0 0 12px; }
/* «метка — значение»: dl.sm-kv > dt + dd */
.sm-kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 16px; margin: 0; }
.sm-kv dt { color: var(--muted); font-weight: 500; }
.sm-kv dd { margin: 0; color: var(--text); }
/* панель фильтров и действий над таблицей: .sm-toolbar (поля и кнопки в ряд, переносятся) */
.sm-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.sm-toolbar__end { margin-left: auto; display: flex; gap: 6px; }
/* таблица модуля: .table.sm-table — без внешней рамки, числа — по правому краю (.sm-num) */
.sm-num, td.sm-num, th.sm-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* мелкое: .sm-muted, .sm-mono, .sm-nowrap, .sm-gap (отступ между элементами в ряд) */
.sm-muted { color: var(--muted); }
.sm-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.sm-nowrap { white-space: nowrap; }
.sm-gap { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* скелет загрузки: .sm-skel (мигает), высота — своя */
.sm-skel { border-radius: 8px; background: var(--soft); animation: sm-adm-blink 1.2s ease-in-out infinite; min-height: 14px; }
@keyframes sm-adm-blink { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .sm-skel { animation: none; } }


/* ---------- страницы без каркаса: вход, ошибка, заглушка витрины */
body.plain { display: block; }
.error { max-width: 560px; margin: 15vh auto; padding: 0 16px; text-align: center; } .error h1 { font-size: 48px; margin: 0 0 8px; } .error h1 b { color: var(--brand); }
.login { max-width: 380px; margin: 12vh auto; padding: 0 16px; } .login .logo { align-items: center; margin-bottom: 18px; }
.login form { padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-s); }
.login .btn { width: 100%; margin-top: 4px; }

/* ---------- окно помощника: плавающее, как консультант сайта (перетащить за заголовок, растянуть за уголок, свернуть в кнопку); на телефоне — во весь экран */
.as-fab { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border: 0; border-radius: 999px; background: var(--btn); color: #fff; font: inherit; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }
.as-fab:hover { background: var(--btn-h); }
.as { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; width: min(400px, calc(100vw - 32px)); height: min(560px, calc(100vh - var(--hdr) - 32px));
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.as.is-drag { user-select: none; opacity: .96; }
.as__head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; background: var(--btn); color: #fff; cursor: move; touch-action: none; user-select: none; }
.as__head h2 { flex: 1; margin: 0; color: #fff; font-size: 15px; }
.as__head button { display: inline-flex; padding: 4px; border: 0; border-radius: 6px; background: transparent; color: #fff; cursor: pointer; }
.as__head button:hover { background: rgba(255, 255, 255, .16); }
.as__msgs { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 12px; overflow-y: auto; }
.msg { max-width: 92%; padding: 8px 10px; border-radius: var(--r); } .msg.me { align-self: flex-end; background: var(--brand-l); } .msg.bot { background: var(--soft); }
.as form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.as textarea { resize: none; min-height: 40px; }
.as__grip { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, var(--line) 50%, var(--line) 60%, transparent 60%, transparent 70%, var(--line) 70%, var(--line) 80%, transparent 80%); }

/* ---------- телефон и планшет */
@media (max-width: 767px) {
  .top__brand { width: auto; border: 0; padding: 0 10px; }
  .menu-toggle { display: inline-flex; margin-left: 8px; }
  .top__tools { gap: 4px; padding: 0 8px; }
  .top__tools .btn-icon span, .who__name { display: none; }
  .side { left: calc(-1 * var(--menu)); transition: left .2s; box-shadow: none; }
  body.menu-open .side { left: 0; box-shadow: var(--shadow); }
  main { padding: calc(var(--hdr) + 14px) 14px 90px; }
  .page-head h1 { font-size: 19px; }
  .as { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; border: 0; }
  .as__grip { display: none; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

h2 { margin: 22px 0 10px; font-size: 16px; }
.sm-card__head h3 { display: flex; align-items: center; }
