/* SISTEMAKOPH Personal Finance - design system v2 ("the passbook, modernized")
   Forest-ink sidebar, mist canvas, white paper surfaces, one user-selectable accent (default brand teal),
   passbook gold for goals. Memorable element: ledger figures - Lora numerals with a small Inter peso sign,
   and ruled ledgers with running balances. Everything else is deliberately quiet.
   Fonts are self-hosted (OFL, see assets/fonts/LICENSE-*), so the strict CSP and offline XAMPP both work. */

@font-face { font-family: "Inter"; src: url("../fonts/inter-Regular.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-Medium.woff") format("woff"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-SemiBold.woff") format("woff"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-Bold.woff") format("woff"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Lora"; src: url("../fonts/lora-variable.woff") format("woff"); font-weight: 400 700; font-style: normal; font-display: swap; }

[hidden] { display: none !important; }

:root {
  --accent: #0f766e;
  --accent-contrast: #ffffff;
  --brand: #0f766e;
  --ink: #0f2b28;
  --ink-2: #173a36;
  --ink-3: #21504a;
  --ink-text: #c9dcd8;
  --canvas: #edf2f0;
  --surface: #ffffff;
  --surface-2: #f5f8f7;
  --line: #d9e3e0;
  --line-strong: #c3d2ce;
  --text: #13201e;
  --muted: #566a66;
  --in: #12805c;
  --out: #c24a3a;
  --gold: #b8860b;
  --gold-soft: #f8efd4;
  --warn: #a8670c;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 43, 40, .05), 0 6px 20px -12px rgba(15, 43, 40, .18);
  --shadow-pop: 0 18px 40px -18px rgba(15, 43, 40, .45);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Lora", Georgia, "Times New Roman", serif;
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --bs-body-font-family: var(--font);
  --bs-body-bg: var(--canvas);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-primary: var(--accent);
  --bs-link-color: var(--accent);
  --bs-link-color-rgb: 15, 118, 110;
  --bs-link-hover-color: var(--ink);
  --bs-focus-ring-color: color-mix(in srgb, var(--accent) 35%, transparent);
  --bs-secondary-color: var(--muted);
}

[data-bs-theme="dark"] {
  --ink: #0a1d1b;
  --ink-2: #12302c;
  --ink-3: #1b423d;
  --ink-text: #b6ccc8;
  --canvas: #0d1918;
  --surface: #13221f;
  --surface-2: #182a27;
  --line: #263b37;
  --line-strong: #33504a;
  --text: #e5eeec;
  --muted: #96aba7;
  --in: #4fd18f;
  --out: #ff8a7a;
  --gold: #e3b341;
  --gold-soft: #3a3016;
  --warn: #f2b14b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-pop: 0 18px 40px -18px rgba(0, 0, 0, .7);
  --bs-body-bg: var(--canvas);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
  --bs-tertiary-bg: var(--surface-2);
  --bs-link-hover-color: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { background: var(--canvas); color: var(--text); }
body { font-family: var(--font); font-size: .9375rem; line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { font-family: var(--font-display); letter-spacing: -.01em; font-weight: 600; color: var(--text); }
h1, .h1 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.75rem); }
h2, .h2 { font-size: 1.25rem; }
h3, .h3 { font-size: 1.05rem; }
.h6, h6 { font-family: var(--font); font-weight: 650; }
p { max-width: 75ch; }
a { text-underline-offset: 3px; }
img, svg, canvas, video { max-width: 100%; }
.text-muted, .form-text { color: var(--muted) !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden-focusable:focus { position: fixed; top: 8px; left: 8px; z-index: 2000; background: var(--surface); padding: .5rem 1rem; border-radius: var(--radius-sm); }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- ledger figures (the signature) ---------- */
.fig { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum" 1, "lnum" 1; white-space: nowrap; }
.fig .cur { font-family: var(--font); font-size: .6em; vertical-align: .42em; margin-right: .1em; opacity: .7; font-weight: 600; }
.fig-xl { font-family: var(--font-display); font-size: clamp(1.9rem, 1.4rem + 2.4vw, 2.8rem); font-weight: 600; letter-spacing: -.02em; line-height: 1.05; }
.fig-lg { font-family: var(--font-display); font-size: clamp(1.2rem, 1.05rem + .6vw, 1.45rem); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.fig-xl .fig, .fig-lg .fig, .fig-xl.fig, .fig-lg.fig { font-feature-settings: "tnum" 1; }
.amt-in { color: var(--in); }
.amt-out { color: var(--out); }
.amt-neutral { color: var(--muted); }

/* ---------- brand lockup (one component everywhere: sidebar, auth, landing, mobile) ---------- */
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; color: inherit; min-width: 0; }
.brand img { width: 36px; height: 36px; flex: 0 0 36px; object-fit: contain; border-radius: 10px; }
.brand-name { font-family: var(--font); font-weight: 700; font-size: .95rem; line-height: 1.12; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name small { display: block; font-weight: 500; font-size: .74rem; opacity: .72; letter-spacing: 0; }
.brand.on-dark { color: #fff; }

/* ---------- application shell ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--ink); color: var(--ink-text);
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; z-index: 1035;
  transition: width .18s ease, flex-basis .18s ease;
}
.sidebar-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem .9rem .85rem 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.collapse-btn.sidebar-close { display: none; }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: .75rem .65rem 1rem; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.nav-group { margin-bottom: .9rem; }
.nav-group-title { font-size: .74rem; font-weight: 600; color: color-mix(in srgb, var(--ink-text) 62%, transparent); padding: .4rem .7rem .3rem; white-space: nowrap; }
.side-link {
  display: flex; align-items: center; gap: .75rem; min-height: 40px; padding: .45rem .7rem; border-radius: 9px;
  color: var(--ink-text); text-decoration: none; font-size: .9rem; font-weight: 500; white-space: nowrap; position: relative;
}
.side-link .bi { font-size: 1.08rem; width: 1.25rem; flex: 0 0 1.25rem; text-align: center; opacity: .9; }
.side-link .label { overflow: hidden; text-overflow: ellipsis; }
.side-link:hover { background: var(--ink-2); color: #fff; }
.side-link.active { background: var(--ink-3); color: #fff; }
.side-link.active::before { content: ""; position: absolute; left: -.65rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); }
.side-link .badge { margin-left: auto; }
.sidebar-foot { flex: 0 0 auto; display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; border-top: 1px solid rgba(255, 255, 255, .06); font-size: .78rem; }
.sidebar-foot .plan { flex: 1; min-width: 0; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collapse-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .12); background: transparent; color: var(--ink-text); display: inline-grid; place-items: center; flex: 0 0 34px; }
.collapse-btn:hover { background: var(--ink-2); color: #fff; }
/* desktop collapsed rail */
.sidebar-collapsed .sidebar { --sidebar-w: 76px; }
.sidebar-collapsed .sidebar .label, .sidebar-collapsed .nav-group-title, .sidebar-collapsed .sidebar .brand-name, .sidebar-collapsed .sidebar-foot .plan { display: none; }
.sidebar-collapsed .sidebar-head { justify-content: center; padding-left: .5rem; padding-right: .5rem; }
.sidebar-collapsed .side-link { justify-content: center; padding: .45rem; }
.sidebar-collapsed .side-link .badge { position: absolute; top: 2px; right: 4px; display: inline-block; font-size: .6rem; }
.sidebar-collapsed .sidebar-foot { justify-content: center; }
.sidebar-collapsed .collapse-btn .bi { transform: rotate(180deg); }
.sidebar-collapsed .nav-group { border-top: 1px solid rgba(255, 255, 255, .06); padding-top: .5rem; }
.sidebar-collapsed .nav-group:first-child { border-top: 0; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020; min-height: var(--topbar-h);
  background: color-mix(in srgb, var(--canvas) 90%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .6rem; padding: .6rem 1.5rem;
  padding-top: max(.6rem, env(safe-area-inset-top));
}
.topbar h1 { font-size: 1.2rem; margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .search { max-width: 360px; flex: 1 1 220px; margin-left: auto; }
.topbar .search .form-control { background: var(--surface); border-radius: 999px; padding-left: 2.3rem; min-height: 40px; }
.topbar .search .bi { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topbar .spacer { flex: 1 1 auto; }
.icon-btn { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 999px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--text); position: relative; text-decoration: none; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn .dot { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--out); color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.avatar { width: 38px; height: 38px; border-radius: 999px; object-fit: cover; background: var(--accent); color: var(--accent-contrast); display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; }
.content { padding: 1.5rem 1.75rem 2.5rem; max-width: 1360px; width: 100%; }
.page-loading .content { opacity: .55; transition: opacity .15s; }

/* ---------- buttons & forms ---------- */
.btn { border-radius: 10px; font-weight: 550; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { min-height: 34px; border-radius: 8px; }
.btn-lg { min-height: 50px; border-radius: 12px; font-size: 1.02rem; }
.btn-accent { background: var(--accent); color: var(--accent-contrast); border: 1px solid var(--accent); font-weight: 600; }
.btn-accent:hover, .btn-accent:focus, .btn-accent:active { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: color-mix(in srgb, var(--accent) 86%, #000); color: var(--accent-contrast); }
.btn-quiet { background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); }
.btn-quiet:hover, .btn-quiet:focus { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.btn-google { background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); font-weight: 600; }
.btn-google:hover { border-color: var(--text); color: var(--text); }
.form-control, .form-select { border-radius: 10px; border-color: var(--line-strong); background-color: var(--surface); color: var(--text); min-height: 42px; font-size: max(16px, .95rem); }
.form-control-sm, .form-select-sm { min-height: 36px; font-size: max(16px, .875rem); }
@media (min-width: 768px) { .form-control, .form-select { font-size: .95rem; } .form-control-sm, .form-select-sm { font-size: .875rem; } }
.form-control-lg { min-height: 50px; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--accent) 22%, transparent); background-color: var(--surface); color: var(--text); }
.form-label { font-weight: 600; font-size: .875rem; margin-bottom: .3rem; }
.form-check-input { width: 1.15em; height: 1.15em; border-color: var(--line-strong); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-label { cursor: pointer; }
textarea.form-control { min-height: 84px; }
.invalid-feedback { font-weight: 500; }

/* ---------- surfaces: three levels, not one card for everything ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); min-width: 0; }
.panel-body { padding: 1.25rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem .35rem; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 1.02rem; }
.panel-head a { font-size: .85rem; font-weight: 550; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .95rem 1.05rem; height: 100%; min-width: 0; }
a.tile { transition: border-color .15s; }
a.tile:hover { border-color: var(--accent); }
.tile-label { font-size: .8rem; font-weight: 550; color: var(--muted); display: flex; align-items: center; gap: .45rem; }
.tile-label .bi { color: var(--accent); }
.tile-sub { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.section-title { font-size: 1.05rem; margin: 1.75rem 0 .75rem; }
.page-intro { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1.5rem; margin-bottom: 1.1rem; }
.page-intro p { margin: 0; color: var(--muted); }

/* Hero band on the dashboard: ink with faint passbook rules, no gradient */
.hero-band {
  background-color: var(--ink); color: #fff; border-radius: var(--radius-lg); padding: 1.5rem 1.75rem; margin-bottom: 1.25rem; position: relative; overflow: hidden;
  background-image: repeating-linear-gradient(180deg, transparent 0 31px, rgba(255, 255, 255, .045) 31px 32px);
}
.hero-band::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--gold); }
.hero-band .label { color: rgba(255, 255, 255, .74); font-size: .86rem; }
.hero-band h2, .hero-band .h4 { color: #fff; }
.hero-band a { color: #fff; }
.hero-band .split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, .12); }
.hero-band .split .fig-lg { color: #fff; }
.flowbar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, .14); margin: .75rem 0 .5rem; }
.flowbar .in { background: #5fd3a0; }
.flowbar .out { background: #ff9c8c; }
.flow-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; font-size: .86rem; }
.flow-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; }

/* Account "wallet" cards */
.wallet { border-radius: var(--radius-lg); padding: 1rem 1.1rem; color: #fff; text-decoration: none; display: block; height: 100%; background: var(--wallet, var(--accent)); position: relative; overflow: hidden; min-height: 136px; }
.wallet::after { content: ""; position: absolute; right: -36px; bottom: -48px; width: 150px; height: 150px; border-radius: 50%; border: 22px solid rgba(255, 255, 255, .10); }
.wallet:hover { color: #fff; filter: brightness(1.06); }
.wallet .w-type { font-size: .78rem; opacity: .88; display: flex; align-items: center; gap: .4rem; }
.wallet .w-name { font-weight: 650; font-size: 1rem; margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet .w-bal { margin-top: .8rem; }
.wallet.archived { filter: grayscale(.8); opacity: .75; }
.wallet.light-text { color: #111827; }

/* progress */
.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.meter.warning > span { background: var(--warn); }
.meter.over > span { background: var(--out); }
.meter.gold > span { background: var(--gold); }
.goal-ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--surface-2) 0); display: grid; place-items: center; flex: 0 0 64px; }
.goal-ring > span { width: 48px; height: 48px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: .78rem; font-weight: 700; }

/* ruled ledger lists */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { display: flex; align-items: center; gap: .85rem; padding: .72rem 1.25rem; border-top: 1px solid var(--line); min-width: 0; }
.ledger li:first-child { border-top: 0; }
.ledger .l-main { flex: 1; min-width: 0; }
.ledger .l-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger .l-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger a.l-title { color: inherit; text-decoration: none; }
.ledger a.l-title:hover { color: var(--accent); }
.cat-dot { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 36px; color: #fff; font-size: 1rem; }
.cat-dot.sm { width: 28px; height: 28px; flex-basis: 28px; font-size: .85rem; border-radius: 8px; }

/* tables: horizontal scroll inside the panel, never the page */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); color: var(--text); margin: 0; }
.table > :not(caption) > * > * { padding: .7rem .9rem; border-color: var(--line); vertical-align: middle; }
.table thead th { font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: color-mix(in srgb, var(--accent) 5%, transparent); }
.table-wrap, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-wrap:focus-visible { outline-offset: -3px; }

.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .16rem .58rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.overdue, .chip.over, .chip.danger { background: color-mix(in srgb, var(--out) 12%, transparent); color: var(--out); border-color: color-mix(in srgb, var(--out) 30%, transparent); }
.chip.due_today, .chip.warning { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.chip.paid, .chip.ok, .chip.upcoming { background: color-mix(in srgb, var(--in) 10%, transparent); color: var(--in); border-color: color-mix(in srgb, var(--in) 25%, transparent); }
.chip.shared, .chip.gold { background: var(--gold-soft); color: var(--gold); border-color: color-mix(in srgb, var(--gold) 35%, transparent); }

/* insights */
.insight { display: flex; gap: .9rem; padding: .9rem 1.1rem; border-left: 4px solid var(--line); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.insight + .insight { margin-top: .6rem; }
.insight.danger { border-left-color: var(--out); }
.insight.warning { border-left-color: var(--warn); }
.insight.success { border-left-color: var(--in); }
.insight.info { border-left-color: var(--accent); }
.insight .bi { font-size: 1.25rem; color: var(--muted); }
.insight-calc { font-size: .78rem; color: var(--muted); margin-top: .25rem; }

/* empty states */
.empty { text-align: center; padding: 2.5rem 1rem; }
.empty .bi { font-size: 2.2rem; color: var(--accent); }
.empty h3 { margin-top: .75rem; }
.empty p { color: var(--muted); max-width: 46ch; margin: .5rem auto 1rem; }
.empty-inline { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; color: var(--muted); font-size: .9rem; }
.empty-inline .bi { font-size: 1.3rem; color: var(--accent); }

/* welcome / onboarding */
.welcome-steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.welcome-steps li { counter-increment: s; position: relative; padding: .9rem 0 .9rem 3rem; border-top: 1px solid var(--line); }
.welcome-steps li::before { content: counter(s); position: absolute; left: 0; top: .9rem; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; font-weight: 700; }
.type-pick { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); height: 100%; }
.type-pick:hover { border-color: var(--accent); color: var(--accent); }
.type-pick .bi { font-size: 1.4rem; color: var(--accent); }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.cal-h { font-size: .78rem; color: var(--muted); padding: .5rem; background: var(--surface-2); border-bottom: 1px solid var(--line); text-align: center; }
.cal-d { min-height: 104px; padding: .35rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .78rem; min-width: 0; }
.cal-d:nth-child(7n) { border-right: 0; }
.cal-d.out { background: var(--surface-2); color: var(--muted); }
.cal-d.today .num { background: var(--accent); color: var(--accent-contrast); border-radius: 999px; }
.cal-d .num { display: inline-grid; place-items: center; width: 24px; height: 24px; font-weight: 600; }
.cal-ev { display: block; border-radius: 5px; padding: .1rem .35rem; margin-top: .2rem; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--surface-2); color: var(--text); border-left: 3px solid var(--accent); }
.cal-ev.overdue { border-left-color: var(--out); }
.cal-ev.paid { border-left-color: var(--in); opacity: .7; text-decoration: line-through; }
.cal-ev.due_today { border-left-color: var(--warn); }
.cal-ev.recurring { border-left-color: var(--gold); }

/* ---------- auth pages (sign in, sign up, reset, verify) ---------- */
.guest { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.guest-side { background: var(--ink); color: var(--ink-text); padding: 2.5rem 3rem; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; position: relative; overflow: hidden;
  background-image: repeating-linear-gradient(180deg, transparent 0 39px, rgba(255, 255, 255, .04) 39px 40px); }
.guest-side::before { content: ""; position: absolute; left: 2rem; top: 0; bottom: 0; width: 1px; background: rgba(201, 151, 28, .35); }
.guest-side h2 { color: #fff; font-size: clamp(1.7rem, 1.2rem + 1.6vw, 2.5rem); line-height: 1.15; max-width: 15ch; font-weight: 600; }
.guest-side .lede { max-width: 40ch; color: var(--ink-text); }
.guest-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1.25rem; padding-bottom: max(2rem, env(safe-area-inset-bottom)); }
.guest-mobile-brand { display: none; }
.guest-card { width: 100%; max-width: 430px; }
.auth-head { margin-bottom: 1.5rem; }
.auth-head h1 { font-size: clamp(1.5rem, 1.3rem + .8vw, 1.85rem); margin-bottom: .35rem; }
.auth-head p { margin: 0; }
.auth-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-size: 1.25rem; margin-bottom: .9rem; }
.auth-divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .82rem; margin: 1.25rem 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-foot { margin-top: 1.75rem; text-align: center; }
.pw-field { position: relative; }
.pw-field .form-control { padding-right: 3rem; }
.pw-toggle { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; }
.pw-toggle:hover { color: var(--text); }
.trust-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; font-size: .9rem; }
.trust-list li { display: flex; gap: .6rem; align-items: flex-start; }
.trust-list .bi { color: var(--gold); margin-top: .15rem; }

/* passbook ledger (landing hero + auth side) */
.passbook { background: var(--surface); color: var(--text); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); overflow: hidden; border: 1px solid var(--line); }
.passbook-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 1rem 1.25rem .75rem; border-bottom: 2px solid var(--ink); }
.passbook-head strong { font-family: var(--font-display); font-size: 1.05rem; }
.passbook-head span { font-size: .8rem; color: var(--muted); }
.passbook table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.passbook th { font-weight: 600; font-size: .74rem; color: var(--muted); text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
.passbook td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.passbook td:first-child, .passbook th:first-child { padding-left: 1.25rem; }
.passbook td:last-child, .passbook th:last-child { padding-right: 1.25rem; text-align: right; }
.passbook .num { text-align: right; font-variant-numeric: tabular-nums; }
.passbook .bal { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; }
.passbook .who { display: block; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }
.passbook .who small { display: block; color: var(--muted); font-size: .74rem; }
.passbook tfoot td { border-bottom: 0; background: var(--surface-2); font-size: .8rem; color: var(--muted); }
.passbook.compact td, .passbook.compact th { padding-top: .4rem; padding-bottom: .4rem; }

/* ---------- landing page ---------- */
.lp { background: var(--canvas); }
.lp-nav { position: sticky; top: 0; z-index: 1030; background: color-mix(in srgb, var(--canvas) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid transparent; }
.lp-nav.scrolled { border-bottom-color: var(--line); }
.lp-nav .inner { display: flex; align-items: center; gap: 1rem; min-height: 68px; padding-top: env(safe-area-inset-top); }
.lp-nav .links { display: flex; gap: 1.5rem; margin-left: 2rem; }
.lp-nav .links a { color: var(--text); text-decoration: none; font-weight: 550; font-size: .92rem; }
.lp-nav .links a:hover { color: var(--accent); }
.lp-nav .actions { margin-left: auto; display: flex; gap: .5rem; flex: 0 0 auto; }
.lp-hero { padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2.5rem, 5vw, 4.5rem); }
.lp-hero h1 { font-size: clamp(2.2rem, 1.4rem + 3.6vw, 3.9rem); line-height: 1.04; letter-spacing: -.025em; font-weight: 600; max-width: 13ch; margin-bottom: 1.1rem; }
.lp-hero .lede { font-size: clamp(1.02rem, .95rem + .35vw, 1.2rem); color: var(--muted); max-width: 52ch; }
.lp-hero .note { font-size: .86rem; color: var(--muted); max-width: 54ch; }
.lp-hero .cta { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.75rem 0 1rem; }
.lp-hero .passbook-wrap { position: relative; }
.lp-hero .passbook-wrap .caption { font-size: .8rem; color: var(--muted); margin-top: .6rem; }
.lp-section { padding: clamp(3rem, 6vw, 5.5rem) 0; }
.lp-section.alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.lp-section.ink { background: var(--ink); color: var(--ink-text); }
.lp-section.ink h2, .lp-section.ink h3 { color: #fff; }
.lp-section h2 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.3rem); line-height: 1.15; max-width: 22ch; margin-bottom: .8rem; }
.lp-section .intro { color: var(--muted); max-width: 60ch; font-size: 1.04rem; margin-bottom: 2.25rem; }
.lp-section.ink .intro { color: var(--ink-text); }
.feature { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: .25rem 1rem; padding: 1.25rem 0; border-top: 1px solid var(--line); }
.feature .ic { grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 11%, transparent); color: var(--accent); font-size: 1.2rem; }
.feature h3 { font-family: var(--font); font-size: 1rem; font-weight: 650; margin: 0; }
.feature p { color: var(--muted); margin: 0; font-size: .93rem; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; counter-reset: st; }
.steps li { counter-increment: st; position: relative; padding-top: 3.2rem; }
.steps li::before { content: counter(st); position: absolute; top: 0; left: 0; font-family: var(--font-display); font-size: 2.2rem; font-weight: 600; color: var(--gold); line-height: 1; }
.steps li::after { content: ""; position: absolute; top: 1.1rem; left: 2.4rem; right: 0; height: 1px; background: var(--line-strong); }
.steps li:last-child::after { display: none; }
.steps h3 { font-family: var(--font); font-size: 1.02rem; font-weight: 650; }
.steps p { color: var(--muted); font-size: .93rem; }
.security-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 2.5rem; }
.security-grid .item { display: flex; gap: .9rem; }
.security-grid .item .bi { font-size: 1.3rem; color: var(--gold); flex: 0 0 auto; margin-top: .1rem; }
.security-grid .item h3 { font-family: var(--font); font-size: 1rem; font-weight: 650; margin: 0 0 .25rem; }
.security-grid .item p { margin: 0; font-size: .92rem; color: var(--ink-text); }
.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
.price-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.5rem; display: flex; flex-direction: column; min-width: 0; }
.price-card.featured { border: 2px solid var(--accent); }
.price-card h3 { font-family: var(--font); font-size: 1.05rem; font-weight: 700; margin: 0 0 .35rem; }
.price-card .price { font-family: var(--font-display); font-size: 2rem; font-weight: 600; margin: .4rem 0 .1rem; }
.price-card .price small { font-family: var(--font); font-size: .85rem; color: var(--muted); font-weight: 500; }
.price-card .desc { color: var(--muted); font-size: .9rem; min-height: 2.6em; }
.price-card ul { list-style: none; padding: 0; margin: 1rem 0 1.5rem; display: grid; gap: .45rem; font-size: .9rem; flex: 1; }
.price-card li { display: flex; gap: .5rem; }
.price-card li .bi { color: var(--in); }
.price-card .status { font-size: .8rem; color: var(--muted); margin-top: .6rem; }
.faq { max-width: 820px; }
.faq details { border-top: 1px solid var(--line); padding: 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; padding: 1.05rem 0; font-weight: 600; font-size: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--font-display); font-size: 1.4rem; line-height: 1; color: var(--accent); transition: transform .15s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--muted); padding-bottom: 1.1rem; margin: 0; }
.lp-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.5rem; }
.lp-footer { background: var(--ink); color: var(--ink-text); padding: 3rem 0 calc(2rem + env(safe-area-inset-bottom)); font-size: .9rem; }
.lp-footer a { color: var(--ink-text); text-decoration: none; }
.lp-footer a:hover { color: #fff; text-decoration: underline; }
.lp-footer h2 { font-family: var(--font); font-size: .86rem; font-weight: 650; color: #fff; margin-bottom: .75rem; }
.lp-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.lp-footer .legal { border-top: 1px solid rgba(255, 255, 255, .1); margin-top: 2.5rem; padding-top: 1.25rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; font-size: .82rem; opacity: .8; }

/* ---------- admin ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; min-width: 0; }
.stat .k { font-size: .78rem; color: var(--muted); font-weight: 550; }
.stat .v { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .75rem; color: var(--muted); }
.stat.attention { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.range-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg a, .seg button { padding: .42rem .8rem; font-size: .85rem; font-weight: 550; color: var(--text); text-decoration: none; border: 0; background: transparent; border-right: 1px solid var(--line); min-height: 36px; }
.seg a:last-child { border-right: 0; }
.seg a[aria-current="true"] { background: var(--accent); color: var(--accent-contrast); }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom)); right: 1rem; z-index: 1090; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast-msg { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: .75rem 1rem; box-shadow: var(--shadow-pop); display: flex; gap: .6rem; align-items: start; animation: toast-in .2s ease-out; }
.toast-msg.danger { border-left-color: var(--out); }
.toast-msg.warning { border-left-color: var(--warn); }
.toast-msg.success { border-left-color: var(--in); }
.toast-msg.info { border-left-color: var(--accent); }
.toast-msg button { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: 0 .2rem; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }
.is-loading { pointer-events: none; opacity: .75; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 6px; min-height: 1em; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- mobile & tablet ---------- */
.bottom-nav { display: none; }
.fab { display: none; }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100%; width: min(86vw, 300px); flex-basis: auto; transform: translateX(-102%); transition: transform .22s ease; box-shadow: none; visibility: hidden; }
  .sidebar-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
  .sidebar-open { overflow: hidden; }
  .sidebar-collapsed .sidebar { width: min(86vw, 300px); }
  .sidebar-collapsed .sidebar .label, .sidebar-collapsed .nav-group-title, .sidebar-collapsed .sidebar .brand-name, .sidebar-collapsed .sidebar-foot .plan { display: initial; }
  .sidebar-collapsed .side-link { justify-content: flex-start; padding: .45rem .7rem; }
  .sidebar-collapsed .side-link .badge { position: static; }
  .sidebar-collapsed .sidebar-head { justify-content: space-between; padding: 1rem .9rem .85rem 1.1rem; }
  .collapse-btn.sidebar-close { display: inline-grid; }
  .collapse-btn.desktop-only { display: none; }
  .sidebar-nav { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(5, 15, 14, .5); z-index: 1034; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .topbar { padding: .5rem 1rem; padding-top: max(.5rem, env(safe-area-inset-top)); gap: .45rem; }
  .topbar .search { display: none; }
  .topbar h1 { flex: 1 1 auto; font-size: 1.1rem; }
  .content { padding: 1rem 1rem calc(6.5rem + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: var(--surface); border-top: 1px solid var(--line); padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottom-nav a { flex: 1; min-width: 0; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; font-size: .7rem; font-weight: 550; color: var(--muted); text-decoration: none; border-radius: 10px; }
  .bottom-nav a .bi { font-size: 1.2rem; }
  .bottom-nav a.active { color: var(--accent); }
  .fab { display: grid; place-items: center; position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: calc(4.9rem + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); border: 0; font-size: 1.5rem; box-shadow: var(--shadow-pop); z-index: 1031; }
  .guest { grid-template-columns: 1fr; }
  .guest-side { display: none; }
  .guest-main { justify-content: flex-start; padding-top: max(1.25rem, env(safe-area-inset-top)); }
  .guest-mobile-brand { display: flex; width: 100%; max-width: 430px; margin: 0 auto 1.75rem; }
  .cal-d { min-height: 72px; font-size: .7rem; padding: .2rem; }
  .cal-ev { font-size: .66rem; padding: 0 .2rem; }
  .ledger li { padding: .65rem 1rem; }
  .hero-band { padding: 1.25rem 1.25rem 1.25rem 1.5rem; }
  .lp-nav .links { display: none; }
  .steps { grid-template-columns: 1fr; gap: 1.75rem; }
  .steps li::after { display: none; }
  .security-grid { grid-template-columns: 1fr; }
}
@media (min-width: 992px) { .sidebar-scrim { display: none !important; } .only-mobile { display: none !important; } }
@media (max-width: 575.98px) {
  .tile .fig-lg { font-size: 1.12rem; }
  .tile { padding: .8rem .85rem; }
  .hero-band .split { grid-template-columns: 1fr 1fr; }
  .hero-band .split > :last-child { grid-column: span 2; }
  .panel-body { padding: 1rem; }
  .panel-head { padding: .9rem 1rem .3rem; }
  .lp-nav .actions .btn { padding-left: .8rem; padding-right: .8rem; }
  .lp-nav .brand-name small { display: none; }
  .passbook td, .passbook th { padding-left: .5rem; padding-right: .5rem; }
  .passbook td:first-child, .passbook th:first-child { padding-left: .9rem; }
  .passbook td:last-child, .passbook th:last-child { padding-right: .9rem; }
  .passbook .hide-xs { display: none; }
  .toast-stack { left: 1rem; right: 1rem; bottom: calc(5rem + env(safe-area-inset-bottom)); max-width: none; }
  .filters-mobile:not([open]) > :not(summary) { display: none; }
  .modal-dialog { margin: .5rem; }
}
@media (max-width: 359.98px) {
  .content { padding-left: .75rem; padding-right: .75rem; }
  .topbar .icon-btn[data-theme-toggle] { display: none; }
  .brand-name { font-size: .88rem; }
  .lp-nav .actions .btn-quiet { display: none; }
}
.filters-mobile > summary { display: none; }
@media (max-width: 767.98px) {
  .filters-mobile > summary { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; list-style: none; font-weight: 600; font-size: .9rem; padding: .45rem .8rem; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
  .filters-mobile > summary::-webkit-details-marker { display: none; }
  .filters-mobile[open] > summary { margin-bottom: .75rem; }
  .filters-mobile:not([open]) > :not(summary) { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .sidebar, .topbar, .bottom-nav, .fab, .no-print, .toast-stack, .sidebar-scrim { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .panel, .tile { box-shadow: none; break-inside: avoid; }
}

/* ---------- charts & bootstrap component theming ---------- */
canvas.chart { width: 100% !important; }
.chart-box { position: relative; height: 260px; min-width: 0; }
.chart-box.sm { height: 210px; }
.chart-box.lg { height: 300px; }
@media (max-width: 575.98px) { .chart-box { height: 230px; } .chart-box.sm { height: 200px; } }
.chart-empty { display: grid; place-items: center; text-align: center; height: 100%; color: var(--muted); font-size: .9rem; padding: 1rem; }
.dropdown-menu { border-color: var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); background: var(--surface); --bs-dropdown-link-color: var(--text); --bs-dropdown-link-hover-bg: var(--surface-2); max-width: calc(100vw - 1.5rem); }
.dropdown-item { display: flex; align-items: center; gap: .55rem; min-height: 38px; }
.modal-content { background: var(--surface); border-radius: var(--radius-lg); border-color: var(--line); color: var(--text); }
.modal-backdrop.show { opacity: .55; }
.nav-tabs { border-color: var(--line); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-link { white-space: nowrap; color: var(--muted); font-weight: 550; }
.nav-tabs .nav-link.active { background: var(--surface); color: var(--text); border-color: var(--line) var(--line) var(--surface); }
.nav-pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: .25rem; }
.nav-pills::-webkit-scrollbar { display: none; }
.nav-pills .nav-link { white-space: nowrap; color: var(--text); font-weight: 550; border-radius: 9px; }
.nav-pills .nav-link.active { background: var(--accent); color: var(--accent-contrast); }
.list-group-item { background: var(--surface); color: var(--text); border-color: var(--line); }
.pagination { flex-wrap: wrap; gap: .25rem; }
.pagination .page-link { color: var(--text); background: var(--surface); border-color: var(--line); border-radius: 8px !important; min-width: 38px; text-align: center; }
.pagination .active .page-link { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.alert { border-radius: var(--radius); }
.btn-close { width: 1.2em; height: 1.2em; }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.min-w-0 { min-width: 0; }
.text-wrap-anywhere { overflow-wrap: anywhere; }
