/* Пульс — дашборд собственника. Один акцент (патина), семантика отдельно, Onest локально, плотные таблицы. */
@font-face { font-family: "Onest"; font-weight: 400 600; font-display: swap; src: url("../fonts/onest-400-cyrillic.fe2bd26ae82a.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 400 600; font-display: swap; src: url("../fonts/onest-400-latin.3db826ed1c5d.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface-2: #f0efea; --surface-3: #e8e6e0;
  --border: #e1dfd8; --border-strong: #c8c5bc;
  --text: #1a1c1b; --text-2: #474c49; --muted: #6c716e;
  --accent: #17696b; --accent-hover: #11585a; --accent-soft: #e2efee; --accent-text: #ffffff; --accent-dim: #9cc4c3;
  --ok: #2b7340; --ok-soft: #e3f1e6; --warn: #9a5800; --warn-soft: #fbefdc; --danger: #b3372f; --danger-soft: #f9e4e2;
  --info: #2e5d99; --info-soft: #e5edf8;
  --pos: #17696b; --neg: #b8573f;
  --shadow: 0 1px 2px rgba(40, 36, 28, .06);
  --radius: 6px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111312; --surface: #181b1a; --surface-2: #1f2321; --surface-3: #282d2b;
  --border: #2a2f2d; --border-strong: #3c4340;
  --text: #e5e8e6; --text-2: #b4bab6; --muted: #8a918d;
  --accent: #4fb0a5; --accent-hover: #67c0b6; --accent-soft: #17302e; --accent-text: #0b1312; --accent-dim: #2b5c58;
  --ok: #5fc07a; --ok-soft: #15301d; --warn: #e0a640; --warn-soft: #33270f; --danger: #ec7a70; --danger-soft: #3a1a18;
  --info: #79a6e6; --info-soft: #182841;
  --pos: #4fb0a5; --neg: #e08568;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111312; --surface: #181b1a; --surface-2: #1f2321; --surface-3: #282d2b;
    --border: #2a2f2d; --border-strong: #3c4340;
    --text: #e5e8e6; --text-2: #b4bab6; --muted: #8a918d;
    --accent: #4fb0a5; --accent-hover: #67c0b6; --accent-soft: #17302e; --accent-text: #0b1312; --accent-dim: #2b5c58;
    --ok: #5fc07a; --ok-soft: #15301d; --warn: #e0a640; --warn-soft: #33270f; --danger: #ec7a70; --danger-soft: #3a1a18;
    --info: #79a6e6; --info-soft: #182841;
    --pos: #4fb0a5; --neg: #e08568;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    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); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { vertical-align: -3px; flex: none; }
.muted { color: var(--muted); }
.t2 { color: var(--text-2); }
.small { font-size: 12px; }
.mono, .num, td.r, th.r { font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 16px; } .mt8 { margin-top: 8px; } .mb { margin-bottom: 12px; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.strong { font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- плашка демо: одна строка 28 px, «О демо» → нижний лист, на телефоне крестик --- */
.demo-bar { background: #20231f; color: #d5d8d3; font-size: 12px; height: 28px; padding: 0 16px; display: flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.demo-bar .db-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.demo-bar .db-btn { flex: none; height: 28px; min-width: 44px; padding: 0 8px; border: 0; background: none; color: #fff; font: inherit; font-weight: 500; 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; }
.demo-bar.is-hidden { display: none; }
.site-foot { max-width: 1240px; margin: 28px auto 0; padding: 14px 0 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.login + .site-foot, body > .site-foot { max-width: 960px; padding: 14px 16px 24px; }

/* --- нижние листы --- */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 170; max-width: 560px; margin: 0 auto; max-height: 82vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); 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; box-shadow: 0 -8px 24px rgba(0, 0, 0, .12); }
.sheet.open, .fsheet.open { transform: none; visibility: visible; }
.sheet-bg { position: fixed; inset: 0; z-index: 165; 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(--border); margin-bottom: 12px; }
.sheet-head b { flex: 1; font-size: 15px; }
.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(--border); font-weight: 500; }

/* --- полоска «что потыкать» --- */
.steps { display: flex; align-items: center; gap: 4px 6px; margin-bottom: 14px; padding: 0 2px 0 12px; border: 1px solid var(--border); 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; 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(--muted); margin: 0 6px; }
.steps a { display: inline-flex; align-items: center; min-height: 36px; font-weight: 500; }
.steps a::before { content: counter(st) ". "; color: var(--muted); margin-right: 3px; }
.steps a.on { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.steps.gone { display: none; }

/* --- сводка: порядок блоков (на телефоне — цифры первыми) --- */
.dash { display: flex; flex-direction: column; }
.dash > * { min-width: 0; }
.alert-line { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px; margin-bottom: 12px; border-radius: 8px; background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border)); color: var(--text); font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.alert-line .ic { color: var(--danger); }
.alert-line span { flex: 1; }
.alert-line b { color: var(--danger); white-space: nowrap; font-size: 13px; }
.alert-line:hover { text-decoration: none; }

/* --- каркас --- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - 28px); }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px 20px; position: sticky; top: 0; height: calc(100vh - 28px); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; }
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; line-height: 1.2; }
.nav-sec { font-size: 11px; color: var(--muted); padding: 12px 10px 4px; font-weight: 500; }
.nav a { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: var(--radius); color: var(--text-2); font-weight: 500; line-height: 20px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { margin-left: auto; font-size: 11px; color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 0 5px; line-height: 18px; }
.side-foot { margin-top: 16px; padding: 12px 10px 0; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.me { display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; }
.me .name { font-weight: 500; font-size: 13px; line-height: 1.15; }
.me .role { font-size: 11px; color: var(--muted); line-height: 1.15; }
.side-foot form { margin: 0; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--text-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.linkbtn:hover { color: var(--accent); }

.topbar { display: none; }
.main { min-width: 0; padding: 20px 28px 48px; }
.container { max-width: 1240px; margin: 0 auto; }

/* --- заголовок страницы --- */
.page-head { display: flex; gap: 12px 20px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .sub { color: var(--muted); margin-top: 3px; font-size: 13px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- кнопки и поля --- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap; font-size: 13px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.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(--danger); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.input, select.input, textarea.input { height: 32px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); min-width: 0; font-size: 13px; }
textarea.input { height: auto; padding: 8px 9px; }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }

/* --- фильтр периода --- */
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; flex-wrap: wrap; }
.seg a { padding: 4px 10px; border-radius: 4px; color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg a:hover { color: var(--text); text-decoration: none; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.range { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; max-width: 100%; }
.range select, .filters select { max-width: 100%; }
.range select { height: 30px; }
.period-note { font-size: 12px; color: var(--muted); }

/* --- панели --- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); min-width: 0; }
.panel-h { display: flex; align-items: center; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-h h2 { display: flex; gap: 8px; align-items: center; }
.panel-h .hint { color: var(--muted); font-size: 12px; }
.panel-h .actions { margin-left: auto; }
.panel-b { padding: 14px 16px; }
.panel-b.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.g73 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.g82 { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); }

/* --- показатели --- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 16px; box-shadow: var(--shadow); }
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.k6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi { padding: 14px 16px; border-right: 1px solid var(--border); min-width: 0; color: inherit; }
a.kpi:hover { background: var(--surface-2); text-decoration: none; }
.kpi:last-child { border-right: 0; }
.kpi .lbl { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.kpi .val { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .val.big { font-size: 26px; }
.kpis.k6 .val.big { font-size: 22px; }
.kpi .cmp { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .cmp b { font-weight: 600; }

/* --- таблицы --- */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.t th, .t td { padding: 0 12px; height: 37px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
.t th { font-weight: 500; color: var(--muted); font-size: 12px; background: var(--surface-2); position: sticky; top: 0; z-index: 1; height: 34px; }
.t th a { color: var(--muted); }
.t th a.on { color: var(--text); }
.t th.r, .t td.r { text-align: right; }
.t td.wrap, .t th.wrap { white-space: normal; min-width: 220px; line-height: 1.35; padding-top: 6px; padding-bottom: 6px; }
.t tbody tr:hover td { background: var(--surface-2); }
.t tr.sum td { font-weight: 600; background: var(--surface-2); }
.t tr.sec td { font-weight: 600; background: var(--surface); color: var(--text); }
.t tr.sub td:first-child { padding-left: 26px; }
.t tr.hl td { background: var(--warn-soft) !important; }
.t tr.neg-row td { background: var(--danger-soft); }
.t td.first, .t th.first { position: sticky; left: 0; background: var(--surface); z-index: 2; }
.t th.first { background: var(--surface-2); z-index: 3; }
.t tr.sum td.first, .t tr:hover td.first { background: var(--surface-2); }
.t tfoot td { font-weight: 600; background: var(--surface-2); border-bottom: 0; }
.t a.cell { color: inherit; display: block; }
.t a.cell:hover { color: var(--accent); }
.t .src { font-size: 12px; color: var(--muted); }
.t .src a { color: var(--muted); }
.t .src a:hover { color: var(--accent); }
.dds .t td.r { min-width: 104px; }

/* --- метки --- */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 20px; padding: 0 7px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); font-weight: 500; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* --- сообщения --- */
.msgs { display: grid; gap: 8px; margin-bottom: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
.msg.success { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); background: var(--ok-soft); }
.msg.error { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--danger-soft); }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.note.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.note.danger > .ic { color: var(--danger); }
.note.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.note.warn > .ic { color: var(--warn); }
.note.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 25%, var(--border)); }
.note.info > .ic { color: var(--info); }
.note .ic { margin-top: 2px; }
.note h3 { font-size: 14px; margin-bottom: 2px; }
.note p:last-child { margin-bottom: 0; }

.empty { text-align: left; padding: 28px 16px; color: var(--text-2); }
.empty h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }

/* --- графики --- */
.chart { display: block; overflow: visible; }
.c-grid { stroke: var(--border); stroke-width: 1; }
.c-base { stroke: var(--border-strong); stroke-width: 1; }
.c-axis { pointer-events: none; fill: var(--muted); font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.c-x { fill: var(--muted); font-size: 11px; }
.c-val { fill: var(--text); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.c-val.hl { fill: var(--neg); }
.c-bar { fill: var(--accent); transition: opacity .15s; }
.c-bar.partial { fill: var(--accent-dim); }
.c-plan { stroke: var(--text-2); stroke-width: 2; stroke-dasharray: 4 3; }
.c-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.c-planline { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.c-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.c-dot.hl { fill: var(--neg); }
.c-hit { fill: transparent; cursor: pointer; }
.c-hit:hover { fill: var(--text); fill-opacity: .05; }
.c-pos { fill: var(--pos); }
.c-neg { fill: var(--neg); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.bar { background: var(--accent); min-width: 0; position: static; height: 10px; } .legend i.partial { background: var(--accent-dim); }
.legend i.plan { height: 0; border-top: 2px dashed var(--text-2); border-radius: 0; vertical-align: 3px; }
.legend i.line { height: 0; border-top: 2px solid var(--accent); border-radius: 0; vertical-align: 3px; }
.legend i.planline { height: 0; border-top: 2px dashed var(--muted); border-radius: 0; vertical-align: 3px; }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; line-height: 1.4; padding: 6px 9px; border-radius: 5px; max-width: 300px; opacity: 0; transition: opacity .12s; }
.tip.on { opacity: 1; }
.dv { display: grid; gap: 2px; }
.dv-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) 110px; gap: 10px; align-items: center; min-height: 30px; border-radius: 4px; padding: 0 6px; }
.dv-row:hover { background: var(--surface-2); }
.dv-name { font-size: 13px; }
.dv-name a { color: var(--text); }
.dv-val { text-align: right; font-weight: 600; font-size: 13px; }
.dv-val.pos { color: var(--pos); } .dv-val.neg { color: var(--neg); }

/* --- полосы выполнения плана --- */
.bar { position: relative; height: 8px; background: var(--surface-3); border-radius: 4px; min-width: 80px; }
.bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; max-width: 100%; }
.bar > span.under { background: var(--warn); }
.bar > i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); }

