/* Layout: one phone column under a banknote-style balance, list rows divided by hairlines, fixed thumb nav. */
:root {
  --logo-pocket: #0F4A47;
  --logo-note: #5BB8A4;
  --logo-note-on-dark: #4CC2B0;
  --bt-plate: transparent;
  --paper: #F3F5F0;
  --raised: #FFFFFF;
  --ink: #142B2A;
  --ink-2: #4C625F;
  --ink-3: #5B706C;
  --line: #D8DFD8;
  --accent: #0F6B62;
  --accent-ink: #FFFFFF;
  --note: #0F4A47;
  --note-2: #1B6660;
  --note-over: #7E2320;
  --note-over-2: #A23A33;
  --on-note: #F1F8F2;
  --on-note-2: #BFDCD3;
  --good: #1B7A4B;
  --near: #94600A;
  --near-bg: #F8EBCF;
  --over: #BE2F27;
  --over-bg: #FAE3DF;
  --track: #E1E6DF;
  --series-income: #1F7EB8;
  --series-spent: #C76A3A;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --logo-pocket: #E9F1EC; --logo-note: #4CC2B0; --bt-plate: #FFFFFF;
    --paper: #101B1C; --raised: #1A2828; --ink: #E9F1EC; --ink-2: #AFC1BC; --ink-3: #8DA29D;
    --line: #2C3D3C; --accent: #4CC2B0; --accent-ink: #082220;
    --note: #123F3D; --note-2: #1F6D65; --note-over: #5E1D1B; --note-over-2: #93362F;
    --on-note: #F1F8F2; --on-note-2: #B6D6CC;
    --good: #5FCB94; --near: #E9B65A; --near-bg: #3A2D12; --over: #FF8A7E; --over-bg: #40201D;
    --track: #2A3A39; --series-income: #3F9BD6; --series-spent: #D2733A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --logo-pocket: #E9F1EC; --logo-note: #4CC2B0; --bt-plate: #FFFFFF;
  --paper: #101B1C; --raised: #1A2828; --ink: #E9F1EC; --ink-2: #AFC1BC; --ink-3: #8DA29D;
  --line: #2C3D3C; --accent: #4CC2B0; --accent-ink: #082220;
  --note: #123F3D; --note-2: #1F6D65; --note-over: #5E1D1B; --note-over-2: #93362F;
  --on-note: #F1F8F2; --on-note-2: #B6D6CC;
  --good: #5FCB94; --near: #E9B65A; --near-bg: #3A2D12; --over: #FF8A7E; --over-bg: #40201D;
  --track: #2A3A39; --series-income: #3F9BD6; --series-spent: #D2733A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.45 var(--body); font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; text-wrap: balance; }
p { margin: 0; }

.page {
  max-width: 560px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px calc(var(--nav-h) + 36px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 24px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-switch { display: flex; align-items: center; gap: 2px; min-width: 0; }
.month-switch h1 { font-size: 1.2rem; min-width: 9.4em; text-align: center; font-weight: 700; }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: 0; background: none; border-radius: 50%; color: var(--ink-2);
}
.icon-btn:active { background: var(--track); }
.icon-btn:disabled { opacity: .3; }
.icon-btn svg, #nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.demo-note {
  font-size: .84rem; color: var(--ink-2); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); padding-bottom: 10px;
}
.demo-note strong { color: var(--ink); }

