
/* Раскладка: рабочее место учётной программы — меню разделов слева, раздел справа, таблицы в центре внимания */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --fg: #1b2330;
  --muted: #5e6b7d;
  --line: #d8dee8;
  --accent: #1f5fbf;
  --accent-soft: #e3ecfa;
  --ok: #1e7d43;
  --ok-soft: #e1f2e7;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --warn: #9a5b00;
  --font-ui: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d; --surface: #1a2029; --surface-2: #222a35; --fg: #e6ebf2; --muted: #98a4b5;
    --line: #2f3946; --accent: #6ea1f0; --accent-soft: #1e2e47; --ok: #5cc584; --ok-soft: #1a3325;
    --bad: #f08a80; --bad-soft: #3d1f1d; --warn: #e3a64a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161d; --surface: #1a2029; --surface-2: #222a35; --fg: #e6ebf2; --muted: #98a4b5;
  --line: #2f3946; --accent: #6ea1f0; --accent-soft: #1e2e47; --ok: #5cc584; --ok-soft: #1a3325;
  --bad: #f08a80; --bad-soft: #3d1f1d; --warn: #e3a64a; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font-ui); }
#app { height: 100%; }
.boot { padding: 40px; color: var(--muted); }
body { margin: 0; }
.login { max-width: 360px; margin: 12vh auto; }
.section-card h2 { margin-bottom: 8px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.status { font-size: 12px; color: var(--muted); padding: 0 10px 8px; }
.status.off { color: var(--bad); }
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100%; }
.shell.nav-off { grid-template-columns: 52px minmax(0, 1fr); }
nav.side { background: var(--surface); border-right: 1px solid var(--line); padding-block: 14px; padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: 10px; overflow-y: auto; }
.brand { padding: 4px 10px 14px; }
.brand b { display: block; font-size: 15px; letter-spacing: .01em; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 4px; }
.navbtn { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--fg); font: inherit; cursor: pointer; }
.navbtn:hover { background: var(--surface-2); }
.navbtn.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { min-width: 0; }
.page { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 22px; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
.sub { color: var(--muted); font-size: 13px; max-width: 70ch; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bar .grow { flex: 1; }
.btn { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, .navbtn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.link { border-color: transparent; background: transparent; color: var(--accent); padding-inline: 6px; }
input, select { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
.req::after { content: " *"; color: var(--bad); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; line-height: 18px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.no { background: var(--surface-2); color: var(--muted); }
.chip.del { background: var(--bad-soft); color: var(--bad); }
.errors { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; }
.note { background: var(--accent-soft); color: var(--fg); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font: 600 22px/1.3 var(--font-num); margin-top: 2px; }
.tile .n { font-size: 12px; color: var(--muted); }
.grid-box { height: 460px; min-height: 280px; }
.grid-box.short { height: 340px; }
.docline { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.docline:last-child { border-bottom: 0; }
.docline button { all: unset; color: var(--accent); cursor: pointer; }
.docline button:focus-visible { outline: 2px solid var(--accent); }
.totals { display: flex; justify-content: flex-end; gap: 18px; font-size: 14px; }
.totals b { font-family: var(--font-num); }
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: min(560px, 100%); max-height: 90%; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 5px 10px; border: 0; background: var(--surface); color: var(--fg); cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); }
.ag-theme-host { width: 100%; height: 100%; }
.mobile-nav { display: none; }
@media (max-width: 760px) {
  .shell, .shell.nav-off { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  nav.side { display: none; }
  .mobile-nav { display: block; padding-block: 10px 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); }
  .mobile-nav select { width: 100%; margin-bottom: 10px; }
  .grid-box { height: 380px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.panel.flush { padding: 0; overflow: hidden; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted-cell { color: var(--muted); }

/* --- отчёты, печать, метки */
:root { --c1: #1f5fbf; --c2: #2e9d6a; --c3: #d08a1c; --c4: #8a4fbf; --c5: #c2453d; --c6: #2a9bb5; --c7: #7d8a2b; --c8: #8c95a3; --warn-soft: #fbf0dc; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --c1: #6ea1f0; --c2: #5cc584; --c3: #e3a64a; --c4: #b58ae6; --c5: #f08a80; --c6: #5ec3da; --c7: #b7c35a; --c8: #98a4b5; --warn-soft: #3a2c12; } }
:root[data-theme="dark"] { --c1: #6ea1f0; --c2: #5cc584; --c3: #e3a64a; --c4: #b58ae6; --c5: #f08a80; --c6: #5ec3da; --c7: #b7c35a; --c8: #98a4b5; --warn-soft: #3a2c12; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
summary.btn.disabled { opacity: .5; cursor: default; }
.menu-list { position: absolute; z-index: 15; top: calc(100% + 4px); right: 0; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 6px 22px rgba(0, 0, 0, .14); display: flex; flex-direction: column; }
.menu-list button { all: unset; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--accent-soft); }
.report { display: flex; flex-direction: column; gap: 14px; }
.chart.bars { display: flex; flex-direction: column; gap: 6px; }
.barrow { display: grid; grid-template-columns: minmax(90px, 220px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.barrow .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barrow .track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.barrow .fill { display: block; height: 100%; background: var(--c1); border-radius: 4px; }
.chart.pie { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.chart.pie svg { width: 200px; max-width: 100%; height: auto; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; min-width: 0; }
.legend > div { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.legend i { width: 12px; height: 12px; border-radius: 3px; }

/* --- конфигуратор */
main.wide .page, .page.wide { max-width: none; }
.cfg { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; align-items: start; }
.tree { position: sticky; top: 0; max-height: calc(100vh - 120px); overflow-y: auto; padding: 8px; }
.tree-head { display: flex; justify-content: space-between; align-items: center; }
.tree-head .btn { font-size: 12px; text-transform: none; letter-spacing: 0; padding: 0 4px; }
.tree-empty { padding: 2px 10px; }
.cfg-editor { min-width: 0; }
h3 { font-size: 13px; margin: 0; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.tbl-wrap { overflow-x: auto; }
table.edit { border-collapse: collapse; width: 100%; font-size: 13px; }
table.edit th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.edit td { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.edit td input:not([type=checkbox]), table.edit td select { width: 100%; min-width: 110px; }
table.edit td.c { text-align: center; }
table.edit td.acts { white-space: nowrap; width: 1%; }
table.edit.map td.ok { color: var(--ok); }
.bad-text { color: var(--bad); }
input.bad { border-color: var(--bad); background: var(--bad-soft); }
.mono { font-family: var(--font-num); }
.rule { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ask { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--bad); }
.palette { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn.chipbtn { padding: 3px 9px; font-size: 12px; border-radius: 12px; background: var(--surface-2); }
.chip.tag { display: inline-flex; align-items: center; gap: 2px; padding-right: 2px; }
.chip.tag .btn { padding: 0 3px; font-size: 12px; }
.pf { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
textarea.tpl { width: 100%; min-height: 340px; resize: vertical; font-size: 13px; line-height: 1.5; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
.pf-preview { min-height: 520px; background: #fff; }
.pf-preview iframe { width: 100%; height: 100%; min-height: 520px; border: 0; display: block; }
@media (max-width: 1100px) { .pf { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .cfg { grid-template-columns: 1fr; } .tree { position: static; max-height: 300px; } }

/* выравнивание чисел: количество — по центру, остальные числа — вправо */
.ag-cell.cell-center { text-align: center; justify-content: center; }
.head-center .ag-header-cell-label { justify-content: center; }
input.al-right, .al-right { text-align: right; }
input.al-center, .al-center { text-align: center; }

/* --- стартовая страница баз */
.launcher { min-height: 100%; background: var(--bg); padding-block: 6vh 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.launcher .page { max-width: 820px; }
.bases { display: flex; flex-direction: column; gap: 10px; }
.basecard { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; cursor: default; }
.basecard.current { border-color: var(--accent); }
.path { word-break: break-all; font-size: 12px; }
.bar .grow, input.grow { flex: 1; min-width: 0; }
.check.mode { align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.check.mode input { margin-top: 3px; }
.fs { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.fs button { all: unset; padding: 6px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--line); }
.fs button:hover, .fs button:focus-visible { background: var(--accent-soft); }
.fs button.file { color: var(--accent); }
.brand-switch { padding: 2px 0 !important; font-size: 12px; display: block; margin-top: 4px; }
.login { max-width: 380px; }

/* --- фото */
.field.wide { grid-column: 1 / -1; }
.imgfield { display: flex; flex-direction: column; gap: 8px; outline: none; }
.imgbox { width: 100%; max-width: 260px; aspect-ratio: 4 / 3; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); text-align: center; padding: 6px; }
.imgbox img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.imgfield:focus-visible .imgbox { outline: 2px solid var(--accent); }
img.thumb { height: 28px; width: 44px; object-fit: contain; vertical-align: middle; border-radius: 3px; }

/* --- загрузка из Excel */
.modal.wide { width: min(860px, 100%); }
.drop { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; }
td.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.req::after { content: " *"; color: var(--bad); }
table.users td, table.users th { padding: 8px 12px; }
a.btn { display: inline-block; text-decoration: none; }
.btn.chipbtn.copied { background: var(--ok-soft); color: var(--ok); }

/* ---------------------------------------------------------------- окна форм */
.work { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.workspace { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.desk { position: absolute; inset: 0; z-index: 1; overflow-y: auto; padding: 18px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
.win { position: absolute; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); min-width: 0; min-height: 0; }
.win.mode-max { inset: 0; border: 0; }
.win.mode-left { top: 0; bottom: 0; left: 0; width: calc(var(--split, .5) * 100%); border-width: 0 1px 0 0; }
.win.mode-right { top: 0; bottom: 0; right: 0; width: calc((1 - var(--split, .5)) * 100%); border-width: 0 0 0 1px; }
/* разделитель между окнами слева и справа */
.splitter { position: absolute; top: 0; bottom: 0; width: 8px; z-index: 30; cursor: col-resize; display: flex; justify-content: center; outline: none; }
.splitter span { width: 2px; height: 100%; background: transparent; transition: background .15s; }
.splitter:hover span, .splitter:focus-visible span, body.resizing .splitter span { background: var(--accent); }
.splitter::after { content: ""; position: absolute; top: 50%; left: 1px; width: 6px; height: 36px; margin-top: -18px; border-radius: 3px; background: var(--line); }
.splitter:hover::after, body.resizing .splitter::after { background: var(--accent); }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
body.resizing iframe { pointer-events: none; }
.win.mode-float { border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, .22); resize: both; overflow: hidden; min-width: 360px; min-height: 220px; }
.win.mode-min { display: none; }
.win-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 14px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 38px; user-select: none; }
.win.mode-float .win-head { cursor: move; }
.win.active .win-head { box-shadow: inset 0 2px 0 var(--accent); }
.win-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.win:not(.active) .win-title { color: var(--muted); }
.win-btns { display: flex; gap: 2px; flex: none; }
.wbtn { display: inline-grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.wbtn:hover { background: var(--surface-2); color: var(--fg); }
.wbtn.on { color: var(--accent); background: var(--accent-soft); }
.wbtn.close:hover { background: var(--bad-soft); color: var(--bad); }
.wbtn:focus-visible { outline: 2px solid var(--accent); }
.win-body { flex: 1; min-height: 0; overflow: auto; }
.win-content { padding: 16px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); min-height: 100%; }
.win-content > .page { max-width: 1400px; }
.modal-layer { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); display: grid; place-items: center; padding: 16px; }
.modal-layer .win { position: relative; inset: auto; width: min(1180px, 100%); height: min(88vh, 100%); border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); overflow: hidden; }
.taskbar { display: flex; gap: 4px; padding: 5px 8px; background: var(--surface); border-top: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: thin; }
.task { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; min-width: 0; padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--fg); font: inherit; font-size: 12px; cursor: pointer; flex: none; }
.task:hover { border-color: var(--accent); }
.task.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.task.min { border-style: dashed; color: var(--muted); }
.task-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-ico { opacity: .7; }
.task-x { border-radius: 4px; padding: 0 4px; color: var(--muted); }
.task-x:hover { background: var(--bad-soft); color: var(--bad); }
.form-actions { position: sticky; bottom: 0; background: var(--bg); padding-block: 10px; border-top: 1px solid var(--line); z-index: 2; }
/* меню слева сворачивается */
.side-top { display: flex; gap: 4px; align-items: flex-start; }
.navtoggle { flex: none; margin-top: 2px; }
.nav-off nav.side { padding-inline: 6px; }
.rail { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.rail-btn { width: 40px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); font: 600 12px var(--font-ui); cursor: pointer; }
.rail-btn:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 760px) {
  .splitter { display: none; }
  .win.mode-left, .win.mode-right, .win.mode-float { inset: 0 !important; width: auto !important; height: auto !important; border: 0; border-radius: 0; }
  .win-btns .wbtn:not(.close) { display: none; }
  .win-btns .wbtn:first-child { display: inline-grid; }
  .work { height: auto; min-height: 0; }
  .modal-layer { padding: 0; }
  .modal-layer .win { height: 100%; border-radius: 0; }
}

/* ---------------------------------------------------------------- контекстное меню, сообщения, вопросы */
.ctxmenu { position: fixed; z-index: 100; min-width: 220px; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); outline: none; }
.ctxmenu button { display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: center; width: 100%; text-align: left; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 13px; padding: 6px 10px 6px 6px; border-radius: 6px; cursor: pointer; }
.ctxmenu button.hi { background: var(--accent-soft); }
.ctxmenu button.danger { color: var(--bad); }
.ctxmenu button:disabled { opacity: .45; cursor: default; }
.ctx-hint { color: var(--muted); font-size: 12px; font-family: var(--font-num); }
.ctx-check { color: var(--accent); }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.toasts { position: fixed; right: 16px; bottom: 56px; z-index: 120; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 8px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 8px 10px 10px; box-shadow: 0 8px 26px rgba(0, 0, 0, .16); font-size: 13px; animation: toast-in .18s ease-out; }
.toast.ok { border-left-color: var(--ok); } .toast.err { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); } .toast.msg { border-left-color: var(--c4); }
.toast-ico { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; }
.toast.ok .toast-ico { background: var(--ok-soft); color: var(--ok); } .toast.err .toast-ico { background: var(--bad-soft); color: var(--bad); } .toast.warn .toast-ico { background: var(--warn-soft); color: var(--warn); }
.toast-text { display: flex; flex-direction: column; gap: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast-x { border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1; padding: 0 4px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.ask-back { z-index: 110; }
.modal.asker { width: min(520px, 100%); }
.calc-expr.fresh { color: var(--accent); }
.ask-text { white-space: pre-wrap; }
ul.chain { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; max-height: 40vh; overflow: auto; }

/* ---------------------------------------------------------------- поля: ссылка, число, калькулятор, штрихкод */
.ref-input, .num-input { position: relative; display: flex; align-items: stretch; min-width: 0; }
.ref-input input, .num-input input { flex: 1; min-width: 0; }
.ref-input input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ref-btn { flex: none; display: inline-grid; place-items: center; min-width: 28px; padding: 0 6px; border: 1px solid var(--line); border-left: 0; background: var(--surface-2); color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.ref-btn:last-of-type { border-radius: 0 6px 6px 0; }
.ref-btn:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.ref-btn:disabled { opacity: .45; cursor: default; }
.ref-btn.clear { font-size: 15px; font-weight: 400; }
.ref-input.ro input { background: var(--surface-2); }
.num-input .calc-btn { display: none; }
.num-input.focus input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.num-input.focus .calc-btn { display: inline-grid; }
.ref-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .16); max-height: 300px; overflow: auto; font-size: 13px; }
.ref-list.fixed { position: fixed; z-index: 90; right: auto; }
.ref-list li { padding: 6px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-list li.hi { background: var(--accent-soft); }
.ref-list li.ref-more { color: var(--accent); border-top: 1px solid var(--line); border-radius: 0; margin-top: 2px; }
.cell-editor.in-cell { height: 100%; width: 100%; }
.cell-editor.in-cell input { border: 0; border-radius: 0; height: 100%; padding: 0 8px; background: var(--surface); outline: none; }
.cell-editor.in-cell .ref-btn { border-top: 0; border-bottom: 0; border-radius: 0; }
.cell-editor.in-cell .calc-btn { display: inline-grid; }
.calc-back { position: fixed; inset: 0; z-index: 115; }
.calc { position: fixed; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; box-shadow: 0 16px 40px rgba(0, 0, 0, .24); display: flex; flex-direction: column; gap: 8px; outline: none; }
.calc-screen { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; text-align: right; }
.calc-expr { font-size: 13px; color: var(--muted); min-height: 18px; overflow-wrap: anywhere; }
.calc-res { font-size: 20px; font-weight: 600; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-k { height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); font: 500 16px var(--font-num); cursor: pointer; }
.calc-k.op { background: var(--surface-2); }
.calc-k.eq { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.calc-k:hover { border-color: var(--accent); }
.barcode-box { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding-left: 8px; }
.barcode-box input { border: 0; width: 170px; }
.bc-ico { color: var(--muted); display: inline-grid; }
.num-prefix { display: flex; align-items: center; gap: 4px; }
.num-prefix input { flex: 1; min-width: 0; }
img.thumb.big { height: 120px; width: auto; }

/* ---------------------------------------------------------------- формы по раскладке */
.form-layout { display: flex; flex-direction: column; gap: 14px; }
.fgroup.nested { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; }
.fgroup-title, details.fgroup summary h3 { margin-bottom: 8px; display: inline; }
details.fgroup summary { cursor: pointer; margin-bottom: 8px; }
.fields.row { display: flex; flex-wrap: wrap; }
.fields.row > .field { flex: 1 1 180px; }
.form-label { font-size: 14px; }
.form-label.hint { font-size: 12px; color: var(--muted); }
.form-label.title { font-size: 16px; font-weight: 600; }
.form-label.warn { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { font: inherit; font-size: 13px; padding: 7px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tabs button.on { background: var(--surface); border-color: var(--line); color: var(--fg); font-weight: 600; }
.tab-body { padding-top: 12px; }
.form-pages { display: flex; flex-direction: column; }
/* редактор форм */
.fdesign { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1000px) { .fdesign { grid-template-columns: 1fr; } }
.fd-tools .btn { padding: 4px 9px; font-size: 12px; }
.ftree-box { border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-height: 160px; max-height: 60vh; overflow: auto; }
ul.ftree { list-style: none; margin: 0; padding: 0; }
ul.ftree ul.ftree { padding-left: 18px; border-left: 1px dotted var(--line); margin-left: 8px; }
.fnode { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.fnode:hover { background: var(--surface-2); }
.fnode.on { background: var(--accent-soft); }
.fnode.off .fname { color: var(--muted); text-decoration: line-through; }
.fkind { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--muted); flex: none; }
.fkind.k-group, .fkind.k-pages, .fkind.k-page { background: var(--accent-soft); color: var(--accent); }
.fkind.k-table { background: var(--ok-soft); color: var(--ok); }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-preview { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; background: var(--bg); }

/* ---------------------------------------------------------------- иерархия справочников */
.cat-split { display: grid; grid-template-columns: minmax(180px, 250px) minmax(0, 1fr); gap: 10px; align-items: start; }
@media (max-width: 860px) { .cat-split { grid-template-columns: 1fr !important; } .cat-resizer { display: none; } }
.ftreeview { padding: 6px; max-height: 460px; overflow: auto; }
.ftreeview ul { list-style: none; margin: 0; padding: 0; }
.tnode { display: flex; align-items: center; gap: 2px; border-radius: 6px; }
.tnode.on { background: var(--accent-soft); }
.tnode.on .tn { color: var(--accent); font-weight: 600; }
.tnode.off .tn { color: var(--muted); }
.tw { border: 0; background: transparent; color: var(--muted); width: 18px; cursor: pointer; padding: 0; font-size: 11px; }
.tn { border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 13px; padding: 5px 6px; cursor: pointer; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; border-radius: 6px; }
.tn:hover { background: var(--surface-2); }
.crumb { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 13px; }
.crumb .btn.on { font-weight: 600; color: var(--fg); }

/* ---------------------------------------------------------------- вход, базы, администрирование */
.start { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.start-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.start-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .start-grid { grid-template-columns: 1fr; } }
.baselist { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow: auto; }
.baseitem { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; outline: none; }
.baseitem:hover { border-color: var(--accent); }
.baseitem:focus-visible { outline: 2px solid var(--accent); }
.baseitem.on { border-color: var(--accent); background: var(--accent-soft); }
.baseitem.na { opacity: .65; }
.bi-name { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.start-base { font-weight: 600; padding: 6px 0; }
fieldset.pwbox { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
fieldset.pwbox legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.marked-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-left: 22px; }
.marked-refs { flex-basis: 100%; display: flex; flex-direction: column; gap: 2px; padding-left: 28px; font-size: 12px; color: var(--muted); }
table.edit.bulk td { vertical-align: top; }

/* числа по правому краю (цены, суммы); количество — по центру */
.ag-cell.cell-right { text-align: right; justify-content: flex-end; }
.head-right .ag-header-cell-label { flex-direction: row-reverse; }
.cell-right .cell-editor input, .ag-cell.cell-right input { text-align: right; }
.cell-center .cell-editor input { text-align: center; }
textarea { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
@media (max-width: 760px) { .form-actions { position: static; } .barcode-box input { width: 120px; } }
.ud-head { all: unset; cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ud-head:focus-visible { outline: 2px solid var(--accent); }
.ud-tbl td { vertical-align: middle; }

/* ---------------------------------------------------------------- компактные формы и таблицы */
.win-body { container-type: inline-size; container-name: win; }
.win-content .page { gap: 10px; }
.win-content .page > h1 { display: none; }   /* название уже в заголовке окна */
.win-content .panel { padding: 10px 12px; }
.win-content .panel.flush { padding: 0; }
.win-content .fields { gap: 8px 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.win-content .field { gap: 2px; }
.win-content input, .win-content select { padding: 5px 7px; }
.win-content .bar { gap: 6px; }
.win-content .btn { padding: 5px 10px; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.win-content .grid-box { height: calc(100vh - 230px); min-height: 220px; }
.win-content .form-table .grid-box { min-height: 0; }
.win-content .page > .hint { font-size: 11px; }
input.search { width: 200px; flex: 0 1 200px; min-width: 90px; }
.form-actions { margin-top: 2px; }
@container win (max-width: 820px) {
  .page > .hint, .panel > .hint { display: none; }
  .kbd { display: none; }
  .barcode-box input { width: 110px; }
  .fields { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; }
  .cat-split { grid-template-columns: 1fr; }
  .ftreeview { max-height: 140px; }
}
@container win (max-width: 560px) {
  .barcode-box { display: none; }
  .form-actions .btn:not(.primary):not(.more) { padding-inline: 8px; }
}
.modal-layer .win-content .grid-box { height: calc(88vh - 210px); }
.fcheck { margin: 0; flex: none; }
ul.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
ul.files li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; font-size: 13px; }
ul.files li:last-child { border-bottom: 0; }
ul.files a { color: var(--accent); }
.attach.over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); }
/* по центру (номер строки, количество): содержимое ячейки AG Grid лежит в .ag-cell-wrapper — центрируем его,
   позиционирование самих ячеек не трогаем (таблица расставляет их сама) */
.ag-cell.cell-center .ag-cell-wrapper { justify-content: center; width: 100%; }
.ag-cell.cell-center .ag-cell-value { flex: 0 1 auto; text-align: center; }

/* менеджер печати */
.printmgr { height: 100%; }
.pm-grid { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: 12px; align-items: stretch; min-height: calc(88vh - 140px); }
.pm-opts .fields.two { grid-template-columns: 1fr 1fr !important; }
.pm-preview { position: relative; background: #8a8f98; min-height: 420px; }
.pm-preview iframe { width: 100%; height: 100%; min-height: 420px; border: 0; display: block; }
.pm-loading { position: absolute; top: 8px; right: 12px; color: #fff; }
@container win (max-width: 760px) { .pm-grid { grid-template-columns: 1fr; } .pm-preview, .pm-preview iframe { min-height: 360px; } }

/* резервное копирование: база заблокирована */
.maint { position: fixed; inset: 0; z-index: 130; background: rgba(10, 14, 20, .55); display: grid; place-items: center; padding: 16px; }
.maint-box { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.progress { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s ease; }
.navbtn.sub { padding: 4px 10px 4px 26px; font-size: 12px; color: var(--muted); }
.navbtn.sub.on { color: var(--accent); }
.sub-ico { display: inline-block; width: 14px; margin-right: 4px; opacity: .8; }
table.edit.linked td { vertical-align: top; }

/* форма документа на всю высоту окна: табличная часть забирает свободное место */
.win-content { display: flex; flex-direction: column; }
.win-content > * { width: 100%; }
.win-content > .page.form-page { flex: 1 0 auto; }
.form-page :is(.form-layout, .stack, .fgroup, .tab-body, .form-pages, .form-table):has(.tp-stretch) { display: flex; flex-direction: column; flex: 1 0 auto; }
.form-page .tp-stretch { flex: 1 0 auto; }
.form-page .tp-stretch > .grid-box.stretch { flex: 1 0 auto; position: relative; }
.form-page .tp-stretch > .grid-box.stretch > .ag-theme-host { position: absolute; inset: 0; }

/* вывод списка */
.out-head > .field:first-child { flex: 2 1 260px; }
.out-wrap { overflow: auto; max-height: min(52vh, 520px); border: 1px solid var(--line); border-radius: 8px; }
table.out-table { border-collapse: collapse; width: 100%; font-size: 12px; }
table.out-table th, table.out-table td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 4px 8px; text-align: left; white-space: nowrap; }
table.out-table thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
table.out-table tfoot th { position: sticky; bottom: 0; background: var(--surface-2); }
table.out-table .n { text-align: right; font-variant-numeric: tabular-nums; }
.fields.row.wide-fields > .field { flex: 1 1 340px; }

/* окно с фото — в левой колонке под деревом групп */
.cat-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.item-pv { display: flex; flex-direction: column; gap: 8px; padding: 8px; min-width: 0; }
.pv-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pv-img { aspect-ratio: 1 / 1; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; cursor: zoom-in; }
.pv-img.empty { cursor: default; color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.pv-img img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pv-name { font-size: 13px; overflow-wrap: anywhere; }
.pv-big { position: fixed; inset: 0; z-index: 90; background: rgba(10, 14, 20, .75); display: grid; place-items: center; padding: 24px; cursor: zoom-out; outline: none; }
.pv-big img { max-width: 92vw; max-height: 84vh; object-fit: contain; background: #fff; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.pv-cap { color: #fff; font-size: 13px; margin-top: 8px; text-align: center; }
@container win (max-width: 620px) { .cat-split { grid-template-columns: 1fr !important; } .item-pv { flex-direction: row; align-items: center; } .item-pv .pv-img { width: 90px; flex: none; } }
.cat-left .item-pv ~ .ftreeview, .cat-left .ftreeview:has(~ .item-pv) { max-height: 300px; }

/* штрихкод документа в форме */
.doc-bc { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 2px 6px; cursor: copy; line-height: 0; }
.doc-bc img { height: 34px; width: auto; }
.doc-bc:hover { border-color: var(--accent); }
td.fixed-cell { min-width: 220px; }
.ctxmenu { overflow-y: auto; }

/* разделитель между колонкой групп/фото и списком справочника */
.cat-split.resizable { gap: 2px; }
.cat-resizer { align-self: stretch; cursor: col-resize; display: flex; justify-content: center; outline: none; border-radius: 4px; }
.cat-resizer span { width: 2px; background: transparent; transition: background .15s; }
.cat-resizer:hover span, .cat-resizer:focus-visible span, body.resizing .cat-resizer span { background: var(--accent); }
.cat-resizer:hover, body.resizing .cat-resizer { background: var(--accent-soft); }
@container win (max-width: 620px) { .cat-resizer { display: none; } }
label.check.off { opacity: .6; }
/* отмечено несколько строк — кнопка группового изменения сама появляется и выделяется */
.btn.bulk-on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; animation: bulk-in .2s ease-out; }
@keyframes bulk-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
/* строка «[..]» — на уровень выше */
.up-row { cursor: pointer; font-weight: 600; }
.up-ico { display: inline-block; color: var(--accent); font-weight: 700; margin-right: 2px; }
.ag-row.up-row-line .ag-cell, tr.up-row-line td { background: var(--surface-2); }

/* поля формы «потоком»: узкие (номер, дата, число) — по содержимому, остальные растягиваются по ширине окна */
.fields.flow { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-start; }
.win-content .fields.flow { gap: 8px 12px; }
.fields.flow > .field.sz-grow { flex: 1 1 260px; min-width: 200px; }
.fields.flow > .field.sz-narrow { flex: 0 1 170px; min-width: 110px; }
.fields.flow > .field.sz-narrow.t-date { flex-basis: 215px; }
.fields.flow > .field.wide { flex: 1 1 100%; }
.fields.flow > .field.sz-narrow:has(input[type=checkbox]) { flex-basis: auto; }
/* модальное окно (выбор, «на основании», карточка) — по высоте содержимого с небольшим запасом, не выше 88% экрана;
   кнопки формы — всегда внизу окна (если содержимое длиннее — прокрутка, кнопки прилипают к низу) */
.modal-layer .win { height: auto; max-height: min(88vh, 100%); min-height: 180px; }
.modal-layer .win-content { min-height: 0; padding-bottom: 12px; }
.modal-layer .win-content > .page.form-page { flex: 0 0 auto; }
.modal-layer .form-page .tp-stretch > .grid-box.stretch { flex: 0 0 auto; }
@media (max-width: 760px) { .modal-layer .win { height: 100%; max-height: none; } }
/* обмен с 1С */
.onec-help ol, .onec-help ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.onec-help p { margin: 4px 0; }
table.onec-map tr.off td { color: var(--muted); }
.bar.wrap { flex-wrap: wrap; }
/* обновление программы */
.upd-back { z-index: 200; }
.modal.upd { width: min(560px, 100%); }
.upd-vers { display: flex; align-items: center; gap: 16px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.upd-vers > div { display: flex; flex-direction: column; gap: 2px; }
.upd-vers b { font-size: 17px; }
.upd-arrow { font-size: 22px; color: var(--accent); }
.upd-steps ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.upd-stage { font-weight: 600; }
.progress { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.upd-drop { position: fixed; inset: 0; z-index: 190; background: rgba(31, 95, 191, .18); border: 4px dashed var(--accent); display: grid; place-items: center; pointer-events: none; }
.upd-drop > div { background: var(--surface); color: var(--fg); padding: 14px 22px; border-radius: 12px; font-size: 18px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.demo-warn { border-color: var(--warn); background: var(--warn-soft); }
.demo-list { max-height: 140px; overflow: auto; }

/* цены и остатки под списком справочника */
.cat-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.win-content .cat-main.with-stats .grid-box { height: calc(100vh - 400px); min-height: 200px; }
.cat-main.with-stats .grid-box { height: 360px; }
.item-stats { padding: 6px 10px 8px; }
.item-stats .pv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.stats-blocks { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.stats-block { min-width: 0; max-width: 100%; }
.stats-scroll { overflow-x: auto; max-width: 100%; }
.stats-table { border-collapse: collapse; font-size: 0.95em; }
.stats-table th, .stats-table td { border: 1px solid var(--line, #ccc); padding: 2px 10px; white-space: nowrap; }
.stats-table th { background: var(--head, rgba(0,0,0,.04)); font-weight: 600; text-align: center; }
.stats-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.stats-table td.neg { color: #c00; }
.stats-table .tot { font-weight: 700; }

.calc-k.wide { grid-column: span 2; font-size: 15px; }
.calc-hint { font-size: 12px; color: var(--muted, #777); margin-top: 2px; }
.bulk-val { display: flex; gap: 6px; align-items: center; } .bulk-val > select { max-width: 45%; } .bulk-val > :not(select):not(.hint) { flex: 1; min-width: 0; }

/* загрузка из 1С: ход и итоги */
.unf-box { border-left: 4px solid var(--accent); }
.unf-plan td { vertical-align: top; }
.modal.imp-modal { width: min(980px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.imp-modal .modal-head h2 { margin: 0 0 8px; }
.imp-modal .modal-body { overflow: auto; min-height: 0; }
.imp-modal .modal-foot { margin-top: 10px; }
.imp-phase { display: flex; align-items: center; gap: 8px; }
.imp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: imp-pulse 1s ease-in-out infinite; }
@keyframes imp-pulse { 0%, 100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1.15); opacity: 1; } }
.imp-bar { flex: none; position: relative; height: 26px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.imp-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 13px; background: var(--accent); transition: width .35s ease; }
.imp-bar.run i { background-image: linear-gradient(45deg, rgba(255,255,255,.28) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.28) 50%, rgba(255,255,255,.28) 75%, transparent 75%, transparent);
  background-size: 28px 28px; animation: imp-stripes .8s linear infinite; }
.imp-bar.ok i { background: var(--ok, #2e7d32); }
.imp-bar.bad i { background: var(--bad, #c62828); }
.imp-bar span { position: relative; display: block; text-align: center; line-height: 24px; font-weight: 700; color: var(--fg); text-shadow: 0 0 3px var(--surface); }
@keyframes imp-stripes { from { background-position: 0 0; } to { background-position: 28px 0; } }
.imp-stats { flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.imp-stats > div { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; }
.imp-stats b { font-size: 1.1em; }
.imp-cur { font-family: var(--font-num, monospace); font-size: .9em; }
.imp-types table td, .imp-types table th { padding: 4px 8px; }
.imp-types tr.cur td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.imp-types tr.fin td:first-child::before { content: '✓ '; color: var(--ok, #2e7d32); font-weight: 700; }
.imp-mini { display: inline-block; vertical-align: middle; width: calc(100% - 70px); min-width: 60px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-right: 6px; }
.imp-mini i { display: block; height: 100%; background: var(--accent); transition: width .35s ease; }
.imp-types tr.fin .imp-mini i { background: var(--ok, #2e7d32); }
.imp-cards { flex: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.imp-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; display: flex; flex-direction: column; animation: imp-pop .4s ease both; }
.imp-card b { font-size: 1.6em; }
.imp-card.ok b { color: var(--ok, #2e7d32); } .imp-card.bad b { color: var(--bad, #c62828); }
.imp-card:nth-child(2) { animation-delay: .06s; } .imp-card:nth-child(3) { animation-delay: .12s; } .imp-card:nth-child(4) { animation-delay: .18s; } .imp-card:nth-child(5) { animation-delay: .24s; }
@keyframes imp-pop { from { transform: translateY(6px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.imp-err .errors { max-height: 260px; overflow: auto; white-space: pre-wrap; }
@media (max-width: 700px) { .imp-stats, .imp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { .imp-bar.run i, .imp-dot, .imp-card { animation: none; } }
.imp-types { max-height: 42vh; overflow: auto; position: relative; }
.imp-types th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.imp-types td:nth-child(2) { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.imp-types tr.wait td { color: var(--muted, #888); }

/* «Колонки…» — видимость колонок таблицы */
.cols-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 14px; max-height: 50vh; overflow: auto; padding: 4px 2px; }
.cols-list label { display: flex; gap: 6px; align-items: center; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.cols-list label:hover { background: var(--surface-2); }

.onec-map tr.hier-note td { padding-top: 0; border-top: none; }
.onec-map tr.hier-note select { margin-left: 8px; max-width: 260px; }
.warn-note { border-left: 4px solid var(--warn, #c77700); }

/* структура подчинённости */
.rel-tree { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; }
.rel-row { display: flex; align-items: center; gap: 8px; padding: 3px 10px; }
.rel-row.cur { background: var(--accent-soft, rgba(31,95,191,.12)); font-weight: 600; }
.rel-ico { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--muted, #999); flex: none; }
.rel-ico.posted { background: var(--ok, #2e7d32); border-color: var(--ok, #2e7d32); }
.rel-ico.marked { background: var(--bad, #c62828); border-color: var(--bad, #c62828); }

/* рабочий стол: сводка */
.home-sum { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 14px; }
.home-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.home-card { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--fg); cursor: pointer; border-top: 4px solid var(--accent); font: inherit; }
.home-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.home-card b { font-size: 1.45em; }
.home-card.money { border-top-color: var(--ok, #2e7d32); }
.home-card.suppliers, .home-card.bad { border-top-color: var(--bad, #c62828); }
.home-card.prepaid { border-top-color: var(--warn, #c77700); }
.home-card .hc-title { font-weight: 600; }
.hc-parts { display: flex; flex-direction: column; font-size: .85em; color: var(--muted, #777); }
.home-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.home-list h3 { margin: 0 0 6px; }
.hl-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }

pre.bsl { max-height: 380px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; white-space: pre; tab-size: 4; }
ol.steps li { margin: 3px 0; }
.ok-text { color: var(--ok, #2e7d32); }

/* скрытые пользователем элементы интерфейса */
.ui-hidden { display: none !important; }
.hidden-list { max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; }
.hidden-list .bar { padding: 2px 0; }
.hl-row .grow { flex: 1; }

/* окно «Интерфейс»: дерево элементов */
.ui-tree { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; }
.ui-node { display: flex; align-items: center; gap: 8px; padding: 3px 10px; cursor: pointer; }
.ui-node:hover { background: var(--surface-2); }
.ui-node.box > span:first-of-type { font-weight: 600; }
.ui-node.dim { opacity: .45; cursor: default; }

/* избранное и звёздочки в левом меню */
.navrow { position: relative; display: flex; align-items: stretch; }
.navrow .navbtn { flex: 1; min-width: 0; padding-right: 26px; }
.navstar { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; color: var(--muted, #999);
  font-size: 15px; line-height: 1; padding: 4px; opacity: 0; transition: opacity .15s; }
.navrow:hover .navstar, .navstar:focus-visible { opacity: 1; }
.navstar.on { opacity: 1; color: #e0a800; }
.nav-fav .navstar.on { opacity: 0; } .nav-fav .navrow:hover .navstar.on { opacity: 1; }
.nav-setup { margin-top: 10px; color: var(--muted, #888); font-size: .92em; }

.hl-item { padding: 4px 0; border-bottom: 1px solid var(--line); }
.hl-item:last-child { border-bottom: 0; }
.hl-doc { display: flex; align-items: center; gap: 8px; padding-left: 14px; font-size: .9em; }
.hl-doc .grow { flex: 1; }
.hl-doc .btn.link { padding: 0; }

/* подсветка документов по меткам выполнения (оплачен / отгружен / получен) */
.ag-row.st-row-full, tr.st-row-full { background: color-mix(in srgb, var(--ok, #2e7d32) 11%, transparent) !important; }
.ag-row.st-row-partial, tr.st-row-partial { background: color-mix(in srgb, var(--warn, #c77700) 13%, transparent) !important; }
.st-filter button { white-space: nowrap; }
.st-filter button.st-full.on { background: var(--ok-soft, #e3f3e8); color: var(--ok, #2e7d32); }
.st-filter button.st-partial.on { background: var(--warn-soft, #fff1d6); color: var(--warn, #9a5b00); }
.st-filter button.st-none.on { background: var(--bad-soft, #fde7e7); color: var(--bad, #c62828); }

/* обмен с 1С: выбор программы */
.onec-systems { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.onec-sys { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--fg); cursor: pointer; font: inherit; min-width: 240px; text-align: left; }
.onec-sys b { font-size: 1.05em; }
.onec-sys span { font-size: .85em; color: var(--muted, #888); }
.onec-sys.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft, rgba(31,95,191,.08)); }
.imp-bar.indet i { opacity: .55; }
.imp-bar.indet span { color: var(--fg); }
.up-prog .imp-types { max-height: 320px; }
.up-mini { gap: 6px; }
/* компактные метки в списках документов: проведение и кольцо выполнения */
.pst { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; font-weight: 700; line-height: 1; vertical-align: middle; }
.pst.ok { background: var(--ok-soft); color: var(--ok); }
.pst.no { border: 1.5px dashed var(--muted); opacity: .6; width: 15px; height: 15px; }
.pst.del { background: var(--bad-soft); color: var(--bad); }
.st-ring { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.st-ring svg { flex: none; display: block; }
.st-ring .bg { fill: none; stroke: var(--line); stroke-width: 2.5; }
.st-ring.partial .fg { fill: none; stroke: var(--warn); stroke-width: 2.5; stroke-linecap: round; }
.st-ring.full circle { fill: var(--ok); stroke: none; }
.st-ring.full path { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.st-ring b { font-size: 11px; font-weight: 600; color: var(--warn); font-variant-numeric: tabular-nums; }
.st-ring b::after { content: '%'; font-weight: 400; }
.st-ring .sr, .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* сворачиваемые списки рабочего стола: итоги в шапке */
.home-lists { align-items: start; }
.home-fold { padding: 0; overflow: hidden; }
.hf-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; background: none; border: 0; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.hf-head:hover { background: var(--surface-2); }
.hf-arrow { display: inline-block; transition: transform .15s ease; color: var(--muted); }
.home-fold.open .hf-arrow { transform: rotate(90deg); }
.hf-sum { font-size: 1.1em; white-space: nowrap; }
.hf-body { padding: 0 14px 10px; border-top: 1px solid var(--line); }
.hl-scroll { max-height: 360px; overflow: auto; padding-top: 6px; }
.hl-unpaid { flex-wrap: nowrap; }
.hl-unpaid .btn.link.hint { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-unpaid .chip { flex: none; }
/* этикетки */
.lbl-preview { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.lbl-sheet { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); border-radius: 3px; overflow: hidden; flex: none; }
.lbl-dlg { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(240px, 1fr); gap: 16px; }
.lbl-dlg-right { max-height: 70vh; overflow: auto; background: var(--surface-2); border-radius: 8px; padding: 10px; }
.lbl-rows { max-height: 46vh; overflow: auto; }
.lbl-rows tr.off td { opacity: .5; }
.lbl-n { width: 72px; }
.lbl-set-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.lbl-plist { gap: 6px; }
.lbl-pitem { display: flex; flex-direction: column; align-items: flex-start; text-align: left; white-space: normal; }
.lbl-pitem.on { border-color: var(--accent); background: var(--accent-soft); }
.cmt-wrap { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.trk-hint { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .9em; }
@media (max-width: 900px) { .lbl-dlg, .lbl-set-grid { grid-template-columns: 1fr; } }
/* отчёты: даты с–по и итоги */
.rp-dates { display: inline-flex; align-items: center; gap: 6px; }
.rp-dates input { width: auto; }
.rp-sums { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-bottom: 10px; }
.rp-sum { display: flex; flex-direction: column; gap: 2px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-width: 150px; }
.rp-sum b { font-size: 1.25em; }
.rp-cnt { align-self: flex-end; }
.stats-block { flex: 1 1 380px; }
.stats-block .bar { min-height: 26px; }
.stats-hist { margin-top: 6px; }
.owned-list { display: flex; flex-direction: column; }
.owned-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.owned-row.marked .btn { text-decoration: line-through; opacity: .7; }
.owner-filter { margin-bottom: 6px; }
/* окно «Колонки»: вертикальный список с перетаскиванием */
.cols-order { display: flex; flex-direction: column; gap: 2px; max-height: 55vh; overflow: auto; }
.col-item { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; border: 1px solid transparent; background: var(--surface); }
.col-item:hover { background: var(--surface-2); }
.col-item.dragging { opacity: .45; }
.col-item.over-before { box-shadow: inset 0 2px 0 var(--accent); }
.col-item.over-after { box-shadow: inset 0 -2px 0 var(--accent); }
.col-grip { cursor: grab; color: var(--muted); font-size: 16px; line-height: 1; user-select: none; }
.col-item .check { flex: 0 1 auto; }
.col-mv { padding: 0 6px; font-size: 14px; }
.finder-list { list-style: none; margin: 8px 0; padding: 0; max-height: 50vh; overflow: auto; }
.finder-list li { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.finder-list li.hi { background: var(--accent-soft); }
/* таблица: анимация загрузки вместо «Loading…» */
.grid-loading { display: inline-flex; align-items: center; gap: 12px; padding: 14px 22px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 4px 18px rgba(0,0,0,.08); color: var(--fg); font-size: 14px; pointer-events: none; }
.gl-spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: gl-rot .8s linear infinite; }
.gl-bars { display: inline-flex; gap: 3px; align-items: flex-end; height: 16px; }
.gl-bars i { display: block; width: 4px; height: 6px; border-radius: 2px; background: var(--accent); animation: gl-bar 1s ease-in-out infinite; }
.gl-bars i:nth-child(2) { animation-delay: .15s; } .gl-bars i:nth-child(3) { animation-delay: .3s; }
@keyframes gl-rot { to { transform: rotate(360deg); } }
@keyframes gl-bar { 0%, 100% { height: 5px; opacity: .5; } 50% { height: 16px; opacity: 1; } }
.grid-empty { color: var(--muted); font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .gl-spin, .gl-bars i { animation-duration: 2.4s; } }
.rp-cover { display: inline-flex; align-items: center; gap: 6px; }
.rp-cover input { width: 70px; }
.reorder-sum { margin-bottom: 10px; border-left: 4px solid var(--accent); }
/* поиск в списках — всегда справа в строке кнопок, одинаковый */
.bar > input.lead-search { order: 99; flex: 0 0 240px; width: 240px; padding-left: 30px; margin-left: auto;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5L14 14'/%3E%3C/svg%3E") no-repeat 9px center; }
@media (max-width: 700px) { .bar > input.lead-search { flex: 1 1 100%; width: 100%; } }
/* долг контрагента — значок в строке заголовка поля (поле и долг — одна секция, ряд не съезжает) */
.field > label:has(.field-aside) { display: flex; align-items: center; gap: 6px; }
.field-aside { margin-left: auto; display: inline-flex; min-width: 0; order: 2; }
.cp-debt { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 11.5px; font-weight: 500; line-height: 16px;
  padding: 0 8px; border-radius: 9px; border: 1px solid transparent; }
.cp-debt b { font-weight: 700; }
.cp-debt.owe-us { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.cp-debt.we-owe { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.cp-debt.zero { background: var(--ok-soft); color: var(--ok); }
.cp-n { opacity: .75; font-weight: 400; }
.st-bar { margin-top: -4px; }
/* окно раздела (компактное меню): все объекты вида, ☆ — в левое меню */
.section-page .bar h1 { margin: 0; }
.section-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.section-group h3 { margin: 0 0 6px; }
.section-item { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.section-item:last-child { border-bottom: 0; }
.section-open { flex: 1; text-align: left; padding: 7px 4px; display: flex; gap: 8px; align-items: center; }
.section-ico { width: 18px; text-align: center; color: var(--muted); }
.section-item .navstar { position: static; transform: none; opacity: .55; font-size: 18px; padding: 4px 8px; } .section-item:hover .navstar, .section-item .navstar.on { opacity: 1; }
/* компактное меню: ⠿ слева — перетаскивание (как строки в документах); быстрые вызовы — с отступом под разделом */
.nav-dnd { align-items: center; }
.nav-grip { flex: none; width: 16px; margin-right: 2px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1; cursor: grab;
  opacity: .35; user-select: none; }
.nav-dnd:hover .nav-grip { opacity: 1; }
.nav-grip:active { cursor: grabbing; }
.nav-sub { padding-left: 16px; }
.nav-sub .navbtn { font-size: .93em; padding-top: 5px; padding-bottom: 5px; }
.nav-sub .navbtn.on, .nav-sub .navbtn:hover { color: var(--accent); }
.navrow.dragging { opacity: .4; }
.navrow.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.navrow.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
/* звёздочка в меню — только при наведении на строку (не «висит») */
nav.side .navstar, nav.side .navstar.on { opacity: 0; }
nav.side .navrow:hover .navstar { opacity: 1; }
nav.side.compact .navrow:not(.nav-dnd) { padding-left: 18px; }
/* окно раздела: звёздочка всегда в своей колонке справа, длинные названия переносятся */
.section-groups { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.section-item { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: center; }
.section-open { min-width: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; }
.section-item .navstar { justify-self: center; width: 32px; }
nav.side .navbtn.on:focus-visible { outline: none; }
/* значок перетаскивания — как у строк таблиц */
.grip-ico { display: block; }
.nav-grip { width: 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); opacity: .55; }
.nav-dnd:hover .nav-grip { opacity: 1; color: var(--fg); }
.col-grip { display: inline-flex; align-items: center; }
/* Alt+` — переключатель окон, как Alt+Tab */
.win-switch { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 9000; min-width: 360px; max-width: min(640px, 92vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.28); padding: 10px; }
.ws-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 9px; cursor: pointer; }
.ws-item.on { background: var(--accent); color: #fff; }
.ws-item.on .hint { color: rgba(255,255,255,.8); }
.ws-item.min { opacity: .8; }
.ws-ico { width: 20px; text-align: center; }
.ws-t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-help { padding: 8px 6px 2px; font-size: 12px; }
/* объект сейчас редактирует другой пользователь — отметка в списке */
.row-lock { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 0 7px; border-radius: 9px; font-size: 11px; line-height: 17px;
  font-weight: 600; background: #fff1d6; color: #8a5300; border: 1px solid #f0c983; white-space: nowrap; vertical-align: middle; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.ag-row.row-locked { box-shadow: inset 3px 0 0 #e0a000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .row-lock { background: #3a2a0c; color: #ffc766; border-color: #6b4c12; } }
:root[data-theme="dark"] .row-lock { background: #3a2a0c; color: #ffc766; border-color: #6b4c12; }
/* пустая таблица / ничего не найдено — картинка с текстом вместо «No Rows» */
.grid-box { position: relative; }
.grid-empty-ov { position: absolute; inset: 48px 0 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  pointer-events: none; text-align: center; padding: 16px; color: var(--muted); }
.grid-empty-ov b { color: var(--fg); font-size: 15px; }
.grid-empty-ov span { max-width: 420px; font-size: 13px; }
.ge-pic { margin-bottom: 4px; }
.ge-sheet { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.5; }
.ge-line { fill: var(--line); }
.ge-glass { fill: var(--surface); stroke: var(--accent); stroke-width: 4; }
.ge-handle { stroke: var(--accent); stroke-width: 6; stroke-linecap: round; }
.ge-dot { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.ge-plus { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
/* своя картинка вместо встроенных надписей AG Grid о пустой таблице (иначе текст двоится) */
.grid-box .ag-overlay-no-rows-wrapper, .grid-box .ag-overlay-no-rows-center, .grid-box .ag-overlay-no-matching-rows-wrapper,
.grid-box [class*="no-matching-rows"], .grid-box [class*="no-rows"] { display: none !important; }

/* --- рабочий стол: валовая прибыль за сутки */
.home-gross { display: flex; flex-direction: column; gap: 12px; margin: 10px 0 14px; }
.hg-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hg-toggle { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 2px 0; cursor: pointer; color: inherit; font: inherit; font-size: 1.05em; }
.home-gross:not(.closed) .hg-toggle .hf-arrow { transform: rotate(90deg); }
.hg-day { width: auto; padding: 3px 6px; }
.hg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.hg-cards > div { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.hg-cards b { font-size: 1.25em; }
.hg-cards .hg-main { border-top: 3px solid var(--ok); }
.hg-cards .hg-main b { font-size: 1.45em; }
.hg-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .hg-body { grid-template-columns: 1fr; } }
.hg-hours { margin: 0; }
.hg-hours svg { width: 100%; height: auto; display: block; }
.hg-pos { fill: var(--c2, var(--ok)); }
.hg-neg { fill: var(--bad); }
.hg-axis { stroke: var(--line); stroke-width: 1; }
.hg-tick { fill: var(--muted); font-size: 10px; text-anchor: middle; font-family: var(--font-num); }
.hg-top { display: flex; flex-direction: column; gap: 4px; }
.hg-top .fill.neg { background: var(--bad); }

/* панель «Цены и остатки» под списком: таблица по числу строк — «Итого» сразу под строками (общий min-height окон его отрывал) */
.win-content .item-stats .grid-box, .item-stats .grid-box { min-height: 0; }

/* ================= рабочий стол: шапка, закладки по темам, карточки, блоки, анимации ================= */
.home { --home-gap: 14px; }
.home-top { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.home-top h1 { margin: 0 0 2px; }
.home-top .hint { text-transform: none; }
.home-top .hint::first-letter { text-transform: uppercase; }
.home-quick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.home-quick .btn { animation: home-rise .35s ease-out both; animation-delay: calc(var(--i, 0) * 40ms); }

.home-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 var(--home-gap); overflow-x: auto; scrollbar-width: none; }
.home-tab { position: relative; background: none; border: 0; padding: 9px 14px 10px; font: inherit; font-weight: 600; color: var(--muted);
  cursor: pointer; white-space: nowrap; border-radius: 8px 8px 0 0; transition: color .15s ease, background .15s ease; }
.home-tab:hover { color: var(--fg); background: var(--surface-2, var(--accent-soft)); }
.home-tab::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0;
  background: var(--accent); transform: scaleX(0); transition: transform .22s ease; }
.home-tab.on { color: var(--accent); }
.home-tab.on::after { transform: scaleX(1); }
.home-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ht-badge { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; font-size: 11px; line-height: 18px;
  text-align: center; background: var(--bad-soft); color: var(--bad); }
.home-page { display: flex; flex-direction: column; gap: var(--home-gap); animation: home-fade .28s ease-out both; }

/* карточки ключевых цифр */
.home .home-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.home .home-card { position: relative; overflow: hidden; gap: 6px; padding: 14px 16px 12px; border-radius: 14px; border: 1px solid var(--line);
  border-top: 3px solid var(--accent); background: var(--surface); cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  animation: home-rise .4s cubic-bezier(.2,.7,.3,1) both; animation-delay: calc(var(--i, 0) * 60ms); }
.home .home-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.10); }
.home .home-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.home .home-card b { font-size: 1.55em; letter-spacing: -.01em; }
.home .home-card .hc-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); }
.hc-ico { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; font-style: normal; font-size: 13px;
  background: var(--accent-soft); color: var(--accent); flex: none; }
.home-card.money { border-top-color: var(--ok); } .home-card.money .hc-ico { background: var(--ok-soft); color: var(--ok); }
.home-card.buyers { border-top-color: var(--accent); }
.home-card.suppliers, .home-card.bad { border-top-color: var(--bad); } .home-card.suppliers .hc-ico { background: var(--bad-soft); color: var(--bad); }
.home-card.prepaid { border-top-color: var(--warn); } .home-card.prepaid .hc-ico { background: var(--warn-soft, var(--accent-soft)); color: var(--warn); }
.home-card.sales { border-top-color: var(--c4, var(--accent)); }

/* основной блок: слева прибыль, справа «требует внимания» */
.home-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: var(--home-gap); align-items: start; }
.home-main.single { grid-template-columns: 1fr; }
@media (max-width: 1100px) { .home-main { grid-template-columns: 1fr; } }
.home-block { margin: 0; padding: 14px 16px; border-radius: 14px; animation: home-rise .45s cubic-bezier(.2,.7,.3,1) both; animation-delay: .12s; }
.home-block + .home-block { animation-delay: .2s; }
.hb-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.hb-head h2 { margin: 0; font-size: 1.05em; }
.home-money { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: var(--home-gap); align-items: start; }
.home-money .hl-scroll { max-height: 62vh; }

/* валовая прибыль */
.home .home-gross { gap: 0; margin: 0; }
.hg-nav { display: flex; align-items: center; gap: 4px; }
.hg-stats { display: grid; grid-template-columns: minmax(180px, auto) 1fr; gap: 10px 24px; align-items: center; padding: 4px 0 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px; }
@media (max-width: 640px) { .hg-stats { grid-template-columns: 1fr; } }
.hg-hero { display: flex; flex-direction: column; gap: 2px; }
.hg-hero b { font-size: 2em; letter-spacing: -.02em; line-height: 1.15; }
.hg-diff { font-size: 12px; color: var(--muted); }
.hg-diff.up { color: var(--ok); } .hg-diff.down { color: var(--bad); }
.hg-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 16px; margin: 0; }
.hg-facts div { min-width: 0; }
.hg-facts dt { font-size: 12px; color: var(--muted); }
.hg-facts dd { margin: 2px 0 0; font-weight: 600; font-size: 1.08em; }
.home-gross .hg-body { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.home-main .home-gross .hg-body { grid-template-columns: 1fr; }
.home-main .home-gross .hg-top { border-top: 1px dashed var(--line); padding-top: 10px; }
.hg-empty { padding: 26px 0; text-align: center; color: var(--muted); }
.hg-pos, .hg-neg { transform-box: fill-box; transform-origin: 50% 100%; animation: hg-grow .55s cubic-bezier(.2,.8,.3,1) both; }
.hg-neg { transform-origin: 50% 0; }
.hg-now .hg-pos { fill: var(--accent); }
.hg-nowbg { fill: var(--accent-soft); opacity: .6; }
.hg-days { margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.hg-days svg { width: 100%; height: auto; display: block; }
.hg-dayg { cursor: pointer; outline: none; }
.hg-hit { fill: transparent; }
.hg-dayg:hover .hg-hit, .hg-dayg:focus-visible .hg-hit { fill: var(--accent-soft); }
.hg-dayg.sel .hg-hit { fill: var(--accent-soft); }
.hg-dayg.sel .hg-pos { fill: var(--accent); }
.hg-tick.sel { fill: var(--accent); font-weight: 600; }
.hg-top .barrow { animation: home-rise .35s ease-out both; animation-delay: calc(.15s + var(--i, 0) * 45ms); }
.hg-top .fill { transform-origin: left center; animation: bar-in .7s cubic-bezier(.2,.8,.3,1) both; animation-delay: calc(.2s + var(--i, 0) * 45ms); }
.hg-skel { display: grid; gap: 10px; padding: 6px 0; }
.hg-skel i { display: block; height: 18px; border-radius: 6px; background: linear-gradient(90deg, var(--line) 25%, var(--surface-2, var(--bg)) 50%, var(--line) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.hg-skel i:nth-child(1) { width: 40%; height: 32px; } .hg-skel i:nth-child(2) { width: 85%; } .hg-skel i:nth-child(3) { height: 110px; }

/* «требует внимания» и списки долгов */
.home .home-fold { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.home .home-fold + .home-fold { margin-top: 10px; }
.home .hf-head { padding: 10px 12px; }
.home .hf-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hf-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.home-fold.open .hf-wrap { grid-template-rows: 1fr; }
.hf-inner { min-height: 0; overflow: hidden; }
.home .hf-body { padding: 0 12px 8px; }
.home-attn .hl-scroll { max-height: 300px; }
.home .hl-doc { padding: 4px 0 4px 2px; border-radius: 6px; transition: background .12s ease; animation: home-fade .3s ease-out both; animation-delay: calc(var(--i, 0) * 25ms); }
.home .hl-doc:hover { background: var(--surface-2, var(--accent-soft)); }
.hl-unpaid { display: grid !important; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; }
.hl-who { display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; }
.hl-who .btn.link { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.home .hl-unpaid .btn.link.hint { max-width: none; flex: 1 1 auto; }
.hl-sum { white-space: nowrap; text-align: right; }

/* разделы */
.home-tiles .tile { animation: home-rise .4s ease-out both; animation-delay: calc(var(--i, 0) * 50ms); transition: box-shadow .18s ease, transform .18s ease; }
.home-tiles .tile:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-1px); }
.home-tiles .tile h3 { margin: 0 0 6px; }

@keyframes home-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes home-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes hg-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes bar-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .home *, .home *::before, .home *::after { animation: none !important; transition: none !important; }
}
/* графики рабочего стола: столбики растягиваются по ширине, подписи — текстом (не масштабируются вместе с картинкой) */
.hg-chart { position: relative; padding-bottom: 20px; }
.hg-svg { display: block; width: 100%; height: 130px; overflow: visible; }
.hg-svg.days { height: 110px; }
.hg-ticks { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; font: 11px/18px var(--font-num); color: var(--muted); }
.hg-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.hg-ticks span:first-child { transform: translateX(-30%); }
.hg-ticks span:last-child { transform: translateX(-75%); }
.hg-ticks span.sel { color: var(--accent); font-weight: 600; }
.home .home-cards { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.home-nodebt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 16px; text-align: center; }
.hnd-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: 22px;
  animation: pop .45s cubic-bezier(.2,1.4,.4,1) both .1s; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* неоплаченные реализации — таблицей */
.ut-wrap { max-height: 62vh; overflow: auto; margin: 0 -2px; }
.ut-wrap.compact { max-height: none; }
.ut { width: 100%; border-collapse: collapse; font-size: .92em; }
.ut thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 600; color: var(--muted);
  font-size: 12px; padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ut th.num, .ut td.num { text-align: right; }
.ut-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.ut-sort:hover { color: var(--fg); }
.ut td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.ut tbody tr { animation: home-fade .3s ease-out both; animation-delay: calc(var(--i, 0) * 22ms); transition: background .12s ease; }
.ut tbody tr:hover { background: var(--surface-2, var(--accent-soft)); }
.ut tbody tr:last-child td { border-bottom: 0; }
.ut .btn.link { padding: 0; }
.ut-cp { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.ut-cp .btn.link { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.ut-sum b { font-weight: 600; }
.ut-sum .hint { display: block; font-size: 11px; }
.compact .ut-cp { max-width: 110px; }
.ut-more { display: block; margin: 6px 0 0 auto; }
.home .home-fold .hf-title { white-space: normal; }
.home-money > .home-fold { margin: 0; animation: home-rise .45s cubic-bezier(.2,.7,.3,1) both .12s; }
.home-money > .home-fold + .home-fold { margin: 0; animation-delay: .2s; }
/* закрытые заказы: оплачены полностью и получены (отгружены) полностью */
.closed-badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px; font: 600 10.5px/16px var(--font-ui);
  background: var(--ok); color: var(--surface); vertical-align: 1px; letter-spacing: .02em; }
.ag-row.st-row-closed { box-shadow: inset 3px 0 0 var(--ok); }
.ag-row.st-row-closed .ag-cell { color: var(--muted); }
.ag-row.st-row-closed .ag-cell .closed-badge { color: var(--surface); }
.chip.closed-chip { background: var(--ok); color: var(--surface); border-color: var(--ok); font-weight: 600; }
/* колонки-значки (проведён, кольца выполнения): шириной со значок, без подписи — название в подсказке */
.ag-header-cell.hdr-icon { padding-left: 0 !important; padding-right: 0 !important; }
.ag-header-cell.hdr-icon .ag-header-cell-label { justify-content: center; }
.ag-cell.cell-icon { padding-left: 0 !important; padding-right: 0 !important; }
.st-ring b { display: none; }
.ut-date { font-family: var(--font-num); font-size: .95em; }
/* панель отборов по выполнению: одна «Все», в группах — только значения */
.st-bar { align-items: center; gap: 8px; flex-wrap: wrap; }
.st-all.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.st-filter { align-items: stretch; }
.st-cap { display: inline-flex; align-items: center; padding: 0 8px 0 10px; font-size: 12px; font-weight: 600; color: var(--muted);
  border-right: 1px solid var(--line); background: var(--surface-2, var(--bg)); white-space: nowrap; }
.st-filter button.zero { opacity: .5; }
.st-filter button.zero.on { opacity: 1; }
/* плитки разделов: каждая ссылка — своей строкой, длинное название переносится, не вылезает за плитку */
.home-tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); align-items: start; }
.home-tiles .tile { min-width: 0; overflow: hidden; }
.tile-links { display: flex; flex-direction: column; gap: 1px; }
.tile-link { display: flex !important; align-items: flex-start; gap: 7px; width: 100%; min-width: 0; text-align: left; padding: 4px 6px !important;
  border-radius: 6px; white-space: normal; height: auto; line-height: 1.3; }
.tile-link:hover { background: var(--accent-soft); }
.tile-link .tl-text { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.tile-link .section-ico { flex: none; width: 16px; text-align: center; color: var(--muted); opacity: .8; font-size: 12px; line-height: 1.3; }
.home-tab:focus:not(:focus-visible) { outline: none; box-shadow: none; }
.tl-ico { flex: none; margin-top: 2px; fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.tile-link:hover .tl-ico { stroke: var(--accent); }
/* справочник: фото не выше 220 px (колонка не длиннее списка с ценами и остатками), список — на освободившуюся высоту */
.cat-left .item-pv .pv-img { width: 100%; max-height: 220px; max-width: 220px; margin: 0 auto; }
.cat-left .item-pv { gap: 6px; }
.cat-left .item-pv .pv-name { text-align: center; }
.cat-left .item-pv > .btn { align-self: center; }
.win-content .cat-main.with-stats .grid-box { height: calc(100vh - 380px); }
.win-content .cat-main:not(.with-stats) .grid-box { height: calc(100vh - 200px); }
