:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-subtle: #f0f3f0;
  --text: #151a17;
  --text-secondary: #68716c;
  --text-tertiary: #929b96;
  --line: #e3e8e4;
  --accent: #276b53;
  --accent-strong: #1f5944;
  --accent-soft: #e7f0ec;
  --danger: #b4473f;
  --danger-soft: #f8e9e7;
  --warning: #8a631a;
  --warning-soft: #faf0d8;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --content-width: 720px;
  --shadow-float: 0 10px 30px rgba(21, 31, 25, .10);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { min-height: 100%; overflow-x: hidden; background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100svh; overflow-x: hidden; background: var(--bg); color: var(--text); touch-action: pan-y pinch-zoom; }
body.modal-open { overflow: hidden; }
button, input, select { max-width: 100%; font: inherit; }
button, a, select, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(30px, 8vw, 40px); line-height: 1.05; letter-spacing: -.045em; }
h2 { font-size: 19px; line-height: 1.25; letter-spacing: -.025em; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted { color: var(--text-secondary); }

.ui-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px, calc((100vw - var(--content-width)) / 2)) 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; font-size: 16px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: white; }
.brand-mark .ui-icon { width: 18px; height: 18px; stroke-width: 1.9; }
.header-add { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 999px; color: var(--accent); font-size: 14px; font-weight: 700; }
.header-add .ui-icon { width: 19px; height: 19px; stroke-width: 2.2; }

.page-shell { width: min(100%, var(--content-width)); margin: 0 auto; padding: 22px 16px calc(106px + env(safe-area-inset-bottom)); }
.bottom-nav {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  height: calc(70px + env(safe-area-inset-bottom));
  padding: 6px 6px env(safe-area-inset-bottom);
  border-top: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.nav-item { display: flex; min-width: 0; min-height: 52px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-tertiary); font-size: 10px; font-weight: 650; }
.nav-item .ui-icon { width: 22px; height: 22px; stroke-width: 1.75; }
.nav-item.active { color: var(--accent); }
.nav-item.active .ui-icon { stroke-width: 2.2; }
.nav-add { align-self: center; justify-self: center; display: grid; place-items: center; width: 52px; height: 52px; margin-top: -22px; border: 5px solid var(--bg); border-radius: 50%; background: var(--accent); color: white; box-shadow: 0 7px 18px rgba(39, 107, 83, .24); }
.nav-add .ui-icon { width: 25px; height: 25px; stroke-width: 2.2; }

.eyebrow { margin-bottom: 5px; color: var(--text-secondary); font-size: 11px; font-weight: 750; letter-spacing: .075em; text-transform: uppercase; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dashboard-heading { display: grid; gap: 10px; margin-bottom: 24px; }
.dashboard-heading .eyebrow { margin-bottom: 0; }
.dashboard-period-controls { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, .72fr) minmax(0, .68fr); gap: 6px; width: 100%; }
.dashboard-period-controls label { position: relative; min-width: 0; }
.dashboard-period-controls label::after { position: absolute; top: 50%; right: 10px; color: var(--accent); font-size: 15px; content: "⌄"; pointer-events: none; transform: translateY(-58%); }
.dashboard-period-controls select { height: 56px; padding: 0 28px 0 10px; border: 0; border-radius: 15px; appearance: none; background-color: var(--surface-subtle); color: var(--text); font-size: clamp(21px, 6vw, 32px); font-weight: 760; letter-spacing: -.04em; text-transform: capitalize; }
.dashboard-period-controls label:nth-child(n + 2) select { padding-inline: 8px 25px; font-size: clamp(18px, 5vw, 25px); letter-spacing: -.025em; }
.dashboard-period-controls label:last-child select { text-transform: uppercase; }
.currency-control { display: grid; gap: 4px; color: var(--text-secondary); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.currency-control select { width: 78px; height: 40px; padding: 0 9px; border-radius: 11px; background-color: var(--surface); font-size: 14px; font-weight: 750; text-transform: none; letter-spacing: 0; }

.month-summary { padding: 4px 0 22px; border-bottom: 1px solid var(--line); }
.month-summary > p, .statistics-total > p { margin-bottom: 5px; color: var(--text-secondary); font-size: 13px; font-weight: 650; }
.month-summary > strong { display: block; overflow-wrap: anywhere; font-size: clamp(44px, 13vw, 64px); font-weight: 720; line-height: 1.04; letter-spacing: -.06em; }
.month-summary > small { display: block; min-height: 16px; margin-top: 6px; color: var(--warning); font-size: 12px; }
.today-summary { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 4px 10px; margin-top: 22px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--surface-subtle); }
.today-summary > span { color: var(--text-secondary); font-size: 14px; font-weight: 650; white-space: nowrap; }
.today-summary > strong { font-size: 18px; letter-spacing: -.025em; }
.today-summary > small { grid-column: 1 / -1; color: var(--warning); font-size: 11px; }
.today-summary > small:empty { display: none; }
.quick-add { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 54px; margin-top: 18px; border-radius: var(--radius-md); background: var(--accent); color: white; font-size: 16px; font-weight: 750; }
.quick-add:active, .primary-button:active { background: var(--accent-strong); transform: translateY(1px); }
.quick-add .ui-icon { width: 21px; height: 21px; stroke-width: 2.2; }

