/* tax it easy! — Mini App. Стиль «табло»: чёрная шапка с логотипом-табло, янтарь #FFA933 — акцент
 * (кнопки, активное, ссылки), не фон. Светлая тема — тёплая бумага, тёмная — графит. Manrope для
 * интерфейса, JetBrains Mono 800 — только в плашках табло (tablo.js).
 * Токены — design/tokens.json. Одна разметка — две темы: отличаются только переменными. */

:root {
  --bg: #F3EEE4;
  --surface: #FFFFFF;
  --sheet: #FFFFFF;
  --tile: #EAE3D6;
  --field: #EAE3D6;
  --line: #E4DDCF;
  --line-strong: #C4BBAA;
  --skel: #E4DDCF;
  --ink: #1C1A16;
  --muted: #7A7367;
  --primary: #FFA933;
  --primary-press: #F09A20;
  --primary-soft: #FFEBCC;
  --primary-ink: #9A5A00;
  --on-primary: #000000;
  --accent: #FFA933;
  --pos: #319751;
  --pos-bg: #d5f5da;
  --pos-text: #09672e;
  --neg: #cf4238;
  --neg-bg: #ffe2dc;
  --neg-press: #ffd0c8;
  --neg-text: #af2b25;
  --warn: #f0b135;
  --warn-bg: #ffecc1;
  --warn-text: #784900;
  --neutral-bg: #ebe7e2;
  --neutral-text: #564b42;
  /* лист месяца («Первичка»): фон строки — чека нет / найден чек / чек не нужен или подтверждено */
  --row-red: #fbe7e1;
  --row-yellow: #fbf0d2;
  --row-green: #e3f2df;
  --press: #efeae2;
  --disabled-bg: #ebe7e2;
  --disabled-fg: #97918a;
  --toast: #241e19;
  --toast-fg: #f5f1ec;
  --toast-link: #FFB84D;
  --scrim: rgba(28, 26, 22, .35);
  --c1: #E8962A; --c2: #56a76a; --c3: #b48c2b; --c4: #bb76b5; --c5: #7d8bdb; --c6: #ce7951; --c7: #979836; --c8: #419bd4;

  /* шапка «ганметал» — одинаковая в обеих темах */
  --head-bg-top: #3B3F45;
  --head-bg-mid: #2A2D32;
  --head-bg-bottom: #1F2125;

  --shadow-low: 0 1px 2px rgba(60, 40, 20, .1);
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 10px 28px rgba(60, 40, 20, .07);
  --shadow-sheet: 0 -2px 6px rgba(60, 40, 20, .05), 0 -16px 48px rgba(60, 40, 20, .14);

  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 22px;
  --gap: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;

  /* старые имена — чтобы не трогать каждый экран */
  --card: var(--surface);
  --text: var(--ink);
  --accent-text: var(--on-primary);
  --link: var(--primary-ink);
  --good: var(--pos);
  --bad: var(--neg);
  --radius: var(--r-lg);
}
:root[data-theme="dark"] {
  --bg: #0E0E0E;
  --surface: #1A1A1A;
  --sheet: #222222;
  --tile: #262626;
  --field: #262626;
  --line: #2E2E2E;
  --line-strong: #4A4A4A;
  --skel: #2E2E2E;
  --ink: #F2EFE8;
  --muted: #9C978D;
  --primary: #FFA933;
  --primary-press: #F09A20;
  --primary-soft: #3A2A10;
  --primary-ink: #FFB84D;
  --on-primary: #000000;
  --accent: #FFA933;
  --pos: #68ca80;
  --pos-bg: #1c3e24;
  --pos-text: #89e29d;
  --neg: #f17264;
  --neg-bg: #572823;
  --neg-press: #66302a;
  --neg-text: #ffb2a6;
  --warn: #f8c655;
  --warn-bg: #46350d;
  --warn-text: #fddb7c;
  --neutral-bg: #2E2E2E;
  --neutral-text: #D4CFC6;
  --row-red: #35201d;
  --row-yellow: #332a14;
  --row-green: #1b2b1e;
  --press: #262626;
  --disabled-bg: #222222;
  --disabled-fg: #6E6A63;
  --toast: #EAE3D6;
  --toast-fg: #1C1A16;
  --toast-link: #FFB84D;
  --scrim: rgba(0, 0, 0, .5);
  --c1: #FFB84D; --c2: #7cc58c; --c3: #d1ac5a; --c4: #d997d2; --c5: #9dabf7; --c6: #eb9a75; --c7: #b5b761; --c8: #6bbaf0;
  /* в тёмной теме теней нет: уровень задаёт светлота поверхности */
  --shadow-low: none;
  --shadow: none;
  --shadow-sheet: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 500 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- иконки: сетка 24, линия 1,75, скруглённые концы --- */
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; }
.btn .ico, .pill .ico, .chip .ico, .subtab .ico, .link .ico { width: 18px; height: 18px; }

