:root {
  --bg: #0F1412;
  --surface: #171E1B;
  --surface2: #1F2824;
  --line: #26302B;
  --line2: #2A3530;
  --text: #ECE8DF;
  --text2: #CFCABF;
  --muted: #9AA69F;
  --gold: #D4A857;
  --gold-ink: #1A1508;
  --red: #F0937A;
  --red-bg: #2A1E19;
  --green: #8FC7A8;
  --green-bg: #17261F;
  --blue: #9FB8D6;
  --blue-bg: #1A2230;
  --amber-bg: #2A2416;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
#app { position: relative; max-width: 520px; height: 100%; margin: 0 auto; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
input, select, textarea { font: inherit; color: var(--text); }
h1, h2 { margin: 0; }
p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* text helpers */
.muted { color: var(--muted); }
.small, small { font-size: 12px; }
.mono { font-family: var(--mono); }
.strong { color: var(--text); font-size: 14px; }
.upper { text-transform: uppercase; letter-spacing: .06em; }
.in { color: var(--green); }
.out { color: var(--red); }
.gold { color: var(--gold); }
.center { text-align: center; }
.link.center { align-self: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* layout */
.demo { position: absolute; top: 0; left: 0; right: 0; z-index: 5; padding: calc(var(--safe-t) + 4px) 12px 4px; text-align: center; font-size: 12px; font-weight: 600; background: var(--blue-bg); color: var(--blue); }
main.screen > * { flex-shrink: 0; }
main.screen { position: absolute; inset: 0 0 calc(76px + var(--safe-b)) 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-t) + 36px) 20px 96px; display: flex; flex-direction: column; gap: 18px; }

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.headl { display: flex; align-items: center; gap: 6px; min-width: 0; }
.head h1 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.08; }
.kicker { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; }
h2 { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .07em; text-transform: uppercase; }
h2.late { color: var(--red); }

