/* ==========================================================================
   Ledgerly — application styles
   1. base  2. primitives  3. shell  4. charts  5. views  6. lock screen
   7. responsive  8. motion & a11y
   ========================================================================== */

/* ---------- 1. base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
::selection { background: var(--primary-soft); }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.small { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.center { text-align: center; }
.mt { margin-top: var(--sp-3); }
.mr-auto { margin-right: auto; }
.grow { flex: 1 1 auto; min-width: 0; }
.eyebrow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-bottom: var(--sp-2); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.gap-sm { gap: var(--sp-2); }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: var(--sp-4); color: var(--muted); }
.boot-mark { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, var(--s6), var(--s2)); animation: pulse 1.4s ease-in-out infinite; }
.noscript { padding: var(--sp-6); text-align: center; }

/* ---------- 2. primitives ---------- */
.icon { flex: none; }

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 40px; padding: 0 var(--sp-4);
  border-radius: var(--r-md); border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: var(--fs-sm); white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  position: relative;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--primary-ink); --btn-bd: transparent; box-shadow: 0 6px 16px -8px var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { --btn-bg: var(--surface); --btn-bd: var(--border-strong); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { --btn-bg: var(--neg); --btn-fg: #fff; --btn-bd: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--neg); filter: brightness(1.08); }
.btn-danger-text { color: var(--neg); }
.btn-sm { height: 32px; padding: 0 var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-xs); }
.btn-lg { height: 48px; font-size: var(--fs-md); border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn.loading { pointer-events: none; }
.btn.loading > :not(.btn-label) { visibility: hidden; }
.btn.loading::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: var(--r-sm); border: 0; background: transparent; color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; }

.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--primary); font-weight: 600; font-size: var(--fs-sm); padding: 6px 4px; }
.link-btn.danger { color: var(--muted); }
.link-btn:hover { text-decoration: underline; }

