/* AzMoney — "winter night" theme. Hexagons nod to heximojis. */
:root {
  --bg: #0E1A2B;
  --surface: #16273D;
  --surface-2: #1E3350;
  --line: #2A4364;
  --text: #E9F1F8;
  --muted: #93A8BF;
  --ice: #8FD3FF;
  --in: #7FE3C4;
  --out: #F49AA8;
  --warn: #F2C46B;
  --ice-ink: #06233A;
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #EEF3F8; --surface: #FFFFFF; --surface-2: #E3EBF3; --line: #CBD8E5;
    --text: #12233A; --muted: #5B7088; --ice: #1C7FC0; --in: #0E8A66; --out: #C4405A; --warn: #A86A00; --ice-ink: #FFFFFF;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #EEF3F8; --surface: #FFFFFF; --surface-2: #E3EBF3; --line: #CBD8E5;
  --text: #12233A; --muted: #5B7088; --ice: #1C7FC0; --in: #0E8A66; --out: #C4405A; --warn: #A86A00; --ice-ink: #FFFFFF;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 var(--font-body); min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ice); }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.in { color: var(--in); } .out { color: var(--out); } .muted { color: var(--muted); } .warn { color: var(--warn); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar h1 { margin: 0; font: 700 1.45rem/1.1 var(--font-display); letter-spacing: -0.01em; }
.topbar .sub { font-size: .8rem; color: var(--muted); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 4px 16px calc(96px + var(--safe-b)); max-width: 560px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  border: 0; background: none; cursor: pointer; padding: 6px 0 4px;
  display: grid; justify-items: center; gap: 2px; color: var(--muted); font-size: .7rem; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--ice); }

/* ---------- blocks ---------- */
section.block { margin: 18px 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 8px; }
.block-head h2 { margin: 0; font: 650 1.05rem/1.2 var(--font-display); }
.link-btn { border: 0; background: none; color: var(--ice); font-weight: 600; font-size: .9rem; cursor: pointer; padding: 4px 2px; }
.panel { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; }
.rows { background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%;
  border: 0; background: none; text-align: left; cursor: pointer;
}
.row + .row { border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.emoji { width: 38px; height: 38px; flex: none; display: grid; place-items: center; font-size: 1.15rem; background: var(--surface-2); border-radius: 12px; }

/* hexagon avatar — the one decorative shape in the app */
.hex {
  width: 44px; height: 48px; flex: none; display: grid; place-items: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--surface-2); font-size: 1.2rem; font-weight: 700;
}
.hex.me { background: var(--ice); color: var(--ice-ink); font-size: .8rem; }

/* ---------- home hero: the month as one bar ---------- */
.hero { padding: 18px 16px 16px; background: var(--surface); border-radius: var(--radius-lg); }
.hero .label { color: var(--muted); font-size: .9rem; }
.hero .big { font: 700 2.6rem/1 var(--font-display); letter-spacing: -0.02em; margin: 4px 0 2px; }
.hero .line { color: var(--muted); font-size: .9rem; }
.monthbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 16px 0 10px; background: var(--surface-2); }
.monthbar span { display: block; height: 100%; transition: width .5s ease; }
.mb-bills { background: var(--warn); } .mb-spent { background: var(--out); } .mb-saved { background: var(--ice); } .mb-left { background: var(--in); }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: .85rem; }
.legend div { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.legend .k { color: var(--muted); display: flex; align-items: center; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: .8rem; color: var(--muted); }
.stat .v { font: 700 1.25rem/1.2 var(--font-display); margin-top: 2px; }
.stat button { all: unset; display: block; cursor: pointer; width: 100%; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); font-size: .9rem; margin: 12px 0; }
.notice.warn { border-left: 3px solid var(--warn); }
.notice button { margin-left: auto; white-space: nowrap; flex: none; }