/* The banknote */
.note {
  position: relative; overflow: hidden; border-radius: 6px; color: var(--on-note);
  background: var(--note); padding: 16px 18px 18px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: inset 0 0 0 1px var(--note-2), inset 0 0 0 5px var(--note), inset 0 0 0 6px var(--note-2);
}
.note.is-over { background: var(--note-over); box-shadow: inset 0 0 0 1px var(--note-over-2), inset 0 0 0 5px var(--note-over), inset 0 0 0 6px var(--note-over-2); }
.note svg.rosette { position: absolute; right: -70px; top: -62px; width: 270px; height: 270px; color: var(--on-note); opacity: .17; pointer-events: none; }
.note > *:not(.rosette) { position: relative; }
.note-serial { font-size: .7rem; letter-spacing: .09em; text-transform: uppercase; color: var(--on-note-2); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.note-label { font-size: .92rem; color: var(--on-note-2); }
.note-figure { font-family: var(--display); font-weight: 700; font-size: clamp(2.3rem, 11vw, 3.1rem); line-height: 1.02; letter-spacing: -.02em; overflow-wrap: anywhere; }
.note-sub { font-size: .92rem; color: var(--on-note); }
.note-meter { position: relative; height: 10px; border-radius: 5px; background: rgba(255,255,255,.18); margin-top: 18px; }
.note-meter > i { display: block; height: 100%; border-radius: 5px; background: var(--on-note); max-width: 100%; }
.note-meter > b { position: absolute; top: -5px; width: 2px; height: 20px; background: var(--on-note); }
.note-meter > em { position: absolute; top: -22px; transform: translateX(-50%); font-size: .68rem; font-style: normal; color: var(--on-note-2); white-space: nowrap; }
.note-btn { align-self: flex-start; border: 1px solid var(--on-note-2); background: none; color: var(--on-note); border-radius: 4px; padding: 9px 14px; font-weight: 600; min-height: 44px; }

/* Three figures */
.ledger { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.ledger > div { padding: 12px 10px; min-width: 0; }
.ledger > div + div { border-left: 1px solid var(--line); }
.ledger > div:first-child { padding-left: 0; }
.label { font-size: .78rem; color: var(--ink-2); }
.ledger strong { display: block; font-family: var(--display); font-size: 1.04rem; overflow-wrap: anywhere; line-height: 1.2; margin-top: 2px; }
.neg { color: var(--over); }
.pos { color: var(--good); }

section { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head h2 { font-size: 1.1rem; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 10px 0 10px 12px; margin: -10px 0; }

/* Alerts */
.alerts { display: flex; flex-direction: column; gap: 6px; }
.alert { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 10px 12px; border-radius: 6px; align-items: start; font-size: .94rem; }
.alert.over { background: var(--over-bg); }
.alert.near { background: var(--near-bg); }
.alert b { font-weight: 700; }
.pill { font-size: .7rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.pill.over { background: var(--over); color: var(--paper); }
.pill.near { background: var(--near); color: var(--paper); }
.pill.ok { color: var(--good); padding-inline: 0; }
.pill.none { color: var(--ink-3); padding-inline: 0; text-transform: none; font-weight: 500; letter-spacing: 0; font-size: .8rem; }
.alert .pill { margin-top: 2px; }

/* Rows */
.rows { display: flex; flex-direction: column; }
.row {
  width: 100%; border: 0; background: none; text-align: left; padding: 11px 0;
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  border-bottom: 1px solid var(--line); min-height: 58px;
}
.rows > :last-child { border-bottom: 0; }
.tile {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: .84rem;
  background: var(--track); color: var(--ink);
}
.tile.income { background: var(--accent); color: var(--accent-ink); }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-sub { font-size: .84rem; color: var(--ink-2); overflow-wrap: anywhere; }
.row-amt { font-weight: 600; text-align: right; white-space: nowrap; }
.day-head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--ink-2); padding-top: 14px; border-bottom: 1px solid var(--line); padding-bottom: 5px; gap: 8px; }

/* Budget rows */
.bud { width: 100%; border: 0; background: none; text-align: left; padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.rows > .bud:last-child { border-bottom: 0; }
.bud-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.bud-top > span:first-child { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.bud-bottom { display: flex; justify-content: space-between; gap: 12px; font-size: .84rem; color: var(--ink-2); align-items: baseline; flex-wrap: wrap; }
.meter { height: 8px; border-radius: 4px; background: var(--track); position: relative; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter.near > i { background: var(--near); }
.meter.over > i { background: var(--over); }
.meter.plain > i { background: var(--ink-3); }

/* Controls */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: none; border-radius: 99px; padding: 8px 14px; min-height: 40px; font-size: .92rem; color: var(--ink); overflow-wrap: anywhere; text-align: left; }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--track); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: none; padding: 10px; border-radius: 6px; font-weight: 600; color: var(--ink-2); min-height: 44px; }
.seg button[aria-checked="true"] { background: var(--raised); color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], select {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--raised); font-size: 16px; min-width: 0;
}
input[type="date"] { -webkit-appearance: none; appearance: none; }
.amount-wrap { display: flex; align-items: baseline; gap: 10px; border-bottom: 2px solid var(--accent); padding-bottom: 4px; }
.amount-wrap span { font-weight: 600; color: var(--ink-2); }
.amount-wrap input { border: 0; background: none; padding: 0; min-height: 0; font-family: var(--display); font-size: 2.3rem; font-weight: 700; flex: 1; width: 100%; min-width: 0; outline: none; border-radius: 0; }
.btn { width: 100%; border: 0; border-radius: 6px; padding: 13px 16px; min-height: 50px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn:disabled { opacity: .6; }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--ink); font-weight: 600; }
.btn.danger { background: none; border: 1px solid var(--over); color: var(--over); font-weight: 600; }
.btn.danger.armed { background: var(--over); color: var(--paper); }
.err { color: var(--over); font-size: .9rem; }
.hint { color: var(--ink-2); font-size: .86rem; }

