/* Runway by ModernEarner — calm, mirror-not-coach UI */
:root {
  --bg: #0c0f14;
  --bg-soft: #12161d;
  --card: #161b24;
  --card-2: #1b212c;
  --line: #232b38;
  --text: #e8edf4;
  --text-dim: #9aa7b8;
  --text-faint: #79859a;

  --calm: #38c79b;      /* healthy / build */
  --steady: #5aa9e6;    /* fine */
  --tight: #e3b341;     /* attention, not alarm */
  --high: #e08a4b;      /* warm warning */
  --critical: #e5687a;  /* used sparingly */
  --accent: #38c79b;

  --r: 16px;
  --r-sm: 10px;
  --shadow: 0 1px 0 rgba(255,255,255,0.03), 0 8px 24px rgba(0,0,0,0.35);
  --safe-area: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100%; padding-bottom: calc(78px + var(--safe-area)); }

/* ---------- header ---------- */
header.app-head {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(12,15,20,0));
  /* keep the header below the iPhone status bar / notch */
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 18px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: conic-gradient(from 200deg, var(--calm), var(--steady));
  display: grid; place-items: center; font-size: 14px; font-weight: 800; color: #06120e;
}
.brand h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand small { display: block; font-size: 10.5px; color: var(--text-faint); font-weight: 500; letter-spacing: 0.02em; }
.icon-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--text-dim);
  width: 36px; height: 36px; border-radius: 10px; font-size: 16px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(0.95); }

main { padding: 4px 16px 24px; }
.view { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px; box-shadow: var(--shadow);
}
.card + .card, .grid + .card, .card + .grid, .stack > * + * { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }

.hero {
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(56,199,155,0.10), transparent 60%),
    var(--card);
  text-align: center; padding: 26px 18px 22px;
}
.hero .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.hero .big { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.hero .unit { font-size: 18px; color: var(--text-dim); font-weight: 600; }
.hero .sub { font-size: 13px; color: var(--text-dim); margin-top: 8px; }

.tri { display: flex; gap: 8px; margin-top: 18px; }
.tri div { flex: 1; background: var(--card-2); border-radius: var(--r-sm); padding: 10px 6px; }
.tri .t-label { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.tri .t-val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 15px; }
.metric .m-top { display: flex; align-items: center; justify-content: space-between; }
.metric .m-label { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
.metric .m-val { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.metric .m-note { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* pressure meter */
.meter-track { height: 8px; background: var(--card-2); border-radius: 6px; overflow: hidden; margin: 10px 0 8px; }
.meter-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease, background 0.4s; }
.pressure-tone { font-size: 12.5px; color: var(--text-dim); }

/* section heads */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.sec-head h2 { font-size: 15px; font-weight: 700; }
.sec-head .hint { font-size: 11.5px; color: var(--text-faint); }

/* ---------- bill triage rows ---------- */
.bill { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.bill + .bill { margin-top: 9px; }
.bill.paid { opacity: 0.5; }
.bill .cbar { width: 4px; align-self: stretch; border-radius: 4px; }
.bill .b-main { flex: 1; min-width: 0; }
.bill .b-name { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.bill .b-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.bill .b-right { text-align: right; }
.bill .b-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.bill .b-cost { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.tag { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 6px; border-radius: 5px; font-weight: 700; }
.chk { width: 24px; height: 24px; border-radius: 7px; border: 1.5px solid var(--line); background: var(--card-2); cursor: pointer; display: grid; place-items: center; color: var(--text-faint); flex-shrink: 0; }
.chk.on { background: var(--calm); border-color: var(--calm); color: #06120e; }

/* alert banner */
.alert {
  background: linear-gradient(180deg, rgba(227,179,65,0.10), var(--card));
  border: 1px solid rgba(227,179,65,0.25);
  border-radius: var(--r); padding: 14px 16px;
}
.alert .a-title { font-size: 12px; font-weight: 700; color: var(--tight); text-transform: uppercase; letter-spacing: 0.05em; }
.alert ul { list-style: none; margin-top: 8px; }
.alert li { font-size: 13.5px; padding: 4px 0; display: flex; justify-content: space-between; gap: 10px; }
.alert li span:last-child { color: var(--text-dim); white-space: nowrap; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-sm); padding: 12px 13px; font-size: 15px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--calm); }
/* visible keyboard focus for every interactive element (a11y) */
[tabindex]:focus-visible, button:focus-visible, a:focus-visible, .chip:focus-visible, .chk:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm);
}
textarea { resize: vertical; min-height: 60px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toggle { display: flex; background: var(--card-2); border-radius: var(--r-sm); padding: 4px; gap: 4px; }
.toggle button { flex: 1; border: none; background: transparent; color: var(--text-dim); padding: 10px; border-radius: 7px; font-size: 14px; font-weight: 600; cursor: pointer; }
.toggle button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.toggle button.on.income { color: var(--calm); }
.toggle button.on.expense { color: var(--high); }

.btn {
  width: 100%; border: none; border-radius: var(--r-sm); padding: 14px; font-size: 15px; font-weight: 700;
  cursor: pointer; background: var(--calm); color: #06120e;
}
.btn:active { transform: scale(0.99); }
.btn.ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--critical); border: 1px solid rgba(229,104,122,0.4); }
.btn-sm { padding: 9px 12px; font-size: 12.5px; width: auto; border-radius: 8px; }

.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.list-item + .list-item { margin-top: 9px; }
.li-name { font-weight: 600; font-size: 14px; }
.li-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.li-amt { font-weight: 700; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 30px 18px; color: var(--text-faint); }
.empty .e-emoji { font-size: 30px; opacity: 0.6; }
.empty p { font-size: 13.5px; margin-top: 8px; }

/* simulator */
.sim-out { text-align: center; padding: 20px; }
.sim-out .delta { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.sim-out .from-to { font-size: 13px; color: var(--text-dim); margin-top: 6px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.chip { background: var(--card-2); border: 1px solid var(--line); color: var(--text-dim); padding: 8px 12px; border-radius: 20px; font-size: 12.5px; cursor: pointer; }
.chip.on { border-color: var(--calm); color: var(--text); }

/* report */
.report-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.report-row:last-child { border-bottom: none; }
.report-row .rr-label { font-size: 13.5px; color: var(--text-dim); }
.report-row .rr-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- bottom nav ---------- */
nav.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  background: rgba(18,22,29,0.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 6px calc(8px + var(--safe-area));
}
nav.tabbar-4 { grid-template-columns: repeat(4, 1fr); }
.amount-xl { font-size: 40px; font-weight: 800; text-align: center; border: none; background: transparent; width: 100%; color: var(--text); letter-spacing: -0.02em; padding: 4px 0; }
.amount-xl:focus { outline: none; }
.tab { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; font-weight: 600; }
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tab.on { color: var(--calm); }
.tab.add .plus { width: 38px; height: 38px; border-radius: 12px; background: var(--calm); color: #06120e; display: grid; place-items: center; margin-top: -2px; }
.tab.add .plus svg { stroke: #06120e; stroke-width: 2.4; }

/* modal / sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 40; display: none; }
.sheet-bg.on { display: block; animation: fade 0.2s; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 41; max-width: 560px; margin: 0 auto;
  background: var(--bg-soft); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line);
  padding: 10px 18px calc(24px + var(--safe-area)); transform: translateY(100%); transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  max-height: 88vh; overflow-y: auto;
}
.sheet.on { transform: translateY(0); }
.sheet .grip { width: 40px; height: 4px; background: var(--line); border-radius: 3px; margin: 6px auto 14px; }
.sheet h3 { font-size: 17px; margin-bottom: 16px; }

.toast {
  position: fixed; bottom: calc(90px + var(--safe-area)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card); border: 1px solid var(--line); color: var(--text); padding: 11px 18px; border-radius: 12px;
  font-size: 13.5px; box-shadow: var(--shadow); z-index: 50; opacity: 0; pointer-events: none; transition: all 0.3s; white-space: nowrap;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* pull-to-refresh indicator (standalone PWA) */
#ptr {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%) translateY(-50px);
  width: 36px; height: 36px; border-radius: 50%; background: var(--card); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--text-dim); z-index: 60; opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease; box-shadow: var(--shadow); font-size: 17px;
  margin-top: env(safe-area-inset-top, 0px); pointer-events: none;
}
#ptr.ready { color: var(--calm); }
#ptr .spinner { width: 17px; height: 17px; border: 2px solid var(--line); border-top-color: var(--calm); border-radius: 50%; display: none; }
#ptr.spin .arrow { display: none; }
#ptr.spin .spinner { display: block; animation: ptrspin 0.6s linear infinite; }
@keyframes ptrspin { to { transform: rotate(360deg); } }

.muted { color: var(--text-dim); }
.tiny { font-size: 11.5px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.disclaimer { font-size: 11px; color: var(--text-faint); text-align: center; padding: 18px 24px 6px; line-height: 1.5; }
