/* =========================================================================
   Household Budget Planner - design system
   Dark-first, mobile-first. Chart colors come from the validated data-viz
   palette (categorical slots 1-4), re-stepped per surface.
   ========================================================================= */

:root {
  color-scheme: dark;

  /* Surfaces & ink */
  --bg:           #0A0D12;
  --bg-soft:      #0E131A;
  --surface:      #141A22;
  --surface-2:    #1C242F;
  --surface-3:    #26303D;
  --line:         rgba(255, 255, 255, .08);
  --line-strong:  rgba(255, 255, 255, .16);
  --ink:          #F2F5F9;
  --ink-2:        #A3AEBD;
  --ink-3:        #6C7A8B;

  /* Brand */
  --accent:       #2DD4A7;
  --accent-soft:  rgba(45, 212, 167, .14);
  --accent-ink:   #04231B;

  /* Status (fixed palette, never themed - always shipped with icon + label) */
  --st-good:      #0ca30c;
  --st-warning:   #fab219;
  --st-serious:   #ec835a;
  --st-critical:  #d03b3b;
  --st-info:      #3987e5;

  /* Categorical chart slots, stepped for the dark surface */
  --series-1:     #3987e5;  /* Needs   */
  --series-2:     #d95926;  /* Musts   */
  --series-3:     #199e70;  /* Wants   */
  --series-4:     #c98500;  /* Savings */
  --grid:         rgba(255, 255, 255, .07);
  --axis:         #6C7A8B;

  /* Shape & motion */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --pad: 16px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, .65);
  --shadow-3: 0 -12px 40px -8px rgba(0, 0, 0, .6);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --appbar-h: 56px;
  --tabbar-h: 60px;
}

/* Light theme - selected values, not an inversion.
   The media query covers the OS setting; the [data-theme] scope covers the
   in-app toggle and must win both ways. */
@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="dark"])) {
    color-scheme: light;
    --bg:          #EEF1F5;
    --bg-soft:     #F5F7FA;
    --surface:     #FFFFFF;
    --surface-2:   #F4F6F9;
    --surface-3:   #E7ECF2;
    --line:        rgba(13, 21, 32, .10);
    --line-strong: rgba(13, 21, 32, .20);
    --ink:         #0D1520;
    --ink-2:       #53637A;
    --ink-3:       #7C8BA0;
    --accent:      #0E9E77;
    --accent-soft: rgba(14, 158, 119, .12);
    --accent-ink:  #FFFFFF;
    --series-1:    #2a78d6;
    --series-2:    #eb6834;
    --series-3:    #1baf7a;
    --series-4:    #eda100;
    --grid:        rgba(13, 21, 32, .08);
    --axis:        #7C8BA0;
    --shadow-2: 0 10px 30px -14px rgba(13, 21, 32, .28);
    --shadow-3: 0 -12px 40px -10px rgba(13, 21, 32, .22);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:          #EEF1F5;
  --bg-soft:     #F5F7FA;
  --surface:     #FFFFFF;
  --surface-2:   #F4F6F9;
  --surface-3:   #E7ECF2;
  --line:        rgba(13, 21, 32, .10);
  --line-strong: rgba(13, 21, 32, .20);
  --ink:         #0D1520;
  --ink-2:       #53637A;
  --ink-3:       #7C8BA0;
  --accent:      #0E9E77;
  --accent-soft: rgba(14, 158, 119, .12);
  --accent-ink:  #FFFFFF;
  --series-1:    #2a78d6;
  --series-2:    #eb6834;
  --series-3:    #1baf7a;
  --series-4:    #eda100;
  --grid:        rgba(13, 21, 32, .08);
  --axis:        #7C8BA0;
  --shadow-2: 0 10px 30px -14px rgba(13, 21, 32, .28);
  --shadow-3: 0 -12px 40px -10px rgba(13, 21, 32, .22);
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }

/* Components below set display on classes that would otherwise out-specify the
   UA's [hidden] rule, so conditional fields must win explicitly. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.num { font-variant-numeric: tabular-nums; }
.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;
}

/* --------------------------------------------------------------- splash */

.splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; gap: 28px; justify-items: center;
  background: var(--bg);
}
.splash[hidden] { display: none; }
.splash__mark {
  width: 76px; height: 76px; border-radius: 22px;
  background: linear-gradient(135deg, #1AC2A8, #075E4E);
  box-shadow: var(--shadow-2);
  position: relative;
}
.splash__mark::after {
  content: ""; position: absolute; inset: 20px;
  border-radius: 50%;
  border: 7px solid #fff;
  border-bottom-color: rgba(255, 255, 255, .45);
  border-left-color: rgba(255, 255, 255, .45);
}
.splash__spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ app shell */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.app[hidden] { display: none; }

.appbar {
  position: sticky; top: 0; z-index: 30;
  padding: calc(var(--safe-t) + 6px) 12px 6px;
  min-height: calc(var(--appbar-h) + var(--safe-t));
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.appbar--scrolled { border-bottom-color: var(--line); }
.appbar__titles { flex: 1; min-width: 0; }
.appbar__title {
  font-size: 19px; font-weight: 680; letter-spacing: -.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar__sub { font-size: 12.5px; color: var(--ink-3); }
.appbar__actions { display: flex; align-items: center; gap: 4px; }

.iconbtn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn:active { transform: scale(.92); }
.iconbtn--accent { color: var(--accent); }

.view {
  flex: 1;
  padding: 4px var(--pad) calc(var(--tabbar-h) + var(--safe-b) + 28px);
  display: flex; flex-direction: column; gap: 14px;
  outline: none;
  animation: viewin .22s var(--ease);
}
/* Full-bleed view for chromeless screens such as sign-in. */
.view--bare { padding: 0; display: block; }

@keyframes viewin { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .view, .sheet__panel, .toast, .splash__spinner { animation: none !important; }
}

/* ---------------------------------------------------------------- tabbar */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-top: 1px solid var(--line);
}
.tab {
  height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; cursor: pointer;
  color: var(--ink-3); font-size: 10.5px; font-weight: 550; letter-spacing: .01em;
  position: relative;
  transition: color .16s;
}
.tab__icon { transition: transform .18s var(--ease); }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] .tab__icon { transform: translateY(-1px) scale(1.06); }
.tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 50%; translate: -50% 0;
  width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}
.tab:active .tab__icon { transform: scale(.88); }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--pad);
}
.card--flush { padding: 0; overflow: hidden; }
.card--quiet { background: var(--bg-soft); }

.card__head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.card__title {
  font-size: 13px; font-weight: 620; color: var(--ink-2);
  letter-spacing: .02em; text-transform: uppercase;
}
.spacer { flex: 1; }

.section-title {
  font-size: 12.5px; font-weight: 640; color: var(--ink-3);
  letter-spacing: .06em; text-transform: uppercase;
  margin: 10px 2px 0;
  display: flex; align-items: center; gap: 8px;
}

/* Hero figure - proportional figures, generous size. */
.hero { display: grid; gap: 4px; }
.hero__label { font-size: 13px; color: var(--ink-2); }
.hero__value {
  font-size: clamp(30px, 9vw, 40px); font-weight: 700; letter-spacing: -.03em;
  line-height: 1.05;
}
.hero__meta { font-size: 13px; color: var(--ink-3); }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 14px;
  display: grid; gap: 3px; align-content: start;
  min-height: 84px;
  text-align: left;
}
button.tile { cursor: pointer; transition: background .15s, transform .1s; }
button.tile:active { transform: scale(.985); }
.tile__label {
  font-size: 11.5px; font-weight: 600; color: var(--ink-3);
  letter-spacing: .04em; text-transform: uppercase;
  display: flex; align-items: center; gap: 5px;
}
.tile__value { font-size: 22px; font-weight: 680; letter-spacing: -.02em; }
.tile__meta { font-size: 12px; color: var(--ink-3); }

/* ---------------------------------------------------------------- chips */

.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  /* Bleed past the view gutter so a clipped chip signals "scroll me". */
  margin: 0 calc(var(--pad) * -1);
  padding: 2px var(--pad) 4px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; cursor: pointer;
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 13px; font-weight: 550;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}
.chip__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge svg { flex: none; }
.badge--good     { color: var(--ink); background: color-mix(in srgb, var(--st-good) 16%, transparent);     border-color: color-mix(in srgb, var(--st-good) 34%, transparent); }
.badge--info     { color: var(--ink); background: color-mix(in srgb, var(--st-info) 16%, transparent);     border-color: color-mix(in srgb, var(--st-info) 34%, transparent); }
.badge--warning  { color: var(--ink); background: color-mix(in srgb, var(--st-warning) 18%, transparent);  border-color: color-mix(in srgb, var(--st-warning) 38%, transparent); }
.badge--critical { color: var(--ink); background: color-mix(in srgb, var(--st-critical) 16%, transparent); border-color: color-mix(in srgb, var(--st-critical) 36%, transparent); }
.badge--good svg     { color: var(--st-good); }
.badge--info svg     { color: var(--st-info); }
.badge--warning svg  { color: var(--st-warning); }
.badge--critical svg { color: var(--st-critical); }