/* Sheet */
#sheet {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh;
  background: var(--paper); color: var(--ink); border-radius: 14px 14px 0 0;
  overflow-y: auto; overscroll-behavior: contain;
}
#sheet::backdrop { background: rgba(6, 20, 19, .55); }
@media (min-width: 600px) { #sheet { margin: auto; max-width: 480px; border-radius: 14px; } }
.sheet-body {
  display: flex; flex-direction: column; gap: 16px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-block: -6px -4px; }
.sheet-head h2 { font-size: 1.25rem; }
.sheet-rows { display: flex; flex-direction: column; gap: 8px; }
.tag-row { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); gap: 8px; min-height: 46px; }
.inline-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.inline-add .btn { width: auto; }

/* Nav */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--raised);
  border-top: 1px solid var(--line);
  padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
}
#nav button { height: var(--nav-h); border: 0; background: none; color: var(--ink-3); font-size: .72rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
#nav button[aria-current="page"] { color: var(--accent); }
#nav .add span { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin-top: -16px; box-shadow: 0 0 0 4px var(--raised); }
#nav .add svg { width: 26px; height: 26px; }

#toast {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px));
  width: min(calc(100% - 32px), 460px); padding: 11px 14px; border-radius: 6px;
  background: var(--ink); color: var(--paper); font-size: .94rem; font-weight: 500;
}

/* Sign-in */
.auth { min-height: 100dvh; max-width: 440px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 24px; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth .note-figure { font-size: 2.3rem; }

/* Chart */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--ink-2); font: 500 11px var(--body); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .income { fill: var(--series-income); }
.chart .spent { fill: var(--series-spent); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit.active { fill: var(--track); fill-opacity: .55; }
.legend { display: flex; gap: 16px; font-size: .84rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.chart-read { font-size: .9rem; min-height: 1.4em; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.facts > div { padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.facts strong { display: block; font-family: var(--display); font-size: 1.12rem; overflow-wrap: anywhere; }
.empty { padding: 18px 0; color: var(--ink-2); }
.empty .btn { margin-top: 12px; }

@media (prefers-reduced-motion: no-preference) {
  #sheet[open] { animation: rise .2s ease-out; }
  @keyframes rise { from { transform: translateY(24px); } to { transform: none; } }
}

/* Pocket Ledger logo. Colours come from the --logo-* tokens so it follows the theme. */
.lp-mark { display: block; flex: none; }
.lp-pocket { fill: var(--logo-pocket); }
.lp-note { fill: var(--logo-note); }
.lp-tab { fill: var(--logo-pocket); opacity: .55; }
.lp-stitch { stroke: var(--stitch, var(--paper)); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .lp-mark { width: 40px; height: 40px; }
.brand b { font-family: var(--display); font-weight: 700; font-size: 1.4rem; letter-spacing: -.02em; }
.note { --logo-pocket: var(--on-note); --logo-note: var(--logo-note-on-dark); --stitch: var(--note); }
.note.is-over { --stitch: var(--note-over); }
.note-brand { display: inline-flex; align-items: center; gap: 6px; }
.note-brand .lp-mark { width: 16px; height: 16px; }

/* BeingTechy credit. Clear space around their wordmark equals its dot (about 10px at this size).
   Their wordmark is made for light surfaces, so dark mode puts it on a white plate, as their guide does. */
.credit { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 14px; border-top: 1px solid var(--line); }
.credit-label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.bt-plate { display: inline-flex; padding: 10px; border-radius: 4px; background: var(--bt-plate); }
.bt-plate img { display: block; height: 22px; width: auto; }
.about { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }

/* Profile */
.avatar { position: relative; display: grid; place-items: center; flex: none; overflow: hidden; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-family: var(--display); font-weight: 700; line-height: 1; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar svg { width: 60%; height: 60%; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.avatar-btn .avatar svg { width: 60%; height: 60%; }
.profile-head { display: flex; gap: 14px; align-items: center; min-width: 0; }
.profile-head > div { display: flex; flex-direction: column; min-width: 0; }
.profile-head b { font-family: var(--display); font-size: 1.2rem; overflow-wrap: anywhere; }
.profile-head span { overflow-wrap: anywhere; }
.sheet-section { font-size: 1rem; padding-top: 12px; border-top: 1px solid var(--line); }
.disclose { border: 1px solid var(--line); border-radius: 6px; }
.disclose > summary { padding: 12px 14px; min-height: 48px; cursor: pointer; font-weight: 600; list-style-position: inside; }
.disclose > .sheet-rows, .disclose > form { padding: 0 14px 14px; gap: 12px; }
.danger-zone > summary { color: var(--over); }