/* --- экран и сетка --- */
.screen { max-width: 640px; margin: 0 auto; padding: 20px 16px 32px; display: grid; gap: 20px; align-content: start; }
.stack { display: grid; gap: 20px; min-width: 0; }
@media (min-width: 560px) { .screen { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 900px) {
  .screen { max-width: 760px; }
  .screen.is-wide { max-width: 1100px; }
  .cols { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 32px; align-items: start; }
}
.cols > * { display: grid; gap: 20px; min-width: 0; align-content: start; }
@media (max-width: 899px) { .cols { display: grid; gap: 20px; } }

/* --- шапка --- */
/* Металлик «ганметал» в обеих темах (design/shapka.html, вариант D): шлифовка и блик сверху,
 * на всю высоту вместе с вкладками, от края до края, под вырезом телефона. */
.top {
  position: sticky; top: 0; z-index: 5; color: #fff;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .022) 0 1px, rgba(0, 0, 0, .02) 1px 2px, transparent 2px 4px),
    linear-gradient(180deg, var(--head-bg-top) 0%, var(--head-bg-mid) 45%, var(--head-bg-bottom) 100%);
  padding-top: env(safe-area-inset-top);
}
/* [знак «t!»] 12 px [надпись-табло / строка бизнеса] — по левому краю, с отступом карточек экрана. */
.bizline {
  display: flex; align-items: stretch; gap: 12px; width: 100%; text-align: left;
  max-width: 640px; margin: 0 auto; padding: 14px 16px 0; min-width: 0;
}
@media (min-width: 560px) { .bizline { padding-left: 24px; padding-right: 24px; } }
/* Бренд: знак слева, справа колонка той же высоты — сверху надпись-табло (верх = верх знака),
 * снизу строка бизнеса (низ = низ знака). */
.brand-mark { flex: none; display: block; line-height: 0; }
.brand-right { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between;
  align-items: flex-start; gap: 4px; }
.brand { display: block; width: 100%; min-width: 0; line-height: 0; }
/* Строка бизнеса: не обрезать, пока хватает места; на узком обрезается форма, а не название. */
.bizsub { display: flex; max-width: 100%; min-width: 0; font-size: 13px; line-height: 1.3; color: #A6A6A6;
  white-space: nowrap; }
.bizsub b { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: #F2F2F2; }
.bizsub #bizform { flex: 0 1000 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; margin-left: .3em; }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));   /* три вкладки — слева, не во всю ширину */ padding: 12px 4px 0; max-width: 640px; margin: 0 auto; }

.tab {
  display: grid; justify-items: center; gap: 4px; padding-bottom: 8px;
  border-bottom: 2px solid transparent; color: #8C8C8C;
  font-size: 10.5px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; min-width: 0;
}
.tab-icon { width: 36px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center;
  transition: background .18s var(--ease), color .18s var(--ease); }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.02em; }
.tab.is-active { border-bottom-color: #FFA933; color: #FFA933; font-weight: 700; }
.tab.is-active .tab-icon { background: rgba(255, 169, 51, .14); color: #FFA933; }
.tab.is-active .ico { stroke-width: 2; }

/* --- заголовки и периоды --- */
.head { display: grid; gap: 8px; }
.head-title { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.period-label { font-size: 24px; font-weight: 800; letter-spacing: -.025em; line-height: 1.2; }
.period-dates { font-size: 13px; color: var(--muted); }
.period { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.arrow {
  width: 40px; height: 40px; border-radius: 50%; background: var(--tile); flex: none;
  display: grid; place-items: center; color: var(--ink);
}
.arrow:disabled { background: transparent; color: var(--disabled-fg); cursor: default; }
.segmented { display: flex; background: var(--tile); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented button {
  flex: 1; min-height: 34px; padding: 0 6px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .18s var(--ease);
}
.segmented button.is-active { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-low); }
:root[data-theme="dark"] .segmented button.is-active { background: var(--sheet); }
.hint { font-size: 13px; color: var(--muted); }
.card-section { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 8px 2px -6px; }

/* --- карточки --- */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 10px; box-shadow: var(--shadow); min-width: 0; }
.card-title { font-size: 13px; color: var(--muted); font-weight: 500; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-head .name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.hero-amount { font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.hero-amount.is-refund { color: var(--primary-ink); }
.hero-amount.is-neg { color: var(--neg-text); }
.hero-sub { font-size: 13px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start; white-space: nowrap;
  min-height: 28px; padding: 0 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: var(--primary-soft); color: var(--primary-ink);
}
button.pill { min-height: 32px; padding: 0 12px; font-size: 13px; flex: none; }
.pill.is-bad { background: var(--neg-bg); color: var(--neg-text); }
.pill.is-warn { background: var(--warn-bg); color: var(--warn-text); }
.pill.is-good { background: var(--pos-bg); color: var(--pos-text); }
.badge { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-xs); background: var(--neutral-bg); color: var(--neutral-text); white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--tile); border-radius: var(--r-md); padding: 12px; display: grid; gap: 4px; min-width: 0; align-content: start; }
.tile-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tile-value { font-size: min(16px, 3.9vw); font-weight: 700; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.02em; }
.tile-value.is-neg { color: var(--neg-text); }
.tile-value.is-pos { color: var(--pos-text); }
.tile-note { font-size: 11.5px; font-weight: 600; color: var(--muted); }
@media (max-width: 359px) { .tiles { grid-template-columns: 1fr 1fr; } .tiles > :last-child { grid-column: 1 / -1; } }

.banner {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--warn-bg); color: var(--warn-text); border-radius: var(--r-lg); padding: 14px 16px;
}
.banner-text { flex: 1; display: grid; gap: 2px; }
.banner-text b { font-size: 15px; }
.banner-text span { font-size: 13px; }
.chev { color: var(--muted); display: grid; place-items: center; flex: none; }
.chev .ico { width: 18px; height: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: var(--tile); color: var(--ink); border: 0;
}
.chip.is-on { background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; box-shadow: inset 0 0 0 2px var(--primary); }
.chip.is-neg { color: var(--neg-text); }

/* --- полосы категорий --- */
.bars { display: grid; gap: 14px; }
.bar { display: grid; gap: 6px; }
.bar-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; font-weight: 600; }
.bar-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 99px; background: var(--tile); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--c1); }
.bars .bar:nth-child(2) .bar-fill { background: var(--c2); }
.bars .bar:nth-child(3) .bar-fill { background: var(--c3); }
.bars .bar:nth-child(4) .bar-fill { background: var(--c4); }
.bars .bar:nth-child(5) .bar-fill { background: var(--c5); }
.bars .bar:nth-child(6) .bar-fill { background: var(--c6); }
.bars .bar:nth-child(7) .bar-fill { background: var(--c7); }
.bars .bar:nth-child(8) .bar-fill { background: var(--c8); }
.bars .bar:nth-child(n+9) .bar-fill { background: var(--muted); }
.bar-share { color: var(--muted); font-size: 12.5px; margin-left: 6px; }

