/* LoopDigit Finance — UI */
:root {
  --brand: #5b3df5;
  --brand-2: #a855f7;
  --brand-soft: rgba(91, 61, 245, .12);
  --bg: #f3f4fb;
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --text: #0f1225;
  --muted: #6b7090;
  --border: #e6e8f3;
  --pos: #059669;
  --neg: #e11d48;
  --warn: #d97706;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 18, 40, .04), 0 8px 24px -12px rgba(16, 18, 40, .12);
  --shadow-lg: 0 24px 60px -20px rgba(60, 40, 180, .35);
  --sidebar: 272px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0a0a17;
  --surface: #13132a;
  --surface-2: #1a1a36;
  --text: #eef0ff;
  --muted: #9a9fc2;
  --border: #25254a;
  --pos: #34d399;
  --neg: #fb7185;
  --warn: #fbbf24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.02rem; font-weight: 700; }
p { margin: 0; }
img { max-width: 100%; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
input, select, textarea, button { font: inherit; color: inherit; }

/* utilities */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pad { padding: 28px 8px; }
.mt { margin-top: 16px; }
.grow { flex: 1; min-width: 0; }
.w-100 { width: 100%; }
.row { display: flex; align-items: center; }
.row.between, .between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap { gap: 16px; }
.gap-sm { gap: 8px; }
.stack > * + * { margin-top: 14px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.zero { color: var(--muted); }
.r { text-align: right; }
.link { color: var(--brand); font-weight: 600; font-size: .88rem; }
.link-btn { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0; font-size: .82rem; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 16px;
  background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 18px; }
.brand-logo { height: 34px; width: auto; }
.logo-dark { display: none; }
[data-theme="dark"] .logo-dark { display: inline; }
[data-theme="dark"] .logo-light { display: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: .93rem;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--brand-soft); color: var(--brand); }
.nav-link small { font-size: .74rem; font-weight: 700; }
.nav-ledgers .nav-link { padding: 8px 12px; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 18px 12px 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--c, var(--brand)); }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.me img, .avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.me strong { display: block; font-size: .88rem; }
.me small { display: block; color: var(--muted); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: inline-grid; place-items: center; font-weight: 800; font-size: .85rem; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.avatar.sm { width: 34px; height: 34px; font-size: .75rem; }
.avatar.lg { width: 60px; height: 60px; font-size: 1.2rem; border-radius: 18px; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 16px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.page-title { font-size: 1.45rem; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-logo img { width: 34px; height: 34px; display: block; }
.content { padding: 8px 32px 48px; max-width: 1280px; display: flex; flex-direction: column; gap: 20px; }

.only-mobile { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; cursor: pointer;
  padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: .9rem; white-space: nowrap; transition: transform .1s, box-shadow .2s, background .2s;
  background: var(--surface-2); color: var(--text);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 8px 20px -8px var(--brand); }
.btn-primary:hover { box-shadow: 0 12px 28px -8px var(--brand); }
.btn-success { background: linear-gradient(135deg, #059669, #10b981); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--neg) 35%, transparent); color: var(--neg); }
.btn-white { background: #fff; color: #111; }
.btn-white-ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.25); }
.btn-sm { padding: 7px 12px; font-size: .82rem; border-radius: 10px; }
.btn-lg { padding: 14px 20px; font-size: .98rem; border-radius: 14px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; color: var(--text);
}

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2.wide-left { grid-template-columns: 1.6fr 1fr; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: -6px; }

/* hero */
.hero, .ledger-hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 26px; color: #fff;
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(255,255,255,.18), transparent 60%),
    radial-gradient(500px 260px at 0% 100%, rgba(236,72,153,.35), transparent 60%),
    linear-gradient(135deg, var(--brand), #7c3aed 55%, #c026d3);
  box-shadow: var(--shadow-lg);
}
.ledger-hero {
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(255,255,255,.22), transparent 60%),
    linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #1e1b4b));
}
.hero::after, .ledger-hero::after {
  content: ""; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%;
  border: 40px solid rgba(255,255,255,.08);
}
.hero-top { display: flex; justify-content: space-between; gap: 16px; position: relative; z-index: 1; }
.hero-greet { font-weight: 600; opacity: .9; margin-bottom: 14px; }
.hero-label { font-size: .85rem; opacity: .8; font-weight: 600; }
.hero-amount { font-size: clamp(2rem, 6vw, 2.8rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; margin-top: 2px; }
.hero-logo { height: 30px; opacity: .95; }
.hero-split { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 22px; }
.hero-split > div { background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.18); border-radius: 16px; padding: 12px 14px; backdrop-filter: blur(6px); }
.hero-split small { display: block; font-size: .74rem; opacity: .85; font-weight: 600; }
.hero-split strong { font-size: 1.05rem; font-weight: 800; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; align-self: flex-end; }
.muted-light { opacity: .8; font-size: .9rem; margin: 12px 0 14px; max-width: 520px; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.qa {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: 18px; font-weight: 700; font-size: .84rem;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .15s;
}
.qa:hover { transform: translateY(-2px); }
.qa-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }

/* ledger cards */
.ledger-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.ledger-card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  overflow: hidden; transition: transform .15s, box-shadow .2s;
}
.ledger-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); }
.ledger-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -20px var(--c); }
.ledger-card-top { display: flex; justify-content: space-between; align-items: center; }
.ledger-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: var(--c); background: var(--c-soft, color-mix(in srgb, var(--c) 14%, transparent)); }
.ledger-icon.lg { width: 52px; height: 52px; border-radius: 16px; background: rgba(255,255,255,.18); color: #fff; }
.ledger-icon.lg svg { width: 24px; height: 24px; }
.ledger-name { margin-top: 14px; font-weight: 700; color: var(--muted); font-size: .88rem; }
.ledger-bal { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }
.bucket-mini { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 4px; }
.bucket-mini div { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.bucket-mini b { font-weight: 700; }

.bucket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.bucket-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.bucket-card small { color: var(--muted); font-weight: 600; }
.bucket-card strong { font-size: 1.3rem; font-weight: 800; }

/* pills / chips */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.pill-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill-ok, .status-done { background: color-mix(in srgb, var(--pos) 16%, transparent); color: var(--pos); }
.status-active { background: var(--brand-soft); color: var(--brand); }
.status-cancelled { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.ledger-card .pill { margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.chip .dot { background: var(--c); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: .7rem; font-weight: 600; margin-left: 4px; }

/* wallets */
.wallet-list, .due-list { display: flex; flex-direction: column; gap: 4px; }
.wallet-row, .due-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; transition: background .15s; }
a.wallet-row:hover, .due-row:hover { background: var(--surface-2); }
.wallet-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.due-row small { display: block; color: var(--muted); font-size: .78rem; }

/* stats */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.stat small { display: block; color: var(--muted); font-size: .76rem; font-weight: 600; }
.stat strong { font-size: 1.1rem; font-weight: 800; }
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.summary-strip > div { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.summary-strip small { display: block; color: var(--muted); font-size: .78rem; font-weight: 600; }
.summary-strip strong { font-size: 1.2rem; font-weight: 800; }

.chart-box { position: relative; height: 240px; margin-top: 12px; }
.chart-box.tall { height: 320px; }

/* transactions */
.txn-list { display: flex; flex-direction: column; }
.txn { display: flex; align-items: center; gap: 12px; padding: 11px 8px; border-radius: 14px; transition: background .15s; }
.txn:hover { background: var(--surface-2); }
.txn-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #fff; flex-shrink: 0; box-shadow: 0 6px 14px -8px rgba(0,0,0,.5); }
.txn-main { flex: 1; min-width: 0; }
.txn-main strong { display: block; font-weight: 700; font-size: .93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-main small { display: block; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-right { text-align: right; flex-shrink: 0; }
.txn-right small { display: block; color: var(--muted); font-size: .74rem; }
.amt { font-weight: 800; font-size: .95rem; }
.amt.transfer { color: #3b82f6; }
.date-head { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 8px 6px; }
.date-head:first-child { padding-top: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 16px; }

/* filters */
.filter-bar { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-row select, .filter-row input, .inline-field input {
  padding: 9px 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2); font-size: .88rem; max-width: 100%;
}
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--muted); font-weight: 600; }
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); }
.search input { flex: 1; border: 0; background: transparent; padding: 11px 0; outline: none; }
.search svg { color: var(--muted); }

/* forms */
.txn-form { max-width: 760px; width: 100%; display: flex; flex-direction: column; gap: 18px; padding: 24px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span { font-size: .82rem; font-weight: 700; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field em { font-style: normal; font-weight: 500; opacity: .8; }
.field input, .field select, .field textarea, .settings-row input:not([type=color]):not([type=checkbox]), .settings-row select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .settings-row input:focus, .settings-row select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--surface); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 16px; padding: 5px; gap: 4px; border: 1px solid var(--border); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 6px; border-radius: 12px; font-weight: 700; font-size: .88rem; color: var(--muted); cursor: pointer; transition: all .2s; }
.seg-out input:checked + span { background: #e11d48; color: #fff; box-shadow: 0 8px 18px -8px #e11d48; }
.seg-in input:checked + span { background: #059669; color: #fff; box-shadow: 0 8px 18px -8px #059669; }
.seg-transfer input:checked + span { background: #2563eb; color: #fff; box-shadow: 0 8px 18px -8px #2563eb; }

.amount-field { display: flex; align-items: baseline; gap: 10px; justify-content: center; padding: 10px 0 4px; border-bottom: 2px solid var(--border); transition: border-color .2s; }
.amount-field:focus-within { border-color: var(--brand); }
.amount-field .cur { font-size: 1.4rem; font-weight: 700; color: var(--muted); }
.amount-field input { border: 0; background: transparent; outline: none; font-size: clamp(2.2rem, 9vw, 3rem); font-weight: 800; letter-spacing: -.03em; width: 100%; max-width: 360px; text-align: center; }
.amount-words { text-align: center; color: var(--muted); font-size: .82rem; min-height: 1.2em; margin-top: -10px; }

.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt input { position: absolute; opacity: 0; pointer-events: none; }
.chip-opt > span {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 99px; border: 1.5px solid var(--border);
  font-weight: 700; font-size: .86rem; cursor: pointer; transition: all .15s; background: var(--surface);
}
.chip-opt .dot { background: var(--c); }
.chip-opt input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.chip-opt input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.transfer-box, .sub-box { border: 1.5px dashed var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 14px; position: relative; background: var(--surface-2); }
.transfer-arrow { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); width: 30px; height: 30px; border-radius: 50%; background: #2563eb; color: #fff; display: grid; place-items: center; }
.transfer-arrow svg { width: 16px; height: 16px; }

.month-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.mchk input { position: absolute; opacity: 0; }
.mchk span { display: block; text-align: center; padding: 8px 4px; border-radius: 10px; border: 1.5px solid var(--border); font-size: .78rem; font-weight: 700; cursor: pointer; background: var(--surface); }
.mchk input:checked + span { background: #059669; border-color: #059669; color: #fff; }
.mchk.taken span { background: var(--surface-2); color: var(--muted); text-decoration: line-through; cursor: not-allowed; opacity: .6; }
.mchk.due:not(.taken) input:not(:checked) + span { border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--warn); }

.hint { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--brand-soft); color: var(--text); font-size: .86rem; }
.hint svg { color: var(--brand); margin-top: 2px; }
.hint:empty, .hint.empty { display: none; }

/* alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: 14px; font-weight: 600; font-size: .9rem; transition: opacity .4s, transform .4s; }
.alert-success { background: color-mix(in srgb, var(--pos) 13%, var(--surface)); color: var(--pos); border: 1px solid color-mix(in srgb, var(--pos) 25%, transparent); }
.alert-error { background: color-mix(in srgb, var(--neg) 12%, var(--surface)); color: var(--neg); border: 1px solid color-mix(in srgb, var(--neg) 25%, transparent); }
.alert.hide { opacity: 0; transform: translateY(-6px); }

/* empty */
.empty { text-align: center; padding: 28px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-icon { width: 60px; height: 60px; border-radius: 20px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 4px; }
.empty-icon svg { width: 28px; height: 28px; }
.empty p { color: var(--muted); font-size: .9rem; max-width: 320px; }
.empty .btn { margin-top: 8px; }

/* clients */
.client-grid, .project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.client-card, .project-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.client-card.archived { opacity: .6; }
.client-card strong { display: block; }
.project-card { gap: 8px; transition: transform .15s; }
.project-card:hover { transform: translateY(-2px); }
.month-strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.ms { display: grid; place-items: center; height: 26px; border-radius: 7px; font-size: .68rem; font-weight: 800; }
.ms.paid, .mcell.paid { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.ms.due, .mcell.due { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.ms.future, .mcell.future { background: var(--surface-2); color: var(--muted); }
.month-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.mcell { position: relative; border-radius: 14px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; }
.mcell b { font-size: .9rem; }
.mcell small { font-size: .7rem; opacity: .8; }
.mcell svg { position: absolute; top: 6px; right: 6px; width: 12px; height: 12px; }
.legend { display: flex; gap: 12px; font-size: .76rem; font-weight: 600; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg-paid::before { background: var(--pos); }
.lg-due::before { background: var(--warn); }
.lg-future::before { background: var(--border); }
.client-hero h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pc-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.pc-nums small { display: block; color: var(--muted); font-size: .72rem; }
.pc-nums b { font-size: .92rem; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 99px; }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th.r, .table td.r { text-align: right; }
.table tr:last-child td { border-bottom: 0; }

/* statement */
.statement-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.statement-wrap { overflow-x: auto; padding: 4px; }
.statement {
  width: 100%; max-width: 720px; background: #fff; color: #111827; border-radius: 22px; padding: 28px; box-shadow: var(--shadow);
  border: 1px solid #ececf3; font-family: "Plus Jakarta Sans", system-ui, sans-serif;
}
.st-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 3px solid var(--brand); }
.st-logo { height: 38px; }
.st-title { text-align: right; }
.st-title h2 { font-size: 1.35rem; }
.st-title p { color: #6b7280; font-weight: 600; font-size: .9rem; }
.st-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: .93rem; }
.st-table th { background: #f4f3ff; color: #4c3fd6; text-align: left; padding: 10px 12px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.st-table th:first-child { border-radius: 10px 0 0 10px; }
.st-table th:last-child { border-radius: 0 10px 10px 0; }
.st-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f5; vertical-align: top; }
.st-table td:first-child { white-space: nowrap; color: #6b7280; font-weight: 600; width: 1%; }
.st-table td.r, .st-table th.r { text-align: right; white-space: nowrap; font-weight: 700; }
.st-table .pos { color: #059669; } .st-table .neg { color: #e11d48; } .st-table .zero { color: #6b7280; }
.st-open td { background: #fafafe; font-weight: 700; }
.st-cat { display: inline-block; font-size: .7rem; background: #f3f4f6; color: #6b7280; padding: 1px 7px; border-radius: 6px; font-weight: 600; margin-left: 4px; }
.st-table tfoot td { border-bottom: 0; font-weight: 700; padding: 6px 12px; color: #374151; }
.st-table tfoot tr:first-child td { padding-top: 16px; }
.st-total td { font-size: 1.12rem; font-weight: 800 !important; border-top: 2px solid #111827 !important; padding-top: 12px !important; }
.st-note { margin-top: 16px; padding: 12px 16px; border-radius: 12px; background: #fff7ed; color: #9a3412; font-weight: 600; }
.st-foot { margin-top: 22px; text-align: center; font-size: .75rem; color: #9ca3af; }

/* settings */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tabs a { padding: 9px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-weight: 700; font-size: .84rem; white-space: nowrap; }
.settings-list, .ledger-settings { display: flex; flex-direction: column; gap: 10px; }
.settings-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.settings-row input:not([type=color]):not([type=checkbox]), .settings-row select { width: auto; padding: 9px 12px; }
.settings-row input.grow { flex: 1; min-width: 160px; }
.settings-row.new { padding-top: 10px; border-top: 1px dashed var(--border); }
.settings-row .bal { font-weight: 800; font-size: .88rem; min-width: 90px; text-align: right; }
.settings-row.sm input:not([type=color]):not([type=checkbox]) { padding: 7px 10px; font-size: .86rem; }
.color-in { width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: none; cursor: pointer; }
.ls-block { border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 16px; padding: 14px; }
.bucket-settings { margin: 10px 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.help-grid > div { background: var(--surface-2); border-radius: 16px; padding: 16px; }
.help-grid h4 { margin-bottom: 6px; font-size: .95rem; }
.help-grid p { color: var(--muted); font-size: .86rem; }

/* bottom nav (mobile) */
.bottom-nav { display: none; }
.sidebar-backdrop { display: none; }

/* login */
.login-body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: #0b0820; color: #fff; overflow: hidden; position: relative; }
.login-bg span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .7; animation: float 14s ease-in-out infinite alternate; }
.login-bg span:nth-child(1) { width: 420px; height: 420px; background: #5b3df5; top: -120px; left: -100px; }
.login-bg span:nth-child(2) { width: 360px; height: 360px; background: #c026d3; bottom: -120px; right: -80px; animation-delay: -5s; }
.login-bg span:nth-child(3) { width: 260px; height: 260px; background: #0ea5e9; top: 40%; left: 55%; opacity: .35; animation-delay: -9s; }
@keyframes float { to { transform: translate(40px, 30px) scale(1.1); } }
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 36px 30px; border-radius: 28px; text-align: center;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 18px;
}
.login-logo { height: 42px; margin: 0 auto 6px; }
.login-card h1 { font-size: 1.9rem; font-weight: 800; line-height: 1.2; }
.grad-text { background: linear-gradient(90deg, #a78bfa, #f0abfc, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-card .muted { color: rgba(255,255,255,.7); font-size: .92rem; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.lf { position: relative; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 14px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); transition: border-color .15s, background .15s; }
.lf:focus-within { border-color: #a78bfa; background: rgba(255,255,255,.12); box-shadow: 0 0 0 4px rgba(167,139,250,.18); }
.lf svg { color: rgba(255,255,255,.6); }
.lf input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: #fff; padding: 14px 0; font-size: .95rem; }
.lf input::placeholder { color: rgba(255,255,255,.5); }
.lf input:-webkit-autofill { -webkit-text-fill-color: #fff; -webkit-box-shadow: 0 0 0 40px #2a2150 inset; caret-color: #fff; }
.pw-toggle { background: none; border: 0; cursor: pointer; padding: 6px; display: grid; place-items: center; }
.login-form .btn { margin-top: 4px; }
.login-card .alert { text-align: left; }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: .78rem; color: rgba(255,255,255,.6); }
.login-copy { position: relative; z-index: 1; margin-top: 18px; font-size: .78rem; color: rgba(255,255,255,.45); }
.login-card .btn-ghost { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inherit !important; }
  .hide-mobile { display: none !important; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: 86%; max-width: 320px; transform: translateX(-102%);
    transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: 20px 0 60px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(8,8,20,.45); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sidebar.open + .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .topbar { padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .page-title { font-size: 1.2rem; }
  .content { padding: 4px 14px calc(100px + var(--safe-b)); gap: 16px; }
  .card { padding: 16px; border-radius: 18px; }
  .hero, .ledger-hero { padding: 20px; border-radius: 24px; }
  .hero-split { grid-template-columns: 1fr 1fr; }
  .hero-logo { height: 22px; }
  .hero-actions .btn { flex: 1; }
  .quick-actions { gap: 8px; }
  .qa { padding: 12px 4px; font-size: .76rem; border-radius: 16px; }
  .ledger-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ledger-card { padding: 14px; }
  .ledger-bal { font-size: 1.15rem; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .txn-form { padding: 18px; }
  .form-actions .btn { flex: 1; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; position: fixed; z-index: 40; left: 10px; right: 10px;
    bottom: calc(10px + var(--safe-b)); height: 66px; padding: 0 6px; border-radius: 22px;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border); box-shadow: 0 16px 40px -12px rgba(20, 16, 60, .35);
  }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .68rem; font-weight: 700; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 0; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .fab {
    width: 56px; height: 56px; border-radius: 18px; margin: -26px auto 0; justify-content: center; color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 12px 26px -8px var(--brand);
  }
  .bottom-nav .fab svg { width: 26px; height: 26px; }
  .statement { padding: 18px; border-radius: 16px; min-width: 340px; }
  .st-logo { height: 28px; }
  .st-title h2 { font-size: 1.05rem; }
  .st-table { font-size: .84rem; }
  .st-table td, .st-table th { padding: 8px 6px; }
  .settings-row .bal { min-width: 0; }
  .settings-row select { flex: 1; }
}
@media (max-width: 380px) {
  .ledger-grid { grid-template-columns: 1fr; }
}

/* print: only the statement */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .bottom-nav, .filter-bar, .statement-actions, .alert, .sidebar-backdrop { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .statement { box-shadow: none; border: 0; max-width: none; }
}

/* fixes */
.seg, .chip-opt, .mchk { position: relative; }
.seg input, .chip-opt input, .mchk input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none; }
.seg span { white-space: nowrap; }
.bucket-mini div { gap: 8px; }
.bucket-mini span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bucket-mini b { white-space: nowrap; }
@media (max-width: 900px) {
  .seg span { font-size: .8rem; gap: 5px; padding: 10px 4px; }
  .seg svg { width: 15px; height: 15px; }
  .bucket-mini div { font-size: .72rem; }
}

/* remember me */
.remember { display: flex; align-items: center; gap: 10px; font-size: .88rem; font-weight: 600; color: rgba(255,255,255,.8); cursor: pointer; user-select: none; padding: 2px; }
.remember input { position: absolute; opacity: 0; width: 0; height: 0; }
.remember .box { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid rgba(255,255,255,.35); display: grid; place-items: center; transition: all .15s; flex-shrink: 0; }
.remember .box svg { width: 14px; height: 14px; color: #fff; opacity: 0; stroke-width: 3; }
.remember input:checked + .box { background: linear-gradient(135deg, #5b3df5, #a855f7); border-color: transparent; }
.remember input:checked + .box svg { opacity: 1; }
.remember input:focus-visible + .box { outline: 2px solid #a78bfa; outline-offset: 2px; }
