/* Финансы магазина: стили. Темы: светлая и тёмная (по системе). */
html { color-scheme: light; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
/* Layout: sticky top bar (title, branch + period filters), tabs, then single-column work area with KPI strip, branch comparison, chart, categories. */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --fg: #151a26;
  --muted: #5d6579;
  --line: #dde0e8;
  --accent: #26407a;
  --accent-fg: #ffffff;
  --aktau: #26407a;
  --aktobe: #b7791f;
  --good: #167a4a;
  --good-bg: #e0f3e9;
  --bad: #b3322c;
  --bad-bg: #fbe5e3;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e121b; --surface: #171c28; --surface-2: #202737; --fg: #e8ebf3; --muted: #97a0b5; --line: #2a3246;
    --accent: #7f9bdc; --accent-fg: #0e121b; --aktau: #7f9bdc; --aktobe: #e0a44a;
    --good: #4fc58a; --good-bg: #15301f; --bad: #ef7a72; --bad-bg: #3a1c1b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e121b; --surface: #171c28; --surface-2: #202737; --fg: #e8ebf3; --muted: #97a0b5; --line: #2a3246;
  --accent: #7f9bdc; --accent-fg: #0e121b; --aktau: #7f9bdc; --aktobe: #e0a44a;
  --good: #4fc58a; --good-bg: #15301f; --bad: #ef7a72; --bad-bg: #3a1c1b; color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.45; padding-inline: 16px; padding-block: 0 48px; }
.wrap { max-width: 1080px; margin: 0 auto; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding-block: 14px 10px; display: grid; gap: 12px; border-bottom: 1px solid var(--line); box-shadow: 0 0 0 100vmax var(--bg); clip-path: inset(0 -100vmax); }
.top-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.brand small { }
@media (max-width: 520px) { .kpi { padding: 10px 14px; } .kpi .v { font-size: 22px; } .brand small { display: none; } header.top { padding-block: 10px 6px; gap: 8px; } }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
select, input[type=text], input[type=date], input[type=number], input[type=email], input[type=password], input[type=month], textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; width: 100%; }
.filters select { width: auto; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; }
nav.tabs button { border: 0; background: none; padding: 8px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }

main { display: grid; gap: 18px; padding-top: 18px; }
section.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.panel h2 { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.panel h2 span { font-size: 12px; font-weight: 500; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.profit .v.neg { color: var(--bad); }
.kpi.profit .v.pos { color: var(--good); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.in { background: var(--good-bg); color: var(--good); }
.pill.out { background: var(--bad-bg); color: var(--bad); }
.in-t { color: var(--good); } .out-t { color: var(--bad); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bar-track { background: var(--surface-2); border-radius: 5px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bad); border-radius: 5px; }
.bar-fill.inc { background: var(--good); }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 13px; font-weight: 500; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.form .wide { grid-column: span 2; }
@media (max-width: 480px) { .form .wide { grid-column: span 1; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty h3 { color: var(--fg); font-size: 17px; margin-bottom: 6px; }
.empty .actions { justify-content: center; margin-top: 14px; }
.note { font-size: 13px; color: var(--muted); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 9px; font-weight: 500; z-index: 20; max-width: calc(100% - 32px); }
textarea { min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.pnl td:first-child, .pnl th:first-child { position: sticky; left: 0; background: var(--surface); min-width: 190px; }
.pnl tr.sub td { font-weight: 700; background: var(--surface-2); }
.pnl tr.sub td:first-child { background: var(--surface-2); }
.pnl tr.tot td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--fg); }
.pnl tr.ind td:first-child { padding-left: 26px; color: var(--muted); }
.pnl td.p { color: var(--muted); font-size: 13px; }
.pnl .neg { color: var(--bad); }
.pill.tr { background: var(--surface-2); color: var(--muted); }
.sumrow td { border-top: 2px solid var(--line); }
.filters.dim { opacity: .35; pointer-events: none; }
.list { display: grid; gap: 0; }
.item { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item.add { border-bottom: 0; padding-bottom: 0; margin-top: 8px; }
.item.edit { background: var(--surface-2); border-radius: 8px; padding: 10px; border-bottom: 0; margin-block: 4px; }
.item input, .item select { width: auto; flex: 1 1 150px; }
.item .grow { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.item .bal { text-align: right; }
.mv { display: grid; gap: 3px; }
.mv .btn { padding: 1px 9px; line-height: 1.2; }
.btn:disabled { opacity: .35; cursor: default; }
.delbox { flex-basis: 100%; background: var(--bad-bg); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.delbox .actions { margin-top: 8px; align-items: center; }
.grid2.one { grid-template-columns: minmax(0, 1fr); }
.item.sub { margin-left: 30px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.item.sub.edit, .item.sub.add { border-bottom: 0; }
.pnl tr.ind2 td { color: var(--muted); font-size: 13px; }
.pnl tr.ind2 td:first-child { padding-left: 84px; }
.pnl tr.grp td { font-weight: 600; }
.pnl tr.ind3 td { color: var(--muted); font-size: 12px; }
.pnl tr.ind3 td:first-child { padding-left: 106px; }
.grpadd { flex-basis: 100%; }
.grpadd { min-width: 0; }
.grpadd select { width: auto; max-width: 100%; min-width: 0; font-size: 13px; padding: 5px 8px; color: var(--muted); text-overflow: ellipsis; }
@media (max-width: 520px) { .grpadd select { width: 100%; } .item .actions { flex-wrap: wrap; } }
.item { min-width: 0; }
.list { min-width: 0; }
.filters input[type=month], .filters input[type=date] { width: auto; }
.rng[hidden], [hidden] { display: none !important; }
.rng { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.kpi .d { font-size: 12px; margin-top: 6px; color: var(--muted); font-weight: 500; }
.kpi .d.up-good { color: var(--good); } .kpi .d.up-bad { color: var(--bad); }
.pnl#ddsTable td:first-child, #ddsTable th:first-child { min-width: 170px; }
.item .lbl { display: grid; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; flex: 1 1 200px; }
.item .lbl select { width: 100%; }
.chips { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 99px; padding: 3px 4px 3px 11px; font-size: 13px; }
.chip button { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 6px; border-radius: 50%; }
.chip button:hover { color: var(--bad); }
.autoln { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.autoln:last-child { border-bottom: 0; }
.item.sublt { background: var(--surface-2); border-radius: 8px; padding: 10px; margin-block: 4px; border-bottom: 0; }
.pnl tr.blk td { font-weight: 600; border-top: 1px solid var(--line); }
.arts { flex-basis: 100%; min-width: 0; }
.arts .item.sub.art { border-bottom: 1px dashed var(--line); }
.arts-add { margin: 6px 0 2px 30px; }
.tg { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 5px; width: 20px; height: 20px; line-height: 1; padding: 0; margin-right: 8px; font-weight: 600; font-size: 14px; vertical-align: middle; }
.tg:hover { color: var(--fg); border-color: var(--muted); }
.tg-sp { display: inline-block; width: 28px; }
.pnl td.r .amt { display: inline-block; }
.pnl td.r .pc { display: inline-block; min-width: 38px; margin-left: 8px; color: var(--muted); font-size: 11px; font-weight: 500; opacity: .85; text-align: right; }
.pnl tr.sub td .pc, .pnl tr.tot td .pc { font-weight: 500; }
.pnl th { padding: 6px 10px; font-size: 11px; }
.pnl td { padding: 4px 10px; font-size: 13px; line-height: 1.3; }
.pnl tr.sub td, .pnl tr.blk td { font-size: 13px; }
.pnl tr.tot td { font-size: 14.5px; padding-block: 6px; }
.pnl tr.ind td:first-child { font-size: 13px; }
.pnl tr.ind2 td { font-size: 12px; }
.pnl tr.ind3 td { font-size: 11px; }
.pnl td.r .pc { font-size: 10.5px; min-width: 34px; margin-left: 6px; }
.pnl .tg { width: 17px; height: 17px; font-size: 13px; margin-right: 7px; }
.pnl .tg-sp { width: 24px; }
.seg.off { opacity: .4; pointer-events: none; }
.filebtn { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; position: relative; cursor: pointer; }
.filebtn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.filebtn.dis { opacity: .5; cursor: not-allowed; }
.filebtn:focus-within .btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.impmap { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.impmap h3 { font-size: 14px; margin-bottom: 10px; }
.form .hint { font-weight: 400; font-size: 11px; color: var(--muted); }
.form label.chk { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--fg); font-weight: 500; }
.form label.chk input { width: auto; }
.impsum { margin: 14px 0 10px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 14px; }
.impbulk { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 10px; font-size: 14px; }
.impbulk select { width: auto; max-width: 100%; min-width: 200px; }
.imptbl { max-height: 72vh; min-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.imptbl table { min-width: 640px; }
.imptbl th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.imptbl td { padding: 5px 10px; font-size: 13px; }
.imptbl td.desc { max-width: 320px; overflow-wrap: anywhere; }
.imptbl select { padding: 4px 8px; font-size: 13px; min-width: 180px; }
.imptbl select.need { border-color: var(--bad); background: var(--bad-bg); }
.imptbl input[type=checkbox] { width: auto; }
.imptbl tr.off td { opacity: .45; }
.status { font-size: 12px; color: var(--muted); }

/* вход и пользователь */
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .who { display: grid; text-align: right; font-weight: 600; font-size: 13px; line-height: 1.2; }
.userbox .who small { font-weight: 500; font-size: 11px; color: var(--muted); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: grid; gap: 14px; }
.login-card h1 { font-size: 20px; letter-spacing: -0.01em; }
.login-card label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.login-card .err { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.linkbtn { border: 0; background: none; color: var(--accent); font-weight: 500; padding: 4px; }

.imptbl td.artcell { white-space: nowrap; }
.imptbl td.artcell select + select { margin-left: 6px; min-width: 130px; }
.impsum.okbox { background: var(--good-bg); color: var(--good); }
.impsum.badbox { background: var(--bad-bg); color: var(--bad); }

/* Таблица импорта прокручивается вместе со страницей, заголовок колонок прилипает под шапкой */
.imptbl, .imptbl.scroll { max-height: none; min-height: 0; overflow: visible; }
.imptbl th { top: var(--hdr-h, 0px); z-index: 2; }
@media (max-width: 860px) {
  .imptbl, .imptbl.scroll { overflow-x: auto; }
  .imptbl th { position: static; }
}
.imptbl td.artcell { white-space: normal; min-width: 190px; }
.imptbl td.artcell select { display: block; width: 100%; }
.imptbl td.artcell select + select { margin: 4px 0 0; min-width: 0; }
.imptbl table { min-width: 0; width: 100%; }
.imptbl td.desc { max-width: 280px; }
.impauto { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.impauto .autotbl { width: 100%; margin-top: 8px; }
.impauto .autotbl td { padding: 4px 8px; font-size: 13px; }
.warnbox { background: var(--surface-2); border: 1px solid var(--line); }

/* Шапка в одну строку: название, точки и период, пользователь */
header.top { gap: 8px; padding-block: 10px 6px; }
.top-row { flex-wrap: wrap; gap: 8px 16px; justify-content: flex-start; }
.top-row .brand { margin-right: auto; }
.top-row .userbox { margin-left: auto; }
.top-row .filters { order: 2; }
.top-row .userbox { order: 3; }
@media (max-width: 860px) { .top-row .brand { margin-right: 0; } .top-row .filters { order: 4; flex-basis: 100%; } .top-row .userbox { margin-left: auto; order: 2; } }
.seg.store button { min-width: 88px; }

/* компактный импорт */
.impctl { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.impctl .sm, select.sm { width: auto; max-width: 260px; padding: 6px 8px; font-size: 13px; }
.filebtn { gap: 8px; }
.btn.small.primary { padding: 6px 12px; font-size: 13px; font-weight: 600; }
.impchips { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: 12px; }
.chip2 { display: inline-flex; gap: 4px; align-items: center; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); font-size: 12.5px; white-space: nowrap; }
.chip2.ok { background: var(--good-bg); color: var(--good); }
.chip2.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.chip2.warn { background: #fdf0d9; color: #8a5a00; }
.chip2.in b { color: var(--good); } .chip2.out b { color: var(--bad); }
.btnchip { border: 0; cursor: pointer; font-family: inherit; color: var(--fg); }
.impauto { margin: 8px 0 0; }
.impbar { position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin: 10px -16px -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; font-size: 13px; }
.bad-t { color: var(--bad); font-weight: 600; } .ok-t { color: var(--good); font-weight: 600; }
.panel.slim { padding: 10px 16px; }
.slimrow { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.panel.drop.over { outline: 2px dashed var(--accent); outline-offset: -6px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip2.warn { background: #3a2c10; color: #f0c26a; } }
:root[data-theme="dark"] .chip2.warn { background: #3a2c10; color: #f0c26a; }

.acctform { display: grid; grid-template-columns: minmax(150px,1.4fr) 130px 130px minmax(170px,1.3fr) 110px auto; gap: 8px 10px; align-items: end; }
.acctform .lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted, #667); min-width: 0; }
.item.acctform input, .item.acctform select { width: 100%; min-width: 0; flex: none; }
.item.acctform .lbl { flex: none; display: flex; flex-direction: column; }
.acctform .actions { display: flex; gap: 6px; }
@media (max-width: 900px) { .acctform { grid-template-columns: 1fr 1fr; } .acctform .f-name, .acctform .f-iban { grid-column: 1 / -1; } }
.warnbox { padding: 8px 12px; border-radius: 8px; font-size: 13px; margin: 8px 0; }
.warnbox.bad { background: #fdecec; border-color: #f3b7b7; color: #9b1c1c; }
.panel.rules h2 { font-size: 15px; margin: 0 0 8px; }
.panel.rules ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.panel.rules li b { color: var(--text, inherit); }
.rules-h { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; background: none; padding: 0; cursor: pointer; color: inherit; text-align: left; }
.rules-h h2 { margin: 0 !important; }
.rules-h .arr { color: var(--accent); font-size: 18px; padding: 0 4px; }
.panel.rules ol { margin-top: 10px; }
.archblk { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 6px; }
.archblk .item { opacity: .8; }

@media (max-width: 700px) { header.top { position: static; } .imptbl th { top: 0 !important; } }