.input {
  width: 100%; height: 42px; padding: 0 var(--sp-3);
  border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea.input { height: auto; padding: 10px var(--sp-3); resize: vertical; min-height: 64px; }
select.input { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:hover { border-color: var(--faint); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.input::placeholder { color: var(--faint); }
.input-sm { height: 34px; font-size: var(--fs-sm); border-radius: var(--r-sm); width: auto; min-width: 0; }
.input-emoji { width: 56px; flex: none; text-align: center; font-size: 1.2rem; padding: 0; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-addon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.amount-wrap { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.amount-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.amount-cur { padding-left: var(--sp-4); color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }
.input-amount { border: 0; box-shadow: none !important; height: 56px; font-size: var(--fs-2xl); font-weight: 650; font-variant-numeric: tabular-nums; background: transparent; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field-hint { font-size: var(--fs-xs); color: var(--muted); }
.field-error { font-size: var(--fs-xs); color: var(--neg); min-height: 0; font-weight: 500; }
.field-error:empty { display: none; }
.has-error .input, .has-error .amount-wrap { border-color: var(--neg); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.suggestion { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--primary); margin-top: 6px; min-height: 18px; }
.suggestion:empty { display: none; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 1 0 auto; border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented-sm button { padding: 5px 10px; font-size: var(--fs-xs); }
.form-grid .segmented { display: flex; width: 100%; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-1); min-width: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.card-flush { padding: 0; gap: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.card-title { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -0.01em; }
.card-sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.card-actions { display: flex; gap: var(--sp-2); align-items: center; flex: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge-success { background: var(--pos-soft); color: var(--pos); }
.badge-warning { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--neg-soft); color: var(--neg); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed var(--border-strong); background: var(--surface-2); color: var(--text-2); padding: 6px 12px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.tag { font-size: var(--fs-xs); color: var(--primary); }

.callout { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--info-soft); color: var(--text); font-size: var(--fs-sm); }
.callout .icon { color: var(--info); }
.callout-action { background: var(--primary-soft); }
.callout-action .icon { color: var(--primary); }
.callout-action > span { flex: 1; font-weight: 600; }
.callout-success { background: var(--pos-soft); }
.callout-success .icon { color: var(--pos); }
.callout-danger { background: var(--neg-soft); }
.callout-danger .icon { color: var(--neg); }

.progress { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: visible; }
.progress-fill { height: 100%; width: var(--w); border-radius: inherit; background: var(--primary); transition: width var(--t-slow) var(--ease); animation: grow var(--t-slow) var(--ease); max-width: 100%; }
.progress-success .progress-fill { background: var(--pos); }
.progress-warning .progress-fill { background: var(--warn); }
.progress-danger .progress-fill { background: var(--neg); }
.progress-goal { height: 12px; }
.progress-goal .progress-fill { background: linear-gradient(90deg, color-mix(in srgb, var(--c, var(--primary)) 70%, white), var(--c, var(--primary))); }
.progress-marker { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--text); opacity: 0.55; }

.stat { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 6px; min-width: 0; overflow: hidden; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.stat-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); flex: none; }
.stat-value { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; line-height: 1.2; }
.stat-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); min-height: 18px; }
.stat-hero { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface) 60%); }
.stat-hero .stat-value { font-size: var(--fs-2xl); }
.stat-hero .stat-icon { background: var(--primary-soft); color: var(--primary); }
.stat-pos .stat-value { color: var(--pos); }
.stat-neg .stat-value { color: var(--neg); }
.delta { font-weight: 650; padding: 1px 7px; border-radius: var(--r-pill); }
.delta-pos { background: var(--pos-soft); color: var(--pos); }
.delta-neg { background: var(--neg-soft); color: var(--neg); }
.delta-neutral { background: var(--surface-2); color: var(--text-2); }

/* categorical slots: one --c per entity, consumed by fills, strokes, backgrounds */
.slot-0, .slot-bg-0, .slot-fill-0, .slot-stroke-0, .slot-soft-0 { --c: var(--s0); }
.slot-1, .slot-bg-1, .slot-fill-1, .slot-stroke-1, .slot-soft-1 { --c: var(--s1); }
.slot-2, .slot-bg-2, .slot-fill-2, .slot-stroke-2, .slot-soft-2 { --c: var(--s2); }
.slot-3, .slot-bg-3, .slot-fill-3, .slot-stroke-3, .slot-soft-3 { --c: var(--s3); }
.slot-4, .slot-bg-4, .slot-fill-4, .slot-stroke-4, .slot-soft-4 { --c: var(--s4); }
.slot-5, .slot-bg-5, .slot-fill-5, .slot-stroke-5, .slot-soft-5 { --c: var(--s5); }
.slot-6, .slot-bg-6, .slot-fill-6, .slot-stroke-6, .slot-soft-6 { --c: var(--s6); }
.slot-7, .slot-bg-7, .slot-fill-7, .slot-stroke-7, .slot-soft-7 { --c: var(--s7); }
.slot--1, .slot-bg--1, .slot-fill--1, .slot-stroke--1, .slot-soft--1 { --c: var(--s-other); }
[class*="slot-bg-"] { background-color: var(--c); }
[class*="slot-fill-"] { fill: var(--c); }
[class*="slot-stroke-"] { stroke: var(--c); }
[class*="slot-soft-"] { background-color: color-mix(in srgb, var(--c) 16%, transparent); }

.cat-dot { display: inline-grid; place-items: center; flex: none; border-radius: 11px; background: color-mix(in srgb, var(--c, var(--s-other)) 16%, transparent); line-height: 1; }
.cat-dot-md { width: 38px; height: 38px; font-size: 1.05rem; }
.cat-dot-sm { width: 26px; height: 26px; font-size: 0.8rem; border-radius: 8px; }
.cat-dot.transfer { background: var(--surface-2); color: var(--text-2); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-8) var(--sp-4); }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--primary-soft); color: var(--primary); margin-bottom: var(--sp-2); }
.empty h3 { font-size: var(--fs-lg); }
.empty p { max-width: 42ch; font-size: var(--fs-sm); }
.empty .btn { margin-top: var(--sp-3); }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton-block { display: grid; gap: 10px; }

