/* Ореховый двор — рабочий инструмент селлера. Один акцент, плотные таблицы, строгая сетка. */
@font-face { font-family: "Golos Text"; font-weight: 400; font-display: swap; src: url("../fonts/golos-text-400-cyrillic.2b8fbbb33a14.woff2") format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 400; font-display: swap; src: url("../fonts/golos-text-400-latin.f57df9832ab8.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Golos Text"; font-weight: 500; font-display: swap; src: url("../fonts/golos-text-500-cyrillic.2b8fbbb33a14.woff2") format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 500; font-display: swap; src: url("../fonts/golos-text-500-latin.f57df9832ab8.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Golos Text"; font-weight: 600; font-display: swap; src: url("../fonts/golos-text-600-cyrillic.2b8fbbb33a14.woff2") format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 600; font-display: swap; src: url("../fonts/golos-text-600-latin.f57df9832ab8.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }

:root {
  --bg: #f4f3f0; --surface: #ffffff; --surface-2: #faf9f7; --line: #e3e0da; --line-strong: #c9c5bd;
  --text: #1c1a17; --text-2: #5b574f; --text-3: #8a857b;
  --accent: #9a5b2b; --accent-hover: #83491f; --accent-soft: #f5ebe1; --accent-text: #7a4420;
  --ok: #1e7f4f; --ok-soft: #e3f3ea; --warn: #b26a00; --warn-soft: #fbefd7; --bad: #b42323; --bad-soft: #fbe5e5; --info: #2a5ea8; --info-soft: #e5edf9;
  --wb: #7b2fbe; --ozon: #005bff;
  --radius: 6px; --shadow: 0 1px 2px rgba(0,0,0,.06);
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar: 228px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a; --surface: #1e2026; --surface-2: #23252c; --line: #2f323a; --line-strong: #454953;
    --text: #ebe9e4; --text-2: #aeaba3; --text-3: #7b786f;
    --accent: #d08a4e; --accent-hover: #e09a5e; --accent-soft: #33271c; --accent-text: #e6a86f;
    --ok: #4cc080; --ok-soft: #173327; --warn: #e2a33a; --warn-soft: #3a2d12; --bad: #ef6b6b; --bad-soft: #3b1d1d; --info: #6c9ee8; --info-soft: #1b2a40;
    --wb: #b07be0; --ozon: #5e93ff; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15161a; --surface: #1e2026; --surface-2: #23252c; --line: #2f323a; --line-strong: #454953;
  --text: #ebe9e4; --text-2: #aeaba3; --text-3: #7b786f;
  --accent: #d08a4e; --accent-hover: #e09a5e; --accent-soft: #33271c; --accent-text: #e6a86f;
  --ok: #4cc080; --ok-soft: #173327; --warn: #e2a33a; --warn-soft: #3a2d12; --bad: #ef6b6b; --bad-soft: #3b1d1d; --info: #6c9ee8; --info-soft: #1b2a40;
  --wb: #b07be0; --ozon: #5e93ff; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); font-feature-settings: "tnum" 1; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.ic { vertical-align: -3px; flex: none; }
.muted { color: var(--text-2); } .dim { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.hidden { display: none !important; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---- каркас */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 14px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.brand-name { font-weight: 600; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--text-3); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 12px 8px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.is-active { background: var(--accent-soft); color: var(--accent-text); }
.nav a .ic { color: var(--text-3); } .nav a.is-active .ic { color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
.content { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--text-2); margin-top: 2px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* одна плашка демо: 28 px, одна строка; кнопки внутри имеют зону 44 px за счёт отрицательных полей */
.demo-bar { background: var(--accent-soft); color: var(--accent-text); border-bottom: 1px solid var(--line); font-size: 12.5px; height: 28px; padding: 0 24px; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.demo-bar .db-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.demo-bar .db-btn { flex: none; min-height: 44px; min-width: 44px; margin: -8px 0; padding: 0 8px; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; display: inline-flex; align-items: center; justify-content: center; }
.demo-bar .db-x { text-decoration: none; margin-left: auto; font-size: 16px; }
.demo-bar.is-hidden { display: none; }
.site-foot { padding: 16px 24px 24px; color: var(--text-3); font-size: 12.5px; }
.site-foot a { display: inline-flex; align-items: center; min-height: 44px; }
/* «что потыкать» — три шага после входа */
.steps { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; margin-bottom: 14px; padding: 2px 4px 2px 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--surface); font-size: 13px; }
.steps .steps-l { color: var(--text-2); }
.steps ol { display: flex; flex-wrap: wrap; gap: 0 4px; margin: 0; padding: 0; list-style: none; counter-reset: st; flex: 1; }
.steps li { counter-increment: st; display: flex; align-items: center; }
.steps li + li::before { content: "→"; color: var(--text-3); margin: 0 4px; }
.steps a { display: inline-flex; align-items: center; min-height: 36px; font-weight: 500; }
.steps a::before { content: counter(st) ". "; color: var(--text-3); margin-right: 3px; }
.steps a.is-active { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.steps .icon-btn { border: 0; background: none; }
/* «Сменить роль» в боковом меню */
.who { display: flex; align-items: center; gap: 8px; padding: 8px; margin: 0 0 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); font-size: 12.5px; }
.who > div { flex: 1; min-width: 0; line-height: 1.25; }
.who { flex-wrap: wrap; }
.who form { flex-basis: 100%; }
.who form .btn { width: 100%; justify-content: center; }
.who b { display: block; font-weight: 600; font-size: 13px; color: var(--text); }
.who span { color: var(--text-3); }
.role-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; background: var(--surface-2); color: var(--text-2); }
.role-chip b { color: var(--text); font-weight: 500; }

/* ---- кнопки */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; line-height: 1.2; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 8px; font-size: 12.5px; }
.btn.lg { padding: 12px 18px; font-size: 15px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* ---- карточки и сетка */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.card-body { padding: 16px; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-aside { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid > * { min-width: 0; }

/* ---- показатели */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi { background: var(--surface); padding: 12px 16px; }
.kpi .label { font-size: 12px; color: var(--text-2); }
.kpi .value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.kpi .delta { font-size: 12px; margin-top: 2px; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }

/* ---- таблицы */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th, .t td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.t th { font-size: 11.5px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
.t th a { color: inherit; display: inline-flex; align-items: center; gap: 3px; }
.t th a.sorted { color: var(--text); }
.t td.num, .t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.t tr:hover td { background: var(--surface-2); }
.t tr.total td { font-weight: 600; background: var(--surface-2); border-top: 2px solid var(--line-strong); }
.t tr.dim td { color: var(--text-3); }
.t .name { font-weight: 500; }
.t .sub { color: var(--text-3); font-size: 12px; }
.t.dense th, .t.dense td { padding: 5px 8px; }
.t td .ic { color: var(--text-3); }
.card > .table-wrap .t tr:last-child td { border-bottom: 0; }

/* ---- статусы */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.mp { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; font-size: 12.5px; }
.mp::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--text-3); }
.mp.wb::before { background: var(--wb); } .mp.ozon::before { background: var(--ozon); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.muted { background: var(--text-3); }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }

/* ---- формы */
.form { display: grid; gap: 12px; }
.form.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field .help { font-size: 12px; color: var(--text-3); }
.field .err { font-size: 12px; color: var(--bad); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 7px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input.lg { font-size: 18px; padding: 12px 14px; }
input[type="checkbox"] { width: auto; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { min-width: 120px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters .search { position: relative; min-width: 220px; }
.filters .search .ic { position: absolute; left: 9px; top: 9px; color: var(--text-3); }
.filters .search input { padding-left: 30px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg a, .seg button { padding: 6px 11px; font-size: 12.5px; font-weight: 500; color: var(--text-2); background: var(--surface); border: 0; border-right: 1px solid var(--line); cursor: pointer; font-family: inherit; }
.seg a:last-child, .seg button:last-child { border-right: 0; }
.seg a:hover { text-decoration: none; background: var(--surface-2); }
.seg .is-active { background: var(--accent-soft); color: var(--accent-text); }

/* ---- сообщения */
.msgs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.msg.success { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.msg.error { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.msg.warning { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.msg.info { border-color: var(--info); background: var(--info-soft); color: var(--info); }
.note { font-size: 12.5px; color: var(--text-2); padding: 10px 12px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty { padding: 28px 16px; text-align: center; color: var(--text-3); }

/* ---- нижний лист (О демо; фильтры на телефоне) */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; max-width: 560px; margin: 0 auto; max-height: 82vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px 12px 0 0; padding: 4px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(105%); visibility: hidden; transition: transform .2s, visibility .2s; }
.sheet.open { transform: none; visibility: visible; }
.sheet-bg { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.4); display: none; }
.sheet-bg.open { display: block; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 4px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.sheet-head b { flex: 1; font-size: 15px; }
.sheet-head .icon-btn { border: 0; background: none; }
.sheet-foot { display: flex; gap: 8px; padding-top: 14px; margin-top: 4px; }
.sheet-foot .btn { flex: 1; justify-content: center; min-height: 44px; }
.sheet p { font-size: 13.5px; }
.sheet .links { display: flex; flex-direction: column; }
.sheet .links a { display: flex; align-items: center; gap: 8px; min-height: 44px; border-top: 1px solid var(--line); font-weight: 500; }
.fsheet { display: contents; }
.fs-sort { width: auto; }
.fs-l { display: none; }

/* ---- вход */
.login-page { min-height: 100vh; display: flex; flex-direction: column; }
.login { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 760px; }
.login-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.login-brand .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.login-brand .brand-name span { font-weight: 400; color: var(--text-3); font-size: 13px; }
.login-box h1 { font-size: 24px; margin: 14px 0 4px; }
.login-box .lead { color: var(--text-2); margin: 0; }
.roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.roles form:first-child { grid-column: 1 / -1; }
.role-card { width: 100%; min-height: 64px; text-align: left; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; font: inherit; color: var(--text); display: flex; gap: 12px; align-items: center; }
.role-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.role-card.first { border-color: var(--accent); border-width: 2px; }
.role-card .ic { color: var(--accent); flex: none; }
.role-card .rc-t { flex: 1; min-width: 0; }
.role-card b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-card b small { font-weight: 400; color: var(--text-2); font-size: 13px; }
.role-card span { color: var(--text-2); font-size: 13px; display: block; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-card .start { flex: none; font-size: 12px; font-weight: 600; color: #fff; background: var(--accent); border-radius: 4px; padding: 2px 8px; margin: 0; }
.role-card .go { color: var(--text-3); }
.login-more details { border-top: 1px solid var(--line); }
.login-more details:last-child { border-bottom: 1px solid var(--line); }
.login-more summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 500; list-style: none; }
.login-more summary::-webkit-details-marker { display: none; }
.login-more summary::after { content: "+"; margin-left: auto; color: var(--text-3); font-size: 18px; }
.login-more details[open] summary::after { content: "−"; }
.login-more .in { padding: 0 0 12px; font-size: 13.5px; color: var(--text-2); }
.login-more ul { margin: 0; padding-left: 18px; }

/* ---- сканер */
.scan-box { display: grid; gap: 12px; }
#reader { width: 100%; max-width: 420px; border-radius: var(--radius); overflow: hidden; background: #000; min-height: 240px; }
.scan-hit { border-left: 3px solid var(--accent); padding: 10px 14px; background: var(--surface-2); }
.big-input { font-size: 20px; letter-spacing: .04em; font-family: var(--mono); }
.qty-row { display: flex; gap: 8px; align-items: center; }
.qty-row input { font-size: 20px; text-align: center; max-width: 140px; }
.qty-row .btn { width: 44px; height: 44px; justify-content: center; font-size: 18px; }

/* ---- штрихкод */
.ean { display: inline-block; background: #fff; padding: 6px 8px 2px; border: 1px solid var(--line); border-radius: 4px; color: #000; text-align: center; }
.ean svg { display: block; }
.ean .code { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; margin-top: 2px; }

/* ---- ИИ-помощник */
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; }
.answer { border-left: 3px solid var(--accent); padding: 12px 16px; background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; }
.answer .meta { font-size: 12px; color: var(--text-3); margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12.5px; cursor: pointer; color: var(--text-2); font-family: inherit; }
.chip:hover { border-color: var(--accent); color: var(--accent-text); }
.htmx-indicator { display: none; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- графики */
.chart { position: relative; height: 260px; }
.chart.sm { height: 180px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---- мобильный */
.mobile-nav, .drawer-toggle { display: none; }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; height: 100vh; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .drawer-toggle { display: inline-grid; }
  .topbar { padding: 8px 12px; }
  .content { padding: 14px 12px 84px; }
  .demo-bar { padding: 6px 12px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.main-aside { grid-template-columns: minmax(0, 1fr); }
  .ask { flex-wrap: wrap; } .ask input { min-width: 0; flex: 1 1 200px; }
  .form.cols-2, .form.cols-3 { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .roles { grid-template-columns: minmax(0, 1fr); }
  .kpi .value { font-size: 19px; }
  .mobile-nav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; font-size: 10.5px; color: var(--text-2); }
  .mobile-nav a.is-active { color: var(--accent); }
  .mobile-nav a:hover { text-decoration: none; }
  .hide-m { display: none !important; }
  .t th, .t td { padding: 7px 8px; }
  .btn.m-block { width: 100%; justify-content: center; }
}
@media (min-width: 961px) { .hide-d { display: none !important; } }

/* ---- телефон < 640: глобальные правила, карточки вместо широких таблиц, фильтры в нижнем листе */
@media (min-width: 640px) { .m-only { display: none !important; } }
@media (max-width: 639px) {
  .d-only { display: none !important; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; min-height: 44px; }
  input.lg, .big-input { font-size: 18px; }
  .btn, .btn.sm { min-height: 44px; min-width: 44px; justify-content: center; }
  .btn.sm { padding: 6px 10px; font-size: 13px; }
  .icon-btn { width: 44px; height: 44px; }
  .seg a, .seg button, .chip { min-height: 44px; display: inline-flex; align-items: center; }
  .chip { font-size: 13px; }
  .nav a { min-height: 44px; }
  .mobile-nav a { font-size: 11px; }
  .card-head > a, .card-head > .small, .delta a, td > a, td > .name, .t td a:not(.btn) { display: inline-flex; align-items: center; flex-wrap: wrap; column-gap: 5px; min-height: 44px; min-width: 44px; }
  .sub a, p a { min-height: 0; }
  label.ck { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin: -6px; }
  label.ck-l { min-height: 44px; }
  input[type=checkbox] { width: 20px; height: 20px; }
  .help input { display: block; width: 100% !important; margin-top: 4px; }

  .topbar { gap: 4px; padding: 4px 8px; }
  .topbar .brand-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; padding-left: 2px; }
  .topbar .spacer, .topbar .role-chip { display: none; }
  .topbar .icon-btn { border-color: transparent; background: none; }
  .demo-bar { padding: 0 4px 0 12px; font-size: 12px; }
  .login { place-items: start center; padding: 14px 16px 24px; }
  .login-box h1 { font-size: 20px; margin-top: 12px; }
  .login-brand .brand-name span { display: none; }
  .role-card b, .role-card span { white-space: normal; }
  .role-card .start { font-size: 11px; padding: 2px 6px; }
  .roles { margin: 14px 0; }
  .db-long { display: none; }
  .content { padding: 12px 12px 84px; }
  .page-head { gap: 10px; margin-bottom: 12px; }
  .page-head h1 { font-size: 19px; }
  .steps { padding: 0 0 0 4px; font-size: 12.5px; flex-wrap: nowrap; gap: 0; }
  .steps .steps-l { display: none; }
  .steps ol { display: grid; grid-template-columns: 1fr 1.35fr 1fr; gap: 0; }
  .steps li + li::before { display: none; }
  .steps li + li { border-left: 1px solid var(--line); }
  .steps a { min-height: 44px; padding: 2px 6px; line-height: 1.2; width: 100%; }
  .site-foot { padding: 8px 12px 96px; }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { padding: 10px 12px; }
  .card-head { padding: 10px 12px; }
  .card-head .legend { flex-basis: 100%; order: 2; }
  .chart { height: 220px; }

  /* фильтры: поиск остаётся, остальное — в нижний лист «Фильтры (N)» */
  .filters { gap: 8px; }
  .filters .search { flex: 1 1 160px; min-width: 0; }
  .filters .search .ic { top: 14px; }
  .filters > .small, .filters > span.muted { flex-basis: 100%; }
  .fbtn { flex: none; }
  .fsheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; max-height: 82vh; overflow-y: auto; background: var(--surface); border-radius: 12px 12px 0 0; border: 1px solid var(--line); padding: 4px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(105%); visibility: hidden; transition: transform .2s, visibility .2s; }
  .fsheet.open { transform: none; visibility: visible; }
  .fsheet > * + * { margin-top: 12px; }
  .fsheet .seg { display: flex; flex-wrap: wrap; gap: 6px; border: 0; overflow: visible; }
  .fsheet .seg a, .fsheet .seg button { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 12px; font-size: 14px; }
  .fsheet .fs-l { display: block; font-size: 12.5px; color: var(--text-2); margin: 12px 0 4px; font-weight: 500; }
  .fsheet select, .fsheet input { width: 100% !important; }
  .fsheet .small.muted { display: none; }

  /* таблица → карточки: заголовок, 3 ключевых числа, остальное по «ещё» */
  .t.mc thead { display: none; }
  .t.mc, .t.mc > tbody { display: block; width: 100%; }
  .t.mc tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); position: relative; }
  .card > .table-wrap .t.mc tr:last-child { border-bottom: 0; }
  .t.mc td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; background: none !important; }
  .t.mc td.num { text-align: left; }
  .t.mc td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--text-3); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .t.mc .mk { order: -2; grid-column: 1 / -1; font-size: 12px; color: var(--text-3); margin-bottom: -6px; }
  .t.mc .mt { order: -1; grid-column: 1 / -1; font-size: 14.5px; }
  .t.mc .mt > a.name, .t.mc .mt > a:first-child { min-height: 44px; }
  .t.mc .mf, .t.mc td.empty { grid-column: 1 / -1; }
  .t.mc .mx, .t.mc .mh { display: none; }
  .t.mc tr.open .mx { display: block; order: 5; }
  .t.mc td.nowrap { white-space: normal; }
  .t.mc .ma { order: 10; grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin: 0 -4px -6px; }
  .t.mc .ma [data-more] { margin-right: auto; color: var(--accent-text); }
  .t.mc .ma form { display: contents; }
  .t.mc tr.total { background: var(--surface-2); border-top: 2px solid var(--line-strong); }
  .t.mc tr.total td { border: 0; }
  .t.mc .mpick { position: absolute; right: 8px; top: 8px; }
  .t.mc tr:has(.mpick) .mt { padding-right: 44px; }
  .t.mc td input { width: 100% !important; text-align: left !important; }
  /* остальные таблицы — не больше 4 колонок (.mh), первая колонка липкая */
  .t .mh { display: none; }
  .table-wrap > .t:not(.mc) tr > td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
  .t:not(.mc) .nowrap-m { white-space: nowrap; }
}
@media print { .sidebar, .topbar, .demo-bar, .mobile-nav, .actions, .filters { display: none !important; } .app { display: block; } .content { padding: 0; } }