/* --- списки --- */
.list { display: grid; gap: 0; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; width: 100%; text-align: left;
  border-top: 1px solid var(--line); min-height: 44px;
}
.list > .row:first-child { border-top: 0; padding-top: 2px; }
button.row { transition: background .12s var(--ease); }
button.row:active { background: var(--press); }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-amount { font-weight: 700; }
.row.is-muted { opacity: .6; }
.row.is-muted .row-title, .row.is-muted .row-amount { text-decoration: line-through; }
.row-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--tile); display: grid; place-items: center; flex: none; color: var(--ink); }
.day { font-size: 12.5px; color: var(--muted); font-weight: 700; margin: 10px 4px -8px; }
.amount-in { color: var(--pos-text); }

.wallet { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.wallet:first-of-type { border-top: 0; }
.wallet-total { font-size: 12px; color: var(--muted); text-align: right; }

/* --- проводка --- */
.lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lines td { padding: 8px 0; border-top: 1px solid var(--line); vertical-align: top; font-weight: 600; }
.lines tr:first-child td { border-top: 0; }
.lines .acc { width: 56px; font-weight: 700; }
.lines .side { width: 64px; color: var(--muted); font-size: 12px; white-space: nowrap; text-align: right; }
.lines .amt { text-align: right; }
.lines tr.is-muted td { color: var(--muted); }
.receipt { width: 100%; border-radius: var(--r-md); background: var(--tile); }

/* --- кнопки --- */
.actions { display: grid; gap: 8px; }
.btn {
  width: 100%; min-height: 48px; padding: 12px 18px; border-radius: 999px; font-size: 14.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  background: var(--primary); color: var(--on-primary);
  transition: background .12s var(--ease), transform .12s var(--ease);
}
.btn:active { background: var(--primary-press); transform: scale(.97); }
.btn.is-secondary { background: var(--tile); color: var(--ink); }
.btn.is-secondary:active { background: var(--press); }
.btn.is-soft { background: var(--primary-soft); color: var(--primary-ink); border-radius: var(--r-md); }
.btn.is-danger { background: var(--neg-bg); color: var(--neg-text); }
.btn.is-danger:active { background: var(--neg-press); }
.btn:disabled { background: var(--disabled-bg); color: var(--disabled-fg); transform: none; }
a.btn { text-decoration: none; }
.link { color: var(--primary-ink); font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--tile); display: grid; place-items: center; flex: none; color: var(--ink); }
.icon-btn:disabled { color: var(--disabled-fg); background: transparent; }

.empty { text-align: center; color: var(--muted); padding: 22px 12px; display: grid; gap: 8px; justify-items: center; font-size: 13px; }
.empty b { color: var(--ink); font-size: 16px; font-weight: 700; }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--pos-bg); color: var(--pos-text); display: grid; place-items: center; }
.empty-icon.is-muted { background: var(--tile); color: var(--muted); }
.footnote { font-size: 11.5px; line-height: 1.45; font-weight: 600; color: var(--muted); padding: 0 4px; margin: 0; }

.skeleton { background: var(--surface); border-radius: var(--r-lg); height: 120px; box-shadow: var(--shadow);
  animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* --- деньги --- */
.subtabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 4px 16px 6px; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-low);
  font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
:root[data-theme="dark"] .subtab { background: var(--tile); }
.subtab.is-active, :root[data-theme="dark"] .subtab.is-active {
  background: var(--primary); color: var(--on-primary); font-weight: 700; box-shadow: none; }