/* toasts */
.toasts { position: fixed; z-index: 90; right: var(--sp-5); bottom: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--sp-3); padding: 10px 10px 10px 14px; border-radius: var(--r-md); background: var(--text); color: var(--bg); box-shadow: var(--shadow-3); font-size: var(--fs-sm); animation: toast-in var(--t-med) var(--ease); }
.toast.leaving { animation: toast-out 180ms var(--ease) forwards; }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: color-mix(in srgb, var(--bg) 16%, transparent); flex: none; }
.toast-success .toast-icon { background: var(--pos); color: #fff; }
.toast-warning .toast-icon { background: var(--warn); color: #111; }
.toast-danger .toast-icon { background: var(--neg); color: #fff; }
.toast .btn-ghost { color: var(--bg); background: color-mix(in srgb, var(--bg) 12%, transparent); }
.toast .btn-ghost:hover { background: color-mix(in srgb, var(--bg) 22%, transparent); color: var(--bg); }
.toast .icon-btn { color: color-mix(in srgb, var(--bg) 70%, transparent); width: 28px; height: 28px; }
.toast .icon-btn:hover { background: color-mix(in srgb, var(--bg) 12%, transparent); color: var(--bg); }

/* modal */
.backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: var(--sp-4); background: var(--overlay); backdrop-filter: blur(3px); animation: fade-in var(--t-med) var(--ease); }
.backdrop.leaving { animation: fade-out 160ms var(--ease) forwards; }
.modal { width: 100%; max-height: min(92vh, 860px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-3); animation: pop-in var(--t-med) var(--ease); outline: none; }
.modal-sm { max-width: 440px; }
.modal-md { max-width: 580px; }
.modal-lg { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) var(--sp-3); }
.modal-title { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }
.modal-body { padding: var(--sp-2) var(--sp-6) var(--sp-5); overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }
body.modal-open { overflow: hidden; }

/* ---------- 3. shell ---------- */
.app-shell { min-height: 100vh; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--primary); color: var(--primary-ink); padding: 8px 14px; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-w); display: flex; flex-direction: column; gap: var(--sp-5); padding: var(--sp-5) var(--sp-4); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: var(--sp-3); font-weight: 750; font-size: var(--fs-lg); letter-spacing: -0.02em; color: var(--text); padding: 0 var(--sp-2); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #fff; background: linear-gradient(135deg, #6366f1, #1baf7a); box-shadow: 0 6px 16px -6px rgba(99, 102, 241, 0.7); flex: none; }
.brand-lg { font-size: var(--fs-xl); justify-content: center; margin-bottom: var(--sp-2); }
.brand-lg .brand-mark { width: 44px; height: 44px; border-radius: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: 10px var(--sp-3); border-radius: var(--r-md); color: var(--text-2); font-weight: 550; font-size: var(--fs-md); border: 0; background: transparent; transition: background var(--t-fast), color var(--t-fast); }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link.active .icon { stroke-width: 2.2; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2); }
.sync-card-mini { display: flex; align-items: center; gap: var(--sp-3); text-align: left; padding: var(--sp-3); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); transition: border-color var(--t-fast); }
.sync-card-mini:hover { border-color: var(--border-strong); }
.sync-dot { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; flex: none; background: var(--surface-2); color: var(--muted); }
.sync-text { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-sm); line-height: 1.3; }
.sync-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tone-success { color: var(--pos); }
.tone-success.sync-dot { background: var(--pos-soft); }
.tone-warning { color: var(--warn); }
.tone-warning.sync-dot { background: var(--warn-soft); }
.tone-danger { color: var(--neg); }
.tone-danger.sync-dot { background: var(--neg-soft); }
.tone-info { color: var(--info); }
.tone-info.sync-dot { background: var(--info-soft); }
.spinning .icon { animation: spin 1s linear infinite; }

