:root {
  --ground: #F3F6F5; --surface: #FFFFFF; --surface-2: #EEF2F0; --ink: #13201B; --ink-2: #3A4944; --muted: #5F6E68; --line: #DFE5E2;
  --accent: #2A78D6; --accent-soft: #E6F0FB; --accent-ink: #1F5FAE;
  --exp: #EB6834; --exp-soft: #FDEDE5; --exp-ink: #B4461A;
  --good: #0B8A3E; --good-soft: #E3F4EA; --bad: #C93434; --bad-soft: #FBE7E7; --warn: #7A5000; --warn-soft: #FBF0D5;
  --seg-tax: #8A969F; --seg-fee: #B5BEC4; --seg-voice: #EB6834; --seg-exp: #C93434; --seg-me: #2A78D6; --seg-partner: #7FB0EC;
  --display: "Onest", "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0E1311; --surface: #151C19; --surface-2: #1C2521; --ink: #E5EDE9; --ink-2: #C3CFCA; --muted: #95A39D; --line: #27322E;
    --accent: #3987E5; --accent-soft: #16263A; --accent-ink: #9CC3F5;
    --exp: #D95926; --exp-soft: #33201A; --exp-ink: #F0A07C;
    --good: #4CC27E; --good-soft: #14291D; --bad: #E66767; --bad-soft: #3A1C1C; --warn: #E8C06A; --warn-soft: #332910;
    --seg-tax: #6F7B83; --seg-fee: #4B555C; --seg-voice: #D95926; --seg-exp: #E66767; --seg-me: #3987E5; --seg-partner: #2C5A90;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0E1311; --surface: #151C19; --surface-2: #1C2521; --ink: #E5EDE9; --ink-2: #C3CFCA; --muted: #95A39D; --line: #27322E;
  --accent: #3987E5; --accent-soft: #16263A; --accent-ink: #9CC3F5;
  --exp: #D95926; --exp-soft: #33201A; --exp-ink: #F0A07C;
  --good: #4CC27E; --good-soft: #14291D; --bad: #E66767; --bad-soft: #3A1C1C; --warn: #E8C06A; --warn-soft: #332910;
  --seg-tax: #6F7B83; --seg-fee: #4B555C; --seg-voice: #D95926; --seg-exp: #E66767; --seg-me: #3987E5; --seg-partner: #2C5A90;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
h1, h2, h3 { margin: 0; font-family: var(--display); text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { padding: 40px 16px; color: var(--muted); text-align: center; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 16px/1.2 var(--display); padding: 0 8px; }
.brand i { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; font-style: normal; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 10px; border-radius: 10px; cursor: pointer; font-weight: 500; color: var(--ink-2); text-align: left; min-height: 42px; }
.nav button:hover { background: var(--surface-2); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.nav svg { width: 19px; height: 19px; flex-shrink: 0; }
.who { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 8px; font-size: 13px; color: var(--muted); }
.who b { color: var(--ink-2); font-weight: 600; }
.linkbtn { border: 0; background: none; padding: 4px 0; color: var(--accent-ink); cursor: pointer; font-size: 13px; text-align: left; font-weight: 500; }

.main { min-width: 0; padding-inline: 28px; padding-block: 22px 60px; display: flex; flex-direction: column; gap: 18px; max-width: 1160px; width: 100%; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.top h1 { margin-right: auto; }
.pills { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--surface-2); border-radius: 11px; padding: 3px; }
.pills button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink-2); min-height: 36px; }
.pills button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
/* .btn задаёт display — без .btn.gear кнопка «Настройки» дублировала меню на компьютере */
.btn.gear { display: none; }
.custom-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent-ink); border-radius: 10px; padding: 4px 6px 4px 12px; font-size: 14px; font-weight: 500; }
.custom-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; width: 28px; height: 28px; border-radius: 8px; }
.custom-chip button:hover { background: var(--surface); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; gap: 10px 12px; flex-wrap: wrap; }
.panel-head h2 { margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.hero > div { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; min-width: 0; border-left: 1px solid var(--line); }
.hero > div:first-child { border-left: 0; background: var(--accent-soft); }
.hero .k { font-size: 13.5px; color: var(--muted); }
.hero > div:first-child .k { color: var(--accent-ink); }
.hero .v { font: 700 34px/1.1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero > div:first-child .v { color: var(--accent-ink); }
.hero .s { font-size: 13px; color: var(--muted); }
.hero .btn { align-self: flex-start; margin-top: 6px; }
.warn { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 14px; }
.warn b { color: inherit; }
.warn .btn { margin-left: auto; }
.errbox { background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 14px; }

.hundred { display: flex; height: 46px; border-radius: 10px; overflow: hidden; gap: 2px; background: var(--surface); }
.hundred > div { display: flex; align-items: center; justify-content: center; min-width: 0; color: #fff; font: 600 13px/1.1 var(--display); text-align: center; padding: 0 2px; overflow: hidden; white-space: nowrap; }
.hundred .lt { color: var(--ink); }
.hundred-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--ink-2); }
.hundred-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hundred-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.metric .k { font-size: 13px; color: var(--muted); }
.metric .v { font: 600 20px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.metric .s { font-size: 12.5px; color: var(--muted); }
.metric button { align-self: flex-start; border: 0; background: none; padding: 0; color: var(--accent-ink); cursor: pointer; font-size: 13px; font-weight: 500; min-height: 28px; }
.cmp { font-size: 12.5px; color: var(--muted); }
.cmp b { font-weight: 600; }
.cmp .up { color: var(--good); } .cmp .down { color: var(--bad); }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--body); }
.chart .gridl { stroke: var(--line); }
.chart .b1 { fill: var(--accent); }
.chart .b1.neg { fill: var(--bad); }
.chart .hit { fill: transparent; }
.chart .hit:hover + .b1, .chart .b1:hover { filter: brightness(1.15); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12.5px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; z-index: 40; }