.subtab.is-add { color: var(--primary-ink); font-weight: 700; background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.subtab .dot { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  font-size: 11.5px; font-weight: 800; background: var(--warn-bg); color: var(--warn-text); }
.grid-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-actions .btn { padding: 12px 8px; font-size: 14px; }
/* кнопка без пары — во всю ширину */
.grid-actions > .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.order-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.order-row:first-child { border-top: 0; }
.order-row .row-main { flex: 1; }

/* --- формы --- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.field input, .field select, .field textarea {
  font: 500 15px/1.3 var(--font); color: var(--ink); background-color: var(--field); border: 0;
  border-radius: var(--r-md); padding: 0 14px; min-height: 48px; width: 100%; -webkit-appearance: none; appearance: none;
  transition: box-shadow .12s var(--ease), background-color .12s var(--ease);
}
.field textarea { padding: 12px 14px; resize: vertical; min-height: 72px; }
.field select { padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; background-color: var(--surface); box-shadow: inset 0 0 0 2px var(--primary); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); font-weight: 500; }
.field small { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.field input[inputmode="decimal"] { font-weight: 700; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.choice { display: grid; gap: 8px; }
.choice button { text-align: left; padding: 12px 14px; border-radius: var(--r-md); background: var(--field); display: grid; gap: 2px; }
.choice button.is-active { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary-ink); }
.choice button:disabled { opacity: .45; }
.choice b { font-size: 15px; font-weight: 700; }
.choice span { font-size: 13px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 14.5px; font-weight: 600; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--primary); }

/* --- тост и плашка --- */
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--toast); color: var(--toast-fg); padding: 12px 16px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: 0 8px 28px rgba(0, 0, 0, .2);
}
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: flex; align-items: flex-end; }
.sheet-panel {
  width: 100%; max-width: 640px; margin: 0 auto; max-height: 85vh; overflow-y: auto;
  background: var(--sheet); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-sheet);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 12px; animation: up .25s var(--ease);
}
.sheet-panel::before { content: ''; width: 36px; height: 4px; border-radius: 99px; background: var(--line-strong); justify-self: center; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.sheet-text { font-size: 14px; line-height: 1.5; color: var(--muted); }
.sheet-text p { margin: 0 0 6px; color: var(--ink); }
.info-btn { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink);
  font: italic 800 12px Georgia, serif; display: inline-grid; place-items: center; flex: none; }
