:root {
  --silver-1: #fcfcfc;
  --silver-2: #f3f3f5;
  --silver-3: #ebebee;
  --ink: #0e0f19;
  --ink-soft: #1a1824;
  --ink-faint: #626775;
  --pos: #16924a;
  --neg: #14121f;
  --card: #ffffff;
  --line: #e7e7ec;
  --accent: #090b20;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--silver-1);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
h1 { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -.5px; }

#app { padding-bottom: calc(78px + var(--safe-b)); min-height: 100%; }
.tab { padding: 0 16px 24px; }
.hidden { display: none !important; }

/* hero */
.hero {
  background: var(--silver-2);
  color: var(--ink); border-radius: 0 0 28px 28px;
  padding: calc(20px + var(--safe-t)) 22px 24px; margin-bottom: 18px;
}
.hero-row { display: flex; justify-content: space-between; align-items: center; }
.hero-label { font-size: 13px; opacity: .8; text-transform: uppercase; letter-spacing: 1px; }
.hero-balance { font-size: 46px; font-weight: 800; letter-spacing: -1.5px; margin: 6px 0 2px; }
.hero-paid { display: block; font-size: 13px; color: var(--ink-faint); margin-bottom: 16px; }
.hero-stats { display: flex; background: var(--silver-1); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.hero-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; }
.hero-col + .hero-col { border-left: 1px solid var(--line); }
.hero-col .k { font-size: 12px; color: var(--ink-faint); }
.hero-col strong { font-size: 19px; letter-spacing: -.3px; }
.edit-btn { background: var(--silver-1); border: 1px solid var(--line); padding: 7px 16px; border-radius: 20px; font-weight: 600; font-size: 14px; }

/* expense to-do list */
.expense-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.exp {
  display: flex; align-items: center; gap: 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  transition: transform .12s ease, opacity .2s ease;
}
.exp:active { transform: scale(.99); }
.exp.paid { opacity: .5; }
.exp.paid .exp-name { text-decoration: line-through; }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink-faint); flex: 0 0 auto; display: grid; place-items: center; transition: .15s; }
.exp.paid .check { background: var(--pos); border-color: var(--pos); color: #fff; }
.exp-name { flex: 1; font-weight: 600; }
.exp-amt { font-weight: 700; color: var(--neg); }

/* generic page head */
.page-head { display: flex; justify-content: space-between; align-items: center; padding: calc(18px + var(--safe-t)) 0 6px; }
.page-note { color: var(--ink-soft); font-size: 14px; margin: 0 0 16px; }

/* budgets */
.budget-grid { display: flex; flex-direction: column; gap: 14px; }
.bcard { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.bcard h3 { margin: 0; font-size: 19px; }
.bcard .goal { font-size: 28px; font-weight: 800; margin: 4px 0 12px; color: var(--accent); }
.bcard .rows { display: flex; gap: 10px; }
.bcard .pill { flex: 1; background: var(--silver-2); border-radius: 12px; padding: 10px; text-align: center; }
.bcard .pill span { display: block; font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .5px; }
.bcard .pill b { font-size: 22px; }
.add-card { width: 100%; margin-top: 16px; padding: 16px; border: 1.5px dashed var(--ink-faint); border-radius: 18px; color: var(--ink-soft); font-weight: 700; }
.add-card:disabled { opacity: .4; }

/* insC */
.ins-summary { margin-bottom: 12px; }
.ins-progress { height: 8px; background: var(--silver-3); border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.ins-progress div { height: 100%; background: var(--pos); width: 0; transition: width .4s; }
.ins-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.ins-table tr { border-bottom: 1px solid var(--line); }
.ins-table td { padding: 13px 16px; font-size: 15px; }
.ins-table td:last-child { text-align: right; font-weight: 700; }
.ins-table tr.done { color: var(--pos); }
.ins-table tr.future td:last-child { color: var(--ink-faint); }

/* tab bar */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: rgba(252,252,252,.9);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 30; }
.tabbtn { flex: 1; padding: 10px 0; font-size: 11px; color: var(--ink-faint); display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; }
.tabbtn .ico { width: 24px; height: 24px; background: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain; }
.ico-balance { -webkit-mask-image: url(icons/expenses.svg); mask-image: url(icons/expenses.svg); }
.ico-budgets { -webkit-mask-image: url(icons/budget.svg); mask-image: url(icons/budget.svg); }
.ico-insc { -webkit-mask-image: url(icons/insC.svg); mask-image: url(icons/insC.svg); }
.tabbtn.active { color: var(--ink); }

/* modal */
.modal { position: fixed; inset: 0; background: var(--silver-1); z-index: 50; display: flex; flex-direction: column; transform: translateY(0); animation: up .25s ease; }
@keyframes up { from { transform: translateY(100%);} to { transform: translateY(0);} }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + var(--safe-t)) 16px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-cancel { color: var(--ink-soft); font-size: 16px; }
.modal-save { color: var(--accent); font-weight: 800; font-size: 16px; }
.modal-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 16px calc(40px + var(--safe-b)); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 600; }
.modal-body label.section { display: block; font-size: 13px; color: var(--ink-soft); margin: 4px 0 8px; font-weight: 600; }
input[type=number], input[type=text], .field input, .row-edit input {
  width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 17px; background: #fff; color: var(--ink); -webkit-appearance: none; appearance: none;
  font-family: inherit; transition: border-color .15s;
}
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input:focus, .row-edit input:focus { outline: none; border-color: var(--ink-soft); }
.row-edit { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.row-edit input.desc { flex: 2; min-width: 0; }
.row-edit input.amt { flex: 1; min-width: 0; }
.row-edit .del { color: #b00; font-size: 22px; padding: 6px; flex: 0 0 auto; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 12px 2px; font-size: 15px; color: var(--ink); }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.modal-add { width: 100%; padding: 14px; border: 1.5px dashed var(--ink-faint); border-radius: 12px; color: var(--ink-soft); font-weight: 700; margin-top: 6px; }
.modal-delete { width: 100%; margin-top: 24px; padding: 14px; background: #fbeaea; color: #b00; border-radius: 12px; font-weight: 700; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