/* --------------------------------------------------------------- buttons */

.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: var(--r-md); border: 1px solid transparent;
  background: var(--surface-2); color: var(--ink);
  font-size: 15px; font-weight: 600;
  transition: transform .1s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }
.btn--danger {
  background: color-mix(in srgb, var(--st-critical) 16%, transparent);
  color: var(--st-critical);
  border-color: color-mix(in srgb, var(--st-critical) 34%, transparent);
}
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: var(--r-sm); }

.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

.fab {
  position: fixed; right: 16px; z-index: 35;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer;
  box-shadow: var(--shadow-2);
  transition: transform .12s var(--ease);
}
.fab:active { transform: scale(.9); }

/* ----------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--line); }

.row {
  width: 100%; text-align: left; background: none; border: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 13px var(--pad); min-height: 58px;
  color: inherit; cursor: pointer;
  transition: background .13s;
}
.row:hover { background: var(--surface-2); }
.row:active { background: var(--surface-3); }
.row--static { cursor: default; }
.row--static:hover { background: none; }
.row__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row__title { font-size: 15px; font-weight: 570; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row__end { text-align: right; display: grid; gap: 2px; flex: none; }
.row__value { font-size: 15.5px; font-weight: 640; letter-spacing: -.01em; }
.row__note { font-size: 11.5px; color: var(--ink-3); }
.row__chev { color: var(--ink-3); flex: none; }
.row--muted .row__title, .row--muted .row__value { color: var(--ink-3); }

.avatar {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: -.02em;
  background: var(--surface-2); color: var(--ink-2);
}

/* ---------------------------------------------------------------- charts */

.legend { display: flex; flex-direction: column; gap: 0; margin-top: 12px; }
.legend__item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 0; font-size: 13.5px;
  border-top: 1px solid var(--line);
}
.legend__item:first-child { border-top: 0; }
.legend__swatch {
  width: 10px; height: 10px; border-radius: 3px; flex: none;
  box-shadow: inset 0 0 0 1px var(--line);
}
.legend__name { flex: 1; color: var(--ink-2); }
.legend__value { font-weight: 620; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.legend__pct { color: var(--ink-3); font-size: 12.5px; min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }

/* 2px surface gaps between stacked segments, per the mark spec. */
.stackbar { display: flex; width: 100%; height: 14px; gap: 2px; }
.stackbar__seg { height: 100%; min-width: 2px; }
.stackbar__seg:first-child { border-radius: 4px 0 0 4px; }
.stackbar__seg:last-child { border-radius: 0 4px 4px 0; }
.stackbar__seg:only-child { border-radius: 4px; }

.chart { width: 100%; overflow: visible; touch-action: pan-y; display: block; }
.chart text { font-size: 10.5px; fill: var(--axis); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }

.chart-wrap { position: relative; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 8px 10px; font-size: 12.5px; line-height: 1.45;
  box-shadow: var(--shadow-2);
  max-width: 230px;
  transition: opacity .1s;
}
.tooltip__date { color: var(--ink-3); font-size: 11.5px; }
.tooltip__value { font-weight: 660; font-variant-numeric: tabular-nums; }
.tooltip__event { color: var(--ink-2); margin-top: 2px; }

/* --------------------------------------------------------------- callout */

.callout {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  text-align: left; width: 100%; cursor: pointer; color: inherit;
}
.callout--static { cursor: default; }
.callout__icon { flex: none; margin-top: 1px; }
.callout__body { flex: 1; display: grid; gap: 2px; }
.callout__title { font-size: 14px; font-weight: 640; }
.callout__text { font-size: 12.5px; color: var(--ink-2); }
.callout--warning  { background: color-mix(in srgb, var(--st-warning) 11%, var(--surface));  border-color: color-mix(in srgb, var(--st-warning) 30%, transparent); }
.callout--info     { background: color-mix(in srgb, var(--st-info) 11%, var(--surface));     border-color: color-mix(in srgb, var(--st-info) 30%, transparent); }
.callout--good     { background: color-mix(in srgb, var(--st-good) 11%, var(--surface));     border-color: color-mix(in srgb, var(--st-good) 30%, transparent); }
.callout--critical { background: color-mix(in srgb, var(--st-critical) 11%, var(--surface)); border-color: color-mix(in srgb, var(--st-critical) 30%, transparent); }
.callout--warning .callout__icon  { color: var(--st-warning); }
.callout--info .callout__icon     { color: var(--st-info); }
.callout--good .callout__icon     { color: var(--st-good); }
.callout--critical .callout__icon { color: var(--st-critical); }

/* ------------------------------------------------------------ empty state */

.empty {
  display: grid; gap: 10px; justify-items: center; text-align: center;
  padding: 44px 24px; color: var(--ink-3);
}
.empty__icon {
  width: 56px; height: 56px; border-radius: 18px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-3);
}
.empty__title { font-size: 16px; font-weight: 620; color: var(--ink); }
.empty__text { font-size: 13.5px; max-width: 34ch; }