.kv { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; min-height: 44px; }
.kv:first-child { border-top: 0; padding-top: 2px; }
.kv-label { color: var(--muted); font-size: 14.5px; flex: 0 0 40%; }
.kv-value { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 700; overflow-wrap: break-word; }
.viewer { display: grid; gap: 8px; }
.viewer canvas, .viewer img { width: 100%; border-radius: var(--r-md); background: #fff; box-shadow: var(--shadow); }
.viewer pre { white-space: pre; overflow-x: auto; font-size: 11px; background: var(--tile); padding: 12px; border-radius: var(--r-md); max-height: 60vh; }

/* --- главный экран --- */
.balance { cursor: pointer; display: grid; gap: 6px; padding: 4px 2px; text-align: left; width: 100%; }
.balance-label { font-size: 13px; color: var(--muted); }
.balance-amount { display: block; width: 100%; min-width: 0; }    /* табло: tablo.js, kind amount */
.balance-wallets { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 12px; }
.balance-wallets > div { display: grid; gap: 3px; min-width: 0; }
.balance-wallets span:first-child { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance-wallets span:last-child { font-size: 15px; font-weight: 600; }
.balance-wallets .is-neg { color: var(--neg-text); }
.dot-level { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot-level.is-bad { background: var(--neg); }
.dot-level.is-warn { background: var(--warn); }
.dot-level.is-info { background: var(--line-strong); }
.dot-level.is-good { background: var(--pos); }
.row.link { color: var(--primary-ink); font-weight: 700; justify-content: center; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-title-row b { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }

/* --- счета клиентам --- */
.avatar { width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; background: var(--primary-soft); color: var(--primary-ink); }
.avatar.is-muted { background: var(--tile); color: var(--muted); }
.items { display: grid; gap: 10px; }
.item { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-md); background: var(--tile); }
.item .field input, .item .field select, .item-top input {
  background-color: var(--surface); min-height: 44px; padding: 0 12px; font: 500 15px var(--font); color: var(--ink);
  border: 0; border-radius: var(--r-sm); width: 100%; -webkit-appearance: none; appearance: none; }
.item .field select { padding-right: 28px; }
.item .field input:focus, .item-top input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }
.item-top { display: flex; gap: 8px; align-items: center; }
.item-top .icon-btn, .advance .icon-btn { background: var(--surface); color: var(--muted); }
.item-grid { display: grid; grid-template-columns: 1fr 1.1fr 1.3fr 1fr; gap: 6px; }
.item-grid .field > span { font-size: 11px; color: var(--muted); }
.item-sum { justify-self: end; font-size: 13px; font-weight: 700; color: var(--muted); }
details.mine summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; min-height: 32px; }
details.mine summary::-webkit-details-marker { display: none; }
details.mine summary::after { content: '›'; color: var(--muted); font-size: 18px; transform: rotate(90deg); transition: transform .18s var(--ease); }
details.mine[open] summary::after { transform: rotate(-90deg); }
.total .hero-amount { font-size: 30px; }
.missing { display: grid; gap: 6px; }
.miss { font-size: 13px; font-weight: 600; padding: 10px 14px; border-radius: var(--r-md); color: var(--neg-text); background: var(--neg-bg); }
.advance { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 8px; align-items: end; padding: 10px 12px;
  border-radius: var(--r-md); background: var(--tile); }
.advance .field input { background-color: var(--surface); min-height: 44px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* --- табло (tablo.js): чёрные плашки, янтарная обводка, едва заметный разрез посередине --- */
.tablo { display: flex; align-items: flex-start; gap: calc(var(--w) * .12); --w: 24px; max-width: 100%; }
.tablo-cell {
  position: relative; flex: none; display: block; width: var(--w); height: calc(var(--w) * 1.4);
  perspective: calc(var(--w) * 6); --r: calc(var(--w) * .2); --stroke: 1.25px;
  /* дробная высота (w × 1,4) даёт щель в долю пикселя между половинами — под ней тёмный корпус, не фон карточки */
  background: #0C0C0C; border-radius: var(--r);
}
.tablo-cell.is-mark { height: calc(var(--w) * 1.16); --r: calc(var(--w) * .18); }
/* Разрез — волосяная полупрозрачная линия на самой плашке, ПОД символом (design/shapka.html): символ
 * целый, «−» остаётся одной чертой. Только внутри плашки. */
.tablo-half::before { content: ""; position: absolute; left: 0; right: 0; height: .5px;
  background: rgba(0, 0, 0, .5); pointer-events: none; }
.tablo-top::before { bottom: 0; }
.tablo-bottom::before { top: 0; }
.tablo-gap { flex: none; width: calc(var(--w) * .16); }
/* Сумма: запятая — на корпусе между плашками, внизу (как на табло цен), цвет как у цифр. */
.tablo.is-amount { align-items: flex-end; }
.tablo-comma { flex: none; width: calc(var(--w) * .28); text-align: center; align-self: flex-end;
  font: 800 calc(var(--w) * .94)/1 "JetBrains Mono", ui-monospace, Menlo, monospace;
  margin-bottom: calc(var(--w) * .1); }
.tablo-half { position: absolute; left: 0; right: 0; height: 50%; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.tablo-half::after {                      /* обводка без линии на разрезе */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border: var(--stroke) solid #FFA933; border-radius: inherit;
}
.tablo-top { top: 0; background: #141414; border-radius: var(--r) var(--r) 0 0; }
.tablo-bottom { bottom: 0; background: #0C0C0C; border-radius: 0 0 var(--r) var(--r); }
.tablo-top::after { border-bottom: 0; }
.tablo-bottom::after { border-top: 0; }
.tablo-face { position: absolute; left: 0; right: 0; height: 200%; display: block; z-index: 1; }
/* Лица плашек не выделяются и не копируются — копируется подпись табло (tablo.js, aria-label). */
.tablo-cell, .tablo-comma, .tablo-gap { user-select: none; -webkit-user-select: none; }
.tablo-top .tablo-face { top: 0; }
.tablo-bottom .tablo-face { bottom: 0; }
.tablo-face svg { display: block; width: 100%; height: 100%; }
.tablo-flap-top { transform-origin: 50% 100%; z-index: 2; animation: tablo-fold var(--t) ease-in forwards; }
.tablo-flap-bottom { transform-origin: 50% 0%; z-index: 2; transform: rotateX(90deg);
  animation: tablo-unfold var(--t) ease-out var(--t) forwards; }
.tablo-shade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.tablo-flap-top .tablo-shade { animation: tablo-shade-in var(--t) ease-in forwards; }
.tablo-flap-bottom .tablo-shade { opacity: .45; animation: tablo-shade-out var(--t) ease-out var(--t) forwards; }
@keyframes tablo-fold { to { transform: rotateX(-90deg); } }
@keyframes tablo-unfold { to { transform: rotateX(0deg); } }
@keyframes tablo-shade-in { to { opacity: .45; } }
@keyframes tablo-shade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tablo-flap-top, .tablo-flap-bottom { animation-duration: 1ms !important; } }

/* --- Dashboard: карточки в фирменной обводке, «Всего на счетах» и «Сальдо» — табло --- */
.dash { display: grid; gap: 20px; min-width: 0; }
.dash-col { display: contents; }             /* телефон: одна колонка, порядок — ниже */
.dash-total { order: 1; }
.dash-saldo { order: 2; }
.dash-tasks { order: 3; }
.dash-actions { order: 4; }
/* Широкий экран: две равные колонки; первая строка — «Всего на счетах» | «Сальдо» одной ширины и высоты,
 * вторая — To do | действия. Содержимое «Всего на счетах» — сверху, лишнее место — внизу карточки. */
@media (min-width: 900px) {
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 32px;
    grid-template-areas: "total saldo" "tasks actions"; }
  .dash-total { grid-area: total; align-self: stretch; align-content: start; }
  .dash-saldo { grid-area: saldo; align-self: stretch; }
  .dash-tasks { grid-area: tasks; align-self: start; }
  .dash-actions { grid-area: actions; align-self: start; }
}
.dash .card { border: 1px solid rgba(255, 169, 51, .35); }
.dash .card-title-row b { display: inline-flex; align-items: center; gap: 8px; }
.dash .card-title-row b::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: #FFA933; flex: none; }
.dash .card-title-row .link { color: var(--primary-ink); }
.dash-total .list .row, .dash-saldo .list .row { min-height: 44px; }
.dash-tasks .row-title { white-space: normal; overflow: visible; }   /* «что случилось — что сделать» целиком */
.saldo-amount { display: block; width: 100%; min-width: 0; }
.saldo-amount .tablo { justify-content: center; }
.dash-saldo .segmented button { font-size: 13px; }
.dash-saldo .segmented button.is-active { background: #141414; color: #FFA933; box-shadow: inset 0 0 0 1.25px #FFA933;
  font-weight: 700; }

/* Стрелки — маленькие плашки табло; при нажатии верхняя половина «щёлкает» (design/saldo.html). */
.saldo-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.saldo-nav-mid { display: grid; justify-items: center; gap: 6px; min-width: 0; }
.period-board { display: flex; justify-content: center; width: 100%; }
.saldo-dates { text-align: center; }
.flap-arrow { width: 40px; height: 40px; border: 0; padding: 0; background: transparent; cursor: pointer; position: relative;
  perspective: 200px; flex: none; }
.flap-arrow .a-top, .flap-arrow .a-bot { position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; }
.flap-arrow .a-top { top: 0; background: #141414; border-radius: 9px 9px 0 0; border: 1.25px solid #FFA933; border-bottom: 0;
  transform-origin: 50% 100%; transition: transform .09s ease-in; }
.flap-arrow .a-bot { bottom: 0; background: #0C0C0C; border-radius: 0 0 9px 9px; border: 1.25px solid #FFA933; border-top: 0; }
.flap-arrow .a-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: .5px; background: rgba(0, 0, 0, .5); }
.flap-arrow svg { position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; z-index: 2; pointer-events: none; }
.flap-arrow.press .a-top { transform: rotateX(-70deg); }
.flap-arrow:disabled { cursor: default; opacity: .28; }

/* Поступило / Списано — строками: подпись слева, сумма справа (длинные суммы не обрезаются). */
.saldo-inout { display: grid; gap: 6px; }
.saldo-inout > div { background: var(--tile); border-radius: 14px; padding: 10px 12px; display: flex;
  justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.saldo-inout span { font-size: 14px; color: var(--muted); font-weight: 600; }
.saldo-inout b { font-size: 16px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.saldo-inout .is-pos { color: var(--pos-text); }
.saldo-inout .is-neg { color: var(--neg-text); }

/* График: 8 периодов, выбранный справа; пара плашек — зелёная (поступило) и красная (списано), однотонные, в
 * янтарной обводке, высота ∝ сумме от максимума в окне. Шкалы нет. */
.saldo-chart { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
/* Столбик — кнопка: Safari на iPhone не держит grid-строки у <button>, поэтому flex и явная высота у .bars. */
.saldo-chart .col { display: flex; flex-direction: column; justify-content: flex-start; cursor: pointer; background: none; border: 0; padding: 0;
  font: inherit; color: inherit; min-width: 0; }
.saldo-chart .col:disabled { cursor: default; opacity: .45; }
.saldo-chart .bars { display: flex; flex: none; height: 112px; width: 100%; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line);
  perspective: 300px; }
.saldo-chart .bar { position: relative; flex: 1; max-width: 16px; height: 0; border-radius: 3px 3px 2px 2px;
  border: 1.25px solid #FFA933; transform-origin: 50% 100%; }
.saldo-chart .bar[style*="height: 0px"] { border: 0; }
.saldo-chart .bar.in { background: #7BD88F; }
.saldo-chart .bar.out { background: #FF6B5A; }
.saldo-chart .col-label { margin-top: 8px; font: 800 10px "JetBrains Mono", ui-monospace, Menlo, monospace; color: var(--muted);
  text-align: center; padding: 3px 0; border-radius: 5px; white-space: nowrap; overflow: hidden; }
.saldo-chart .col.is-active .col-label { background: #141414; color: #FFA933; box-shadow: inset 0 0 0 1px #FFA933; }
@media (prefers-reduced-motion: reduce) { .flap-arrow .a-top { transition: none; } }
.row-amount.is-pos { color: var(--pos-text); }
.row-amount.is-neg { color: var(--neg-text); }

/* Две плашки-действия под «Сальдо»: рядом, на узком экране (и в узкой правой колонке) — друг под другом. */
.dash-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; min-width: 0; }
.dash-action { display: flex; align-items: center; gap: 14px; text-align: left; min-height: 96px; padding: 18px;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease); }
.dash-action:active { transform: scale(.98); }
.dash-action:hover { box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 169, 51, .55); }
.dash-action-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--primary-ink); }
.dash-action-icon .ico { width: 26px; height: 26px; }
.dash-action-text { display: grid; gap: 3px; min-width: 0; }
.dash-action-text b { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }

/* Окно поверх экрана (конструктор счёта, «проверь и проведи»): телефон — панель снизу почти во всю высоту,
 * широкий экран — модальное окно по центру. Внутри — обычные экраны (show() рисует сюда). */
.overlay { position: fixed; inset: 0; z-index: 15; background: var(--scrim); display: flex; align-items: flex-end; }
.overlay-panel { width: 100%; max-height: calc(100% - 24px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-sheet); animation: rise .25s var(--ease); }
@keyframes rise { from { transform: translateY(24px); } }   /* без прозрачности: Dashboard под окном не просвечивает */
.overlay-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 18px; background: var(--bg); border-bottom: 1px solid var(--line); }
.overlay-head b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.overlay-body { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); display: grid; gap: 20px; align-content: start; }
body.has-overlay { overflow: hidden; }
/* Тост при открытом окне или панели — сверху, чтобы не закрывать их кнопки. */
body.has-overlay .toast, .sheet:not([hidden]) ~ .toast { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
@media (min-width: 900px) {
  .overlay { align-items: center; justify-content: center; padding: 32px; }
  .overlay-panel { max-width: 820px; max-height: calc(100vh - 64px); border-radius: 22px; }
  .overlay-body { padding: 20px 28px 28px; }
}

/* Карточка «проверь и проведи»: чего не хватает — подсвечено. */
.field.is-missing input, .field.is-missing select { box-shadow: inset 0 0 0 2px var(--warn); }
.field .need { font-style: normal; color: var(--neg-text); font-weight: 700; }

/* Документы: переключатель Входящие / Исходящие и фильтры. */
.docs-dir { align-self: start; justify-self: start; }
.docs-dir button { flex: none; overflow: visible; text-overflow: clip; white-space: nowrap; padding-left: 16px; padding-right: 16px; }
.docs-filters { gap: 10px; }
/* Крестик очистки поиска — цветом интерфейса, не системным синим. */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; cursor: pointer; background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
}
input[type="search"]::-webkit-search-cancel-button:hover { background: var(--ink); }
.duplicate { border: 1px solid var(--warn); }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 479px) { .row3 { grid-template-columns: 1fr 1fr; } .row3 > :first-child { grid-column: 1 / -1; } }
.upload-list .row { width: 100%; text-align: left; }
/* Окно проверки PDF-выписки: дата, сумма, убрать — в строку, описание под ними. */
.statement-review { gap: 0; }
.review-line { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) 40px; gap: 8px 10px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line); }
.review-line:first-child { border-top: 0; }
.review-line input { min-width: 0; width: 100%; height: 40px; padding: 0 10px; border: 0; border-radius: 12px;
  background: var(--tile); color: var(--ink); font: inherit; font-weight: 600; }
