:root {
  color-scheme: light;
  --bg: #f2f5f4;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --ink: #18242a;
  --muted: #6f7d83;
  --line: #d9e1df;
  --green: #427b64;
  --green-soft: #e6f0eb;
  --amber: #a96f2e;
  --amber-soft: #f7eee2;
  --blue: #47728f;
  --blue-soft: #e8f0f4;
  --red: #a4534f;
  --red-soft: #f7e9e7;
  --nav: #171e22;
  --touch-target: 44px;
  --field-height: 52px;
  --radius-card: 16px;
  --shadow-card: 0 6px 24px rgba(28, 48, 52, .045);
  --shadow-dock: 0 8px 20px rgba(11, 19, 22, .18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; background: var(--bg); color: var(--ink); }
body { min-width: 320px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(71, 114, 143, .28);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.app { width: 100%; max-width: 430px; min-height: 100dvh; margin: 0 auto; padding: 0 16px calc(104px + env(safe-area-inset-bottom)); }
main, .section, .stack, .op { min-width: 0; }
.top { position: sticky; z-index: 12; top: 0; min-height: calc(56px + env(safe-area-inset-top)); margin: 0 -16px; padding: max(14px, env(safe-area-inset-top)) 16px 10px; background: rgba(242, 245, 244, .94); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.top-row { display: grid; grid-template-columns: var(--touch-target) 1fr var(--touch-target); align-items: center; gap: 8px; }
.top-row > div { grid-column: 2; min-width: 0; text-align: center; }
.top-row > div:first-child:last-child { grid-column: 1 / -1; text-align: left; }
.top h1 { margin: 0; font-size: 26px; line-height: 30px; letter-spacing: -.035em; }
.demo { display: none; }
.icon-btn, .back, .close-btn { width: var(--touch-target); height: var(--touch-target); display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-size: 19px; }
.back { grid-column: 1; }
.icon-btn, .close-btn { grid-column: 3; }

.section { margin: 18px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 2px 10px; }
.section-head h2 { margin: 0; font-size: 18px; line-height: 24px; letter-spacing: -.015em; }
.section-head span, .muted { color: var(--muted); font-size: 13px; line-height: 18px; }
.stack { display: grid; gap: 10px; }
.card { border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.ambient-in { border-color: rgba(66, 123, 100, .34); box-shadow: 0 0 18px rgba(66, 123, 100, .07); }
.ambient-out { border-color: rgba(169, 111, 46, .34); box-shadow: 0 0 18px rgba(169, 111, 46, .07); }
.positive { color: var(--green); }
.negative { color: var(--amber); }
.danger-text { color: var(--red); }

.incoming { padding: 15px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
.incoming-main { min-width: 0; }
.incoming strong, .op strong { font-size: 15px; line-height: 20px; }
.incoming small, .op small { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; line-height: 18px; }
.amount { white-space: nowrap; font-size: 17px; line-height: 22px; font-weight: 760; }
.incoming-actions { grid-column: 1 / -1; display: grid; }
.incoming-actions .btn { min-height: var(--touch-target); }
.incoming-more { width: 100%; min-height: var(--touch-target); border: 0; background: transparent; color: #315d6c; text-align: center; font-weight: 700; }
.control-summary { width: 100%; min-height: 58px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; }
.control-summary > span { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.control-summary i { color: var(--muted); font-size: 13px; font-style: normal; white-space: nowrap; }
.control-summary i.danger-text { color: var(--red); }
.control-summary i b { color: var(--ink); font-size: 16px; }
.control-summary > strong { color: var(--muted); font-size: 20px; }

.btn { min-height: var(--touch-target); padding: 0 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); font-weight: 720; }
.btn.primary { min-height: 52px; border-color: #17313b; background: #17313b; color: #fff; }
.btn.soft { background: var(--surface-soft); }
.btn.danger { border-color: rgba(164, 83, 79, .25); background: var(--red-soft); color: var(--red); }
.btn:disabled { cursor: not-allowed; opacity: .48; }
.btn-block { width: 100%; }
.link-btn { min-width: var(--touch-target); min-height: var(--touch-target); padding: 0 8px; border: 0; border-radius: 10px; background: transparent; color: #315d6c; font-weight: 720; }

.cash-strip { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 5px; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.cash-strip::-webkit-scrollbar, .suggestions::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.cash-card { min-width: min(78vw, 306px); padding: 14px; scroll-snap-align: start; }
.cash-card-full { width: 100%; min-width: 0; }
.cash-card button { width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; }
.cash-kind { display: flex; align-items: center; justify-content: flex-end; gap: 7px; color: var(--muted); font-size: 13px; line-height: 24px; }
.cash-kind i { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fbfcfc; color: #526168; font-size: 14px; font-style: normal; font-weight: 780; }
.cash-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; line-height: 20px; }
.currency { width: var(--touch-target); height: var(--touch-target); display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; background: #fbfcfc; color: #526168; font-size: 19px; font-weight: 780; }
.balance { display: block; margin: 6px 0 7px; overflow: hidden; font-size: 26px; line-height: 31px; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.month { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; line-height: 18px; white-space: nowrap; }
.carousel-dots { display: flex; justify-content: center; gap: 5px; margin-top: 8px; }
.carousel-dots i { width: 5px; height: 5px; border-radius: 50%; background: #c7d1ce; }
.carousel-dots i.active { width: 14px; border-radius: 999px; background: var(--ink); }

.op-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.op { width: 100%; min-height: 60px; padding: 8px 12px; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 9px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--surface); text-align: left; }
.op:last-child { border-bottom: 0; }
.op-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #eff3f1; font-style: normal; font-size: 16px; }
.op-copy { min-width: 0; }
.op-copy strong, .op-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 5px; padding: 0 5px; border-radius: 999px; background: var(--green); color: #fff; font-size: 11px; vertical-align: 1px; }
.op-meta { min-width: 94px; text-align: right; }
.op-meta > span { display: block; font-size: 15px; line-height: 20px; font-weight: 780; }
.op.compact { min-height: 56px; padding-top: 7px; padding-bottom: 7px; }
.op.compact .op-meta { min-width: 82px; }
.status-pill { display: inline-flex; align-items: center; min-height: 24px; margin-top: 5px; padding: 2px 8px; border-radius: 999px; background: #edf1f0; color: var(--muted); font-size: 11px; line-height: 16px; }
.status-pill.reconciled { background: var(--green-soft); color: var(--green); }
.status-pill.attention { background: var(--amber-soft); color: var(--amber); }

.dock { position: fixed; z-index: 30; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); width: min(240px, calc(100vw - 32px)); height: 58px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px; border-radius: 30px; background: var(--nav); box-shadow: var(--shadow-dock); transform: translateX(-50%); }
.dock button { position: relative; min-width: var(--touch-target); min-height: var(--touch-target); display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #93a0a5; }
.dock button.active { background: #f8faf9; color: #172328; }
.dock button.plus[aria-expanded="true"] .nav-plus { transform: rotate(45deg); }
.nav-icon { position: relative; display: block; width: 22px; height: 22px; color: currentColor; transition: transform 180ms ease; }
.nav-summary { border: 1.8px solid currentColor; border-radius: 6px; }
.nav-summary::before, .nav-summary::after, .nav-plus::before, .nav-plus::after { content: ""; position: absolute; background: currentColor; }
.nav-summary::before { left: 9px; top: 3px; width: 1.8px; height: 14px; }
.nav-summary::after { left: 3px; top: 9px; width: 14px; height: 1.8px; }
.nav-plus::before, .nav-plus::after { left: 50%; top: 50%; width: 17px; height: 2px; border-radius: 2px; transform: translate(-50%, -50%); }
.nav-plus::after { transform: translate(-50%, -50%) rotate(90deg); }
.nav-cash { top: 3px; height: 16px; border: 1.8px solid currentColor; border-radius: 5px; box-shadow: 0 -5px 0 -3px currentColor; }
.nav-cash::after { content: ""; position: absolute; right: 3px; bottom: 4px; width: 5px; height: 2px; background: currentColor; }
.nav-report { width: 20px; border: 1.8px solid currentColor; border-radius: 5px; background: linear-gradient(to top,currentColor 0 6px,transparent 6px) 3px 12px/3px 5px no-repeat,linear-gradient(to top,currentColor 0 10px,transparent 10px) 8px 8px/3px 9px no-repeat,linear-gradient(to top,currentColor 0 14px,transparent 14px) 13px 4px/3px 13px no-repeat; }

.scrim, .sheet-scrim { position: fixed; inset: 0; border: 0; background: rgba(17, 27, 32, .46); }
.scrim { z-index: 20; }
.sheet-scrim { z-index: 45; }
.fan { position: fixed; z-index: 60; isolation: isolate; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); width: 168px; height: 82px; pointer-events: none; transform: translateX(-50%); }
.fan button { position: absolute; width: var(--touch-target); height: var(--touch-target); display: grid; place-items: center; padding: 0; border: 1px solid rgba(255, 255, 255, .78); border-radius: 50%; appearance: none; -webkit-appearance: none; opacity: 1; visibility: visible; pointer-events: auto; color: #fff; font-size: 20px; box-shadow: 0 10px 24px rgba(0, 0, 0, .22); transform: none; }
.fan button:nth-child(1) { left: 10px; bottom: 0; background: var(--green); }
.fan button:nth-child(2) { left: 62px; bottom: 30px; background: var(--amber); }
.fan button:nth-child(3) { right: 10px; bottom: 0; background: var(--blue); }

.form-screen { padding-bottom: 16px; }
.form { display: grid; gap: 17px; }
.field { min-width: 0; display: grid; gap: 7px; }
.field > span, .field > label { color: var(--muted); font-size: 13px; line-height: 18px; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; min-height: var(--field-height); padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); font-size: 16px; }
.field textarea { min-height: 92px; padding-top: 14px; resize: vertical; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); background: #fffafa; }
.field-error { color: var(--red); font-size: 12px; line-height: 16px; }
.money-field { position: relative; }
.money-field input { padding-right: 64px; font-size: 26px; font-weight: 760; }
.money-field b { position: absolute; right: 16px; top: 37px; color: var(--muted); font-size: 18px; }
.currency-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.currency-pick button { min-width: 52px; height: 52px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-size: 20px; }
.currency-pick button.active { border-color: #244956; background: #244956; color: #fff; }
.selected-cashbox { margin-top: 3px; color: var(--muted); font-size: 13px; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.search { position: relative; }
.search input { padding-left: 44px; }
.search::before { content: "⌕"; position: absolute; z-index: 1; left: 15px; top: 38px; color: var(--muted); font-size: 21px; }
.suggestion-label { margin: -4px 0 0; color: var(--muted); font-size: 12px; }
.suggestions { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.chip { min-height: var(--touch-target); padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); white-space: nowrap; }
.chip.active { border-color: #6e929e; background: var(--blue-soft); }
.transfer-note { padding: 12px 14px; border-radius: 13px; background: var(--blue-soft); color: #294f62; font-size: 13px; line-height: 18px; }
.transfer-choice { padding: 15px; background: var(--blue-soft); color: #294f62; }
.transfer-choice h3, .transfer-choice p { margin: 0 0 10px; }
.preview { padding: 16px; background: #17313b; color: #fff; }
.preview h3 { margin: 0 0 13px; color: #c1d0d5; font-size: 14px; }
.preview-lines { display: grid; gap: 10px; }
.preview-line { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; line-height: 20px; }
.preview-line span { color: #b5c5ca; }
.preview-line strong { max-width: 62%; text-align: right; }
.submit-bar { position: sticky; z-index: 6; bottom: 0; display: grid; gap: 8px; margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 18%); }

.tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.tabs button { min-width: 64px; min-height: 52px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 20px; }
.tabs button.active { border-color: #244956; background: #244956; color: #fff; }
.cashbox-hero { padding: 18px; }
.cashbox-hero .balance { margin-bottom: 12px; }
.filter-toolbar, .report-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.filter-toolbar input, .report-toolbar select { min-width: 0; height: var(--field-height); border: 1px solid var(--line); border-radius: 13px; background: var(--surface); font-size: 16px; }
.filter-toolbar input { padding: 0 14px; }
.filter-toolbar .btn, .report-toolbar .btn { min-height: var(--field-height); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filters input, .filters select { min-width: 0; width: 100%; height: var(--field-height); padding: 0 11px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); font-size: 16px; }
.filter-wide { grid-column: 1 / -1; }
.filter-dialog { margin: 18px 0 6px; }
.active-filters { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; }
.empty { padding: 28px 18px; border: 1px dashed #cbd5d2; border-radius: var(--radius-card); color: var(--muted); background: rgba(255,255,255,.48); text-align: center; font-size: 14px; line-height: 20px; }

.sheet { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; max-height: calc(100dvh - 24px - env(safe-area-inset-top)); padding: 10px 16px calc(22px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; border-radius: 22px 22px 0 0; background: var(--surface); box-shadow: 0 -18px 50px rgba(0, 0, 0, .17); }
.handle { width: 42px; height: 4px; margin: 0 auto 16px; border-radius: 5px; background: #d5dddb; }
.sheet-head { display: grid; grid-template-columns: 1fr var(--touch-target); align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet h2 { margin: 0; font-size: 22px; line-height: 28px; }
.template { width: 100%; min-height: 70px; padding: 13px 4px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.template strong { font-size: 15px; }
.template small { color: var(--muted); font-size: 13px; }
.template::after { content: "›"; grid-column: 2; grid-row: 1 / span 2; color: var(--muted); font-size: 24px; }
.review-sheet .preview-lines { margin: 8px 0 18px; }
.review-sheet .preview-line span { color: var(--muted); }
.review-sheet .preview-line strong { color: var(--ink); }
.dialog-card { padding: 4px 0; }
.dialog-actions { display: grid; gap: 8px; margin-top: 18px; }
.operation-leg { padding: 12px 0; border-bottom: 1px solid var(--line); }
.operation-leg:last-child { border-bottom: 0; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { min-height: 82px; padding: 14px; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 6px; font-size: 21px; line-height: 26px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 14px; background: #e2e8e6; }
.segmented button { min-height: var(--touch-target); border: 0; border-radius: 11px; background: transparent; font-weight: 680; }
.segmented button.active { background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .07); }
.report-total { padding: 17px; }
.report-total strong { display: block; margin: 5px 0 10px; font-size: 25px; }

.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); width: min(calc(100% - 32px), 398px); padding: 13px 15px; border-radius: 13px; background: #172328; color: #fff; box-shadow: 0 12px 30px rgba(0, 0, 0, .23); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #722f2c; }
.toast.success { background: #214d3b; }
.desktop-note { display: none; }

@media (max-width: 370px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .top { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .cash-strip, .suggestions, .tabs { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .submit-bar { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .op { grid-template-columns: 38px minmax(0, 1fr) auto; padding-left: 11px; padding-right: 11px; }
  .op-meta { min-width: 86px; }
}

@media (min-width: 700px) {
  body { display: grid; place-items: start center; }
  .app { min-height: 900px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); box-shadow: 0 20px 60px rgba(30, 45, 50, .12); }
  .sheet { left: 50%; width: 430px; transform: translateX(-50%); }
}

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