.main-col { margin-left: var(--sidebar-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-6); background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.topbar-title { font-weight: 650; font-size: var(--fs-md); color: var(--text-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-1); }
.menu-btn { display: none; }
.sync-pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-xs); font-weight: 650; color: var(--muted); transition: border-color var(--t-fast); }
.sync-pill:hover { border-color: var(--border-strong); }
.sync-pill.tone-neutral { color: var(--muted); }
.banner-host:empty { display: none; }
.banner { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-4) var(--sp-6) 0; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); font-size: var(--fs-sm); border: 1px solid; animation: slide-down var(--t-med) var(--ease); }
.banner > span { flex: 1; }
.banner-danger { background: var(--neg-soft); border-color: color-mix(in srgb, var(--neg) 30%, transparent); color: var(--text); }
.banner-danger .icon { color: var(--neg); }
.banner-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner-warning .icon { color: var(--warn); }
.content { padding: var(--sp-6); max-width: 1440px; margin: 0 auto; outline: none; }

.bottom-nav, .fab, .scrim { display: none; }

/* ---------- 4. charts ---------- */
.chart-wrap { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.chart { position: relative; width: 100%; overflow: hidden; }
.chart-svg { overflow: visible; touch-action: pan-y; }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.axis-text { fill: var(--axis-text); font-size: 11px; font-variant-numeric: tabular-nums; }
.bar { transition: opacity var(--t-fast); }
.hovering .bar-group:not(.active) .bar { opacity: 0.35; }
.hit { fill: transparent; cursor: crosshair; }
.area { fill-opacity: 0.12; stroke: none; }
.line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dot { stroke: var(--surface); stroke-width: 2; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-xs); color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend-key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-line { height: 3px; width: 14px; border-radius: 2px; }

.chart-tip { position: fixed; left: 0; top: 0; z-index: 95; pointer-events: none; min-width: 150px; max-width: 280px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); font-size: var(--fs-xs); opacity: 0; transition: opacity var(--t-fast); }
.chart-tip.show { opacity: 1; }
.tip-title { font-weight: 650; margin-bottom: 6px; color: var(--text); }
.tip-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.tip-row + .tip-row { margin-top: 3px; }
.tip-key { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip-name { flex: 1; }
.tip-val { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }

.donut-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--sp-5); }
.donut-figure { display: grid; place-items: center; }
.donut-track { stroke: var(--surface-2); }
.donut-seg { transition: opacity var(--t-fast), stroke-dasharray var(--t-slow) var(--ease); cursor: pointer; outline: none; }
.donut-seg.dim { opacity: 0.25; }
.donut-value { fill: var(--text); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.donut-label { fill: var(--muted); font-size: 11px; }
.donut-legend { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.donut-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 38px; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 8px; font-size: var(--fs-sm); transition: opacity var(--t-fast), background var(--t-fast); }
.donut-legend li.clickable { cursor: pointer; }
.donut-legend li:hover { background: var(--surface-2); }
.donut-legend li.dim { opacity: 0.45; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.legend-pct { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; font-size: var(--fs-xs); }

.chart-spark { margin: 4px -4px -6px; }
.spark { overflow: visible; }

.gauge { overflow: visible; }
.gauge-track { fill: none; stroke: var(--surface-3); stroke-width: 14; stroke-linecap: round; }
.gauge-fill { fill: none; stroke-width: 14; stroke-linecap: round; stroke: var(--primary); }
.gauge-good .gauge-fill { stroke: var(--pos); }
.gauge-ok .gauge-fill { stroke: var(--s0); }
.gauge-warn .gauge-fill { stroke: var(--warn); }
.gauge-bad .gauge-fill { stroke: var(--neg); }
.gauge-value { fill: var(--text); font-size: 40px; font-weight: 750; letter-spacing: -0.03em; }
.gauge-label { fill: var(--muted); font-size: 12px; }

.hbar-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.hbar-top { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); margin-bottom: 5px; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.hbar-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar-track { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.hbar-fill { height: 100%; width: var(--w); border-radius: inherit; animation: grow var(--t-slow) var(--ease); }
.hbar-sub { margin-top: 3px; }

.heat-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat-cell { position: relative; height: 56px; border-radius: 10px; background: color-mix(in srgb, var(--s0) calc(var(--a) * 100%), var(--surface-2)); display: grid; place-items: end center; padding-bottom: 6px; cursor: default; transition: transform var(--t-fast); }
.heat-cell:hover { transform: translateY(-2px); }
.heat-label { font-size: 11px; font-weight: 650; color: var(--text); background: color-mix(in srgb, var(--surface) 80%, transparent); padding: 0 6px; border-radius: 6px; }

/* ---------- 5. views ---------- */
.view { display: flex; flex-direction: column; gap: var(--sp-5); animation: view-in var(--t-med) var(--ease); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-4); }
.page-title { font-size: var(--fs-3xl); font-weight: 750; letter-spacing: -0.03em; line-height: 1.15; outline: none; }
.page-sub { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
.kpi-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid { display: grid; gap: var(--sp-5); align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card, .grid > .stack { height: 100%; }

.health { display: grid; place-items: center; margin-top: -4px; }
.health-list { display: flex; flex-direction: column; gap: var(--sp-3); font-size: var(--fs-sm); }
.health-list .progress { height: 6px; margin: 4px 0 3px; }

.mini-budgets { display: flex; flex-direction: column; gap: var(--sp-4); font-size: var(--fs-sm); }
.mini-budgets .progress { margin: 8px 0 6px; }

.insights { display: flex; flex-direction: column; gap: var(--sp-2); }
.insight { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid transparent; transition: border-color var(--t-fast); }
.insight:hover { border-color: var(--border); }
.insight-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; }
.insight-danger .insight-icon { background: var(--neg-soft); color: var(--neg); }
.insight-warning .insight-icon { background: var(--warn-soft); color: var(--warn); }
.insight-primary .insight-icon { background: var(--primary-soft); color: var(--primary); }
.insight-info .insight-icon { background: var(--info-soft); color: var(--info); }
.insight-success .insight-icon { background: var(--pos-soft); color: var(--pos); }
.insight-title { font-weight: 650; font-size: var(--fs-sm); line-height: 1.35; }
.insight-detail { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; line-height: 1.45; }
.insight-action { grid-column: 2; justify-self: start; margin-top: 4px; height: 28px; padding: 0 8px; color: var(--primary); margin-left: -8px; }

.upcoming { display: flex; flex-direction: column; }
.upcoming li { display: grid; grid-template-columns: 82px auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); padding: 9px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.upcoming li:last-child { border-bottom: 0; }
.up-date { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tx-list { display: flex; flex-direction: column; }
.tx-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); transition: background var(--t-fast); }
.tx-row:last-child { border-bottom: 0; }
.tx-row:hover { background: var(--surface-2); }
.tx-row.selected { background: var(--primary-soft); }
.tx-check { display: grid; place-items: center; padding-left: var(--sp-4); cursor: pointer; }
.tx-check input { width: 17px; height: 17px; accent-color: var(--primary); }
.tx-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-3); padding: 11px var(--sp-4); border: 0; background: transparent; text-align: left; }
.tx-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tx-payee { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-xs); color: var(--muted); }
.tx-flag { display: inline-flex; color: var(--primary); }
.tx-amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-day { display: flex; justify-content: space-between; padding: 14px var(--sp-4) 6px; font-size: var(--fs-xs); font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: var(--topbar-h); z-index: 1; }
.tx-list.compact .tx-main { padding: 9px 0; }
.tx-list.compact .tx-row:hover { background: transparent; }
.tx-list.compact .cat-dot-md { width: 34px; height: 34px; }