.review-line input[inputmode="decimal"] { text-align: right; font-variant-numeric: tabular-nums; }
.review-line .row-sub { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-line.is-muted { opacity: .45; }
.review-line.is-muted .row-sub { text-decoration: line-through; }

/* --- широкий экран (≥ 900 px): после базовых правил шапки и вкладок, чтобы их перебить ---
 * Сверху — полоса во всю ширину окна с блоком бренда (тот же, что на телефоне, плашки того же размера);
 * под ней слева — боковое меню 232 px. Полоса и меню закреплены, прокручивается только контент.
 * Левый край знака = левый край иконок меню (отступ 20 px). */
@media (min-width: 900px) {
  :root { --bar-h: calc(86px + env(safe-area-inset-top)); }
  body { padding-left: 232px; padding-top: var(--bar-h); }
  .top { position: fixed; left: 0; right: 0; top: 0; height: var(--bar-h); }
  .bizline { max-width: none; margin: 0; padding: calc(14px + env(safe-area-inset-top)) 20px 14px; }
  .tabs {
    position: fixed; left: 0; top: var(--bar-h); bottom: 0; width: 232px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 2px; max-width: none; margin: 0; padding: 18px 12px 20px 0;
    background:
      repeating-linear-gradient(90deg, rgba(255, 255, 255, .022) 0 1px, rgba(0, 0, 0, .02) 1px 2px, transparent 2px 4px),
      linear-gradient(180deg, var(--head-bg-mid) 0%, var(--head-bg-bottom) 100%);
    border-top: 1px solid rgba(255, 255, 255, .06);
  }
  .tab {
    display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px 0 17px;
    border-bottom: 0; border-left: 3px solid transparent; border-radius: 0 12px 12px 0;
    font-size: 14px; justify-items: stretch;
  }
  .tab-icon { width: 24px; height: 24px; }
  .tab.is-active { background: rgba(255, 169, 51, .14); border-left-color: #FFA933; }
  .tab.is-active .tab-icon { background: none; }
  .tab-label { overflow: visible; }
  /* Контент прижат к меню: левый отступ 32 px, без пустой полосы между меню и карточками. */
  .screen, .screen.is-wide { margin: 0; padding-left: 32px; padding-right: 32px; }
}

/* --- лист месяца («Первичка», sheet.js): цвет — не единственный признак, у строки есть подпись и иконка --- */
.sheet-month { flex-direction: column; justify-content: center; gap: 0; min-height: 48px; padding: 4px 14px; line-height: 1.2; }
.sheet-month small { font-size: 11px; font-weight: 600; opacity: .75; }
.sheet-month .ico { display: none; }
.sheet-list { padding: 8px; gap: 4px; }
.sheet-list .row, .sheet-row { border-top: 0; border-radius: var(--r-md); padding: 10px 12px; min-height: 52px; }
.list > .sheet-row:first-child { padding-top: 10px; }
.sheet-row + .sheet-row { margin-top: 4px; }
.sheet-row.is-red { background: var(--row-red); }
.sheet-row.is-yellow { background: var(--row-yellow); }
.sheet-row.is-green_open, .sheet-row.is-green_done { background: var(--row-green); }
.sheet-row.is-selected { box-shadow: inset 0 0 0 2px var(--primary); }
.sheet-row .row-sub { color: var(--ink); opacity: .72; }
.sheet-state { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface); }
.sheet-state .ico { width: 18px; height: 18px; }
.is-red > .sheet-state { color: var(--neg-text); }
.is-yellow > .sheet-state, .sheet-state.is-yellow { color: var(--warn-text); }
.is-green_open > .sheet-state, .is-green_done > .sheet-state { color: var(--pos-text); }
.sheet-check { width: 30px; height: 30px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface); box-shadow: inset 0 0 0 2px var(--pos); color: var(--on-primary); }
.sheet-check.is-on { background: var(--pos); color: #fff; }
.sheet-check:disabled { opacity: .7; cursor: default; }
.sheet-check .ico { width: 18px; height: 18px; stroke-width: 2.5; }
.sheet-foot { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 2; padding: 10px 10px 10px 16px;
  grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line); }