.list { display: flex; flex-direction: column; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 11px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .main-t { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.item .main-t small { display: block; color: var(--muted); font-size: 13px; }
.item .amt { font: 600 15px var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; }
.item .acts { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.item.refund .amt { color: var(--bad); }
.day-h { display: flex; justify-content: space-between; gap: 10px; padding: 14px 0 6px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.day-h:first-child { border-top: 0; padding-top: 0; }
.day-h b { color: var(--ink-2); font-weight: 600; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.chip.blue { background: var(--accent-soft); color: var(--accent-ink); }
.chip.orange { background: var(--exp-soft); color: var(--exp-ink); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warnc { background: var(--warn-soft); color: var(--warn); }
.chip.badc { background: var(--bad-soft); color: var(--bad); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.fld select, .fld input { height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 10px; color: var(--ink); min-width: 0; font-size: 16px; }
.strip { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 12px 14px; background: var(--surface-2); border-radius: 11px; }
.strip div { display: flex; flex-direction: column; }
.strip span { font-size: 12.5px; color: var(--muted); }
.strip b { font: 600 17px var(--display); font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); font-size: 15px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.big-add { width: 100%; min-height: 48px; font-size: 16px; }
.panel > .btn.sm { align-self: flex-start; }

.pieces { display: grid; gap: 10px; }
.piece-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.piece-row:first-child { border-top: 0; }
.piece-row small { display: block; color: var(--muted); font-size: 13px; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font: 600 20px/1 var(--display); }
.stepper button:hover { background: var(--surface-2); }
.stepper button:disabled { opacity: .4; cursor: default; }
.stepper output { min-width: 34px; text-align: center; font: 700 20px var(--display); font-variant-numeric: tabular-nums; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-h { font-size: 12px; color: var(--muted); text-align: center; }
.cal-d { aspect-ratio: 1 / 1; max-width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; min-width: 0; }
.cal-d span { font-size: 11.5px; color: var(--muted); }
.cal-d b { font: 700 15px/1.1 var(--display); color: var(--ink); min-height: 17px; }
.cal-d.on { background: var(--accent-soft); border-color: transparent; }
.cal-d.on b { color: var(--accent-ink); }
.cal-d.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-d:disabled { opacity: .35; cursor: default; }
details summary { cursor: pointer; font-weight: 500; color: var(--accent-ink); list-style: none; min-height: 32px; display: flex; align-items: center; }
details summary::-webkit-details-marker { display: none; }

.ledger { display: flex; flex-direction: column; }
.lg { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.lg:first-child { border-top: 0; }
.lg .n { white-space: nowrap; }
.lg.sub { color: var(--muted); font-size: 13.5px; padding-block: 2px 8px; border-top: 0; }
.lg.res { font: 600 16px var(--display); border-top: 1px solid var(--ink-2); }
.lg.pay { font: 700 22px var(--display); border-top: 2px solid var(--ink); padding-top: 12px; }
.lg.pay .n.neg { color: var(--bad); }
.note { font-size: 14px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 11px 13px; }
.can { background: var(--good-soft); color: var(--good); border-radius: 10px; padding: 11px 13px; font-size: 14px; }
.can b { font-family: var(--display); }

.scen { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.scen div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.scen span { font-size: 13px; color: var(--muted); display: block; }
.scen b { font: 700 20px var(--display); font-variant-numeric: tabular-nums; }
.scen .mid-s { background: var(--accent-soft); }
.scen .mid-s b { color: var(--accent-ink); }
.big-num { font: 700 28px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.big-num span { font: 500 16px var(--body); color: var(--muted); }
.meter { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--good); border-radius: 5px; }
.meter i.w { background: var(--warn); }

.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 18px; align-items: start; }
.form { display: grid; gap: 10px; }
.form label { display: grid; grid-template-columns: minmax(0, 1fr) 210px; align-items: center; gap: 10px; font-size: 14px; }
.form input, .form select { height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 10px; min-width: 0; font-size: 16px; width: 100%; }
.form input[type="checkbox"] { width: 22px; height: 22px; justify-self: start; }
.form .auto { font-size: 14px; color: var(--muted); }
.form .hint { font-size: 12.5px; color: var(--muted); margin-top: -4px; }
.set-h { font: 600 14px var(--display); margin-top: 4px; }
fieldset.checks { border: 0; padding: 0; margin: 0; min-width: 0; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); flex-wrap: wrap; }
.checks input[type="checkbox"] { width: 20px; height: 20px; }
.checks select { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 8px; font-size: 14px; }
.log-list { max-height: 420px; overflow-y: auto; }

.login { min-height: 100vh; display: grid; place-items: center; padding-inline: 16px; padding-block: 24px; }
.login form { width: min(380px, 100%); }
.login .btn { width: 100%; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--surface); color: var(--ink); width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(10, 20, 16, .35); }
.dlg { padding: 20px; display: grid; gap: 12px; }
.dlg .fld input, .dlg .fld select { width: 100%; }
.err { color: var(--bad); font-size: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); padding-top: 4px; }
.dlg .plan { max-height: 300px; overflow-y: auto; font-size: 14px; }

@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .hero > div { border-left: 0; border-top: 1px solid var(--line); }
  .hero > div:first-child { border-top: 0; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); border-right: 0; border-top: 1px solid var(--line); z-index: 10; gap: 0; }
  .brand, .who { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-between; }
  .nav button { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 2px; flex: 1; align-items: center; min-height: 52px; }
  .nav button[data-v="set"] { display: none; }
  .btn.gear { display: inline-flex; }
  .main { padding-inline: 16px; padding-block: 14px 100px; gap: 14px; }
  .top h1 { font-size: 19px; width: 100%; }
  .scen { grid-template-columns: 1fr; }
  .hero .v { font-size: 30px; }
  .form label { grid-template-columns: 1fr; gap: 4px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  dialog { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .mob-who { display: flex !important; }
}
.mob-who { display: none; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); padding-top: 6px; }
@media (prefers-reduced-motion: no-preference) { .meter i { transition: width .35s ease; } }