/* ---------- IOUs ---------- */
.iou-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.iou { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 14px 12px; }
.iou + .iou { border-top: 1px solid var(--line); }
.iou .who { display: grid; justify-items: center; gap: 4px; width: 58px; text-align: center; cursor: pointer; background: none; border: 0; padding: 0; }
.iou .who small { font-size: .78rem; font-weight: 600; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tug { display: grid; gap: 4px; text-align: center; cursor: pointer; background: none; border: 0; padding: 0; }
.tug .amount { font: 700 1.35rem/1 var(--font-display); }
.tug .arrow { height: 14px; position: relative; }
.tug .arrow::before { content: ""; position: absolute; left: 6px; right: 6px; top: 6px; height: 2px; background: currentColor; border-radius: 2px; }
.tug .arrow::after { content: ""; position: absolute; top: 1px; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.tug.to-me .arrow::after { right: 0; border-left: 9px solid currentColor; }
.tug.to-them .arrow::after { left: 0; border-right: 9px solid currentColor; }
.tug .caption { font-size: .78rem; color: var(--muted); }
.tug.to-me { color: var(--in); } .tug.to-them { color: var(--out); } .tug.even { color: var(--muted); }
.tug.even .arrow::before { left: 18px; right: 18px; }
.iou-actions { display: flex; gap: 8px; justify-content: center; padding: 0 12px 14px; }
.plus { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); font-size: 1.3rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }

/* ---------- goals ---------- */
.goal { padding: 14px; }
.goal + .goal { border-top: 1px solid var(--line); }
.goal-top { display: flex; gap: 12px; align-items: center; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin: 10px 0 6px; }
.bar span { display: block; height: 100%; background: var(--ice); border-radius: 5px; }
.bar.em span { background: var(--in); }
.bar.over span { background: var(--out); }

/* ---------- forms + sheets ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer;
  background: var(--ice); color: var(--ice-ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--out); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

label.field { display: block; margin: 12px 0; font-size: .88rem; color: var(--muted); font-weight: 600; }
label.field > input, label.field > select, label.field > textarea { display: block; margin-top: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 16px; font-weight: 500;
}
.field textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, monospace; font-size: 13px; }
.field .hint { font-weight: 400; font-size: .8rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two label.field { margin: 0; }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--ice); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 9px 4px; border-radius: 9px; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.choice { display: grid; gap: 8px; }
.choice button { text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; }
.choice button[aria-pressed="true"] { border-color: var(--ice); background: var(--surface-2); }
.choice button small { display: block; font-weight: 400; color: var(--muted); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(4, 10, 20, .55); z-index: 50; opacity: 0; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 8px 18px calc(22px + var(--safe-b));
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  max-width: 560px; margin: 0 auto;
}
.sheet.open { transform: translateY(0); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { margin: 4px 0 6px; font: 700 1.3rem/1.2 var(--font-display); }
.sheet p { margin: 6px 0; color: var(--muted); font-size: .92rem; }

.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); transform: translateX(-50%) translateY(-20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem;
  opacity: 0; transition: all .2s; z-index: 70; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: calc(100% - 32px); pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ice); color: var(--ice-ink); border-color: var(--ice); }
.search { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; margin-bottom: 10px; }
.day-head { font-size: .8rem; font-weight: 700; color: var(--muted); margin: 16px 4px 6px; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.tag.soon { color: var(--warn); } .tag.over { color: var(--out); } .tag.ok { color: var(--in); }

.empty { text-align: center; padding: 28px 18px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font: 650 1.1rem/1.3 var(--font-display); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

/* insights */
.catbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; }
.catbar + .catbar { border-top: 1px solid var(--line); }
.catbar .bar { grid-column: 1 / -1; margin: 4px 0 0; height: 8px; position: relative; overflow: visible; }
.catbar .avg { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--text); opacity: .6; border-radius: 1px; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding: 10px 4px 0; }
.chart .col { flex: 1; display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 6px; }
.chart .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; }
.chart .pair span { flex: 1; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .col small { text-align: center; color: var(--muted); font-size: .72rem; }

/* login */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate .card { width: 100%; max-width: 380px; }
.gate .logo { width: 64px; height: 70px; margin-bottom: 18px; }
.gate h1 { font: 700 2rem/1.1 var(--font-display); margin: 0 0 6px; }
.gate p { color: var(--muted); margin: 0 0 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.row.panel { background: var(--surface); padding: 14px 16px; }

/* paycheck chart */
.paychart { display: block; width: 100%; height: auto; margin: 14px 0 6px; overflow: visible; }
.paychart .pc-fill { fill: var(--in); opacity: .55; transition: opacity .15s; }
.paychart .pc-bar { cursor: pointer; outline: none; }
.paychart .pc-bar.on .pc-fill, .paychart .pc-bar:focus-visible .pc-fill { opacity: 1; }
.paychart .pc-bar:last-of-type .pc-fill { opacity: .9; }
.paychart .pc-avg { stroke: var(--text); stroke-width: 1.2; stroke-dasharray: 4 4; opacity: .5; }
.paychart .pc-label { fill: var(--muted); font-size: 10px; font-family: var(--font-body); }