.acc-mini { display: flex; flex-direction: column; gap: var(--sp-1); }
.acc-mini li { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); padding: 8px 0; font-size: var(--fs-sm); }
.acc-chip { width: 6px; height: 28px; border-radius: 3px; }
.acc-name { display: flex; flex-direction: column; overflow: hidden; font-weight: 600; }
.acc-name .small { font-weight: 400; }
.acc-total { padding-top: var(--sp-3); border-top: 1px solid var(--border); font-size: var(--fs-sm); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border-bottom: 1px solid var(--border); }
.search-wrap { position: relative; flex: 1 1 260px; min-width: 0; }
.search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-wrap .input { padding-left: 38px; }
.toolbar-filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); width: 100%; }
.toolbar-filters .input-sm { flex: 0 1 auto; max-width: 220px; }
.tx-summary { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); padding: 10px var(--sp-4); font-size: var(--fs-sm); background: var(--surface-2); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-4); background: var(--primary-soft); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); animation: slide-down var(--t-med) var(--ease); }
.load-more { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); padding: var(--sp-4); border-top: 1px solid var(--border); }
.import-preview { padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); display: flex; flex-direction: column; gap: var(--sp-2); }
.import-sample li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: var(--sp-3); padding: 4px 0; border-bottom: 1px dashed var(--border); }
.import-sample li span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.month-nav { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.month-label { min-width: 132px; text-align: center; font-weight: 650; font-size: var(--fs-sm); }

.budget-grid, .goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-4); }
.budget, .goal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); box-shadow: var(--shadow-1); transition: transform var(--t-fast), box-shadow var(--t-fast); }
.budget:hover, .goal:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.budget-over { border-color: color-mix(in srgb, var(--neg) 35%, var(--border)); }
.budget-pace { border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.budget-name, .goal-name { font-size: var(--fs-md); font-weight: 650; }
.budget-amounts, .goal-amounts { display: flex; align-items: baseline; gap: 4px; font-size: var(--fs-sm); }
.budget-spent, .goal-saved { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.budget-pct { margin-left: auto; font-weight: 650; color: var(--text-2); }
.budget-note { color: var(--text-2); line-height: 1.45; }
.budget-pace .budget-note { color: var(--warn); }
.budget-over .budget-note { color: var(--neg); }
.unbudgeted li { display: flex; align-items: center; gap: var(--sp-3); padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.unbudgeted li:last-child { border-bottom: 0; }

.goal-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; font-size: 1.35rem; flex: none; }
.goal-bar { display: flex; align-items: center; gap: var(--sp-3); }
.goal-bar .progress { flex: 1; }
.goal-pct { font-weight: 700; font-size: var(--fs-sm); min-width: 40px; text-align: right; }
.goal-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-2); }
.goal-stats dt { font-size: var(--fs-xs); color: var(--muted); }
.goal-stats dd { font-size: var(--fs-sm); font-weight: 650; font-variant-numeric: tabular-nums; }
.goal-done { background: linear-gradient(160deg, var(--pos-soft), var(--surface) 55%); }

