:root {
  color-scheme: dark;
  --bg: #06110e;
  --surface: #0c1b16;
  --surface-raised: #132720;
  --surface-soft: #10221c;
  --text: #f1faf5;
  --muted: #a8bdb3;
  --border: #294339;
  --accent: #4de7b3;
  --accent-strong: #20c793;
  --income: #65d6a2;
  --expense: #ff8490;
  --expense-surface: #4b2227;
  --focus: #71b8ff;
  --shadow: 0 18px 54px rgb(0 0 0 / 22%);
  --radius: 22px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f6f2;
  --surface: #fffefa;
  --surface-raised: #ffffff;
  --surface-soft: #e8f1ec;
  --text: #10251c;
  --muted: #50685d;
  --border: #cadbd2;
  --accent: #087a5c;
  --accent-strong: #06684e;
  --income: #087a52;
  --expense: #b52f44;
  --expense-surface: #f7e5e7;
  --focus: #176ba8;
  --shadow: 0 18px 54px rgb(28 61 48 / 10%);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus), transparent 15%); outline-offset: 3px; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.app-shell { min-height: 100vh; }
.side-nav { display: none; }
.main-area { min-width: 0; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(16px,4vw,40px); border-bottom: 1px solid var(--border); background: color-mix(in srgb,var(--bg) 90%,transparent); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(18px); }
.brand { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 800; letter-spacing: .17em; }
.brand svg { width: 28px; height: 28px; color: var(--accent); }
.brand--desktop { display: none; }
.topbar__controls { display: flex; align-items: center; gap: 6px; }
.compact-control, .icon-control, .account-control { min-width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; }
.compact-control { padding: 0 12px; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.icon-control { display: grid; place-items: center; }
.icon-control svg { width: 20px; height: 20px; }
.account-control { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 11px; color: var(--accent); font-size: 13px; font-weight: 750; }
.account-control svg { width: 19px; height: 19px; }
.compact-control:hover, .icon-control:hover, .account-control:hover { border-color: var(--accent); background: var(--surface-raised); }

.content-frame { width: min(100%,1180px); margin: 0 auto; padding: clamp(20px,4vw,48px) clamp(16px,4vw,40px) calc(96px + var(--safe-bottom)); }
.preview-badge { width: fit-content; margin: 0 0 12px auto; padding: 5px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; }
.data-status { margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--muted); font-size: 14px; }
.data-status[data-tone="warning"] { border-color: color-mix(in srgb,#ffc56b 48%,var(--border)); color: var(--text); }
.data-status[data-tone="error"] { border-color: color-mix(in srgb,var(--expense) 50%,var(--border)); color: var(--text); }
.money-dashboard { display: grid; gap: 18px; }
.money-column { display: grid; gap: 14px; min-width: 0; align-content: start; }
.raslin-cut { clip-path: polygon(0 0,100% 0,100% 100%,16px 100%,0 calc(100% - 16px)); }
.balance-card, .operations-card, .goal-invitation { border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.balance-card { padding: clamp(22px,5vw,34px); }
.card-kicker, .period-label, .picker-section-label { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.balance-value { width: 100%; min-height: 60px; display: flex; align-items: baseline; gap: 8px; margin: 6px 0 24px; padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.balance-value:hover #currentAmount { color: var(--accent); }
#currentAmount { font-size: clamp(38px,9vw,58px); line-height: 1; font-weight: 780; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.balance-currency { color: var(--muted); font-size: 17px; font-weight: 700; }
.period-stats { display: grid; grid-template-columns: 1fr 1fr; margin-top: 9px; }
.period-stats > div { display: grid; gap: 3px; }
.period-stats > div + div { padding-left: 18px; border-left: 1px solid var(--border); }
.period-stats span { color: var(--muted); font-size: 13px; }
.period-stats strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.money-positive { color: var(--income); }
.money-negative { color: var(--expense); }
.money-actions { width: min(100%,460px); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-button { min-height: 52px; padding: 0 14px; border: 0; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; cursor: pointer; }
.action-button--add { color: #06110e; background: linear-gradient(135deg,#8ff1d0,var(--accent-strong)); }
.action-button--spend { color: #fff; background: linear-gradient(135deg,#d45b4e,#a93b3f); }
.action-button:hover { transform: translateY(-1px); filter: saturate(1.08); }
.action-button:active { transform: translateY(0); }

.goal-invitation { display: grid; grid-template-columns: auto 1fr; gap: 13px; align-items: center; padding: 18px; box-shadow: none; }
.goal-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: var(--accent); background: var(--surface-soft); }
.goal-mark svg { width: 26px; }
.goal-invitation h2 { margin: 0 0 3px; font-size: 16px; }
.goal-invitation p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.quiet-button { grid-column: 1 / -1; min-height: 46px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border: 1px solid var(--border); border-radius: 14px; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }
.quiet-button:hover { background: var(--surface-soft); border-color: var(--accent); }

.operations-card { min-width: 0; padding: clamp(20px,4vw,30px); }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.card-heading h2 { margin: 3px 0 0; font-size: clamp(20px,3vw,25px); }
.text-button { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }
.operation-list { display: grid; }
.operation-row { width: 100%; min-height: 66px; display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; }
.operation-row:hover { background: color-mix(in srgb,var(--surface-soft) 65%,transparent); }
.operation-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: var(--surface-soft); color: var(--accent); font-size: 20px; }
.operation-copy { display: grid; min-width: 0; }
.operation-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operation-copy small { color: var(--muted); }
.operation-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-state { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 7px; text-align: center; color: var(--muted); }
.empty-state[hidden] { display: none; }
.empty-state svg { width: 44px; height: 44px; margin-bottom: 5px; color: var(--accent); }
.empty-state h3 { margin: 0; color: var(--text); }
.empty-state p { margin: 0; font-size: 14px; }

.mobile-nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; min-height: calc(72px + var(--safe-bottom)); padding: 8px 10px var(--safe-bottom); display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid var(--border); background: color-mix(in srgb,var(--surface) 95%,transparent); backdrop-filter: blur(18px); }
.mobile-nav__item { min-height: 54px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); display: grid; place-items: center; align-content: center; gap: 3px; font-size: 11px; cursor: pointer; }
.mobile-nav__item svg { width: 21px; height: 21px; }
.mobile-nav__item.is-active { color: var(--accent); background: var(--surface-soft); }

.picker-dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: var(--text); }
.picker-dialog::backdrop { background: rgb(0 0 0 / 52%); backdrop-filter: blur(4px); }
.picker-panel { position: fixed; left: 0; right: 0; bottom: 0; width: 100%; max-height: min(82vh,720px); overflow: auto; padding: 22px 18px calc(22px + var(--safe-bottom)); border: 1px solid var(--border); border-radius: 24px 24px 0 0; background: var(--surface-raised); box-shadow: var(--shadow); }
.picker-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 18px; }
.picker-heading h2 { margin: 3px 0 0; font-size: 24px; }
.dialog-close { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); font-size: 26px; line-height: 1; cursor: pointer; }
.search-field { min-height: 50px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 0 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.search-field:focus-within { border-color: var(--focus); }
.search-field svg { width: 20px; height: 20px; color: var(--muted); }
.search-field input { width: 100%; min-width: 0; height: 48px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; }
.picker-list { display: grid; gap: 7px; }
.picker-option { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 14px; border: 1px solid transparent; border-radius: 14px; background: transparent; text-align: left; cursor: pointer; }
.picker-option:hover, .picker-option.is-selected { border-color: var(--border); background: var(--surface); }
.picker-option > span:first-child { display: grid; gap: 1px; }
.picker-option small { color: var(--muted); }
.picker-check { opacity: 0; color: var(--accent); font-size: 19px; }
.picker-option.is-selected .picker-check { opacity: 1; }
.picker-section-label { margin: 18px 0 8px; }
.currency-chips { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.currency-chip { min-height: 46px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); font-weight: 760; cursor: pointer; }
.currency-chip.is-selected { border-color: var(--accent); color: var(--accent); background: var(--surface-soft); }
.show-all-button { width: 100%; min-height: 46px; margin: 10px 0; border: 0; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }
.picker-panel--confirm { max-height: none; }
.confirm-copy { margin: 0; color: var(--text); line-height: 1.55; }
.warning-box { margin-top: 14px; padding: 13px 14px; border-left: 3px solid var(--expense); background: var(--expense-surface); color: var(--text); font-size: 14px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.secondary-button, .primary-button { min-height: 48px; border-radius: 14px; font-weight: 730; cursor: pointer; }
.secondary-button { border: 1px solid var(--border); background: transparent; }
.primary-button { border: 0; color: #06110e; background: var(--accent); }
.picker-panel--auth { max-height: none; }
.auth-copy { margin: 0 0 18px; color: var(--muted); line-height: 1.55; }
.auth-field { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
.auth-field input { width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid var(--border); border-radius: 14px; outline: 0; background: var(--surface); color: var(--text); font-size: 16px; }
.auth-field input:focus { border-color: var(--focus); }
.auth-submit { width: 100%; margin-top: 14px; padding-inline: 16px; }
.auth-submit:disabled { cursor: wait; opacity: .62; }
.signed-in-email { min-height: 50px; display: flex; align-items: center; padding: 0 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow-wrap: anywhere; }
.auth-message { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.auth-message[data-tone="error"] { border-color: color-mix(in srgb,var(--expense) 50%,var(--border)); color: var(--text); }

@media (min-width: 700px) {
  .content-frame { padding-bottom: 48px; }
  .money-dashboard { grid-template-columns: minmax(300px, .82fr) minmax(360px, 1.18fr); align-items: start; gap: clamp(18px,3vw,30px); }
  .mobile-nav { display: none; }
  .goal-invitation { padding: 20px; }
  .picker-dialog { display: none; place-items: center; padding: 24px; }
  .picker-dialog[open] { display: grid; }
  .picker-panel { position: static; width: min(100%,520px); max-height: min(78vh,720px); border-radius: 24px; padding: 26px; }
  .picker-panel--confirm, .picker-panel--auth { width: min(100%,500px); }
}

@media (min-width: 1040px) {
  .app-shell { display: grid; grid-template-columns: 224px minmax(0,1fr); }
  .side-nav { position: sticky; top: 0; min-height: 100vh; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px; border-right: 1px solid var(--border); background: var(--surface); }
  .brand--desktop { display: inline-flex; padding: 0 10px 28px; }
  .brand--mobile { display: none; }
  .side-nav__items { display: grid; gap: 6px; }
  .nav-item { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); cursor: pointer; text-align: left; }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item:hover, .nav-item.is-active { color: var(--accent); background: var(--surface-soft); }
  .side-nav__settings { margin-top: auto; }
  .topbar { justify-content: flex-end; padding-inline: 40px; }
  .content-frame { padding-top: 52px; }
  .money-actions { width: 100%; max-width: 460px; }
}

@media (prefers-reduced-motion: no-preference) {
  .action-button, .compact-control, .icon-control, .account-control, .picker-option { transition: transform 90ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease; }
}
