/* Natalina — the design system from the mockups, in one file. */

:root {
  --paper: #FBF9F5;
  --card: #FFFFFF;
  --sunken: #F5F1E7;
  --chip: #F1ECE2;
  --ink: #171614;
  --ink-2: #45413B;
  --muted: #8C867C;
  --faint: #A29B8E;
  --line: #EFEAE0;
  --line-2: #E8E3D9;

  --fixed: #3F5EA8;
  --variable: #B0702C;
  --mark: #2E2C28;
  --good: #4E8F6E;
  --alert: #A8562F;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  --r-sm: 9px;
  --r: 13px;
  --r-lg: 16px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabs-h: 78px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; text-align: left; }
a { color: var(--fixed); text-decoration: none; }
a:hover { color: #2E4A87; }
[hidden] { display: none !important; }

#app { display: flex; min-height: 100%; }

#view {
  flex: 1;
  min-width: 0;
  padding-bottom: calc(var(--tabs-h) + var(--safe-b));
  outline: none;
}

/* ------------------------------------------------------------- typography */

.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: #9A948A;
}
.serif { font-family: var(--serif); letter-spacing: -0.015em; }
.num { font-variant-numeric: tabular-nums; }
.screen-title { font-size: 15px; font-weight: 600; }
h2.section { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }

.big-amount { display: flex; align-items: baseline; gap: 6px; }
.big-amount .sym { font-family: var(--serif); font-size: 19px; color: var(--muted); }
.big-amount .val { font-family: var(--serif); font-size: 44px; line-height: 1.05; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ chrome */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: calc(env(safe-area-inset-top, 0px) + 18px) 14px 0;
}
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px; color: var(--muted);
}
.icon-btn:hover { background: var(--chip); }
.icon-btn:disabled { color: #D8D2C6; cursor: default; background: none; }

.pad { padding: 0 20px; }
.stack { display: flex; flex-direction: column; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 20px;
}

/* --------------------------------------------------------------- tab bars */

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: flex-start;
  height: calc(var(--tabs-h) + var(--safe-b));
  padding: 10px 0 var(--safe-b);
  background: rgba(251, 249, 245, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid #ECE6DB;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; width: 84px; height: 52px; color: #9A948A; font-size: 10.5px; font-weight: 500;
}
.tab[aria-current="page"] { color: var(--fixed); font-weight: 600; }

#fab {
  position: fixed; right: 20px; z-index: 31;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 16px);
  display: flex; align-items: center; justify-content: center;
  width: 58px; height: 58px; border-radius: 29px;
  background: var(--fixed); color: #fff;
  box-shadow: 0 8px 22px rgba(63, 94, 168, 0.32);
}
#fab:active { transform: scale(0.96); }

/* ---------------------------------------------------------------- pieces */

.split-bar { display: flex; gap: 2px; height: 10px; }
.split-bar > i { display: block; border-radius: 2px; }
.split-bar > i:first-child { border-radius: 5px 2px 2px 5px; }
.split-bar > i:last-child { border-radius: 2px 5px 5px 2px; }