/* --- календарь --- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px; min-height: 86px; font-size: 12px; color: inherit; display: block; }
a.day:hover { border-color: var(--border-strong); text-decoration: none; }
.day.we { background: var(--surface-2); }
.day.neg { border-color: var(--danger); background: var(--danger-soft); }
.day.today { box-shadow: inset 0 0 0 1px var(--accent); }
.day .d { color: var(--muted); font-weight: 500; }
.day .in { color: var(--ok); }
.day .out { color: var(--text-2); }
.day .bal { font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.day .accneg { color: var(--danger); font-weight: 600; }

/* --- сводка в Telegram --- */
.phone { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px; max-width: 420px; }
.bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5; box-shadow: var(--shadow); white-space: normal; }
.bubble .time { text-align: right; font-size: 11px; color: var(--muted); margin-top: 4px; }
.bot { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }

/* --- вопрос --- */
.ask-box { display: flex; gap: 8px; }
.ask-box .input { flex: 1; height: 40px; font-size: 14px; }
.ask-box .btn { height: 40px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 6px; padding: 5px 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 4px; height: 12px; margin: 8px 0; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
.htmx-request .hide-on-req { display: none; }
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.how > div { padding: 10px 12px; border-right: 1px solid var(--border); background: var(--surface-2); font-size: 12px; }
.how > div:last-child { border-right: 0; }
.how b { display: block; font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.reason { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.reason:last-child { border-bottom: 0; }
.reason .n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 12px; font-weight: 600; }

/* --- вход --- */
.login { max-width: 960px; margin: 48px auto 0; padding: 0 16px; display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); grid-template-areas: "head roles" "more roles"; gap: 8px 40px; align-items: start; }
.login-head { grid-area: head; }
.login-roles { grid-area: roles; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; box-shadow: var(--shadow); }
.login-more { grid-area: more; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 17px; }
.login-brand .brand-mark { width: 34px; height: 34px; border-radius: 8px; }
.login-brand .muted { font-size: 14px; }
.login h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin-bottom: 12px; }
.login .lead { color: var(--text-2); font-size: 15px; max-width: 520px; }
.login .more { border-top: 1px solid var(--border); max-width: 520px; }
.login .more:first-child { border-top: 0; }
.login .more summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--text); list-style: none; }
.login .more summary::-webkit-details-marker { display: none; }
.login .more summary::after { content: "+"; margin-left: auto; color: var(--muted); font-weight: 400; font-size: 18px; }
.login .more[open] summary::after { content: "−"; }
.login .more > :not(summary) { margin-bottom: 14px; }
.role-btn { width: 100%; min-height: 64px; text-align: left; display: grid; grid-template-columns: 36px minmax(0, 1fr) 16px; gap: 12px; align-items: center; padding: 10px 14px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; margin-bottom: 10px; color: var(--text); }
.role-btn:hover { border-color: var(--accent); }
.role-btn.start { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.role-btn .avatar { width: 36px; height: 36px; font-size: 13px; }
.role-btn b { display: block; font-size: 15px; line-height: 1.25; }
.role-btn b em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 6px; margin-left: 4px; vertical-align: 1px; white-space: nowrap; }
.role-btn .rb-t > span { display: block; font-size: 13px; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.facts { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; max-width: 520px; }
.facts li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; color: var(--text-2); }
.facts .ic { color: var(--accent); margin-top: 2px; }

