:root {
  --bg: #0F1311;
  --surface: #181D1A;
  --line: #252B27;
  --line-strong: #333B36;
  --bar: #131714;
  --text: #EEF2EF;
  --muted: #9AA59F;
  --green: #7DD3A3;
  --green-fill: #3FA772;
  --green-button: #2E8159;
  --red: #F08C86;
  --red-fill: #D0605A;
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Manrope, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green); }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 16px calc(env(safe-area-inset-bottom) + 110px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.eyebrow { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
h2.label { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--muted); }
.red { color: var(--red); }
.green { color: var(--green); }
.small { font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.divider { height: 1px; background: var(--line); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.big { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.mid { font-size: 22px; font-weight: 800; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; background: var(--green-fill); border-radius: 4px; }
.bar.thin { height: 6px; }
.bar.red > div { background: var(--red-fill); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); text-decoration: none; flex: none;
}
.pill { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); white-space: nowrap; }

.month-nav { display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 600; }
.month-nav button { width: 44px; height: 44px; background: none; border: 0; color: var(--muted); font-size: 20px; }
.month-nav button:disabled { opacity: 0.3; cursor: default; }

/* Bill rows */
.bill { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; background: none; border: 0; padding: 0; text-align: left; }
.bill .name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill .amt { font-size: 15px; font-weight: 700; white-space: nowrap; }
.bill.done .name, .bill.done .amt { color: var(--muted); }
.bill.done .amt { text-decoration: line-through; }
.right { display: flex; align-items: center; gap: 10px; flex: none; }
.paid-btn {
  min-width: 64px; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--green);
  font-weight: 700; font-size: 13px;
}
.paid-btn.is-paid { background: var(--green-button); border-color: var(--green-button); color: #fff; }

/* Home */
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 14px; min-height: 132px;
  color: var(--text); text-decoration: none;
}
.tile.wide { grid-column: span 2; }
.tile .t { font-size: 17px; font-weight: 700; }
.tile.soon { opacity: 0.75; }

.primary {
  height: 54px; border-radius: 16px; border: 0; background: var(--green-button); color: #fff;
  font-weight: 700; font-size: 16px; width: 100%;
}
.secondary {
  height: 48px; border-radius: 14px; border: 1px solid var(--line-strong); background: transparent;
  font-weight: 700; font-size: 15px; width: 100%;
}
.danger { color: var(--red); }
.link-btn { background: none; border: 0; color: var(--green); font-weight: 700; padding: 8px 0; text-align: left; }

/* Bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bar); border-top: 1px solid var(--line);
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 44px; justify-content: center;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabs a.on { color: var(--green); font-weight: 700; }

/* Bottom sheet */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-top-left-radius: 24px; border-top-right-radius: 24px;
  border: 1px solid var(--line); border-bottom: 0;
  padding: 20px 20px calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column; gap: 14px;
}
.sheet h3 { margin: 0; font-size: 22px; font-weight: 800; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  height: 48px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg);
  padding: 0 14px; font-size: 16px;
}
.field textarea { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.note { font-size: 14px; color: var(--muted); line-height: 1.5; white-space: pre-wrap; }
.center { text-align: center; }
.empty { color: var(--muted); font-size: 14px; }
.error { color: var(--red); font-size: 14px; }
.link-btn.danger { color: var(--red); }
.sheet > *, .sheet form > * { flex-shrink: 0; }
.field { min-width: 0; } .field input, .field select, .field textarea { width: 100%; min-width: 0; }

/* Dashboard / Master list switch */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.segmented a { min-height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: 14px; text-decoration: none; }
.segmented a.on { background: var(--line-strong); color: var(--text); }

/* Calmer look, closer to the mock-up: green is kept for progress and the main button only. */
main { padding-left: 24px; padding-right: 24px; }
.paid-btn { color: var(--text); }
.paid-btn.is-paid { background: transparent; border-color: var(--line); color: var(--green); }
.link-btn { color: var(--text); }
.tile .green { color: var(--green); }
.tabs a.on { color: var(--text); }
/* Unpaid bills get an action button that clearly reads as a to-do, not a status. */
.paid-btn { min-width: 92px; white-space: nowrap; }
.paid-btn:not(.is-paid) { background: var(--line); border-color: var(--line-strong); }
.paid-btn.is-paid { border-color: transparent; }

/* ---------- Themes: Home is neutral obsidian; each app brings its own color ---------- */
body[data-theme="home"] {
  --bg: #0D0D0F; --surface: #151518; --line: #242428; --line-strong: #2A2A30; --bar: #111113;
  --text: #EDEDED; --muted: #8A8A92;
}
body { background: var(--bg); }
body[data-theme="home"] .tabs a.on { color: var(--text); }

.bento { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.app-tile {
  border-radius: 24px; padding: 18px; min-height: 168px; box-sizing: border-box;
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  text-decoration: none; color: var(--text); border: 1px solid transparent;
}
.app-tile.wide { grid-column: span 2; min-height: 196px; padding: 20px; }
.app-tile .t { font-size: 17px; font-weight: 700; }
.app-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.app-sub { font-size: 14px; }
.app-tile svg { width: 26px; height: 26px; }
.app-green { background: #14231B; border-color: #22382B; }
.app-green .app-label, .app-green .row > span:last-child { color: #7DD3A3; font-size: 13px; }
.app-green .row > span:last-child { font-size: 22px; }
.app-green .app-sub { color: #A9C9B7; }
.app-gold { background: #261F12; border-color: #3A2F18; }
.app-gold svg { color: #E2B65C; }
.app-gold .app-sub { color: #BDA978; }
.app-blue { background: #121C2E; border-color: #1E2C46; }
.app-blue svg { color: #7FA8F5; }
.app-blue .app-sub { color: #94A9CF; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px; background: #1D3226; color: #CFE9DA; }

/* ---------- Expense Tracker color ---------- */
body[data-theme="expense"] .segmented a.on { background: var(--green-button); color: #fff; }
.hero { background: #14281D; border-color: #22402F; }
.hero .big { font-size: 46px; }
.hero-sub { color: #A9C9B7; }
.hero .bar { height: 10px; background: #0E1A13; }
.hero .bar > div { background: #4FC283; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px; border-radius: 16px; border: 1px solid; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat .mid { font-size: 20px; }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-red { background: #2A1615; border-color: #44221F; } .stat-red .stat-label { color: #F0A49F; }
.stat-amber { background: #2B2312; border-color: #45381A; } .stat-amber .stat-label { color: #F0C978; }
.stat-purple { background: #211A2E; border-color: #352A4A; } .stat-purple .stat-label { color: #C3A9F2; }
.tint-red { background: #1F1413; border-color: #3A1F1D; }
.tint-purple { background: #1C1727; border-color: #352A4A; }
.purple { color: #C3A9F2; }
.amber { color: #F0C978; }
.stripe { width: 6px; height: 36px; border-radius: 3px; flex: none; margin-right: 12px; }
.bill { display: flex; align-items: center; }
.catbar { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 8px; min-width: 0; }
.legend i, .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.paid-btn { min-width: 84px; padding: 0 10px; }
.swatches { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.swatches legend { margin-bottom: 8px; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; width: 44px; height: 44px; margin: 0; cursor: pointer; }
.swatches span { display: block; width: 44px; height: 44px; border-radius: 12px; border: 3px solid transparent; box-sizing: border-box; }
.swatches input:checked + span { border-color: var(--text); }
.swatches input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
