/* Expense — light, calm, whitespace-first. System fonts (SF on iPhone), one accent, reserved status colors. */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --line: #e8e8e4;
  --ink: #141413;
  --ink-2: #4a4a47;
  --muted: #8a8a85;
  --accent: #141413;
  --blue: #2a78d6;
  --blue-soft: #e7f0fb;
  --good: #0ca30c;       /* status: on track   */
  --warning: #fab219;    /* status: careful    */
  --serious: #ec835a;    /* status: at limit   */
  --critical: #d03b3b;   /* status: over       */
  --good-ink: #067a06;
  --warning-ink: #8a5a00;
  --serious-ink: #a8431c;
  --critical-ink: #b02a2a;
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 4px 16px rgba(20, 20, 19, .04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.ink2 { color: var(--ink-2); }

/* layout */
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 18px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: 1fr 1fr; }
@media (min-width: 760px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
  body { padding-bottom: 0; }
  .wrap { padding-top: 28px; }
}
.stack > * + * { margin-top: 12px; }
.section { margin-top: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 10px; }
.section-head a { font-size: 14px; color: var(--ink-2); }

/* top bar (desktop) + tab bar (mobile) */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(247, 247, 245, .86); backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; }
.topbar .in { max-width: 980px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 22px; }
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.topnav { display: none; gap: 4px; }
.topnav a { padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-size: 14px; }
.topnav a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow); }
.icon-btn svg { width: 18px; height: 18px; }
.badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--critical); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); padding: 4px 0; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--ink); }

/* cards */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card.tight { padding: 14px 16px; }
.card-link { display: block; transition: transform .12s ease; }
.card-link:active { transform: scale(.99); }
.label { font-size: 13px; color: var(--muted); font-weight: 500; }
.hero { font-size: 52px; font-weight: 680; letter-spacing: -0.035em; line-height: 1.05; margin-top: 6px; }
.hero .cur { font-size: 20px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.big { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; }
.big .cur { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-2); }