.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------------------------------------------------------------- forms */

.field { display: grid; gap: 6px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field__hint { font-size: 11.5px; color: var(--ink-3); }

.input, .select, .textarea {
  width: 100%; min-height: 48px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.textarea { min-height: 84px; resize: vertical; }
.select { appearance: none; padding-right: 38px; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; translate: 0 -65%;
  width: 8px; height: 8px; pointer-events: none;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  rotate: 45deg;
}
.input--money { font-size: 17px; font-weight: 620; font-variant-numeric: tabular-nums; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form { display: grid; gap: 14px; }

.switchrow {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; cursor: pointer;
}
.switchrow__body { flex: 1; display: grid; gap: 2px; }
.switch {
  appearance: none; flex: none; cursor: pointer;
  width: 46px; height: 28px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line);
  position: relative; transition: background .18s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink-2); transition: transform .18s var(--ease), background .18s;
}
.switch:checked { background: var(--accent); border-color: transparent; }
.switch:checked::after { transform: translateX(18px); background: #fff; }

.segmented {
  display: flex; gap: 3px; padding: 3px;
  background: var(--surface-2); border-radius: var(--r-md);
  border: 1px solid var(--line);
}
.segmented__btn {
  flex: 1; min-height: 36px; border: 0; cursor: pointer;
  border-radius: 11px; background: transparent; color: var(--ink-2);
  font-size: 13.5px; font-weight: 600;
  transition: background .15s, color .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.segmented__btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.stepper {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 3px;
}
.stepper__label {
  flex: 1; text-align: center; font-size: 14px; font-weight: 620;
  padding: 7px 4px; cursor: pointer; border: 0; background: none; color: inherit;
  border-radius: var(--r-sm);
}
.stepper__label:hover { background: var(--surface-2); }

/* ---------------------------------------------------------------- sheets */

.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3, 6, 10, .55);
  backdrop-filter: blur(2px);
  animation: fade .2s var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed; inset: 0; z-index: 51;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
}
.sheet__panel {
  pointer-events: auto;
  width: 100%; max-width: 560px;
  max-height: min(88dvh, 780px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  animation: sheetin .28s var(--ease);
}
@keyframes sheetin { from { transform: translateY(100%); } }
.sheet__grip {
  width: 38px; height: 4px; border-radius: 99px; background: var(--line-strong);
  margin: 9px auto 0; flex: none;
}
.sheet__head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px var(--pad) 8px; flex: none;
}
.sheet__title { flex: 1; font-size: 17px; font-weight: 680; letter-spacing: -.015em; }
.sheet__body { overflow-y: auto; padding: 4px var(--pad) 12px; -webkit-overflow-scrolling: touch; }
.sheet__foot {
  flex: none; display: flex; gap: 10px;
  padding: 12px var(--pad) calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet__foot > .btn { flex: 1; }

/* --------------------------------------------------------------- toasts */

.toasts {
  position: fixed; z-index: 60; left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: 460px; width: fit-content;
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px; border-radius: 999px;
  background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2);
  font-size: 13.5px; font-weight: 550;
  animation: toastin .24s var(--ease);
}
@keyframes toastin { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.toast--out { opacity: 0; transform: translateY(8px); transition: all .2s; }
.toast--good svg { color: var(--st-good); }
.toast--critical svg { color: var(--st-critical); }

.banner {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-radius: var(--r-md);
  font-size: 12.5px; font-weight: 550;
  background: color-mix(in srgb, var(--st-warning) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--st-warning) 32%, transparent);
}
.banner svg { color: var(--st-warning); flex: none; }

.ptr {
  position: fixed; left: 50%; z-index: 25;
  top: calc(var(--safe-t) + 54px);
  translate: -50% 0;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: var(--shadow-2); color: var(--accent);
  opacity: 0; pointer-events: none;
}

/* ------------------------------------------------------------- auth view */

.auth {
  min-height: 100dvh;
  display: grid; align-content: center; justify-items: center; gap: 22px;
  padding: calc(var(--safe-t) + 32px) 22px calc(var(--safe-b) + 32px);
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 12%, var(--bg)) 0%, var(--bg) 62%);
}
.auth__mark {
  width: 68px; height: 68px; border-radius: 20px;
  background: linear-gradient(135deg, #1AC2A8, #075E4E);
  box-shadow: var(--shadow-2); position: relative;
}
.auth__mark::after {
  content: ""; position: absolute; inset: 18px; border-radius: 50%;
  border: 6px solid #fff;
  border-bottom-color: rgba(255, 255, 255, .45);
  border-left-color: rgba(255, 255, 255, .45);
}
.auth__head { text-align: center; display: grid; gap: 6px; justify-items: center; }
.auth__title { font-size: 23px; font-weight: 700; letter-spacing: -.025em; }
.auth__sub { font-size: 14px; color: var(--ink-2); max-width: 32ch; }
.auth__card { width: 100%; max-width: 380px; display: grid; gap: 14px; }

/* --------------------------------------------------- copyable plan rows */

.transfer {
  display: flex; align-items: center; gap: 12px;
  padding: 13px var(--pad);
  width: 100%; text-align: left; border: 0; background: none; color: inherit;
  cursor: pointer; transition: background .13s;
}
.transfer:hover { background: var(--surface-2); }
.transfer:active { background: var(--surface-3); }
.transfer__main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.transfer__name { font-size: 15px; font-weight: 580; }
.transfer__iban {
  font: 500 11.5px/1.3 ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  color: var(--ink-3); letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: 5px;
}
.transfer__amount {
  font-size: 17px; font-weight: 680; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; flex: none;
  display: flex; align-items: center; gap: 7px;
}
.transfer__amount svg { color: var(--ink-3); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; font-weight: 570; }
.kv dd.mono { font: 500 12px/1.4 ui-monospace, Menlo, monospace; word-break: break-all; }

pre.plaintext {
  margin: 0; padding: 14px; overflow-x: auto;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--r-md);
  font: 400 11.5px/1.6 ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  color: var(--ink-2); white-space: pre; -webkit-overflow-scrolling: touch;
}