.section-block { margin-top: 30px; }
.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.section-title > a { min-height: 32px; padding: 6px 0; color: var(--accent); font-size: 14px; font-weight: 700; }
.source-label { display: block; margin-top: 3px; color: var(--text-tertiary); font-size: 11px; font-weight: 500; }

.expense-list, .history-day { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.expense-swipe { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--danger); }
.expense-swipe:last-child { border-bottom: 0; }
.expense-row { position: relative; z-index: 1; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 72px; padding: 12px; outline: none; background: var(--surface); cursor: pointer; touch-action: pan-y; transition: transform .2s cubic-bezier(.2, .75, .25, 1); }
.expense-row:focus-visible { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.expense-swipe.is-open .expense-row { transform: translateX(-92px); }
.expense-delete-action { position: absolute; z-index: 0; top: 0; right: 0; bottom: 0; display: flex; width: 92px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0; border: 0; background: var(--danger); color: white; font-size: 11px; font-weight: 750; cursor: pointer; }
.expense-delete-action .ui-icon { width: 20px; height: 20px; }
.category-icon, .category-bar-icon { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px; background: var(--surface-subtle); color: var(--accent); }
.category-icon .ui-icon, .category-bar-icon .ui-icon { width: 20px; height: 20px; }
.expense-main { min-width: 0; }
.expense-main > strong { display: block; overflow: hidden; font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.expense-main > small, .expense-amount small { display: block; margin-top: 3px; color: var(--text-secondary); font-size: 12px; line-height: 1.25; }
.expense-main > small:not(.accounting-note) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-main .accounting-note { color: var(--accent); }
.expense-amount { min-width: 70px; text-align: right; }
.expense-amount > strong { display: block; font-size: 15px; font-weight: 720; white-space: nowrap; letter-spacing: -.015em; }
.expense-refunded .expense-amount { color: var(--text-tertiary); text-decoration: line-through; }
.status-line { display: flex; flex-wrap: wrap; gap: 4px; }
.status-badge { display: inline-flex; margin-top: 5px; padding: 3px 6px; border-radius: 999px; font-size: 9px; font-weight: 750; line-height: 1.2; }
.pending-badge { background: var(--warning-soft); color: var(--warning); }
.deposit-badge { background: #e8eff8; color: #3e6386; }
.refunded-badge { background: var(--surface-subtle); color: var(--text-secondary); }
.recurring-badge { background: #eee9f8; color: #684a91; }
.payment-badge { align-items: center; gap: 3px; background: var(--surface-subtle); color: var(--text-secondary); }
.payment-badge .ui-icon { width: 11px; height: 11px; stroke-width: 2; }
.fee-badge { background: var(--warning-soft); color: var(--warning); }
.exchange-badge { background: var(--accent-soft); color: var(--accent-strong); }
.deposit-quick-action { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; margin-top: 3px; padding: 2px 8px; border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent); border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 9px; font-weight: 750; cursor: pointer; }
.deposit-quick-action .ui-icon { width: 12px; height: 12px; }

.category-bars { display: grid; gap: 17px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.category-bar { display: flex; align-items: center; gap: 12px; }
.category-bar-link { margin: -8px; padding: 8px; border-radius: 14px; transition: background .15s ease; }
.category-bar-link:active { background: var(--surface-subtle); }
.category-bar-chevron { flex: 0 0 auto; width: 17px; height: 17px; color: var(--text-tertiary); }
.category-bar-icon { width: 34px; height: 34px; border-radius: 10px; }
.category-bar-icon .ui-icon { width: 18px; height: 18px; }
.category-bar-body { min-width: 0; flex: 1; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 13px; }
.bar-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label strong { font-size: 13px; white-space: nowrap; }
.bar-track { overflow: hidden; height: 5px; border-radius: 99px; background: var(--surface-subtle); }
.bar-fill { height: 100%; min-width: 3px; border-radius: inherit; background: var(--accent); }

.form-heading { margin-bottom: 18px; }
.form-heading h1 { margin-top: 5px; }
.back-link { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; margin-left: -8px; padding: 0 8px; color: var(--accent); font-size: 14px; font-weight: 700; }
.back-link .ui-icon { width: 19px; height: 19px; }
.expense-form { display: grid; min-width: 0; gap: 20px; padding-bottom: 68px; }
.expense-form > * { min-width: 0; }
.expense-mode-fields { display: grid; min-width: 0; gap: 20px; }
.expense-form label, .filters-grid label, .period-controls label { display: grid; min-width: 0; gap: 7px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
input, select { width: 100%; min-width: 0; height: 50px; padding: 0 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none; background: var(--surface); color: var(--text); font-size: 16px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent); }
.date-control { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 18px; align-items: center; width: 100%; min-width: 0; height: 50px; overflow: hidden; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.date-control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent); }
.date-control input[type="date"] { position: absolute; z-index: 2; inset: 0; width: 100%; min-width: 0; max-width: none; height: 100%; margin: 0; padding: 0; border: 0; border-radius: inherit; opacity: 0; cursor: pointer; appearance: none; -webkit-appearance: none; }
.date-control-value { display: flex; min-width: 0; height: 100%; align-items: center; overflow: hidden; color: var(--text); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.date-control-value.placeholder { color: var(--text-tertiary); font-weight: 500; }
.date-control > .ui-icon { width: 18px; height: 18px; color: var(--text-secondary); pointer-events: none; }
.category-select-field { display: grid; min-width: 0; gap: 7px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.amount-box { padding: 23px 18px 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); text-align: center; }
.amount-box > label { color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.amount-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; width: min(100%, 520px); margin: 0 auto; }
.amount-input input { width: 100%; min-width: 0; height: 86px; padding: 0 2px 0 0; border: 0; background: transparent; box-shadow: none; color: var(--text); text-align: right; font-size: clamp(44px, 13vw, 70px); font-weight: 680; line-height: 1; letter-spacing: -.04em; }
.amount-input input::placeholder { color: var(--text-tertiary); }
.amount-input span { min-width: max-content; padding-right: 2px; color: var(--accent); text-align: left; font-size: 25px; font-weight: 700; white-space: nowrap; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 9px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.currency-pills { width: 100%; max-width: 100%; overflow: hidden; }
.currency-pills > div { display: flex; width: 100%; max-width: 100%; gap: 7px; overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 2px; scrollbar-width: none; }
.currency-pills > div::-webkit-scrollbar { display: none; }
.choice-pill { flex: 0 0 56px; }
.choice-pill input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); opacity: 0; pointer-events: none; }
.choice-pill span { display: grid; place-items: center; min-width: 54px; height: 44px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: 13px; font-weight: 750; }
.choice-pill input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.payment-methods { display: flex; width: 100%; max-width: 100%; gap: 7px; overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 2px; scrollbar-width: none; }
.payment-methods::-webkit-scrollbar { display: none; }
.payment-choice { min-width: 0; flex: 0 0 auto; cursor: pointer; }
.payment-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.payment-choice span { display: flex; min-width: 108px; min-height: 48px; align-items: center; justify-content: center; gap: 7px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--text-secondary); text-align: center; }
.payment-choice .ui-icon { flex: 0 0 auto; width: 18px; height: 18px; }
.payment-choice b { overflow: hidden; max-width: 145px; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.payment-choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--accent); }
.form-section { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.exchange-fields h2 { font-size: 17px; }
.exchange-help { margin-top: 5px; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.exchange-leg { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(90px, .65fr); gap: 9px; }
.exchange-leg label { display: grid; min-width: 0; gap: 7px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.exchange-leg input, .exchange-leg select { min-width: 0; }
.exchange-arrow { height: 8px; color: var(--accent); font-size: 20px; font-weight: 700; line-height: 8px; text-align: center; }
.optional { margin-left: 3px; color: var(--text-tertiary); font-weight: 500; }
.compact-fields { gap: 16px; }
.date-time-row { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, .8fr); gap: 9px; }
.source-note { display: flex; align-items: flex-start; gap: 7px; color: var(--text-tertiary); font-size: 11px; font-weight: 500; line-height: 1.4; }
.source-note .ui-icon { flex: 0 0 auto; width: 15px; height: 15px; margin-top: 1px; }
.more-fields { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.more-fields > summary { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 15px; color: var(--text-secondary); font-size: 13px; font-weight: 700; cursor: pointer; list-style: none; }
.more-fields > summary::-webkit-details-marker { display: none; }
.more-fields > summary .ui-icon { width: 18px; height: 18px; transition: transform .18s ease; }
.more-fields[open] > summary .ui-icon { transform: rotate(90deg); }
.more-fields-content { display: grid; gap: 15px; padding: 2px 15px 15px; }
.expense-form .deposit-toggle { display: flex; align-items: flex-start; gap: 11px; padding: 13px; border-radius: 13px; background: var(--surface-subtle); color: var(--text); cursor: pointer; }
.expense-form .deposit-toggle input { flex: 0 0 auto; width: 21px; min-width: 21px; height: 21px; margin: 1px 0 0; padding: 0; accent-color: var(--accent); box-shadow: none; }
.deposit-toggle span { display: grid; gap: 3px; }
.deposit-toggle strong { font-size: 13px; }
.deposit-toggle small { color: var(--text-secondary); font-size: 11px; font-weight: 500; line-height: 1.35; }
.primary-button, .secondary-button { min-height: 48px; padding: 0 17px; border: 0; border-radius: 14px; font-weight: 750; cursor: pointer; }
.primary-button { background: var(--accent); color: white; }
.secondary-button { background: var(--accent-soft); color: var(--accent-strong); }
.primary-button:disabled, .secondary-button:disabled { opacity: .55; cursor: default; }
.danger-button { background: var(--danger) !important; color: white !important; }
.sticky-save { position: fixed; z-index: 20; left: 50%; bottom: calc(79px + env(safe-area-inset-bottom)); width: min(calc(100vw - 32px), calc(var(--content-width) - 32px)); min-height: 54px; box-shadow: 0 9px 26px rgba(39, 107, 83, .19); transform: translateX(-50%); }
.form-error { padding: 12px 14px; border-radius: 13px; background: var(--danger-soft); color: var(--danger); font-size: 13px; line-height: 1.4; }

.filters-card { margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.filters-card > summary { display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 0 15px; cursor: pointer; list-style: none; }
.filters-card > summary::-webkit-details-marker { display: none; }
.filters-card > summary > span { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.filters-card > summary .ui-icon { width: 18px; height: 18px; color: var(--text-secondary); }
.filters-card .disclosure-icon { transition: transform .18s ease; }
.filters-card[open] .disclosure-icon { transform: rotate(90deg); }
.filters-content { padding: 2px 15px 15px; border-top: 1px solid var(--line); }
.filters-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; margin: 14px 0; }
.history-date-range { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 10px; min-width: 0; width: 100%; }
.history-date-range label { display: grid; min-width: 0; width: 100%; overflow: hidden; align-content: start; }
.history-date-range .date-control { padding-inline: 10px; }
.history-date-range .date-control-value { font-size: 15px; }
.filters-grid .wide-filter { grid-column: 1 / -1; }
.filters-content .secondary-button { width: 100%; }
.history-list { display: grid; gap: 24px; }
.history-group { min-width: 0; }
.history-date { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 3px 9px; }
.history-date h2 { font-size: 15px; text-transform: capitalize; }
.history-date strong { color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.active-history-filter { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 18px; padding: 12px 13px; border-radius: 13px; background: var(--accent-soft); color: var(--accent-strong); }
.active-history-filter strong { display: block; font-size: 13px; }
.active-history-filter small { display: block; margin-top: 2px; font-size: 11px; text-transform: capitalize; }
.active-history-filter .text-button { flex: 0 0 auto; }

.period-controls { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr) minmax(0, 1fr); gap: 8px; margin-bottom: 22px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.period-controls.two-controls { grid-template-columns: minmax(0, 1.35fr) minmax(0, .85fr); }
.period-controls select { height: 44px; padding: 0 9px; font-size: 14px; }
.statistics-total { padding: 4px 0 22px; border-bottom: 1px solid var(--line); }
.statistics-total > strong { display: block; overflow-wrap: anywhere; font-size: clamp(42px, 12vw, 60px); font-weight: 720; line-height: 1.05; letter-spacing: -.055em; }
.statistics-total > small { display: block; margin-top: 8px; color: var(--text-tertiary); font-size: 11px; }
.daily-chart { min-height: 116px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.daily-list { display: grid; gap: 0; padding: 6px 16px; }
.daily-row { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
.daily-row-link { margin: 0 -8px; padding: 12px 8px; border-radius: 12px; }
.daily-row-link:active { background: var(--surface-subtle); }
.daily-row:last-child { border-bottom: 0; }
.daily-row-heading { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.daily-row-heading span { color: var(--text-secondary); font-size: 12px; font-weight: 650; text-transform: capitalize; }
.daily-row-heading strong { font-size: 13px; white-space: nowrap; }
.daily-track { overflow: hidden; height: 7px; border-radius: 99px; background: var(--surface-subtle); }
.daily-fill { height: 100%; min-width: 4px; border-radius: inherit; background: var(--accent); }
.daily-chart > .empty-state { min-height: 180px; }

.settings-group { margin-bottom: 28px; }
.settings-group > h2, .settings-group > .section-title { margin: 0 3px 10px; }
.settings-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-row > span { min-width: 0; }
.settings-row strong { display: block; font-size: 14px; }
.settings-row small { display: block; margin-top: 3px; color: var(--text-secondary); font-size: 11px; font-weight: 500; line-height: 1.3; }
.settings-row select { flex: 0 0 auto; width: auto; max-width: 46%; height: 42px; border-color: transparent; background-color: var(--surface-subtle); font-size: 14px; font-weight: 700; }
.percent-field { display: grid; flex: 0 0 96px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px; height: 42px; padding-right: 11px; border-radius: 11px; background: var(--surface-subtle); }
.percent-field input { height: 42px; padding: 0 2px 0 10px; border: 0; background: transparent; box-shadow: none; text-align: right; font-size: 15px; font-weight: 700; }
.percent-field b { color: var(--text-secondary); font-size: 13px; }
.settings-hint { margin: 9px 4px 0; color: var(--text-tertiary); font-size: 11px; line-height: 1.4; }
.settings-save { width: 100%; margin-top: 12px; }
.payment-card-create { display: grid; gap: 12px; margin-bottom: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.payment-card-create > label, .payment-card-editor-fields > label, .payment-card-create .settings-form-grid > label { display: grid; gap: 6px; color: var(--text-secondary); font-size: 11px; font-weight: 650; }
.payment-card-create input, .payment-card-create select, .payment-card-editor-fields input, .payment-card-editor-fields select { height: 44px; background: var(--surface); font-size: 14px; }
.payment-card-editor { border-bottom: 1px solid var(--line); }
.payment-card-editor:last-child { border-bottom: 0; }
.payment-card-editor > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 64px; padding: 10px 13px; cursor: pointer; list-style: none; }
.payment-card-editor > summary::-webkit-details-marker { display: none; }
.payment-card-editor > summary > .ui-icon { flex: 0 0 auto; width: 18px; height: 18px; color: var(--text-tertiary); transition: transform .18s ease; }
.payment-card-editor[open] > summary > .ui-icon { transform: rotate(90deg); }
.payment-card-editor-fields { display: grid; gap: 13px; padding: 13px; border-top: 1px solid var(--line); background: var(--surface-subtle); }
.card-editor-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.card-editor-actions .secondary-button { min-height: 44px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 10px; }
.inline-form .secondary-button { min-width: 92px; }
.category-create-form { display: grid; gap: 12px; margin-bottom: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.category-create-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px auto; gap: 8px; align-items: start; }
.category-create-row .secondary-button { min-height: 50px; }
.icon-select { position: relative; min-width: 0; }
.icon-select-trigger { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-select-trigger > .icon-select-current-icon { display: grid; flex: 0 0 auto; color: var(--accent); }
.icon-select-trigger .ui-icon { width: 20px; height: 20px; }
.icon-select-label { overflow: hidden; min-width: 0; flex: 1; font-size: 13px; font-weight: 650; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.icon-select-chevron { flex: 0 0 auto; width: 16px !important; height: 16px !important; color: var(--text-tertiary); transform: rotate(90deg); transition: transform .16s ease; }
.icon-select-trigger[aria-expanded="true"] .icon-select-chevron { transform: rotate(-90deg); }
.icon-select-menu { position: absolute; z-index: 45; top: calc(100% + 6px); right: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: min(320px, calc(100vw - 48px)); max-height: 330px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-float); }
.icon-select-option { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 42px; padding: 6px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--text-secondary); font-size: 11px; font-weight: 650; text-align: left; cursor: pointer; }
.icon-select-option .ui-icon { flex: 0 0 auto; width: 19px; height: 19px; color: var(--accent); }
.icon-select-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-select-option.selected { background: var(--accent-soft); color: var(--accent-strong); }
#new-category-icon-select .icon-select-trigger { width: 54px; height: 50px; padding: 0; justify-content: center; }
#new-category-icon-select .icon-select-label, #new-category-icon-select .icon-select-chevron { display: none; }
.compact-icon-field .icon-select-trigger { margin-top: 6px; }
.category-editor-fields .icon-select-menu { position: static; width: 100%; margin-top: 6px; box-shadow: none; }
.category-create-form fieldset, .category-editor fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.category-create-form legend, .category-editor legend { margin-bottom: 8px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.icon-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.icon-choice { min-width: 0; cursor: pointer; }
.icon-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.icon-choice span { display: grid; min-height: 62px; place-items: center; gap: 3px; padding: 7px 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text-secondary); }
.icon-choice .ui-icon { width: 21px; height: 21px; color: var(--accent); }
.icon-choice small { overflow: hidden; width: 100%; font-size: 9px; font-weight: 650; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.icon-choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--accent); }
.category-setting { min-height: 58px; }
.category-setting.archived { opacity: .58; }
.category-setting-name { display: flex; align-items: center; gap: 10px; }
.category-active-toggle { flex: 0 0 auto; width: 21px; min-width: 21px; height: 21px; margin: 0; padding: 0; accent-color: var(--accent); box-shadow: none; cursor: pointer; }
.category-active-toggle:disabled { opacity: .55; cursor: default; }
.category-setting-name > span { overflow: hidden; min-width: 0; }
.category-setting-name strong, .category-setting-name small { display: block; }
.category-setting-name small { margin-top: 3px; color: var(--text-secondary); font-size: 11px; font-weight: 500; line-height: 1.3; }
.category-setting-name .category-icon { width: 34px; height: 34px; }
.category-setting-name .category-icon .ui-icon { width: 18px; height: 18px; }
.category-editor, .recurring-editor { border-bottom: 1px solid var(--line); }
.category-editor:last-child, .recurring-editor:last-child { border-bottom: 0; }
.category-editor.archived > summary, .recurring-editor.archived > summary { opacity: .58; }
.category-editor > summary, .recurring-editor > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 64px; padding: 10px 13px; cursor: pointer; list-style: none; }
.category-editor > summary .category-setting-name { flex: 1; }
.category-editor > summary > span, .recurring-editor > summary > span { min-width: 0; }
.category-editor > summary::-webkit-details-marker, .recurring-editor > summary::-webkit-details-marker { display: none; }
.category-editor > summary > .ui-icon, .recurring-editor > summary > .ui-icon { flex: 0 0 auto; width: 18px; height: 18px; color: var(--text-tertiary); transition: transform .18s ease; }
.category-editor[open] > summary > .ui-icon, .recurring-editor[open] > summary > .ui-icon { transform: rotate(90deg); }
.category-editor-fields, .recurring-editor-fields { display: grid; gap: 13px; padding: 13px; border-top: 1px solid var(--line); background: var(--surface-subtle); }
.category-editor-fields > label, .recurring-editor-fields > label, .settings-form-grid > label { display: grid; gap: 6px; color: var(--text-secondary); font-size: 11px; font-weight: 650; }
.category-editor-fields input, .recurring-editor-fields input, .recurring-editor-fields select { height: 44px; background: var(--surface); font-size: 14px; }
.settings-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 11px; }
.editor-actions { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.editor-actions .secondary-button { min-height: 44px; }
.text-button { min-height: 40px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; color: var(--accent); font-size: 12px; font-weight: 700; cursor: pointer; }
.empty-state { display: grid; place-items: center; padding: 32px 18px; color: var(--text-secondary); text-align: center; }
.empty-state .empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 11px; border-radius: 15px; background: var(--surface-subtle); color: var(--accent); }
.empty-state strong { color: var(--text); font-size: 14px; }
.empty-state p { max-width: 300px; margin-top: 5px; font-size: 12px; line-height: 1.45; }
.error-state { display: flex; align-items: flex-start; gap: 10px; padding: 15px; border: 1px solid #efd1ce; border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger); }
.error-state > .ui-icon { flex: 0 0 auto; width: 20px; height: 20px; }
.error-state strong { font-size: 13px; }
.error-state p { margin-top: 3px; font-size: 11px; line-height: 1.4; }
.warning-box { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 16px; padding: 12px 13px; border-radius: 13px; background: var(--warning-soft); color: var(--warning); font-size: 12px; line-height: 1.4; }
.warning-box .ui-icon { flex: 0 0 auto; width: 18px; height: 18px; }
.loading-block { position: relative; min-height: 116px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.loading-block::before { content: ""; position: absolute; inset: 14px; border-radius: 12px; background: linear-gradient(100deg, #f0f2f0 20%, #fafbfa 40%, #f0f2f0 60%); background-size: 220% 100%; animation: loading 1.2s ease-in-out infinite; }
@keyframes loading { to { background-position-x: -220%; } }

.toast { position: fixed; z-index: 90; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 32px); padding: 11px 14px; border-radius: 999px; background: #26312b; box-shadow: var(--shadow-float); color: white; font-size: 13px; font-weight: 650; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { background: var(--danger); }
.toast .ui-icon { width: 17px; height: 17px; stroke-width: 2.2; }
.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 18px max(12px, env(safe-area-inset-left)) calc(18px + env(safe-area-inset-bottom)); background: rgba(12, 17, 14, .32); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card { position: relative; width: min(100%, 420px); padding: 24px 20px 18px; border-radius: 24px; background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,.2); text-align: center; }
.modal-close { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); }
.modal-icon { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 15px; background: var(--warning-soft); color: var(--warning); }
.modal-card h2 { font-size: 20px; }
.modal-card > p { margin: 8px auto 20px; color: var(--text-secondary); font-size: 13px; line-height: 1.45; }
.modal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }

.login-shell { display: grid; min-height: 100vh; min-height: 100svh; place-items: center; padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.login-card { width: min(100%, 420px); padding: 24px; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow-float); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 34px; font-size: 16px; font-weight: 760; }
.login-copy h1 { margin: 6px 0 8px; font-size: 38px; }
.login-copy > p:last-child { margin: 0 0 24px; color: var(--text-secondary); font-size: 14px; line-height: 1.45; }
.login-form { display: grid; gap: 14px; }
.login-status { margin: -10px 0 16px; padding: 11px 13px; border-radius: 13px; background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; font-weight: 650; text-align: center; }
.login-form label { display: grid; gap: 7px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.login-form .primary-button, .passkey-button { width: 100%; min-height: 52px; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-tertiary); font-size: 12px; }
.login-divider::before, .login-divider::after { flex: 1; height: 1px; background: var(--line); content: ""; }
.passkey-button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.passkey-button .ui-icon { width: 19px; height: 19px; }
.login-security-note { margin: 18px 4px 0; color: var(--text-tertiary); font-size: 11px; line-height: 1.45; text-align: center; }
.security-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.security-card strong { display: block; font-size: 14px; }
.security-card p { margin: 4px 0 0; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.security-list { margin-top: 10px; }
.security-list:empty { display: none; }
.danger-text { color: var(--danger) !important; }
.logout-button { width: 100%; margin-top: 12px; }
.theme-toggle { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 66px; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.theme-toggle-icon { display: grid; flex: 0 0 auto; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.theme-toggle-icon .ui-icon { width: 20px; height: 20px; }
.theme-toggle > span:last-child { min-width: 0; }
.theme-toggle strong, .theme-toggle small { display: block; }
.theme-toggle strong { font-size: 14px; }
.theme-toggle small { margin-top: 3px; color: var(--text-secondary); font-size: 11px; font-weight: 500; }

@media (min-width: 700px) {
  .page-shell { padding-inline: 24px; }
  .bottom-nav { left: 50%; right: auto; width: 620px; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; }
  .modal-backdrop { align-items: center; }
  .dashboard-heading, .page-heading { margin-top: 8px; }
  .icon-picker { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 374px) {
  .page-shell { padding-inline: 12px; }
  .app-header { padding-inline: 12px; }
  .header-add span { display: none; }
  .header-add { width: 40px; padding: 0; }
  .expense-row { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; padding-inline: 10px; }
  .category-icon { width: 36px; height: 36px; }
  .expense-amount { min-width: 60px; }
  .expense-amount > strong { font-size: 14px; }
  .period-controls { grid-template-columns: 1fr 1fr; }
  .period-controls:not(.two-controls) label:last-child { grid-column: 1 / -1; }
  .filters-grid { grid-template-columns: 1fr; }
  .login-card { padding: 20px; border-radius: 22px; }
  .security-card { grid-template-columns: 1fr; }
  .security-card .secondary-button { width: 100%; }
  .category-create-row { grid-template-columns: minmax(0, 1fr) 54px; }
  .category-create-row .secondary-button { grid-column: 1 / -1; }
  .editor-actions { grid-template-columns: 1fr; }
  .editor-actions .text-button { width: 100%; }
}

@media (max-width: 699px) {
  .icon-select-menu,
  .category-editor-fields .icon-select-menu {
    position: fixed;
    z-index: 90;
    top: auto;
    right: 12px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-height: min(58svh, 480px);
    margin: 0;
    padding: 10px;
    border-radius: 18px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .24);
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101411;
    --surface: #181e1a;
    --surface-subtle: #222a25;
    --text: #f1f4f2;
    --text-secondary: #adb7b1;
    --text-tertiary: #7f8b84;
    --line: #303a34;
    --accent: #69b894;
    --accent-strong: #a9dec6;
    --accent-soft: #203a2e;
    --danger: #df716a;
    --danger-soft: #3b2322;
    --warning: #e2bb68;
    --warning-soft: #392f1d;
    --shadow-float: 0 14px 38px rgba(0, 0, 0, .34);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .bottom-nav { background: rgba(24, 30, 26, .94); }
  :root:not([data-theme="light"]) .deposit-badge { background: #223241; color: #9bc0e0; }
  :root:not([data-theme="light"]) .recurring-badge { background: #302940; color: #c2ace2; }
  :root:not([data-theme="light"]) .loading-block::before { background: linear-gradient(100deg, #222a25 20%, #2a332d 40%, #222a25 60%); background-size: 220% 100%; }
  :root:not([data-theme="light"]) .modal-backdrop { background: rgba(0, 0, 0, .56); }
}

:root[data-theme="dark"] {
  --bg: #101411;
  --surface: #181e1a;
  --surface-subtle: #222a25;
  --text: #f1f4f2;
  --text-secondary: #adb7b1;
  --text-tertiary: #7f8b84;
  --line: #303a34;
  --accent: #69b894;
  --accent-strong: #a9dec6;
  --accent-soft: #203a2e;
  --danger: #df716a;
  --danger-soft: #3b2322;
  --warning: #e2bb68;
  --warning-soft: #392f1d;
  --shadow-float: 0 14px 38px rgba(0, 0, 0, .34);
  color-scheme: dark;
}
:root[data-theme="dark"] .bottom-nav { background: rgba(24, 30, 26, .94); }
:root[data-theme="dark"] .deposit-badge { background: #223241; color: #9bc0e0; }
:root[data-theme="dark"] .recurring-badge { background: #302940; color: #c2ace2; }
:root[data-theme="dark"] .loading-block::before { background: linear-gradient(100deg, #222a25 20%, #2a332d 40%, #222a25 60%); background-size: 220% 100%; }
:root[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, .56); }
:root[data-theme="light"] {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-subtle: #f0f3f0;
  --text: #151a17;
  --text-secondary: #68716c;
  --text-tertiary: #929b96;
  --line: #e3e8e4;
  --accent: #276b53;
  --accent-strong: #1f5944;
  --accent-soft: #e7f0ec;
  --danger: #b4473f;
  --danger-soft: #f8e9e7;
  --warning: #8a631a;
  --warning-soft: #faf0d8;
  --shadow-float: 0 10px 30px rgba(21, 31, 25, .10);
  color-scheme: light;
}
:root[data-theme="light"] .bottom-nav { background: rgba(255, 255, 255, .94); }

.app-locked body { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