/* status */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.good { background: #e8f6e8; color: var(--good-ink); }
.pill.warning { background: #fef4dd; color: var(--warning-ink); }
.pill.serious { background: #fdeee7; color: var(--serious-ink); }
.pill.critical { background: #fbe9e9; color: var(--critical-ink); }
.pill.blue { background: var(--blue-soft); color: #1c5cab; }
.pill.dark { background: var(--ink); color: #fff; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--good); max-width: 100%; }
.meter.warning > span { background: var(--warning); }
.meter.serious > span { background: var(--serious); }
.meter.critical > span { background: var(--critical); }
.meter.muted > span { background: var(--muted); }

/* budget rows */
.brow { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline; }
.brow .name { font-weight: 600; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.brow .left { font-weight: 650; font-size: 17px; text-align: right; }
.brow .meta { color: var(--muted); font-size: 13px; }
.brow .meta.r { text-align: right; }
.subbars { margin-top: 12px; display: grid; gap: 7px; }
.subbar { display: grid; grid-template-columns: 110px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; color: var(--ink-2); }
.subbar .track { height: 6px; background: var(--blue-soft); border-radius: 3px; overflow: hidden; }
.subbar .track span { display: block; height: 100%; background: var(--blue); border-radius: 3px; }
.subbar .v { text-align: right; font-variant-numeric: tabular-nums; }

/* lists */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
a.row:hover { background: #fbfbfa; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--muted); font-size: 13px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.row .amt.credit { color: var(--good-ink); }
.row .amt.neutral { color: var(--muted); }
.row .amt.void { color: var(--muted); text-decoration: line-through; }
.avatar { width: 36px; height: 36px; border-radius: 11px; background: var(--surface-2); display: grid; place-items: center;
  font-weight: 650; font-size: 14px; color: var(--ink-2); flex: none; }
.day { font-size: 13px; color: var(--muted); font-weight: 600; margin: 18px 4px 8px; display: flex; justify-content: space-between; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }

/* forms */
label.f { display: block; font-size: 13px; color: var(--ink-2); font-weight: 550; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 11px 12px; outline: none; transition: border-color .12s, box-shadow .12s; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input:focus, select:focus, textarea:focus { border-color: #bdbdb7; box-shadow: 0 0 0 4px rgba(20, 20, 19, .06); }
input[type=checkbox] { width: 18px; height: 18px; padding: 0; border-radius: 6px; display: inline-grid; place-items: center; vertical-align: -3px; }
input[type=checkbox]:checked { background: var(--ink); border-color: var(--ink); }
input[type=checkbox]:checked::after { content: "✓"; color: #fff; font-size: 12px; font-weight: 700; }
textarea { min-height: 120px; resize: vertical; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > * { width: auto; }
.inline select, .inline input { flex: 1 1 160px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px;
  border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; background: var(--ink); color: #fff; white-space: nowrap; }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink-2); padding: 10px 12px; }
.btn.danger { background: #fbe9e9; color: var(--critical-ink); }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn.full { width: 100%; padding: 13px; }
.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 999px; gap: 2px; }
.seg label { padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 550; color: var(--ink-2); cursor: pointer; }
.seg input { display: none; }
.seg input:checked + span { color: var(--ink); }
.seg label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters select, .filters input { width: auto; min-width: 130px; font-size: 14px; padding: 8px 30px 8px 12px; border-radius: 999px; }
.filters input { padding-right: 12px; min-width: 150px; }

/* notices */
.flash { background: var(--ink); color: #fff; border-radius: var(--radius-s); padding: 11px 14px; font-size: 14px; margin-bottom: 14px; }
.error { background: #fbe9e9; color: var(--critical-ink); border-radius: var(--radius-s); padding: 11px 14px; font-size: 14px; margin-bottom: 14px; }
.note { background: var(--surface-2); border-radius: var(--radius-s); padding: 12px 14px; font-size: 14px; color: var(--ink-2); }
.raw { direction: rtl; text-align: right; white-space: pre-wrap; font-size: 14px; background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-s); unicode-bidi: plaintext; }
details > summary { cursor: pointer; list-style: none; color: var(--ink-2); font-size: 14px; font-weight: 550; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; margin-right: 6px; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }

/* setup checklist */
.check { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.check:last-child { border-bottom: 0; }
.tick { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #cfcfca; display: grid; place-items: center; flex: none; font-size: 11px; }
.tick.done { background: var(--ink); border-color: var(--ink); color: #fff; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.scroll-x { overflow-x: auto; }

/* chart bars (single series, direct-labelled) */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 96px 1fr 84px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar .track { height: 10px; border-radius: 0 4px 4px 0; background: transparent; position: relative; }
.bar .track span { display: block; height: 100%; background: var(--blue); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar .track .limit { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--blue); margin-right: 5px; vertical-align: -1px; }
.legend i.limit { width: 2px; height: 12px; background: var(--ink); border-radius: 1px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px 24px; }

.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: 14px; }
.hide-sm { display: none; }
@media (min-width: 760px) { .hide-sm { display: initial; } }

/* SVG meters (CSP forbids inline styles, so widths are SVG attributes) */
.meter-svg { display: block; width: 100%; height: 6px; margin-top: 10px; overflow: visible; }
.meter-svg .track { fill: var(--surface-2); }
.meter-svg .fill { fill: var(--good); }
.meter-svg.warning .fill { fill: var(--warning); }
.meter-svg.serious .fill { fill: var(--serious); }
.meter-svg.critical .fill { fill: var(--critical); }
.meter-svg.muted .fill { fill: var(--muted); }
.meter-svg.blue .track { fill: var(--blue-soft); }
.meter-svg.blue .fill { fill: var(--blue); }
.meter-svg .limit { fill: var(--ink); }
.meter-svg.thin { height: 6px; margin-top: 0; }
.login-brand { margin-bottom: 22px; }
.login-title { font-size: 22px; margin-bottom: 6px; }
.login-sub { margin-bottom: 20px; }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.right { text-align: right; } .nowrap { white-space: nowrap; } .w100 { width: 100%; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.stat { min-width: 0; }
.stat .v { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 600; }

.pill.wrap { white-space: normal; line-height: 1.35; border-radius: 12px; padding: 6px 10px; }
.row .main, .card, .brow > * { min-width: 0; }

@media (min-width: 760px) { .topnav { display: flex; } .tabbar { display: none; } }
.meter-svg { border-radius: 3px; overflow: hidden; }