/* ------------------------------------------------------- desktop layout */

@media (min-width: 900px) {
  :root { --pad: 20px; }

  .app {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "nav bar" "nav view";
    max-width: 1280px; margin: 0 auto;
  }
  .appbar {
    grid-area: bar;
    padding: 18px 28px 10px;
    background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
    border-bottom: 0;
  }
  .appbar__title { font-size: 26px; letter-spacing: -.025em; }
  .view {
    grid-area: view;
    padding: 6px 28px 60px;
    max-width: 960px;
  }
  .tabbar {
    grid-area: nav;
    position: sticky; top: 0; align-self: start;
    left: auto; right: auto; bottom: auto;
    height: 100dvh;
    display: flex; flex-direction: column; gap: 4px;
    padding: 24px 14px;
    border-top: 0; border-right: 1px solid var(--line);
    background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .tabbar::before {
    content: "Budget Planner";
    font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--ink-3); padding: 0 12px 16px;
  }
  .tab {
    height: 46px; flex-direction: row; justify-content: flex-start; gap: 13px;
    padding: 0 12px; border-radius: var(--r-md); font-size: 14.5px; font-weight: 570;
  }
  .tab:hover { background: var(--surface-2); color: var(--ink); }
  .tab[aria-current="page"] { background: var(--accent-soft); }
  .tab[aria-current="page"]::before { display: none; }

  .fab { display: none; }
  .toasts { bottom: 24px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }

  .sheet { align-items: center; }
  .sheet__panel {
    max-width: 520px; border-radius: var(--r-xl); border-bottom: 1px solid var(--line);
    animation: dialogin .22s var(--ease);
  }
  @keyframes dialogin { from { opacity: 0; transform: translateY(14px) scale(.98); } }
  .sheet__grip { display: none; }
  .sheet__foot { padding-bottom: 14px; }
  .ptr { display: none; }
}

@media (min-width: 1180px) {
  .view { max-width: 1000px; }
}