.rec-list { display: flex; flex-direction: column; }
.rec { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto; align-items: center; gap: var(--sp-3); padding: 11px 0; border-bottom: 1px solid var(--border); }
.rec:last-child { border-bottom: 0; }
.rec.inactive { opacity: 0.55; }
.rec-text { display: flex; flex-direction: column; min-width: 0; }
.rec-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-amt { font-weight: 650; }
.rec-actions { display: flex; align-items: center; gap: 4px; }

.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-3); }
.acc-tile { position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; padding: var(--sp-4) var(--sp-4) var(--sp-4) calc(var(--sp-4) + 6px); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); overflow: hidden; transition: transform var(--t-fast), border-color var(--t-fast); }
.acc-tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.acc-tile.archived { opacity: 0.6; }
.acc-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.acc-tile-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.acc-type { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 650; }
.acc-tile-name { font-weight: 650; }
.acc-tile-bal { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.sync-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.sync-msg { width: 100%; font-size: var(--fs-sm); color: var(--text-2); }
.resolution { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-md); background: var(--neg-soft); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-3) var(--sp-5); }
.kv dt { font-size: var(--fs-xs); color: var(--muted); }
.kv dd { font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.kv a { display: inline-flex; align-items: center; gap: 4px; }
.sec-list { display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.sec-list li { display: flex; gap: var(--sp-3); align-items: flex-start; }
.sec-list .icon { color: var(--pos); margin-top: 2px; }
.strength { display: flex; align-items: center; gap: var(--sp-3); margin-top: 8px; }
.strength-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 120px; flex: none; }
.strength-bar span { height: 5px; border-radius: 3px; background: var(--surface-3); transition: background var(--t-med); }
.strength-bar.s1 span:nth-child(-n+1) { background: var(--neg); }
.strength-bar.s2 span:nth-child(-n+2) { background: var(--warn); }
.strength-bar.s3 span:nth-child(-n+3) { background: var(--s0); }
.strength-bar.s4 span { background: var(--pos); }
.data-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-3); }
.data-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); transition: border-color var(--t-fast), transform var(--t-fast); }
.data-tile:hover { border-color: var(--primary); transform: translateY(-1px); }
.data-tile-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); margin-bottom: 6px; }
.data-tile-label { font-weight: 650; font-size: var(--fs-sm); }
.data-tile-danger .data-tile-icon { background: var(--neg-soft); color: var(--neg); }
.data-tile-danger:hover { border-color: var(--neg); }
.cat-group + .cat-group { margin-top: var(--sp-2); }
.chip-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.cat-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-sm); transition: border-color var(--t-fast); }
.cat-chip:hover { border-color: var(--border-strong); }
.cat-chip .cat-dot-sm { border-radius: 50%; }
.rule-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.rule { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); text-align: left; }
.rule:hover { border-color: var(--border-strong); }
.rule .icon { color: var(--muted); }
.about { padding: var(--sp-4) var(--sp-5); }