.sheet-foot .btn { width: auto; padding-left: 18px; padding-right: 18px; white-space: nowrap; }
.sheet-left { font-size: 13px; font-weight: 700; line-height: 1.35; }
.sheet-facts { display: grid; gap: 6px; }
.sheet-fact { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 10px; font-size: 14px; }
.sheet-fact span { color: var(--muted); font-weight: 600; }
.sheet-fact b { font-weight: 600; overflow-wrap: anywhere; }
.sheet-reason { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--pos-text); font-weight: 600; }
.sheet-report { display: grid; gap: 12px; max-height: 60vh; overflow-y: auto; }
.sheet-report p { margin: 0; }
.sheet-cols { display: grid; gap: 20px; }
.sheet-main, .sheet-side { display: grid; gap: 20px; min-width: 0; align-content: start; }
@media (min-width: 900px) {
  .sheet-cols { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 28px; align-items: start; }
  .sheet-side { position: sticky; top: calc(var(--bar-h) + 16px); max-height: calc(100vh - var(--bar-h) - 32px); overflow-y: auto; padding-bottom: 8px; }
}

/* --- поле даты «ДД.ММ.ГГГГ» (ui.dateField / ui.monthField): кнопка-календарь внутри поля справа --- */
.date-field { display: grid; gap: 6px; min-width: 0; }
.date-row { position: relative; display: block; }
.date-row .date-text { padding-right: 48px; font-variant-numeric: tabular-nums; font-weight: 600; }
.date-field.is-month .date-row .date-text { padding-right: 14px; }
.date-button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: var(--r-sm); color: var(--muted); }
.date-button:active { background: var(--press); }
.date-button .ico { width: 20px; height: 20px; }
.date-row .date-picker { position: absolute; right: 4px; bottom: 0; width: 40px; height: 1px; min-height: 0; opacity: 0;
  pointer-events: none; border: 0; padding: 0; }
