/* style.css — Bean & Leaf cash book. Same identity as the Menu Costing and POS apps:
   leaf green + roasted brown on cool sage paper. Money in = green ▲, money out = brown ▼. */
:root {
  --bg: #e9eee8; --surface: #ffffff; --surface-2: #f3f6f1; --ink: #18231d; --ink-2: #4f5d55; --ink-3: #7a877f;
  --line: #d3dcd3; --accent: #2b6a4c; --accent-ink: #ffffff; --accent-soft: #dcebe1; --roast: #6b3f24; --roast-soft: #f1e6dc;
  --in: #23764a; --out: #8a4a26; --good: #23764a; --warn: #a85a06; --bad: #b42318; --good-soft: #def1e5; --warn-soft: #fbecd7; --bad-soft: #fbe2df;
  --shadow: 0 1px 0 rgba(24,35,29,.04), 0 6px 20px -12px rgba(24,35,29,.25);
  --font-display: 'Bricolage Grotesque', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --r-sm: 8px; --r-md: 14px; --r-lg: 20px;
  color-scheme: light; box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111814; --surface: #19221d; --surface-2: #1f2a24; --ink: #e3ebe5; --ink-2: #a6b3ab; --ink-3: #7e8c84; --line: #2d3a33;
    --accent: #78c99f; --accent-ink: #0d1a13; --accent-soft: #1f3a2c; --roast: #d8a77c; --roast-soft: #33251b;
    --in: #72d29d; --out: #e0a47a; --good: #72d29d; --warn: #f2a855; --bad: #f58a80; --good-soft: #193526; --warn-soft: #3a2a14; --bad-soft: #3d1d1a;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.8); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111814; --surface: #19221d; --surface-2: #1f2a24; --ink: #e3ebe5; --ink-2: #a6b3ab; --ink-3: #7e8c84; --line: #2d3a33;
  --accent: #78c99f; --accent-ink: #0d1a13; --accent-soft: #1f3a2c; --roast: #d8a77c; --roast-soft: #33251b;
  --in: #72d29d; --out: #e0a47a; --good: #72d29d; --warn: #f2a855; --bad: #f58a80; --good-soft: #193526; --warn-soft: #3a2a14; --bad-soft: #3d1d1a;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.8); color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body.no-scroll { overflow: hidden; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.15; }
h2 { font-size: 19px; font-weight: 800; } h3 { font-size: 15px; }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.neg { color: var(--bad) !important; } .pos { color: var(--good); } .muted { color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: 13px; margin: 0; }
.note { margin: 0; background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; color: var(--ink-2); font-size: 14px; }
.empty { color: var(--ink-2); text-align: center; padding: 24px 12px; margin: 0; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; } .grow { flex: 1; min-width: 0; } .nowrap { white-space: nowrap; }
kbd { font-family: inherit; font-size: 11px; border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; opacity: .7; }
.app { max-width: 1320px; margin: 0 auto; padding: 12px 18px 32px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--accent-ink); } .btn-primary:hover { filter: brightness(1.07); }
.btn-quiet { background: var(--surface); border-color: var(--line); } .btn-quiet:hover { border-color: var(--ink-3); }
.btn-danger { background: var(--bad); color: #fff; } .btn-danger-text { color: var(--bad); margin-right: auto; }
.btn-icon { width: 44px; padding: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 700; cursor: pointer; min-height: 32px; }
.mini { background: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 6px 8px; min-height: 36px; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.mini .i { width: 15px; height: 15px; }
.mini:hover { background: var(--surface-2); color: var(--ink); } .mini-danger:hover { background: var(--bad-soft); color: var(--bad); }

/* header & nav */
.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 4px 0 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; transform: rotate(-6deg); }
.brand-name { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.brand-tag { margin: 0; font-size: 13px; color: var(--ink-2); }
.header-actions { display: flex; gap: 8px; align-items: center; }
.save-warn { background: var(--bad-soft); color: var(--bad); border-radius: var(--r-sm); padding: 10px 14px; font-weight: 600; margin-bottom: 10px; }
.nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.nav-btn { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; padding: 12px 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; min-height: 48px; }
.nav-btn[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.fab { display: none; }

/* common */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters-panel { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; min-height: 40px; font-weight: 600; cursor: pointer; }
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.search { position: relative; display: flex; align-items: center; }
.search .i { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.search input { min-height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px 8px 38px; width: 240px; max-width: 100%; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field input, .field select { min-height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 8px 10px; width: 100%; }
.field.inline input, .field.inline select { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px; }
.amount-field input { font-family: var(--font-display); font-size: 34px; font-weight: 700; min-height: 64px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 8px 16px; min-height: 40px; font-weight: 600; color: var(--ink-2); cursor: pointer; flex: 1; }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.seg-wide { margin-bottom: 14px; } .seg-type { width: 100%; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: var(--accent-soft); color: var(--accent); }
.count-badge { min-width: 20px; height: 20px; border-radius: 10px; background: var(--roast); color: var(--roast-soft); font-size: 12px; display: inline-grid; place-items: center; padding: 0 6px; margin-left: 4px; }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; color: var(--roast); background: var(--roast-soft); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.tag .i { width: 11px; height: 11px; }
.alert { display: flex; gap: 10px; border-radius: var(--r-md); padding: 10px 12px; font-size: 13px; }
.alert div { display: flex; flex-direction: column; gap: 2px; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.card-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; min-width: 0; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.big { font-family: var(--font-display); font-size: 22px; margin-left: 6px; }
.amt { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.amt .i { width: 14px; height: 14px; }
.amt-in { color: var(--in); } .amt-out { color: var(--out); } .amt-t { color: var(--ink-2); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.card-block .table-wrap { border: 0; border-radius: 0; }
.table { width: 100%; border-collapse: collapse; min-width: 620px; }
.card-block .table { min-width: 0; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .sub { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; }
.row-link { cursor: pointer; } .row-link:hover td { background: var(--surface-2); }
.row-acts { text-align: right; white-space: nowrap; }
tr.is-inactive td, li.is-inactive { opacity: .55; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; color: var(--ink-2); font-size: 14px; flex-wrap: wrap; }
.pager div { display: flex; align-items: center; gap: 10px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list small { display: block; font-size: 12px; color: var(--ink-3); }
.list b { font-variant-numeric: tabular-nums; }
.date-pill { font-size: 12px; font-weight: 700; background: var(--surface-2); border-radius: 6px; padding: 4px 8px; white-space: nowrap; }

/* dashboard */
.hero { background: var(--roast); color: var(--roast-soft); border-radius: var(--r-lg); padding: 18px 20px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
:root[data-theme="dark"] .hero { color: #1d130c; }
.hero-main { display: flex; flex-direction: column; }
.hero-main span, .hero-main small { opacity: .8; font-size: 13px; }
.hero-main b { font-family: var(--font-display); font-size: clamp(34px, 5vw, 48px); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.acc-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.acc-chip { background: rgba(255,255,255,.12); border-radius: var(--r-md); padding: 8px 12px; display: flex; flex-direction: column; min-width: 120px; }
:root[data-theme="dark"] .acc-chip { background: rgba(0,0,0,.12); }
.acc-chip small { opacity: .8; font-size: 12px; } .acc-chip b { font-variant-numeric: tabular-nums; font-size: 17px; }
.acc-chip.is-neg b { color: #ffb4ab; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 13px; color: var(--ink-3); }
.kpi b { font-family: var(--font-display); font-size: 28px; font-variant-numeric: tabular-nums; }
.delta { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.delta.pos { color: var(--good); } .delta.neg { color: var(--bad) !important; }
.due-banner { display: flex; align-items: center; gap: 12px; background: var(--warn-soft); color: var(--warn); border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 14px; }
.due-banner div { flex: 1; display: flex; flex-direction: column; min-width: 0; } .due-banner span { font-size: 13px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.totals-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 12px; }
.totals-bar > div:not(.grow) { display: flex; flex-direction: column; padding-right: 18px; }
.totals-bar span { font-size: 12px; color: var(--ink-3); } .totals-bar b { font-family: var(--font-display); font-size: 20px; font-variant-numeric: tabular-nums; }
.due-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.due-list li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; flex-wrap: wrap; }
.due-list small { display: block; color: var(--ink-3); font-size: 12px; }
.radio-cards { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-cards legend { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.radio-cards label { display: flex; gap: 10px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; cursor: pointer; }
.radio-cards label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-cards input { accent-color: var(--accent); width: 18px; height: 18px; margin-top: 2px; }
.radio-cards small { display: block; color: var(--ink-3); font-size: 12px; }
.chips.recent { margin-bottom: 6px; } .chips.recent .chip { min-height: 36px; padding: 6px 12px; font-size: 13px; }

/* debts & budgets */
.aging { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.age { position: relative; background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px 12px; display: flex; flex-direction: column; overflow: hidden; }
.age span { font-size: 12px; color: var(--ink-3); } .age b { font-variant-numeric: tabular-nums; }
.age i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--good); }
.age-1-30 i { background: var(--warn); } .age-31-60 i, .age-61\+ i { background: var(--bad); }
.month-nav { display: flex; align-items: center; gap: 10px; } .month-nav b { font-family: var(--font-display); font-size: 20px; min-width: 170px; text-align: center; }
.budget-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.budget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.budget-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.budget-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.budget-acts { display: flex; gap: 4px; border-top: 1px solid var(--line); padding-top: 6px; }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 99px; background: var(--good); }
.s-near .bar span { background: var(--warn); } .s-over .bar span { background: var(--bad); }
.s-over { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sum-grid > div { background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.sum-grid span { font-size: 12px; color: var(--ink-3); } .sum-grid b { font-variant-numeric: tabular-nums; }
.sum-grid .hl { background: var(--accent-soft); }

/* reports */
.period { margin: -4px 0 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period .muted { font-weight: 400; font-size: 13px; }
.rep-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.rep-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.pl td { padding: 7px 10px; } .pl .indent { padding-left: 14px; color: var(--ink-2); }
.pl .subtotal td { font-weight: 700; background: var(--surface-2); }
.pl .total td { font-weight: 800; border-top: 2px solid var(--line); }
.pl .grand td { font-family: var(--font-display); font-weight: 800; font-size: 17px; border-top: 2px solid var(--ink); }
.pl small { font-family: var(--font-body); font-weight: 500; color: var(--ink-3); font-size: 12px; margin-left: 6px; }
.cf { display: flex; flex-direction: column; }
.cf-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.cf-row b { font-variant-numeric: tabular-nums; }
.cf-row.sec { font-weight: 700; border-bottom-style: solid; }
.cf-row.edge { font-family: var(--font-display); font-weight: 800; font-size: 16px; background: var(--surface-2); padding: 8px; border-radius: var(--r-sm); border: 0; margin: 4px 0; }
.cf .indent { padding-left: 14px; color: var(--ink-2); }
.cf .hint { margin-top: 6px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.l-rev { background: var(--accent); } .l-exp { background: var(--roast); } .l-net { background: var(--ink); border-radius: 50% !important; }
.chart-wrap { overflow-x: auto; }
.chart { width: 100%; min-width: 560px; height: auto; display: block; }
.chart .b-rev { fill: var(--accent); } .chart .b-exp { fill: var(--roast); opacity: .85; }
.chart .net-line { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.chart .net-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 2.5; } .chart .net-dot.neg { stroke: var(--bad); }
.chart .zero { stroke: var(--line); } .chart .axis { fill: var(--ink-3); font-size: 12px; font-family: var(--font-body); }
.breakdown { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.breakdown li { position: relative; display: grid; grid-template-columns: 1fr auto 56px; gap: 10px; padding: 6px 8px 9px; border-radius: var(--r-sm); background: var(--surface-2); overflow: hidden; }
.breakdown b { font-variant-numeric: tabular-nums; } .breakdown small { text-align: right; color: var(--ink-3); }
.breakdown i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--roast); }
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.settings .card-block { margin: 0; } .span-2 { grid-column: 1 / -1; }
.cat-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.cat-group h3 { font-size: 13px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); padding: 2px 0; }
.cat-list small { color: var(--ink-3); }

/* dialogs */
.overlay { position: fixed; inset: 0; background: rgba(10, 16, 12, .5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.dialog { background: var(--surface); border-radius: var(--r-lg); width: min(580px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 30px 60px -20px rgba(0,0,0,.45); }
.dialog-wide { width: min(820px, 100%); } .dialog-small { width: min(460px, 100%); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 6px; gap: 10px; }
.dialog-head h2 { font-size: 21px; }
.dialog-body { padding: 10px 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog-body p { margin: 0; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.bad { background: var(--bad); color: #fff; }
.print-area { display: none; }

/* responsive */
@media (max-width: 1100px) { .rep-grid { grid-template-columns: 1fr; } .hide-md { display: none; } }
@media (max-width: 820px) {
  .app { padding: 10px 12px calc(88px + env(safe-area-inset-bottom, 0px)); }
  .hide-sm { display: none; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 0; margin: 0; padding: 4px 2px env(safe-area-inset-bottom, 0px); justify-content: space-around; }
  .nav-btn { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 2px; border-bottom: 0; border-top: 3px solid transparent; min-height: 56px; flex: 1; }
  .nav-btn[aria-current="page"] { border-top-color: var(--accent); }
  .fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: 0 12px 28px -8px rgba(0,0,0,.45); z-index: 31; cursor: pointer; }
  .fab .i { width: 26px; height: 26px; stroke-width: 2.5; }
  .kpis, .dash-grid, .rep-grid2, .settings { grid-template-columns: 1fr; }
  .aging { grid-template-columns: repeat(2, 1fr); }
  .radio-cards { grid-template-columns: 1fr; }
  .search, .search input { width: 100%; }
  .filters .field.inline { flex: 1 1 140px; } .filters .field.inline select { width: 100%; }
  .overlay { padding: 0; align-items: stretch; }
  .dialog, .dialog-wide { width: 100%; max-height: none; height: 100%; border-radius: 0; }
  .dialog-small { height: auto; margin: auto 14px; border-radius: var(--r-lg); }
  .toast { top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto; transform: translate(-50%, -20px); } .toast.show { transform: translate(-50%, 0); }
  .brand-name { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

/* print */
@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; color: #111 !important; }
  .app, #dialogs, .toast, .fab { display: none !important; }
  .print-area { display: block !important; }
  .print-doc { font-family: var(--font-body); color: #111; }
  .print-doc h1 { font-size: 22pt; } .print-doc > p { color: #555; margin: 2pt 0 12pt; } .print-doc h2 { margin: 14pt 0 6pt; font-size: 14pt; }
  .print-doc .table-wrap { border: 0; overflow: visible; } .print-doc .table { min-width: 0; }
  .print-doc .table th { background: #f0f2f0; color: #444; } .print-doc .table td, .print-doc .table th { padding: 4pt 6pt; border-bottom: 1px solid #ccc; }
  .print-doc .cf-row.edge { background: #f0f2f0; }
  tr { break-inside: avoid; }
}