.slot-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.slot-swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); transition: transform var(--t-fast), box-shadow var(--t-fast); }
.slot-swatch:hover { transform: scale(1.1); }
.slot-swatch.active { box-shadow: 0 0 0 2px var(--text); }

/* ---------- 6. lock screen ---------- */
.lock-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-5); padding: var(--sp-6) var(--sp-4); }
.lock-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-8); box-shadow: var(--shadow-3); display: flex; flex-direction: column; gap: var(--sp-5); animation: pop-in var(--t-slow) var(--ease); }
.lock-title { font-size: var(--fs-2xl); font-weight: 750; letter-spacing: -0.03em; text-align: center; }
.lock-card .muted { text-align: center; font-size: var(--fs-sm); }
.lock-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.lock-foot { display: flex; align-items: center; gap: 6px; color: var(--muted); text-align: center; max-width: 460px; justify-content: center; }
.shake { animation: shake 360ms var(--ease); }

/* ---------- 7. responsive ---------- */
@media (max-width: 1279px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 1099px) {
  :root { --sidebar-w: var(--rail-w); }
  .sidebar { padding: var(--sp-5) var(--sp-3); align-items: center; }
  .brand-name, .nav-label, .sync-text { display: none; }
  .brand { padding: 0; }
  .nav-link { justify-content: center; padding: 11px; }
  .sync-card-mini { padding: 6px; border: 0; background: transparent; justify-content: center; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  :root { --sidebar-w: 0px; }
  body { font-size: var(--fs-md); }
  .sidebar { width: 280px; align-items: stretch; padding: var(--sp-5) var(--sp-4); transform: translateX(-104%); transition: transform var(--t-med) var(--ease); box-shadow: var(--shadow-3); background: var(--surface); }
  .brand-name, .nav-label, .sync-text { display: initial; }
  .sync-text { display: flex; }
  .brand { padding: 0 var(--sp-2); }
  .nav-link { justify-content: flex-start; padding: 12px var(--sp-3); }
  .sync-card-mini { padding: var(--sp-3); border: 1px solid var(--border); background: var(--surface); justify-content: flex-start; }
  .drawer-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity var(--t-med); }
  .drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .main-col { margin-left: 0; }
  .menu-btn { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 0 var(--sp-4); }
  .sync-pill-label { display: none; }
  .sync-pill { width: 34px; padding: 0; justify-content: center; }
  .content { padding: var(--sp-4) var(--sp-4) calc(var(--bottom-h) + 88px); }
  .banner { margin: var(--sp-3) var(--sp-4) 0; }
  .page-title { font-size: var(--fs-2xl); }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .hide-sm { display: none !important; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 > :last-child:nth-child(odd) { grid-column: auto; }
  .kpi-grid, .kpi-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .kpi-grid > .stat-hero { grid-column: 1 / -1; }
  .stat { padding: var(--sp-3) var(--sp-4); }
  .stat-value { font-size: var(--fs-lg); }
  .stat-hero .stat-value { font-size: var(--fs-2xl); }
  .stat-icon { display: none; }
  .card { padding: var(--sp-4); }
  .card-flush { padding: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .donut-legend { width: 100%; }
  .toolbar-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .toolbar-filters::-webkit-scrollbar { display: none; }
  .toolbar-filters .input-sm { flex: none; }
  .tx-check { padding-left: var(--sp-3); }
  .tx-main { padding: 10px var(--sp-3); }
  .rec { grid-template-columns: auto minmax(0, 1fr) auto; }
  .rec-when { grid-column: 2; grid-row: 2; }
  .rec-actions { grid-column: 3; grid-row: 2; justify-self: end; }
  .upcoming li { grid-template-columns: 70px auto minmax(0, 1fr) auto; }
  .budget-grid, .goal-grid { grid-template-columns: minmax(0, 1fr); }
  .month-label { min-width: 110px; }

  .bottom-nav { display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px) saturate(1.4); border-top: 1px solid var(--border); }
  .bottom-link { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; }
  .bottom-link:hover { text-decoration: none; }
  .bottom-link.active { color: var(--primary); }
  .fab { display: grid; place-items: center; position: fixed; z-index: 31; right: var(--sp-4); bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 16px); width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--primary); color: var(--primary-ink); box-shadow: 0 12px 28px -8px var(--primary); transition: transform var(--t-fast); }
  .fab:active { transform: scale(0.94); }
  .toasts { left: 16px; right: 16px; width: auto; bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 84px); }

  .backdrop { align-items: end; padding: 0; }
  .modal { max-width: none !important; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 94dvh; animation: sheet-in var(--t-med) var(--ease); }
  .modal-head { padding: var(--sp-4) var(--sp-4) var(--sp-2); }
  .modal-body { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
  .modal-foot { padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom)); border-radius: 0; }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot .mr-auto { flex: 0 0 auto; }
  .lock-card { padding: var(--sp-6) var(--sp-5); }
}
@media (max-width: 359px) {
  .kpi-grid, .kpi-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 8. motion & a11y ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(0.88); opacity: 0.7; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes grow { from { width: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-6px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.97); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .progress-fill, .hbar-fill, [class*="slot-bg-"] { forced-color-adjust: none; }
  .btn, .card, .stat { border: 1px solid CanvasText; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .fab, .toasts, .banner-host { display: none !important; }
  .main-col { margin: 0; }
  body { background: #fff; }
}

/* dashboard cash-flow summary */
.flow-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--border); margin-top: auto; }
.flow-summary dt { font-size: var(--fs-xs); color: var(--muted); }
.flow-summary dd { font-weight: 650; font-variant-numeric: tabular-nums; }
@media (max-width: 767px) { .flow-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