.date-field.is-error .date-row .date-text { box-shadow: inset 0 0 0 2px var(--neg); }
.date-field .date-error { font-size: 11.5px; font-weight: 700; color: var(--neg-text); }
.date-button:focus { outline: none; }
.date-button:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }

/* --- автопроводки (TZ_AUTO_RULES) --- */
.auto-rules .row.is-off .row-title { color: var(--muted); }
.sheet-auto .check { padding: 0; }

/* --- TZ_NAV: «Первичка» на телефоне — подпись состояния переносится, «авто» — плашкой у суммы --- */
.sheet-row .row-sub { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3; }
.sheet-amount { display: grid; justify-items: end; gap: 3px; flex: none; }
.sheet-auto-pill { font-size: 11px; padding: 1px 8px; min-height: 0; }
.books-switch { width: 100%; }
.auto-rules .row-sub { white-space: normal; }

/* --- TZ_NAV: кошельки с Dashboard, «Настройки» --- */
.dash-wallet-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.dash-closed summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; padding: 6px 0; }
.back-link { justify-self: start; margin-bottom: 2px; }
.settings-cols { display: grid; gap: 20px; }
.settings-list .row-title { font-weight: 700; }
.settings-list .row.is-active { background: var(--press); border-radius: var(--r-md); padding-left: 10px; padding-right: 10px; }
@media (min-width: 900px) {
  .settings-cols { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 28px; align-items: start; }
  .settings-cols > .settings-nav { position: sticky; top: calc(var(--bar-h) + 16px); }
}