.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.legend-row b { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.swatch { width: 8px; height: 8px; border-radius: 4px; flex: none; }
.swatch.fixed { background: var(--fixed); }
.swatch.variable { background: var(--variable); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  height: 44px; padding: 0 18px; border-radius: 22px;
  border: 1px solid var(--line-2); background: var(--card);
  color: var(--muted); font-size: 13.5px; font-weight: 500;
}
.chip[aria-pressed="true"] { background: #17161A; border-color: #17161A; color: #fff; font-weight: 600; }

.day-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 2px 8px; font-size: 11.5px; color: #9A948A;
}
.day-head span:first-child { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 13px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
}
.row:hover { background: #FFFDF9; }
.row .glyph {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 11px; flex: none;
}
.row .body { flex: 1; min-width: 0; }
.row .name { font-size: 14.5px; font-weight: 500; letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; color: var(--muted); }
.row .val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.tag {
  font-size: 9px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: #7C766C; background: var(--chip); padding: 2px 5px; border-radius: 4px;
}

.empty { padding: 48px 24px; text-align: center; color: var(--faint); font-size: 13.5px; line-height: 1.6; }

.note {
  display: flex; gap: 10px; padding: 18px 22px 0;
  font-size: 12.5px; line-height: 1.5; color: var(--muted);
}

/* --------------------------------------------------------------- controls */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 18px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line-2);
  font-size: 14.5px; font-weight: 600; color: var(--ink-2);
}
.btn:hover { background: #FFFDF8; }
.btn.primary { background: var(--fixed); border-color: var(--fixed); color: #fff; box-shadow: 0 6px 18px rgba(63, 94, 168, 0.28); }
.btn.primary:hover { background: #37538F; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.danger { color: #97331F; border-color: #E9D6CF; background: #FCF4F1; }
.btn.dashed { border-style: dashed; border-color: #D8D1C3; background: transparent; color: var(--muted); font-weight: 500; }
.btn.block { width: 100%; }
.btn.tall { height: 54px; font-size: 16px; border-radius: 15px; }
.btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line-2);
  font-size: 15px; color: var(--ink); outline: none;
}
.input:focus { border-color: var(--fixed); box-shadow: 0 0 0 3px rgba(63, 94, 168, 0.12); }
.input.code { letter-spacing: 0.3em; text-transform: uppercase; font-weight: 600; text-align: center; }

.switch { display: flex; align-items: center; width: 51px; height: 44px; flex: none; }
.switch > span {
  position: relative; display: block; width: 51px; height: 31px; border-radius: 16px;
  background: #DED8CB; transition: background .18s ease;
}
.switch > span > i {
  position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 14px;
  background: #fff; box-shadow: 0 1px 3px rgba(23, 22, 20, 0.22); transition: left .18s ease;
}
.switch[aria-checked="true"] > span { background: var(--fixed); }
.switch[aria-checked="true"] > span > i { left: 22px; }
.switch.variable[aria-checked="true"] > span { background: var(--variable); }
.switch.good[aria-checked="true"] > span { background: var(--good); }

.seg { display: flex; gap: 4px; padding: 4px; height: 52px; background: var(--chip); border-radius: 15px; }
.seg > button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 11px; font-size: 14px; font-weight: 500; color: #7C766C;
}
.seg > button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(23, 22, 20, 0.10); }

/* -------------------------------------------------------------- add view */