/* --- палитра команд --- */
.palette { position: fixed; inset: 0; background: rgba(20, 20, 18, .35); display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 200; }
.palette.on { display: flex; }
.palette-box { width: min(560px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); overflow: hidden; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 12px 14px; font-size: 15px; background: transparent; outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li a { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.palette li a.sel, .palette li a:hover { background: var(--accent-soft); text-decoration: none; }
.palette li small { margin-left: auto; color: var(--muted); }
kbd { font: 11px/1 var(--font); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; color: var(--text-2); background: var(--surface); }

.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 10px 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.err-page { max-width: 560px; margin: 60px auto; padding: 0 16px; }
.err-page .code { font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.list-plain { margin: 0; padding-left: 18px; }
.list-plain li { margin-bottom: 4px; }
.code-pre { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; white-space: pre-wrap; margin: 0; }

/* --- телефон и планшет --- */
@media (max-width: 1100px) {
  .kpis, .kpis.k6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis:not(.k3):not(.k4) .kpi:nth-child(3n) { border-right: 0; }
  .kpis:not(.k3):not(.k4) .kpi:nth-child(n+4) { border-top: 1px solid var(--border); }
  .g73, .g82 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; height: 100vh; z-index: 150; transform: translateX(-100%); transition: transform .18s; box-shadow: 0 0 24px rgba(0, 0, 0, .2); }
  body.menu-open .side { transform: none; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 140; }
  body.menu-open .scrim { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
  .topbar .brand { padding: 0; }
  .topbar .icon-btn { margin-left: auto; }
  .main { padding: 14px 16px 40px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "roles" "more"; gap: 16px; margin-top: 20px; }
  .how { grid-template-columns: minmax(0, 1fr); }
  .how > div { border-right: 0; border-bottom: 1px solid var(--border); }
}
@media (max-width: 639px) {
  h1 { font-size: 19px; }
  .kpis, .kpis.k3, .kpis.k4, .kpis.k6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .val { white-space: normal; }
  .filters input[type=search] { width: 100% !important; }
  .kpi { border-right: 1px solid var(--border) !important; border-top: 1px solid var(--border); padding: 11px 12px; }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi:nth-child(2n) { border-right: 0 !important; }
  .kpi .val { font-size: 18px; } .kpi .val.big { font-size: 20px; }
  .c-x.minor { display: none; }
  .week { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 0; display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
  .day .bal { margin-top: 0; }
  .day.we.empty-day { display: none; }
  .dv-row { grid-template-columns: 112px minmax(0, 1fr) 84px; gap: 6px; }
  .dv-name { font-size: 12px; }
  .panel-h { padding: 10px 12px; }
  .panel-b { padding: 12px; }
  .t th, .t td { padding: 0 9px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 6px; }
  .ask-box { flex-direction: column; }
  .hide-sm { display: none !important; }
}
.icon-btn { width: 36px; height: 36px; border-radius: var(--radius); border: 1px solid transparent; background: transparent; color: var(--text-2); display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }


/* ===== телефон < 640 px: зоны нажатия 44, поля 16 px, фильтры в нижнем листе, таблицы ≤ 4 колонок или карточки ===== */
@media (min-width: 640px) {
  .m-only { display: none !important; }
  .fsheet:not(.filters), .sheet-btns { display: contents; }
}
@media (max-width: 639px) {
  .d-only { display: none !important; }
  .demo-bar { justify-content: flex-start; padding: 0 0 0 12px; }
  .db-long { display: none; }
  .demo-bar .db-btn { min-height: 44px; margin: -8px 0; }
  .main { padding: 12px 14px 32px; }
  .topbar { height: 52px; padding: 0 4px; gap: 4px; }
  .topbar .brand { min-height: 44px; padding: 0 6px; }
  .icon-btn { width: 44px; height: 44px; }
  input, select, textarea, .input, select.input, textarea.input, .palette input { font-size: 16px; }
  .input, select.input { height: 44px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .btn, .btn.sm { min-height: 44px; height: auto; padding: 0 14px; font-size: 14px; }
  .btn.sm.ghost { min-width: 44px; justify-content: center; padding: 0 10px; }
  .linkbtn { min-height: 44px; }
  .nav a { min-height: 44px; }
  .side-foot kbd { display: none; }
  .page-head { margin-bottom: 10px; gap: 8px; align-items: stretch; }
  .page-head > div:first-child { min-width: 0; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; justify-content: center; }
  .crumbs a, .panel-h a.actions, a.actions.small { display: inline-flex; align-items: center; min-height: 44px; }
  .panel-h { padding: 4px 12px; min-height: 44px; }
  .chip { min-height: 44px; display: inline-flex; align-items: center; }
  .seg a { min-height: 44px; display: inline-flex; align-items: center; }
  .pager { padding: 8px 12px; }
  label.f { font-size: 13px; }
  label.row { min-height: 44px; }
  details > summary.btn, summary { min-height: 44px; }
  .small { font-size: 12px; }
  .tag { font-size: 11.5px; }
  .site-foot { margin-top: 20px; }
  .site-foot a { display: inline-flex; align-items: center; min-height: 44px; }
  .msg { font-size: 14px; }
  .note { padding: 10px 12px; }
  .note .actions .btn { flex: 1 1 auto; justify-content: center; }
  .day { min-height: 44px; }
  /* полоска шагов: три равные кнопки в ряд */
  .steps { padding: 0 0 0 4px; gap: 0; font-size: 12.5px; }
  .steps .steps-l { display: none; }
  .steps ol { display: grid; grid-template-columns: 1fr 1.2fr 1fr; }
  .steps li + li::before { display: none; }
  .steps li + li { border-left: 1px solid var(--border); }
  .steps a { min-height: 44px; padding: 2px 6px; line-height: 1.2; width: 100%; }
  .steps .icon-btn { width: 44px; }
  /* фильтры → нижний лист */
  .fbtn { display: inline-flex; width: 100%; justify-content: flex-start; margin-bottom: 12px; }
  .fbtn span { overflow: hidden; text-overflow: ellipsis; }
  .fsheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 170; max-height: 82vh; overflow-y: auto; margin: 0; background: var(--surface); border: 1px solid var(--border); 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; box-shadow: 0 -8px 24px rgba(0, 0, 0, .12); }
  .fsheet > * + * { margin-top: 12px; }
  .fsheet .seg { display: flex; flex-wrap: wrap; gap: 6px; background: none; border: 0; padding: 0; }
  .fsheet .seg a { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 12px; font-size: 14px; }
  .fsheet .seg a.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: none; }
  .fsheet .range, .fsheet label.range { display: flex; flex-direction: column; align-items: stretch; gap: 8px; color: var(--text-2); }
  .fsheet select, .fsheet input:not([type=hidden]) { width: 100% !important; }
  .fsheet .fs-l { font-size: 12.5px; color: var(--text-2); font-weight: 500; margin-top: 4px; }
  .fsheet .btn { justify-content: center; }
  .fsheet .primary-m { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
  .fsheet .sheet-btns { display: flex; gap: 8px; }
  .fsheet .sheet-btns .btn { flex: 1; }
  .fsheet .period-note { display: block; }
  .filters { margin-bottom: 12px; }
  .filters input[type=search] { width: 100% !important; }
  /* сводка: цифры → тревога → шаги → остальное */
  .dash .o-head { order: 1; }
  .dash .o-period { order: 2; }
  .dash .o-kpis { order: 3; }
  .dash .o-alert { order: 4; }
  .dash .o-steps { order: 5; }
  .dash .o-rest { order: 6; }
  .dash .o-gap { order: 7; margin-top: 16px; scroll-margin-top: 64px; }
  .dash .o-head .sub { font-size: 12.5px; }
  .dash .o-head .actions .btn { min-height: 40px; }
  .dash .o-head { flex-wrap: nowrap; }
  .dash .o-head .actions { width: auto; flex: none; }
  .dash .o-head { align-items: flex-start; }
  .dash .o-head .actions .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dash .o-head .actions .btn { min-width: 44px; min-height: 44px; padding: 0 10px; }
  .dash .fbtn { margin-bottom: 10px; }
  .dash .panel-h .hint { display: none; }
  .dash .kpis { margin-bottom: 10px; }
  .kpi { min-height: 44px; }
  .kpi .lbl { font-size: 11.5px; }
  .kpi .cmp { font-size: 11.5px; }
  /* таблицы: ≤ 4 колонок, первая липкая; .mc — карточки */
  .t th, .t td { height: 44px; }
  .t td.wrap, .t th.wrap { min-width: 0; white-space: normal; }
  .t a.cell { display: flex; align-items: center; min-height: 44px; }
  .t td a:not(.cell):not(.btn), .t .src a { display: inline-flex; align-items: center; min-height: 44px; }
  .tw .t tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
  .tw .t thead tr > :first-child, .tw .t tfoot tr > :first-child, .tw .t tr.sum > :first-child { background: var(--surface-2); }
  .tw .t tr.neg-row > :first-child { background: var(--danger-soft); }
  .tw .t tr.hl > :first-child { background: var(--warn-soft); }
  .t th.w-bar { min-width: 0; }
  .t .bar { min-width: 48px; }
  .t.mc thead { display: none; }
  .t.mc, .t.mc tbody, .t.mc tfoot { display: block; }
  .t.mc tr { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
  .t.mc tr > td { display: block; position: static; height: auto; min-height: 0; padding: 0; border: 0; background: none !important; white-space: normal; }
  .t.mc tr.neg-row { background: var(--danger-soft); }
  .t.mc tr.hl { background: var(--warn-soft); }
  .t.mc td.hide-sm { display: none; }
  .t.mc td:empty { display: none; }
  .t.mc td.mc-title { order: -2; flex: 1 1 100%; font-size: 14px; }
  .t.mc td.mc-date { order: -1; color: var(--muted); font-size: 12.5px; }
  .t.mc td.mc-num { margin-left: auto; font-size: 14px; }
  .t.mc td.mc-art { flex: 1 1 100%; }
  .t.mc td:has(form) { flex: 1 1 100%; }
  .t.mc td form.row { flex-wrap: wrap !important; }
  .t.mc td form select { max-width: none !important; flex: 1 1 100%; }
  .t.mc td[data-l]::before { content: attr(data-l) " "; color: var(--muted); font-weight: 400; font-size: 12px; }
  .t.mc .strong-m { font-weight: 600; }
  .t.mc tfoot tr { background: var(--surface-2); font-weight: 600; }
  .t.mc tfoot td { background: none; }
  .t.mc-raw tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 12px; }
  .t.mc-raw td.mc-title { grid-column: 1 / -1; font-weight: 600; color: var(--text); }
  .t.mc-raw td { font-size: 13px; overflow-wrap: anywhere; }
  .t.mc-raw td[data-l]::before { display: block; }
  .t.mc-raw td.mc-title::before { display: inline; }
  .tw[style*="max-height"] { max-height: none !important; }
  .t.mc .t-x { display: none; }
  .dv-row { min-height: 44px; }
  .dv-name a { display: inline-flex; align-items: center; min-height: 44px; }
  .reason a { display: inline-flex; align-items: center; min-height: 44px; }
  .ask-box .input, .ask-box .btn { height: 48px; }
  .bubble a { display: inline-flex; min-height: 44px; align-items: center; }
  .crumbs a { min-width: 44px; }
  .login h1 { font-size: 24px; }
  .login-brand { margin-bottom: 14px; }
  .tw .t td:first-child { white-space: normal; line-height: 1.3; }
  .t .src a, .t td a:not(.cell):not(.btn) { min-width: 44px; }
  a.tap, label.tap, .empty a { display: inline-flex; align-items: center; min-height: 44px; gap: 6px; }
  label.tap { min-width: 44px; }
  .input.file { height: auto; min-height: 44px; }
  .ask-box .input { flex: none; width: 100%; font-size: 16px; }
  /* график шире экрана: листается пальцем, столбец ≥ 44 px */
  .chart-scroll { margin: 0 -12px; padding: 0 12px; }
  .chart-scroll > svg.chart { min-width: calc(var(--n, 12) * 46px); }
  /* ДДС: прокрутка к ячейке не прячет её под липкой первой колонкой */
  .dds .tw { scroll-padding-left: 150px; }
  .dds .t td.first, .dds .t th.first { width: 140px; min-width: 140px; max-width: 140px; white-space: normal; line-height: 1.25; }
}
@media print { .side, .topbar, .demo-bar, .filters, .actions, .steps, .fbtn, .site-foot { display: none !important; } .shell { display: block; } }