.iconbtn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 22px; border: 1px solid var(--line2); display: inline-flex; align-items: center; justify-content: center; color: var(--gold); }
.iconbtn.gold { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.iconbtn.back { border: 0; color: var(--text); margin-left: -12px; }

.panel { padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.panel.tight { padding: 14px 16px; gap: 4px; }
.panel.card { width: 100%; text-align: left; }
.panel.raised { background: #1E2622; border-color: #3A463F; }
.panel.dashed { border-style: dashed; border-color: #3A463F; }
.panel.warn { background: var(--red-bg); border-color: #4A2F25; }
.panel.greenpanel { background: var(--green-bg); border-color: #2C4A3A; gap: 6px; color: #B9D9C7; }
.panel.greenpanel b { display: flex; align-items: center; gap: 8px; color: var(--text); }
.panel.center { align-items: center; text-align: center; }
.panel.welcome h2 { font-family: var(--serif); font-size: 24px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text); }
.panel.welcome p { color: var(--text2); font-size: 14px; line-height: 1.5; }
.panelhead { display: flex; justify-content: space-between; align-items: center; }
.panelhead b { font-size: 14px; }
.cardtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; width: 100%; }
.cardtop.plain { text-align: left; min-height: 32px; }
.cardtop .mono { font-size: 14px; color: var(--text2); }
.link { color: var(--gold); font-size: 13px; font-weight: 600; min-height: 36px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid2 > div, .grid3 > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat small { color: var(--muted); }
.big { font-family: var(--mono); font-size: 22px; }
.mid { font-family: var(--mono); font-size: 15px; }
.huge { font-family: var(--mono); font-size: 34px; }

.alert { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--red-bg); border: 1px solid #4A2F25; color: var(--red); text-align: left; width: 100%; }
.alert span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.alert b { color: var(--text); font-size: 14px; }
.alert small { color: #F0B5A4; }

/* lists */
.list { display: flex; flex-direction: column; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #222B27; }
.row:last-child { border-bottom: 0; }
.row.done { opacity: .6; }
.rowmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; min-height: 44px; justify-content: center; }
.rowmain .t { font-size: 15px; font-weight: 600; }
.rowmain .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowmain .n { font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--muted); text-transform: uppercase; }
.rowmain .n.late, .rowmain .n.soon { color: var(--red); }
.rowmain .n.in { color: var(--green); }
.rowend { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.amt { font-family: var(--mono); font-size: 14px; }
.amt.in { color: var(--green); }
.amt.save { color: var(--blue); }

.dateblock { width: 46px; height: 50px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; background: var(--surface2); }
.dateblock b { font-size: 17px; line-height: 1; }
.dateblock span { font-size: 10px; letter-spacing: .06em; margin-top: 2px; }
.dateblock.late, .dateblock.soon { background: var(--red-bg); color: var(--red); }
.dateblock.in { background: var(--green-bg); color: var(--green); }
.dateblock.save { background: var(--blue-bg); color: var(--blue); }

.mini { min-height: 34px; padding: 0 12px; border-radius: 17px; background: var(--gold); color: var(--gold-ink); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.mini.ghost { background: transparent; color: var(--green); border: 1px solid #2C4A3A; }

.tag { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; background: var(--surface2); color: var(--text2); white-space: nowrap; }
.tag.green { background: var(--green-bg); color: var(--green); }
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.gold { background: var(--amber-bg); color: #E6C07A; }
.tag.blue { background: var(--blue-bg); color: var(--blue); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.seg button { min-height: 44px; border-radius: 10px; font-size: 14px; font-weight: 600; text-align: center; }
.seg button.on { background: var(--gold); color: var(--gold-ink); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { min-height: 92px; padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; gap: 8px; color: var(--gold); text-align: left; }
.tile span { display: flex; flex-direction: column; gap: 2px; }
.tile b { color: var(--text); font-size: 13px; }
.tile small { color: var(--muted); }

.bar { height: 6px; border-radius: 3px; background: var(--line2); overflow: hidden; }
.bar > div { height: 100%; border-radius: 3px; background: var(--gold); }
.bar > .green { background: var(--green); }

.foot { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.foot svg { color: var(--green); }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); line-height: 1.45; }
.note svg { color: var(--green); flex-shrink: 0; }
.empty { padding: 22px 18px; border-radius: 16px; border: 1px dashed #3A463F; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; color: var(--muted); font-size: 14px; }

/* buttons & forms */
.btn { min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line2); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text); text-align: center; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.ghost { color: var(--gold); }
.btn.wide { width: 100%; }
.btn.danger { color: var(--red); border-color: #4A2F25; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface); font-size: 16px; outline: none; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); }
.field input[type=range] { padding: 0; min-height: 36px; border: 0; background: transparent; accent-color: var(--gold); }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text2); line-height: 1.45; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--gold); flex-shrink: 0; }
.error { padding: 10px 14px; border-radius: 12px; background: var(--red-bg); color: #F0B5A4; font-size: 13px; line-height: 1.4; }
.info { padding: 10px 14px; border-radius: 12px; background: var(--green-bg); color: #B9D9C7; font-size: 13px; line-height: 1.4; }

/* settings rows */
.setrow { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 60px; border-bottom: 1px solid #222B27; width: 100%; text-align: left; color: var(--gold); position: relative; }
.setrow:last-child { border-bottom: 0; }
.setrow > span:not(.ic) { flex: 1; display: flex; flex-direction: column; gap: 3px; color: var(--text); }
.setrow b { font-size: 15px; font-weight: 600; }
.setrow small { color: var(--muted); line-height: 1.4; }
.setrow select { min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line2); background: var(--surface2); font-size: 15px; }
.setrow .unit { color: var(--muted); }
.setrow .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--surface2); display: flex; align-items: center; justify-content: center; }
.hidden-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* calculator */
.calcscreen { align-items: flex-end; min-height: 100px; justify-content: flex-end; gap: 4px; }
.calcscreen span { font-family: var(--mono); font-size: 40px; line-height: 1; max-width: 100%; overflow: hidden; }
.keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.k { min-height: 62px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; text-align: center; }
.k.fn { background: var(--surface2); }
.k.op { color: var(--gold); }
.k.op.on { background: #3A3220; }
.k.eq { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }

/* plan */
.stackbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--line2); }
.c1 { background: var(--red); } .c2 { background: #E6C07A; } .c3 { background: #6E8FB8; } .c4 { background: #B08FC7; } .c5 { background: var(--green); } .c6 { background: #4A5650; }
.legend { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.legend i { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; }
.legend span:nth-child(2) { flex: 1; }
.legend.total { padding-top: 8px; border-top: 1px solid var(--line); font-weight: 700; }

/* bottom nav + fab */
.tabs { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 8px calc(10px + var(--safe-b)); background: #121916; border-top: 1px solid var(--line); }
.tabs button { min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: #8E9A93; text-align: center; }
.tabs button.on { color: var(--gold); }
.fab { position: absolute; right: 20px; bottom: calc(96px + var(--safe-b)); z-index: 4; width: 56px; height: 56px; border-radius: 28px; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 24px rgba(0, 0, 0, .45); }

/* sheet */
.sheet { position: absolute; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column; }
.sheethead { display: flex; justify-content: space-between; align-items: center; padding: calc(var(--safe-t) + 20px) 20px 12px; border-bottom: 1px solid var(--line); }
.sheethead h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; text-transform: none; letter-spacing: 0; color: var(--text); }
.sheetbody > * { flex-shrink: 0; }
.sheetbody { flex: 1; overflow-y: auto; padding: 18px 20px calc(32px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }

/* lock screens */
.gate > * { flex-shrink: 0; }
.gate { height: 100%; overflow-y: auto; padding: calc(var(--safe-t) + 72px) 28px 40px; display: flex; flex-direction: column; gap: 26px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.seal { width: 68px; height: 68px; border-radius: 34px; border: 1.5px solid var(--gold); color: var(--gold); display: flex; align-items: center; justify-content: center; }
.brand h1 { font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1; }
.brand p { color: var(--muted); font-size: 15px; }
.gate .foot { margin-top: auto; }

.toast { position: absolute; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); z-index: 20; padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; max-width: 90%; text-align: center; }

/* vault */
[hidden] { display: none !important; }
.search { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; min-height: 44px; }
.vrow { display: flex; flex-direction: column; gap: 8px; padding: 10px 6px 10px 14px; border-bottom: 1px solid #222B27; }
.vrow:last-child { border-bottom: 0; }
.vtop { display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--surface2); color: var(--gold); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.rowmain .t .tag { margin-left: 4px; vertical-align: 2px; }
.rowmain .pw { font-size: 13px; color: var(--text2); word-break: break-all; }
.iconbtn.plain { border: 0; color: var(--muted); }
.iconbtn.plain:last-child { color: var(--gold); }
.vextra { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 50px; }
a.mini { text-decoration: none; }
.mini.ghost.gen { align-self: flex-start; color: var(--gold); border-color: var(--line2); margin-top: 2px; }

/* bank details */
.formhead { margin: 10px 0 -4px; font-size: 13px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--gold); }
.vextra.flush { padding-left: 0; }
.kvlist { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; border-top: 1px solid var(--line); }
.kv { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.kv > span:first-child { width: 42%; flex-shrink: 0; }
.kv .mono { flex: 1; min-width: 0; word-break: break-all; font-size: 14px; }
.iconbtn.sm { width: 40px; height: 40px; color: var(--gold); }