.amount-display { padding: 18px 20px 12px; text-align: center; }
.amount-display .line { display: flex; align-items: baseline; justify-content: center; gap: 7px; margin-top: 6px; }
.amount-display .sym { font-family: var(--serif); font-size: 21px; color: var(--muted); }
.amount-display .val { font-family: var(--serif); font-size: 52px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.amount-display .val.zero { color: #C3BCAF; }
.caret { display: inline-block; width: 2px; height: 38px; border-radius: 1px; background: var(--fixed); animation: caret 1.1s steps(1, end) infinite; }
@keyframes caret { 0%, 55% { opacity: 1 } 56%, 100% { opacity: 0 } }

.group-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; }
.group-head .eyebrow { color: var(--muted); }
.group-head .hint { font-size: 11px; color: #B3ACA0; }

.cat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cat {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 60px; border-radius: var(--r); border: 1.5px solid var(--line-2);
  background: var(--card); color: var(--muted); transition: all .12s ease;
}
.cat span { font-size: 10.5px; font-weight: 500; }
.cat[aria-pressed="true"] { font-weight: 600; }
.cat[aria-pressed="true"].fixed { border-color: var(--fixed); background: rgba(63, 94, 168, 0.07); color: var(--fixed); }
.cat[aria-pressed="true"].variable { border-color: var(--variable); background: rgba(176, 112, 44, 0.07); color: var(--variable); }
.cat:active { transform: scale(0.96); }

.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 16px; }
.key {
  display: flex; align-items: center; justify-content: center; height: 48px;
  border-radius: var(--r); background: var(--card); border: 1px solid #EDE8DE;
  font-family: var(--serif); font-size: 22px; transition: transform .08s ease;
}
.key.util { background: var(--chip); border-color: var(--line-2); color: var(--muted); }
.key:active { transform: scale(0.96); }

/* ------------------------------------------------------------ report bits */

/* Phone: each stat is a compact row. Desktop turns them back into three tiles. */
.kpis { display: grid; grid-template-columns: 1fr; gap: 10px; }
.kpi { display: grid; grid-template-columns: 1fr auto; align-items: baseline; padding: 15px 18px; }
.kpi > :first-child { grid-column: 1; grid-row: 1; }
.kpi .val { grid-column: 2; grid-row: 1; display: flex; align-items: baseline; gap: 5px; justify-content: flex-end; }
.kpi .foot { grid-column: 1 / -1; }
.kpi .val .sym { font-family: var(--serif); font-size: 17px; color: var(--muted); }
.kpi .val .n { font-family: var(--serif); font-size: 26px; line-height: 1; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12.5px; margin-top: 6px; color: var(--muted); }
.kpi .foot.up { color: var(--alert); }
.kpi .foot.down { color: var(--good); }

.bars { display: flex; flex-direction: column; gap: 4px; }
.bar-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 30px; padding: 0 4px; border-radius: 7px; transition: opacity .15s ease;
}
.bar-row.dim { opacity: 0.35; }
.bar-row { gap: 8px; }
.bar-row .label { width: 72px; flex: none; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row[aria-pressed="true"] .label { font-weight: 600; }
.bar-row .track { flex: 1; min-width: 16px; height: 9px; border-radius: 5px; background: #F1ECE1; }
.bar-row .track > i { display: block; height: 9px; border-radius: 0 4px 4px 0; background: var(--mark); }
.bar-row .amt { width: 76px; flex: none; text-align: right; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-row .pct { width: 28px; flex: none; text-align: right; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.chart { position: relative; height: 150px; margin-top: 14px; }
.chart .cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 3px; }
.chart .cols > i { flex: 1; min-width: 0; border-radius: 4px 4px 0 0; background: var(--mark); }
.chart .cols > i.future { background: #EDE8DE; }
.chart .avg { position: absolute; left: 0; right: 0; border-top: 1px dashed #D9D2C4; }
.chart .avg-label { position: absolute; right: 0; font-size: 10.5px; color: var(--faint); background: var(--card); padding: 0 4px; }
.chart-axis { display: flex; justify-content: space-between; margin-top: 8px; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.tx-row { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px solid #F3EEE4; }
.tx-row:last-child { border-bottom: 0; }
.tx-row .d { width: 46px; flex: none; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tx-row .n { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-row .a { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- prompts */

.prompt {
  border: 1px solid #E4D9C4; background: #FDF8EC;
  border-radius: var(--r-lg); padding: 14px 16px;
}
.prompt .head { display: flex; align-items: center; gap: 9px; }
.prompt .head b { font-size: 14px; font-weight: 600; }
.prompt p { margin: 6px 0 12px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.prompt .act { display: flex; gap: 8px; }
.prompt .act .input { flex: 1; }

/* --------------------------------------------------------------- balance */

.balance {
  display: block; width: 100%; margin-top: 16px;
  padding: 14px 16px; border-radius: var(--r-lg);
  border: 1px solid transparent;
}
.balance.good { background: #EDF2EC; border-color: #DCE7DC; }
.balance.bad  { background: #FBF0EC; border-color: #F0DED6; }
.balance .row-1 { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.balance .label { font-size: 12.5px; font-weight: 600; }
.balance .value { font-family: var(--serif); font-size: 30px; line-height: 1.05; letter-spacing: -0.015em; }
.balance.good .label, .balance.good .value { color: #35624A; }
.balance.bad  .label, .balance.bad  .value { color: #8E3B22; }
.balance .row-2 {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.balance .spent-share { flex-basis: 100%; }

/* The report's copy of the card. On a phone the label and the number each get
   their own line — side by side, the number wraps mid-figure. */
.balance.big .row-1 { flex-direction: column; align-items: flex-start; gap: 2px; }
.balance.big .value { font-size: 32px; }
.balance.big .row-2 { font-size: 12.5px; margin-top: 8px; }

.empty-balance {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--card); border: 1px dashed #DDD6C8;
  font-size: 12.5px; color: var(--muted); line-height: 1.4;
}
.empty-balance:hover { background: #FFFDF8; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 6px 10px; border-radius: 20px; white-space: nowrap;
  background: #EDF2EC; color: #46614F; font-size: 11.5px; font-weight: 500;
}
.sync-pill .swatch { background: var(--good); width: 6px; height: 6px; }
.sync-pill.warn { background: #FBF1E8; color: #8A5A2B; }
.sync-pill.warn .swatch { background: var(--variable); }
.sync-pill.off { background: var(--chip); color: var(--muted); }
.sync-pill.off .swatch { background: #C3BCAF; }

/* ----------------------------------------------------------- sheet, toast */

#sheet-host:empty, #toast-host:empty { display: none; }

.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(23, 22, 20, 0.32);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease both;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--paper); border-radius: 22px 22px 0 0;
  padding: 8px 20px calc(24px + var(--safe-b));
  animation: rise .2s cubic-bezier(.2, .8, .3, 1) both;
}
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: #DDD6C8; margin: 8px auto 14px; }
.sheet h3 { margin: 0 0 14px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.sheet .field + .field { margin-top: 14px; }
.sheet .actions { display: flex; gap: 8px; margin-top: 20px; }
.sheet .actions .btn { flex: 1; }

#toast-host { position: fixed; left: 16px; right: 16px; z-index: 80; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px; border-radius: 15px;
  background: #17161A; color: #fff; font-size: 13.5px; line-height: 1.35;
  box-shadow: 0 12px 30px rgba(23, 22, 20, 0.24);
  animation: rise .22s ease both;
}
.toast .ok { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 11px; background: var(--good); flex: none; }
.toast.bad .ok { background: var(--alert); }

@keyframes rise { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

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

/* ------------------------------------------------------------- wide screen */

#rail { display: none; }

@media (min-width: 1024px) {
  #app { min-height: 100vh; }
  #tabs, #fab { display: none; }
  #view { padding-bottom: 0; }

  #rail {
    display: flex; flex-direction: column; width: 236px; flex: none;
    padding: 28px 18px; background: var(--sunken);
    border-right: 1px solid #EAE4D7; position: sticky; top: 0; height: 100vh;
  }
  .rail-brand {
    display: flex; align-items: center; gap: 9px; padding: 0 8px;
    font-family: var(--serif); font-size: 21px; letter-spacing: -0.01em;
  }
  .rail-brand .dot { width: 9px; height: 9px; border-radius: 5px; background: var(--fixed); }
  .rail-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 26px; }
  .rail-nav .tab {
    flex-direction: row; width: 100%; height: 38px; gap: 10px;
    padding: 0 10px; border-radius: var(--r-sm); font-size: 14px; justify-content: flex-start;
  }
  .rail-nav .tab[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(23, 22, 20, 0.05); }
  .rail-foot { margin-top: auto; }

  .wide { max-width: 1180px; padding: 30px 36px 60px; }
  .wide.narrow { max-width: 780px; }

  .balance.big { padding: 20px 22px; }
  .balance.big .row-1 { flex-direction: row; align-items: baseline; gap: 12px; }
  .balance.big .label { font-size: 13px; }
  .balance.big .value { font-size: 40px; }
  .balance.big .spent-share { flex-basis: auto; margin-left: auto; }

  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .kpi { display: block; padding: 18px 20px; }
  .kpi .val { margin-top: 7px; justify-content: flex-start; }
  .kpi .val .n { font-size: 30px; }
  .kpi .foot { margin-top: 7px; }
  .wide .topbar { padding-top: 0; padding-left: 0; padding-right: 0; }
  .two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  .two-col-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; }
  .big-amount .val { font-size: 52px; }
  .chart { height: 190px; }
  .cat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .keypad { max-width: 420px; margin: 0 auto; }
  .amount-display .val { font-size: 60px; }
}

@media (min-width: 1024px) {
  .phone-only { display: none !important; }
}
@media (max-width: 1023px) {
  .wide-only { display: none !important; }
  .two-col, .two-col-inner { display: flex; flex-direction: column; gap: 18px; }
}
