/* =====================================================================
   Joint Budget — design system
   Tokens → base → shell → components → sheet (grid) → pages → motion
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg:          #f4f5f9;
  --surface:     #ffffff;
  --surface-2:   #f8f9fc;
  --surface-3:   #eef0f6;
  --border:      #e5e7ef;
  --border-2:    #d6d9e4;
  --text:        #10131c;
  --text-2:      #4a5263;
  --muted:       #8a92a5;

  --brand:       #6250d6;
  --brand-2:     #8a7cf0;
  --brand-ink:   #ffffff;
  --brand-soft:  rgba(98, 80, 214, .09);
  --brand-soft-2:rgba(98, 80, 214, .16);

  /* People — categorical slots 1 & 2 (validated, CVD-safe) */
  --u1:          #2a78d6;
  --u1-soft:     rgba(42, 120, 214, .10);
  --u2:          #eb6834;
  --u2-soft:     rgba(235, 104, 52, .11);

  /* Series that aren't people */
  --s-joint:     #1baf7a;
  --s-extra:     #6250d6;

  /* Status — always paired with an icon or label */
  --good:        #13803b;
  --good-soft:   rgba(12, 163, 12, .10);
  --bad:         #c93434;
  --bad-soft:    rgba(208, 59, 59, .09);
  --warn:        #a26a00;
  --warn-mark:   #f0a800;
  --warn-soft:   rgba(250, 178, 25, .16);

  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   18px;
  --shadow-xs:   0 1px 2px rgba(16, 19, 28, .05);
  --shadow-sm:   0 1px 2px rgba(16, 19, 28, .04), 0 2px 8px rgba(16, 19, 28, .04);
  --shadow:      0 2px 4px rgba(16, 19, 28, .04), 0 10px 30px rgba(16, 19, 28, .07);
  --shadow-lg:   0 20px 60px rgba(16, 19, 28, .18);

  --sidebar-w:   248px;
  --topbar-h:    68px;
  --ease:        cubic-bezier(.22, .9, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --font:        'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display:'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:          #0c0d12;
  --surface:     #15171e;
  --surface-2:   #1a1c24;
  --surface-3:   #22252f;
  --border:      #262934;
  --border-2:    #343846;
  --text:        #eef0f5;
  --text-2:      #b4bacb;
  --muted:       #7c8496;

  --brand:       #9085e9;
  --brand-2:     #a99ff2;
  --brand-ink:   #0f0d1f;
  --brand-soft:  rgba(144, 133, 233, .12);
  --brand-soft-2:rgba(144, 133, 233, .22);

  --u1:          #3987e5;
  --u1-soft:     rgba(57, 135, 229, .16);
  --u2:          #d95926;
  --u2-soft:     rgba(217, 89, 38, .17);

  --s-joint:     #199e70;
  --s-extra:     #9085e9;

  --good:        #4cc777;
  --good-soft:   rgba(76, 199, 119, .13);
  --bad:         #f07272;
  --bad-soft:    rgba(240, 114, 114, .13);
  --warn:        #f2bb3d;
  --warn-mark:   #f2bb3d;
  --warn-soft:   rgba(242, 187, 61, .14);

  --shadow-xs:   0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .2);
  --shadow:      0 2px 4px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg:   0 20px 60px rgba(0, 0, 0, .6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .35s var(--ease), border-color .35s var(--ease), color .35s var(--ease), fill .35s, stroke .35s !important;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); color: var(--text); letter-spacing: -.01em; margin: 0; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted) !important; }
.text-2 { color: var(--text-2) !important; }
.good { color: var(--good) !important; }
.bad { color: var(--bad) !important; }
.warn { color: var(--warn) !important; }
.u1 { color: var(--u1) !important; }
.u2 { color: var(--u2) !important; }
::selection { background: var(--brand-soft-2); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: transform .35s var(--ease);
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 22px;
  color: var(--text);
}
.sidebar .brand:hover { color: var(--text); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  color: #fff; font-size: 18px;
  background: linear-gradient(135deg, #7b6cf6 0%, #5a46d0 55%, #2a78d6 100%);
  box-shadow: 0 6px 16px rgba(98, 80, 214, .35), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 16px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; }

.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0;
  border-radius: 10px;
  color: var(--text-2); font-weight: 550; font-size: 14px;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.nav-item i { font-size: 17px; width: 20px; text-align: center; transition: transform .3s var(--ease-spring); }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item:hover i { transform: scale(1.12); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--brand);
  animation: grow-y .4s var(--ease);
}
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.sidebar-foot form { margin: 0; }
.sidebar-foot button.nav-item { width: 100%; border: 0; background: none; text-align: left; font: inherit; font-weight: 550; cursor: pointer; }
.sidebar-foot button.nav-item:hover { color: var(--bad); background: var(--bad-soft); }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s, box-shadow .25s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.page-title { font-size: 21px; font-weight: 800; line-height: 1.15; }
.page-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.page { padding: 8px 28px 48px; flex: 1; }

.scrim { position: fixed; inset: 0; background: rgba(8, 10, 18, .45); backdrop-filter: blur(2px); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .3s; }

/* ---------- FY switcher ---------- */
.fy-switch {
  display: inline-flex; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; box-shadow: var(--shadow-xs);
}
.fy-switch a {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text-2);
  transition: background .2s, color .2s, transform .2s;
}
.fy-switch a:hover { background: var(--surface-3); color: var(--text); }
.fy-switch a:active { transform: scale(.9); }
.fy-switch .fy-label { padding: 0 10px; font-weight: 700; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fy-switch .fy-label small { font-weight: 600; color: var(--muted); margin-right: 4px; font-size: 11px; letter-spacing: .04em; }
.fy-switch .fy-now { width: auto; border-radius: 999px; padding: 0 10px; font-size: 11.5px; font-weight: 700; color: var(--brand); background: var(--brand-soft); margin-left: 2px; }
.fy-switch .fy-now:hover { background: var(--brand-soft-2); color: var(--brand); }

/* ---------- Buttons ---------- */
.btn-x {
  --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  font: 600 13.5px/1 var(--font);
  color: var(--b-fg); background: var(--b-bg);
  border: 1px solid var(--b-bd); border-radius: 10px;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s, color .2s, opacity .2s;
  box-shadow: var(--shadow-xs);
}
.btn-x:hover { border-color: var(--border-2); background: var(--surface-2); color: var(--b-fg); }
.btn-x:active { transform: translateY(1px) scale(.98); }
.btn-x:disabled { opacity: .55; cursor: not-allowed; }
.btn-x.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; gap: 6px; }
.btn-x.lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-x.block { width: 100%; }
.btn-x.primary {
  --b-fg: var(--brand-ink); --b-bd: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, #fff) 0%, var(--brand) 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 16px color-mix(in srgb, var(--brand) 30%, transparent), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-x.primary:hover { filter: brightness(1.06); color: var(--brand-ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 10px 24px color-mix(in srgb, var(--brand) 38%, transparent); }
.btn-x.danger { --b-fg: #fff; --b-bd: transparent; background: var(--bad); }
.btn-x.danger:hover { filter: brightness(1.07); color: #fff; background: var(--bad); }
.btn-x.ghost { --b-bg: transparent; --b-bd: transparent; box-shadow: none; }
.btn-x.ghost:hover { background: var(--surface-3); }
.btn-x.soft { --b-bg: var(--brand-soft); --b-fg: var(--brand); --b-bd: transparent; box-shadow: none; }
.btn-x.soft:hover { background: var(--brand-soft-2); color: var(--brand); }

.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: background .2s, color .2s, transform .15s, border-color .2s;
  box-shadow: var(--shadow-xs);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; box-shadow: none; }
.icon-btn.bare { border-color: transparent; background: transparent; box-shadow: none; }
.icon-btn.bare:hover { background: var(--surface-3); }
.theme-btn i { transition: transform .5s var(--ease-spring); }
.theme-btn:hover i { transform: rotate(-25deg) scale(1.1); }

/* ---------- Cards ---------- */
.card-x {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-x.pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 0; }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body-x { padding: 16px 22px 20px; }
.hover-lift { transition: transform .3s var(--ease), box-shadow .3s var(--ease); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 14px; }
.section-title h2 { font-size: 17px; font-weight: 800; }
.section-title .sub { font-size: 12.5px; color: var(--muted); }
.section-title .actions { margin-left: auto; }

.grid-auto { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-dash { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }

/* ---------- KPI / stat tiles ---------- */
.kpi { position: relative; overflow: hidden; padding: 18px 20px; }
.kpi-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-size: 18px; color: var(--brand); background: var(--brand-soft); margin-bottom: 14px;
}
.kpi-icon.joint { color: var(--s-joint); background: color-mix(in srgb, var(--s-joint) 12%, transparent); }
.kpi-icon.good  { color: var(--good); background: var(--good-soft); }
.kpi-icon.warn  { color: var(--warn); background: var(--warn-soft); }
.kpi-icon.u1    { color: var(--u1); background: var(--u1-soft); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; line-height: 1.2; }
.kpi-value .cur { font-size: .65em; font-weight: 700; color: var(--muted); margin-right: 2px; vertical-align: 2px; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-soft) 0%, transparent 70%); pointer-events: none;
}

.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.delta.up   { color: var(--bad); background: var(--bad-soft); }
.delta.down { color: var(--good); background: var(--good-soft); }
.delta.flat { color: var(--muted); background: var(--surface-3); }

/* ---------- Pills / chips / avatars ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.good  { background: var(--good-soft); color: var(--good) !important; }
.pill.bad   { background: var(--bad-soft); color: var(--bad) !important; }
.pill.warn  { background: var(--warn-soft); color: var(--warn) !important; }
.pill.u1    { background: var(--u1-soft); color: var(--u1) !important; }
.pill.u2    { background: var(--u2-soft); color: var(--u2) !important; }

.avatar {
  --av: var(--u1);
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--av) 75%, #fff) 0%, var(--av) 100%);
  box-shadow: 0 0 0 3px var(--surface), 0 4px 10px color-mix(in srgb, var(--av) 35%, transparent);
}
.avatar.s1 { --av: var(--u2); }
.avatar.sm { width: 22px; height: 22px; font-size: 10.5px; box-shadow: 0 0 0 2px var(--surface); }
.avatar.lg { width: 48px; height: 48px; font-size: 19px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--u1); }
.dot.s1 { background: var(--u2); }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px; background: var(--surface-3); position: relative; }
.segmented button, .segmented a {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2); font: 600 13px var(--font); cursor: pointer;
  transition: color .2s;
}
.segmented button:hover, .segmented a:hover { color: var(--text); }
.segmented .active { color: var(--text); }
.segmented .seg-thumb {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: 0;
  border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .4s var(--ease), width .4s var(--ease);
}

/* ---------- Month strip ---------- */
.month-strip {
  display: grid; grid-template-columns: repeat(12, minmax(62px, 1fr)); gap: 6px;
  overflow-x: auto; padding: 6px; margin: 0 -6px;
  scroll-snap-type: x mandatory;
}
.month-chip {
  position: relative; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 10px 4px 9px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; font: inherit;
  transition: transform .2s var(--ease), border-color .2s, background .2s, color .2s, box-shadow .2s;
}
.month-chip:hover { transform: translateY(-2px); border-color: var(--border-2); color: var(--text); box-shadow: var(--shadow-sm); }
.month-chip .m { font-weight: 750; font-size: 13.5px; }
.month-chip .y { font-size: 10.5px; color: var(--muted); }
.month-chip .bar { width: 22px; height: 3px; border-radius: 3px; background: var(--border); margin-top: 5px; overflow: hidden; }
.month-chip .bar i { display: block; height: 100%; background: var(--s-joint); border-radius: 3px; }
.month-chip.now::after { content: ''; position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); animation: pulse-dot 2s infinite; }
.month-chip.active {
  color: var(--brand-ink); border-color: transparent;
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 82%, #fff), var(--brand));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 32%, transparent);
}
.month-chip.active .y { color: color-mix(in srgb, var(--brand-ink) 75%, transparent); }
.month-chip.active .bar { background: rgba(255,255,255,.3); }
.month-chip.active .bar i { background: #fff; }
.month-chip.active.now::after { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }

/* ---------- Settlement cards (dashboard / reports) ---------- */
.settle {
  --av: var(--u1); --av-soft: var(--u1-soft);
  position: relative; overflow: hidden; padding: 20px 22px;
}
.settle.s1 { --av: var(--u2); --av-soft: var(--u2-soft); }
.settle::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--av), color-mix(in srgb, var(--av) 40%, transparent));
}
.settle-head { display: flex; align-items: center; gap: 12px; }
.settle-name { font-weight: 750; font-size: 15px; }
.settle-ratio { font-size: 12px; color: var(--muted); }
.settle-amount { margin: 18px 0 4px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.settle-amount .big { font-family: var(--font-display); font-size: 34px; font-weight: 800; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1; }
.settle-verdict { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; }
.settle-verdict.pay { color: var(--bad); background: var(--bad-soft); }
.settle-verdict.get { color: var(--good); background: var(--good-soft); }
.settle-verdict.even { color: var(--muted); background: var(--surface-3); }
.breakdown { list-style: none; padding: 0; margin: 16px 0 0; border-top: 1px dashed var(--border-2); }
.breakdown li { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.breakdown li:last-child { border-bottom: 0; }
.breakdown .lbl { color: var(--text-2); display: flex; flex-direction: column; }
.breakdown .lbl small { color: var(--muted); font-size: 11px; font-style: italic; }
.breakdown .val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown li.total { border-top: 1px solid var(--border-2); border-bottom: 0; margin-top: 2px; padding-top: 10px; }
.breakdown li.total .lbl { color: var(--text); font-weight: 700; }

/* Income split bar */
.split-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--surface-3); }
.split-bar > span { height: 100%; transition: width 1s var(--ease); width: 0; }
.split-bar > span:first-child { background: var(--u1); border-radius: 999px 0 0 999px; }
.split-bar > span:last-child { background: var(--u2); border-radius: 0 999px 999px 0; }
.split-legend { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12.5px; }
.split-legend b { font-variant-numeric: tabular-nums; }

/* Category bars */
.cat-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.cat-bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; font-size: 13px; }
.cat-bars .name { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); font-weight: 550; }
.cat-bars .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bars .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.cat-bars .track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.cat-bars .track i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--s-joint); transition: width 1.1s var(--ease); }

/* Ring gauge */
.ring { --p: 0; --c: var(--brand); position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.ring .track { stroke: var(--surface-3); }
.ring .fill { stroke: var(--c); stroke-dasharray: 100 100; stroke-dashoffset: 100; transition: stroke-dashoffset 1.4s var(--ease); }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .center b { font-family: var(--font-display); font-size: 26px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ring .center small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; margin-top: 3px; }

.progress-x { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-x i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--good), color-mix(in srgb, var(--good) 70%, #fff)); transition: width 1.2s var(--ease); }

.empty {
  text-align: center; padding: 42px 20px; color: var(--muted);
}
.empty .ico { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; font-size: 28px; color: var(--brand); background: var(--brand-soft); animation: float 4s ease-in-out infinite; }
.empty h4 { font-size: 16px; font-weight: 750; margin-bottom: 4px; }
.empty p { margin: 0 auto 16px; max-width: 380px; font-size: 13px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.input-x, .select-x {
  width: 100%; height: 44px; padding: 0 14px;
  font: 500 14px var(--font); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input-x::placeholder { color: var(--muted); }
.input-x:hover, .select-x:hover { border-color: var(--border-2); }
.input-x:focus, .select-x:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-soft); }
.input-wrap { position: relative; }
.input-wrap > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-wrap > .input-x { padding-left: 40px; }
.input-wrap > .peek { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.input-group-x { display: flex; align-items: stretch; }
.input-group-x .input-x { border-radius: 11px 0 0 11px; }
.input-group-x .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: 0; border-radius: 0 11px 11px 0; background: var(--surface-3); color: var(--text-2); font-weight: 600; }

.alert-x { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13px; margin-bottom: 16px; }
.alert-x.bad  { background: var(--bad-soft); color: var(--bad); }
.alert-x.good { background: var(--good-soft); color: var(--good); }
.alert-x ul { margin: 0; padding: 0; list-style: none; }

/* ---------- Dialog ---------- */
.dlg {
  border: 0; padding: 0; width: min(440px, calc(100vw - 32px));
  border-radius: 20px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dlg::backdrop { background: rgba(8, 10, 18, .5); backdrop-filter: blur(3px); }
.dlg[open] { animation: dlg-in .35s var(--ease-spring); }
.dlg[open]::backdrop { animation: fade-in .25s ease; }
.dlg.closing { animation: dlg-out .2s ease forwards; }
.dlg.closing::backdrop { animation: fade-out .2s ease forwards; }
.dlg-body { padding: 24px 24px 8px; }
.dlg-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; margin-bottom: 14px; color: var(--brand); background: var(--brand-soft); }
.dlg-icon.danger { color: var(--bad); background: var(--bad-soft); }
.dlg h3 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.dlg p { color: var(--text-2); font-size: 13.5px; margin: 0 0 12px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 22px; }

/* ---------- Dropdown (Bootstrap menu re-skin) ---------- */
.dropdown-menu {
  --bs-dropdown-bg: var(--surface);
  --bs-dropdown-color: var(--text);
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-link-color: var(--text-2);
  --bs-dropdown-link-hover-bg: var(--surface-3);
  --bs-dropdown-link-hover-color: var(--text);
  --bs-dropdown-link-active-bg: var(--brand-soft);
  --bs-dropdown-link-active-color: var(--brand);
  --bs-dropdown-divider-bg: var(--border);
  --bs-dropdown-header-color: var(--muted);
  padding: 6px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; min-width: 200px;
  animation: pop-in .18s var(--ease);
}
.dropdown-item { border-radius: 8px; padding: 8px 10px; display: flex; align-items: center; gap: 10px; font-weight: 550; }
.dropdown-item i { width: 16px; text-align: center; color: var(--muted); }
.dropdown-item.active i, .dropdown-item:active i { color: inherit; }
.dropdown-item.danger { color: var(--bad); }
.dropdown-item.danger i { color: var(--bad); }
.dropdown-item.danger:hover { background: var(--bad-soft); color: var(--bad); }
.dropdown-header { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 6px 10px 4px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 1100; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast-x {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 380px; padding: 11px 14px 11px 12px;
  background: var(--text); color: var(--bg);
  border-radius: 13px; box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 550;
  animation: toast-in .45s var(--ease-spring);
}
.toast-x .t-ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; background: rgba(255,255,255,.12); }
[data-theme="dark"] .toast-x .t-ico { background: rgba(0,0,0,.08); }
.toast-x.good .t-ico { color: #4cc777; }
.toast-x.bad .t-ico { color: #f07272; }
[data-theme="dark"] .toast-x.good .t-ico { color: #13803b; }
[data-theme="dark"] .toast-x.bad .t-ico { color: #c93434; }
.toast-x.out { animation: toast-out .3s var(--ease) forwards; }

/* Save indicator in the topbar */
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); opacity: 0; transition: opacity .3s; }
.save-state.show { opacity: 1; }
.save-state .spin { width: 12px; height: 12px; border: 2px solid var(--border-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.save-state.done .spin { display: none; }
.save-state .ok { display: none; color: var(--good); }
.save-state.done .ok { display: inline; }

/* =====================================================================
   SHEET — the yearly planner grid
   ===================================================================== */
.sheet-card { overflow: hidden; }
.sheet-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sheet-toolbar .legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-left: auto; }
.sheet-toolbar .legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.legend .sw.unv { background: color-mix(in srgb, var(--warn-mark) 12%, var(--surface)); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--warn-mark) 55%, transparent); }
.legend .sw.unv-now { background: color-mix(in srgb, var(--warn-mark) 32%, var(--surface)); box-shadow: inset 0 -3px 0 var(--warn-mark); }
.legend .sw.now { background: var(--brand-soft-2); }

.sheet-scroll { overflow: auto; max-height: calc(100vh - 168px); position: relative; }
.sheet {
  border-collapse: separate; border-spacing: 0;
  width: 100%; min-width: 1320px;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.sheet th, .sheet td { border-bottom: 1px solid var(--border); padding: 0; height: 44px; vertical-align: middle; background: var(--surface); }
.sheet td + td, .sheet th + th { border-left: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }

/* Sticky header + first column */
.sheet thead th { position: sticky; top: 0; z-index: 6; background: var(--surface-2); height: 58px; border-bottom: 1px solid var(--border-2); }
.sheet .lbl { position: sticky; left: 0; z-index: 4; width: 250px; min-width: 250px; max-width: 250px; border-right: 1px solid var(--border-2); }
/* An open row menu must paint above the sticky label cells of the rows below it */
.sheet td.lbl:has(.dropdown-menu.show) { z-index: 9; }
.sheet thead th.lbl { z-index: 8; text-align: left; padding: 0 16px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sheet-scroll.scrolled-x .lbl { box-shadow: 6px 0 12px -6px rgba(16,19,28,.14); }

/* Month header */
.mh { position: relative; text-align: center; padding: 0 6px; min-width: 104px; transition: background .15s; }
.mh.col-hl { background: color-mix(in srgb, var(--brand) 7%, var(--surface-2)); }
.mh.col-hl .m { color: var(--brand); }
.mh .m { display: block; font-weight: 750; font-size: 13px; color: var(--text); }
.mh .y { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); }
.mh .mh-act { position: absolute; top: 4px; right: 4px; opacity: 0; transition: opacity .2s; }
.mh:hover .mh-act, .mh .mh-act:focus-within { opacity: 1; }
.mh.now { background: color-mix(in srgb, var(--brand) 12%, var(--surface-2)) !important; }
.mh.now .m { color: var(--brand); }
.mh.now::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--brand); }
.now-tag { display: inline-block; margin-top: 2px; font-size: 9.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-ink); background: var(--brand); padding: 1px 6px; border-radius: 99px; }

/* Columns: current month tint, past months recede */
.sheet td.now { background: color-mix(in srgb, var(--brand) 5%, var(--surface)); }
.sheet td.past .ci, .sheet td.past .cv { color: var(--text-2); }

/* Section rows */
.sec td { height: auto; background: var(--surface-2); border-bottom: 1px solid var(--border-2); }
.sec .sec-in { position: sticky; left: 0; display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; width: max-content; max-width: 100vw; }
.sec-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; flex: none; }
.sec-ico.joint { color: var(--s-joint); background: color-mix(in srgb, var(--s-joint) 13%, transparent); }
.sec-ico.income { color: var(--good); background: var(--good-soft); }
.sec-ico.extra { color: var(--s-extra); background: color-mix(in srgb, var(--s-extra) 13%, transparent); }
.sec-ico.settle-ic { color: var(--brand); background: var(--brand-soft); }
.sec-ico.u1 { color: var(--u1); background: var(--u1-soft); }
.sec h4 { font-size: 14px; font-weight: 800; }
.sec .sec-sub { font-size: 12px; color: var(--muted); }
.sec .sec-actions { display: flex; gap: 8px; margin-left: 18px; }

/* Row label cell */
.lbl-in { display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px; min-height: 44px; }
.lbl-in .grip { width: 18px; color: var(--muted); cursor: grab; opacity: 0; transition: opacity .2s; font-size: 14px; display: grid; place-items: center; }
.lbl-in .grip:active { cursor: grabbing; }
tr:hover .lbl-in .grip { opacity: .8; }
.lbl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lbl-name { font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 6px; padding: 1px 5px; margin-left: -5px; outline: none; transition: background .2s, box-shadow .2s; cursor: text; }
.lbl-name:hover { background: var(--surface-3); }
.lbl-name:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--brand); text-overflow: clip; }
.lbl-meta { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.lbl-meta > span:last-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lbl-meta .link-chip { flex: none; }
.lbl-static { padding: 6px 16px; font-weight: 650; display: flex; align-items: center; gap: 10px; min-height: 44px; }
.lbl-static .lbl-meta { font-weight: 500; }
.row-menu { opacity: 0; transition: opacity .2s; }
tr:hover .row-menu, .row-menu.show, .row-menu:focus-visible { opacity: 1; }
.link-chip { display: inline-flex; align-items: center; gap: 4px; border: 0; padding: 1px 7px 1px 2px; border-radius: 99px; font-size: 10.5px; font-weight: 700; cursor: pointer; background: var(--u1-soft); color: var(--u1); }
.link-chip.s1 { background: var(--u2-soft); color: var(--u2); }
.link-chip .avatar.sm { width: 16px; height: 16px; font-size: 9px; box-shadow: none; }

/* Data cell */
.cell { position: relative; height: 100%; display: flex; align-items: center; }
.ci {
  width: 100%; height: 44px; padding: 0 12px 0 14px;
  border: 0; background: transparent; color: var(--text);
  font: 600 13px var(--font); font-variant-numeric: tabular-nums; text-align: right;
  border-radius: 0; outline: none;
  transition: background .15s, box-shadow .15s;
  -moz-appearance: textfield;
}
.ci::-webkit-outer-spin-button, .ci::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ci::placeholder { color: color-mix(in srgb, var(--muted) 50%, transparent); }
.ci:hover { background: var(--surface-3); }
.ci:focus { background: var(--surface); box-shadow: inset 0 0 0 2px var(--brand); position: relative; z-index: 2; }
.ci.u1 { color: var(--u1); }
.ci.u2 { color: var(--u2); }
.ci.income { color: var(--good); font-weight: 700; }
.ci.extra { color: var(--s-extra); font-weight: 700; }
.cv { display: block; padding: 0 12px; text-align: right; font-weight: 650; }

.sheet tbody tr:not(.sec):not(.tot):hover td { background: color-mix(in srgb, var(--brand) 3%, var(--surface)); }
.sheet tbody tr:not(.sec):not(.tot):hover td.now { background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }

/* Unverified + verify toggle */
.sheet td.unv { background: color-mix(in srgb, var(--warn-mark) 9%, var(--surface)) !important; box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--warn-mark) 55%, transparent); }
.sheet td.now.unv { background: color-mix(in srgb, var(--warn-mark) 30%, var(--surface)) !important; box-shadow: inset 0 -3px 0 var(--warn-mark); }
.sheet td.now.unv .ci { color: var(--text); font-weight: 750; }
.sheet tbody tr:not(.sec):not(.tot):hover td.unv { background: color-mix(in srgb, var(--warn-mark) 16%, var(--surface)) !important; }
.sheet tbody tr:not(.sec):not(.tot):hover td.now.unv { background: color-mix(in srgb, var(--warn-mark) 38%, var(--surface)) !important; }
.vchk {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%) scale(.6); z-index: 3;
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-2);
  display: grid; place-items: center; padding: 0; cursor: pointer;
  background: var(--surface); color: transparent; font-size: 12px;
  opacity: 0; transition: opacity .2s, transform .25s var(--ease-spring), background .2s, border-color .2s, color .2s;
}
td:hover .vchk, .vchk:focus-visible { opacity: 1; transform: translateY(-50%) scale(1); }
td.unv .vchk { border-color: var(--warn-mark); }
.vchk.on { background: var(--good); border-color: var(--good); color: #fff; }
td:hover .vchk.on { transform: translateY(-50%) scale(1); }
.vchk.on.pop { animation: check-pop .45s var(--ease-spring); }
td.has-chk .ci { padding-left: 28px; }

/* Split cell: total input + per-person shares underneath */
.split-shares { position: absolute; left: 0; right: 12px; bottom: 3px; display: flex; justify-content: flex-end; gap: 6px; font-size: 10px; font-weight: 700; pointer-events: none; }
.split-cell .ci { padding-bottom: 12px; }

/* Secondary info lines inside income / extra cells */
.sub-line { position: absolute; left: 6px; right: 12px; bottom: 3px; display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); font-weight: 600; pointer-events: none; }
.rich .ci { padding-bottom: 13px; }
.rich { min-height: 52px; }
.sheet tr.tall td { height: 54px; }
.cell .cp-btn { position: absolute; left: 4px; top: 4px; z-index: 3; opacity: 0; transition: opacity .2s; }
td:hover .cell .cp-btn { opacity: 1; }

/* Absorption stepper */
.stepper { display: flex; align-items: center; justify-content: center; gap: 2px; padding: 0 6px; }
.stepper button { width: 22px; height: 22px; border: 0; border-radius: 6px; background: var(--surface-3); color: var(--text-2); cursor: pointer; font-weight: 800; line-height: 1; display: grid; place-items: center; transition: background .15s, transform .1s; }
.stepper button:hover { background: var(--brand-soft-2); color: var(--brand); }
.stepper button:active { transform: scale(.88); }
.stepper .ci { width: 52px; height: 30px; padding: 0 2px; text-align: center; border-radius: 6px; color: var(--s-extra); font-weight: 800; }
.stepper .pct { font-size: 11px; color: var(--muted); font-weight: 700; margin-left: -4px; margin-right: 2px; }

/* Totals */
.tot td { background: var(--surface-2); font-weight: 800; }
.tot .cv { font-weight: 800; }
.tot.grand td { background: color-mix(in srgb, var(--brand) 7%, var(--surface-2)); border-top: 1px solid var(--border-2); }
.tot.grand .cv { color: var(--brand); font-size: 14px; }
.tot td.now { background: color-mix(in srgb, var(--brand) 11%, var(--surface-2)); }

/* Load (burden) chips */
.load-chip { display: inline-flex; white-space: nowrap; box-shadow: 0 0 0 3px var(--surface), var(--shadow-sm); align-items: center; justify-content: center; min-width: 46px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.load-chip.ok   { color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.load-chip.mid  { color: var(--warn); background: color-mix(in srgb, var(--warn-mark) 20%, var(--surface)); }
.load-chip.high { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
/* Expense-load badge that straddles the line between the two income rows */
.load-over { position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 50%); z-index: 3; pointer-events: auto; cursor: help; }
.lbl .load-over { left: auto; right: 12px; transform: translateY(50%); }
.sheet td.lbl.lbl-over { z-index: 5; }
.sheet tr.load-row td { height: 62px; }
.load-row .rich .ci { padding-bottom: 24px; }
.load-row .sub-line { bottom: 13px; }
.load-row .lbl-static { padding-bottom: 14px; }
.cell-center { display: flex; justify-content: center; align-items: center; height: 100%; }

/* Pend to pay chips */
.pend { display: flex; flex-direction: column; align-items: flex-end; padding: 0 10px; line-height: 1.15; }
.pend b { font-size: 14px; font-weight: 800; }
.pend small { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.pend.pay b, .pend.pay small { color: var(--bad); }
.pend.get b, .pend.get small { color: var(--good); }

/* Hidden rows */
tr.row-hidden td { height: 10px; }
tr.row-hidden td > * { display: none !important; }
tr.row-hidden td.lbl > .lbl-in { display: flex !important; min-height: 10px; padding: 0 10px; }
tr.row-hidden .lbl-in > *:not(.lbl-main):not(.row-menu) { display: none; }
tr.row-hidden .lbl-name { font-size: 10px; font-weight: 500; font-style: italic; color: var(--muted); line-height: 10px; padding: 0 5px; }
tr.row-hidden .lbl-meta { display: none; }
tr.row-hidden .row-menu { top: -9px; }
.sheet.hide-hidden tr.row-hidden { display: none; }
.sheet tr.row-hidden td { background: repeating-linear-gradient(-45deg, var(--surface), var(--surface) 4px, var(--surface-2) 4px, var(--surface-2) 8px); }

/* Drag & drop */
tr.dragging td { opacity: .4; }
tr.drop-before td { box-shadow: inset 0 3px 0 var(--brand); }
tr.drop-after td { box-shadow: inset 0 -3px 0 var(--brand); }

.add-row td { background: var(--surface); }
.add-row-btn {
  position: sticky; left: 0;
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0; height: 40px; padding: 0 16px;
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font: 600 13px var(--font);
  transition: color .2s;
}
.add-row-btn:hover { color: var(--brand); }
.add-row-btn i { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; border: 1.5px dashed currentColor; transition: transform .3s var(--ease-spring); }
.add-row-btn:hover i { transform: rotate(90deg); }

/* Feedback animations on cells */
.ci.saved { animation: saved-flash 1s var(--ease); }
.ci.error { animation: shake .4s; box-shadow: inset 0 0 0 2px var(--bad); }
.bump { animation: bump .7s var(--ease); }
.sheet-host.refreshing .sheet { transition: opacity .2s; }

/* ---------- Personal page ---------- */
.person-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }

/* ---------- Reports ---------- */
.chart-box { position: relative; height: 260px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); font-weight: 600; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.table-x { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table-x th { text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border-2); background: var(--surface-2); position: sticky; top: 0; }
.table-x td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-x th { white-space: nowrap; }
.table-x th:first-child, .table-x td:first-child { text-align: left; }
.table-x tbody tr { transition: background .15s; }
.table-x tbody tr:hover { background: var(--surface-2); }
.table-x tr.now td { background: var(--brand-soft); }
.table-x tfoot td { font-weight: 800; border-top: 1px solid var(--border-2); border-bottom: 0; background: var(--surface-2); }

/* Shareable settlement card — always rendered light so the image reads well in chat apps */
.share-card {
  color-scheme: light;
  --text: #10131c; --text-2: #4a5263; --muted: #8a92a5; --border: #e5e7ef; --border-2: #d6d9e4; --surface: #fff; --surface-3: #eef0f6;
  --u1: #2a78d6; --u2: #eb6834; --good: #13803b; --bad: #c93434; --good-soft: rgba(12,163,12,.10); --bad-soft: rgba(208,59,59,.09);
  width: 100%; max-width: 420px; margin: 0 auto; color: var(--text);
  background: #fff; border-radius: 18px; overflow: hidden; border: 1px solid #e5e7ef;
}
.share-head { padding: 18px 20px 16px; color: #fff; background: linear-gradient(135deg, #7b6cf6 0%, #5a46d0 55%, #2a78d6 100%); }
.share-head .t { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.share-head .s { font-size: 12px; opacity: .85; }
.share-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.share-person { border: 1px solid #e5e7ef; border-radius: 14px; padding: 12px 14px; background: #fafbfd; }
.share-person .hd { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.share-person .hd .avatar { box-shadow: none; }
.share-person .nm { font-weight: 750; font-size: 14px; }
.share-person .bd { font-size: 12px; }
.share-person .bd > div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; color: #4a5263; }
.share-person .bd > div b { color: #10131c; font-variant-numeric: tabular-nums; }
.share-person .bd .items { font-size: 10.5px; font-style: italic; color: #8a92a5; padding: 0 0 2px 8px; display: block; }
.share-person .res { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; padding-top: 8px; border-top: 1px solid #e5e7ef; font-weight: 700; font-size: 13px; }
.share-person .res b { font-size: 17px; font-family: var(--font-display); }
.share-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: #8a92a5; padding: 10px 4px 0; border-top: 1px dashed #d6d9e4; }
.share-foot b { color: #10131c; }

/* ---------- Auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; background: var(--bg); }
.auth-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.auth-bg .blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; animation: blob 22s ease-in-out infinite; }
.auth-bg .b1 { width: 520px; height: 520px; background: #7b6cf6; top: -160px; left: -120px; }
.auth-bg .b2 { width: 460px; height: 460px; background: #2a78d6; bottom: -160px; right: -100px; animation-delay: -7s; }
.auth-bg .b3 { width: 360px; height: 360px; background: #eb6834; top: 40%; left: 55%; opacity: .3; animation-delay: -14s; }
[data-theme="dark"] .auth-bg .blob { opacity: .32; }
.auth-bg .grid-lines { position: absolute; inset: 0; background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 48px 48px; mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%); opacity: .5; }
.auth-card {
  position: relative; z-index: 1; width: min(420px, 100%);
  padding: 36px 34px 30px; border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  box-shadow: var(--shadow-lg);
  animation: rise .7s var(--ease) both;
}
.auth-card .brand-mark { width: 56px; height: 56px; border-radius: 17px; font-size: 26px; margin: 0 auto 18px; animation: float 5s ease-in-out infinite; }
.auth-card h1 { text-align: center; font-size: 24px; font-weight: 800; }
.auth-card .lead-x { text-align: center; color: var(--muted); font-size: 13.5px; margin: 6px 0 26px; }
.auth-card.shake { animation: rise .7s var(--ease) both, shake .5s .1s; }
.auth-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }
.auth-theme { position: fixed; top: 18px; right: 18px; z-index: 2; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(16px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes dlg-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 3px var(--brand-soft); } 50% { box-shadow: 0 0 0 6px transparent; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes blob { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(60px, -40px) scale(1.1); } 66% { transform: translate(-40px, 50px) scale(.93); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes saved-flash { 0% { background: var(--good-soft); box-shadow: inset 0 0 0 2px var(--good); } 100% { background: transparent; box-shadow: inset 0 0 0 0 transparent; } }
@keyframes bump { 0% { background: var(--brand-soft-2); } 100% { background: transparent; } }
@keyframes check-pop { 0% { transform: translateY(-50%) scale(.5); } 60% { transform: translateY(-50%) scale(1.25); } 100% { transform: translateY(-50%) scale(1); } }

.reveal { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.fade-panel { animation: rise .45s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-dash { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 992px) {
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .page { padding: 8px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page-sub { display: none; }
  .page-title { font-size: 18px; }
  .fy-switch .fy-label small, .fy-switch .fy-now { display: none; }
  .save-state { display: none; }
  .kpi-value { font-size: 22px; }
  .settle-amount .big { font-size: 28px; }
  .sheet .lbl { width: 170px; min-width: 170px; max-width: 170px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast-x { max-width: none; }
  .sheet-toolbar .legend { display: none; }
  .grid-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 14px; }
  .kpi::after { display: none; }
}

@media print {
  .sidebar, .topbar, .sheet-toolbar, .toasts, .row-menu, .vchk, .add-row { display: none !important; }
  .main { margin: 0; }
  .sheet-scroll { max-height: none; overflow: visible; }
}

/* ---------- Minimal Bootstrap pieces (only reboot CSS is loaded) ---------- */
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.dropdown, .dropup { position: relative; }
.dropdown-menu { position: absolute; z-index: 1000; display: none; margin: 0; list-style: none; text-align: left; background: var(--bs-dropdown-bg); color: var(--bs-dropdown-color); border: 1px solid var(--bs-dropdown-border-color); background-clip: padding-box; }
.dropdown-menu.show { display: block; }
.dropdown-item { width: 100%; clear: both; color: var(--bs-dropdown-link-color); text-align: inherit; white-space: nowrap; background: transparent; border: 0; text-decoration: none; cursor: pointer; font: inherit; font-weight: 550; }
.dropdown-item:hover, .dropdown-item:focus { color: var(--bs-dropdown-link-hover-color); background: var(--bs-dropdown-link-hover-bg); }
.dropdown-item.active, .dropdown-item:active { color: var(--bs-dropdown-link-active-color); background: var(--bs-dropdown-link-active-bg); }
.dropdown-divider { height: 0; margin: 6px 4px; border: 0; border-top: 1px solid var(--bs-dropdown-divider-bg); opacity: 1; }
.dropdown-header { display: block; margin: 0; white-space: nowrap; color: var(--bs-dropdown-header-color); }

/* html2canvas can't parse color-mix(), so the share card uses plain colours only */
.share-card .avatar { background: #2a78d6; box-shadow: none; }
.share-card .avatar.s1 { background: #eb6834; }

/* Chart cards that sit beside a taller card grow their plot to fill the space */
.flex-card { display: flex; flex-direction: column; }
.flex-card > .card-body-x { flex: 1; display: flex; flex-direction: column; }
.flex-card .chart-box { flex: 1; height: auto; min-height: 260px; }

/* =====================================================================
   v2 — collapsible sidebar, command palette, context menu, hero, glow
   ===================================================================== */

/* ---------- Collapsible sidebar (desktop rail) ---------- */
.sidebar { transition: transform .35s var(--ease), width .35s var(--ease), padding .35s var(--ease); overflow-x: hidden; }
.main { transition: margin-left .35s var(--ease); }
html.no-anim .sidebar, html.no-anim .main { transition: none; }
.nav-text, .brand-text { white-space: nowrap; transition: opacity .2s; }
@media (min-width: 993px) {
  html.sb-collapsed { --sidebar-w: 78px; }
  html.sb-collapsed .sidebar { padding: 18px 12px; }
  html.sb-collapsed .nav-text, html.sb-collapsed .brand-text { opacity: 0; pointer-events: none; width: 0; overflow: hidden; }
  html.sb-collapsed .nav-label { height: 1px; padding: 0; margin: 12px 8px; background: var(--border); overflow: hidden; color: transparent; }
  html.sb-collapsed .nav-item { justify-content: center; padding: 11px 0; gap: 0; }
  html.sb-collapsed .brand { justify-content: center; padding: 4px 0 22px; gap: 0; }
  html.sb-collapsed .nav-item.active::before { left: -12px; }
  html.sb-collapsed .menu-btn i { transform: scaleX(-1); }
}
.menu-btn i { transition: transform .35s var(--ease); }

/* ---------- Command palette ---------- */
.cmd-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 8px 0 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: 500 13px var(--font); cursor: pointer; box-shadow: var(--shadow-xs); transition: border-color .2s, color .2s;
}
.cmd-btn:hover { border-color: var(--border-2); color: var(--text-2); }
.kbd { display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); font: 600 11px var(--font); color: var(--muted); }
.cmd {
  border: 0; padding: 0; margin: 12vh auto auto; width: min(620px, calc(100vw - 24px));
  border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden;
}
.cmd::backdrop { background: rgba(8, 10, 18, .45); backdrop-filter: blur(4px); }
.cmd[open] { animation: dlg-in .3s var(--ease-spring); }
.cmd-search { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.cmd-search i { color: var(--muted); font-size: 17px; }
.cmd-search input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font: 500 16px var(--font); }
.cmd-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 8px; margin: 0; list-style: none; }
.cmd-group { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 4px; }
.cmd-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; cursor: pointer; color: var(--text-2); font-weight: 550; }
.cmd-item i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--text-2); flex: none; transition: background .15s, color .15s; }
.cmd-item small { margin-left: auto; color: var(--muted); font-weight: 500; }
.cmd-item.sel { background: var(--brand-soft); color: var(--text); }
.cmd-item.sel i { background: var(--brand); color: var(--brand-ink); }
.cmd-empty { padding: 28px; text-align: center; color: var(--muted); }
.cmd-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); background: var(--surface-2); }

/* ---------- Cell context menu ---------- */
.ctx-menu {
  position: fixed; z-index: 1200; min-width: 240px; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: pop-in .14s var(--ease); font-size: 13px;
}
.ctx-menu .ctx-title { padding: 6px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ctx-menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font: 550 13px var(--font); cursor: pointer; text-align: left; }
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: var(--surface-3); color: var(--text); outline: none; }
.ctx-menu button i { width: 16px; color: var(--muted); }
.ctx-menu button kbd { margin-left: auto; font: 600 10.5px var(--font); color: var(--muted); background: none; padding: 0; }
.ctx-menu button.danger { color: var(--bad); }
.ctx-menu button.danger i { color: var(--bad); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 4px; opacity: 1; }

/* ---------- Sparklines in row labels ---------- */
.spark { flex: none; width: 52px; height: 22px; opacity: .8; transition: opacity .2s; overflow: visible; }
.spark polyline { fill: none; stroke: var(--s-joint); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spark .area { fill: color-mix(in srgb, var(--s-joint) 14%, transparent); stroke: none; }
.spark circle { fill: var(--brand); stroke: var(--surface); stroke-width: 1.5; }
tr:hover .spark { opacity: 1; }
tr.row-hidden .spark { display: none; }
tr.row-filtered { display: none; }

/* Toolbar search */
.sheet-search { position: relative; }
.sheet-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.sheet-search input { height: 32px; width: 180px; padding: 0 10px 0 30px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: 500 12.5px var(--font); transition: width .3s var(--ease), border-color .2s, box-shadow .2s; }
.sheet-search input:focus { outline: none; width: 230px; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }

/* ---------- Cursor glow on interactive cards ---------- */
.hover-lift { --mx: 50%; --my: 50%; }
.hover-lift:hover { background-image: radial-gradient(420px circle at var(--mx) var(--my), color-mix(in srgb, var(--brand) 9%, transparent), transparent 45%); }

/* ---------- Dashboard hero ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: 24px; padding: 28px 30px; margin: 16px 0 6px; color: #fff;
  background: linear-gradient(120deg, #4b36c9, #6d5cf2 35%, #2a78d6 70%, #4b36c9);
  background-size: 260% 260%;
  animation: hero-pan 16s ease-in-out infinite;
  box-shadow: 0 20px 50px -18px rgba(75, 54, 201, .55);
}
[data-theme="dark"] .hero { background: linear-gradient(120deg, #2c2177, #4b3bb8 35%, #1d4f93 70%, #2c2177); background-size: 260% 260%; box-shadow: 0 20px 50px -18px rgba(0, 0, 0, .7); }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; filter: blur(40px); z-index: -1; animation: blob 18s ease-in-out infinite; }
.hero::before { width: 320px; height: 320px; right: -60px; top: -120px; background: rgba(235, 104, 52, .5); }
.hero::after { width: 260px; height: 260px; left: 30%; bottom: -160px; background: rgba(27, 175, 122, .45); animation-delay: -9s; }
.hero-grid { position: absolute; inset: 0; z-index: -1; opacity: .16; background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px); background-size: 34px 34px; mask-image: linear-gradient(90deg, transparent, #000 60%); -webkit-mask-image: linear-gradient(90deg, transparent, #000 60%); }
.hero-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: rgba(255,255,255,.16); }
.hero-badge .live { width: 7px; height: 7px; border-radius: 50%; background: #7cf0b4; animation: live 1.8s infinite; }
.hero h2 { color: #fff; font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 10px 0 4px; }
.hero-sub { opacity: .88; font-size: 14px; max-width: 620px; }
.hero-flows { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 22px; }
.flow {
  flex: 1; min-width: 230px; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 16px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .3s var(--ease), background .3s;
}
.flow:hover { transform: translateY(-3px); background: rgba(255,255,255,.18); }
.flow .avatar { box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.flow .who { font-size: 12.5px; opacity: .88; }
.flow .amt { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.flow .dir { margin-left: auto; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: rgba(255,255,255,.16); }
.flow .dir.pay { color: #ffd2c2; }
.flow .dir.get { color: #b9f5d4; }
.hero-total { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 18px; font-size: 13px; }
.hero-total > span { opacity: .92; }
.hero-total b { font-variant-numeric: tabular-nums; }
.hero-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn-x.glass { --b-bg: rgba(255,255,255,.14); --b-fg: #fff; --b-bd: rgba(255,255,255,.24); box-shadow: none; }
.btn-x.glass:hover { background: rgba(255,255,255,.24); color: #fff; border-color: rgba(255,255,255,.4); }
.btn-x.white { --b-bg: #fff; --b-fg: #3b2bb3; --b-bd: transparent; }
.btn-x.white:hover { background: #f1efff; color: #3b2bb3; }
@keyframes hero-pan { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(124,240,180,.7); } 70% { box-shadow: 0 0 0 8px rgba(124,240,180,0); } 100% { box-shadow: 0 0 0 0 rgba(124,240,180,0); } }

/* Confetti canvas */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1300; }

@media (max-width: 640px) {
  .cmd-btn .lbl-txt, .cmd-btn .kbd { display: none; }
  .cmd-btn { width: 38px; justify-content: center; padding: 0; }
  .hero { padding: 22px 18px; border-radius: 20px; }
  .hero h2 { font-size: 24px; }
  .hero-actions { margin-left: 0; }
  .sheet-search input, .sheet-search input:focus { width: 140px; }
}

/* Load row: anchor overlays to the table cell so the badge sits exactly on the row border */
.sheet tr.load-row td:not(.lbl) { position: relative; }
.sheet tr.load-row .cell { position: static; }

/* ---------- Row labels: overlay grip + menu so the name, chips and amounts get the full width ---------- */
.lbl-in { position: relative; padding: 6px 10px 6px 18px; gap: 8px; }
.lbl-in .grip { position: absolute; left: 1px; top: 50%; margin-top: -10px; height: 20px; width: 16px; }
.lbl-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.lbl-top .lbl-name { flex: 0 1 auto; min-width: 0; }
.lbl-chips { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.lbl-chips .avatar.sm { width: 18px; height: 18px; font-size: 9.5px; box-shadow: none; }
.lbl-chips .link-chip { padding: 1px 6px 1px 1px; font-size: 10px; gap: 3px; font-family: var(--font); }
.lbl-meta .amt, .lbl-meta > span:last-child { overflow: visible; text-overflow: clip; }
/* The menu floats over the sparkline on hover instead of reserving its own column (no transforms: the dropdown uses fixed positioning) */
.lbl-in .row-menu { position: absolute; right: 6px; top: 50%; margin-top: -14px; z-index: 2; }
.lbl-in .row-menu > .icon-btn { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.lbl-in .row-menu > .icon-btn:hover { background: var(--surface-3); }

/* Split rows: one compact chip — overlapping initials + both percentages */
.split-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px 1px 1px; border: 0; border-radius: 99px; background: var(--surface-3); cursor: pointer; font: 700 10px var(--font); color: var(--muted); transition: background .2s; }
.split-chip:hover { background: var(--brand-soft-2); }
.split-chip .avatar.sm { box-shadow: 0 0 0 1.5px var(--surface-3); }
.split-chip .avatar.sm + .avatar.sm { margin-left: -7px; }
.split-chip .pct { font-variant-numeric: tabular-nums; }

/* ---------- Row labels v3: the name owns line 1; chips + amounts + sparkline share line 2 ---------- */
.lbl-in {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name name" "meta spark";
  align-items: center;
  column-gap: 8px; row-gap: 1px;
}
.lbl-in > .lbl-main { display: contents; }
.lbl-in .lbl-top, .lbl-in > .lbl-main > .lbl-name { grid-area: name; min-width: 0; }
.lbl-in .lbl-meta { grid-area: meta; min-width: 0; gap: 5px; }
.lbl-in > .spark { grid-area: spark; }
.lbl-top { display: block; }
/* Long names wrap onto a second line rather than being cut off */
.lbl-in .lbl-name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  white-space: normal; overflow-wrap: anywhere; overflow: hidden; line-height: 1.3; max-width: 100%;
}
.lbl-in .lbl-name:focus { -webkit-line-clamp: unset; line-clamp: none; }
.lbl-meta .avatar.sm { width: 17px; height: 17px; font-size: 9px; box-shadow: none; flex: none; }
.split-chip { padding: 1px; gap: 0; background: transparent; }
.split-chip .avatar.sm { box-shadow: 0 0 0 1.5px var(--surface); }
.split-chip:hover { background: var(--brand-soft-2); }
/* Menu floats over the sparkline (line 2), never over the name */
.lbl-in .row-menu { top: auto; bottom: 4px; margin-top: 0; }
tr.row-hidden .lbl-in { display: flex !important; }
tr.row-hidden .row-menu { top: -9px; bottom: auto; }
.split-chip .avatar.sm + .avatar.sm { margin-left: -4px; }

/* ---------- Calculators ---------- */
.calc-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px; align-items: start; }
.calc-nav { position: sticky; top: calc(var(--topbar-h) + 12px); padding: 8px; max-height: calc(100vh - var(--topbar-h) - 28px); overflow-y: auto; }
.calc-nav-label { font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 8px 10px 4px; }
.calc-nav-label:first-child { padding-top: 4px; }
.calc-link { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 12.5px; transition: background .15s, color .15s; white-space: nowrap; }
.calc-link i { font-size: 15px; color: var(--muted); transition: color .15s; }
.calc-link:hover { background: var(--surface-3); color: var(--text); }
.calc-link.active { background: var(--brand-soft); color: var(--brand); }
.calc-link.active i { color: var(--brand); }

.calc-stage { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.calc-head.card-head { padding: 12px 16px 0; }
.calc-head .kpi-icon { width: 34px; height: 34px; font-size: 16px; }
.calc-head { align-items: flex-start; }
.calc-head .sub { margin-top: 2px; }
.calc-ico { margin: 0; flex: none; }
.kpi-icon.bad { color: var(--bad); background: var(--bad-soft); }
.calc-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; padding: 16px 20px 20px; }
.calc-results { padding-left: 24px; border-left: 1px solid var(--border); }
.calc-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 22px; align-content: start; }
.calc-inputs .calc-group, .calc-inputs .calc-field.wide { grid-column: 1 / -1; }

.calc-field { margin-bottom: 14px; min-width: 0; }
.calc-field > label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calc-ctl { display: flex; flex-direction: column; gap: 9px; }
.calc-ctl .range-x { width: 100%; }
.calc-pair { display: flex; align-items: stretch; height: 34px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.calc-pair:hover { border-color: var(--border-2); }
.calc-pair:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--surface); }
.calc-pair .calc-num:hover, .calc-pair .calc-num:focus-within { box-shadow: none; background: transparent; }
.calc-pair .calc-num { height: auto; min-width: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.calc-pair .calc-num:first-child { flex: 0 0 auto; width: auto; box-sizing: border-box; padding: 0 8px; gap: 2px; border-right: 1px solid var(--border); }
.calc-pair .calc-num:first-child:hover, .calc-pair .calc-num:first-child:focus-within { border-right-color: var(--border); }
.calc-pair .calc-num:first-child input { width: 2.5ch; flex: none; }
.calc-pair .calc-num:last-child { flex: 1 1 0; min-width: 0; box-sizing: border-box; }
.calc-num { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 10px; flex: none; width: 100%; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-weight: 600; transition: border-color .2s, box-shadow .2s; }
.calc-num:hover { border-color: var(--border-2); }
.calc-num:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--surface); }
.calc-num input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; text-align: right; font: 700 14px var(--font); color: var(--text); font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.calc-num input::-webkit-outer-spin-button, .calc-num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc-hint { font-size: 11px; color: var(--muted); margin-top: 6px; min-height: 0; line-height: 1.35; }
.calc-hint:empty { display: none; }
.calc-check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.calc-check input { width: 16px; height: 16px; accent-color: var(--brand); }
.calc-num.date { width: 100%; }
.calc-num input[type=date] { text-align: left; min-width: 0; }
.calc-group { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: var(--brand); padding: 6px 0 12px; margin-top: 6px; }
.calc-group::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.calc-inputs > .calc-group:first-child { margin-top: 0; }
.calc-field.wide > label { margin-bottom: 6px; }
.calc-seg { display: flex; flex-wrap: wrap; }
.calc-seg button { height: 30px; padding: 0 12px; font-size: 12px; white-space: nowrap; }

.range-x { --fill: 0%; -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; margin: 0; border-radius: 99px; background: linear-gradient(90deg, var(--brand) var(--fill), var(--surface-3) var(--fill)); cursor: pointer; }
.range-x:focus { outline: none; }
.calc-ctl .range-x { height: 4px; }
.range-x::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); box-shadow: var(--shadow-sm); transform: scale(0); transition: transform .15s var(--ease-spring); }
.calc-field:hover .range-x::-webkit-slider-thumb, .range-x:hover::-webkit-slider-thumb, .range-x:focus-visible::-webkit-slider-thumb, .range-x:active::-webkit-slider-thumb { transform: scale(1); }
.range-x::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); box-shadow: var(--shadow-sm); transform: scale(0); transition: transform .15s var(--ease-spring); }
.calc-field:hover .range-x::-moz-range-thumb, .range-x:hover::-moz-range-thumb, .range-x:focus-visible::-moz-range-thumb, .range-x:active::-moz-range-thumb { transform: scale(1); }

.calc-results { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.calc-hero { position: relative; overflow: hidden; padding: 12px 16px; border-radius: var(--radius); color: #fff; background: linear-gradient(125deg, #5141c4, #6250d6 45%, #2a78d6); box-shadow: 0 14px 34px -16px rgba(98, 80, 214, .7); }
[data-theme="dark"] .calc-hero { background: linear-gradient(125deg, #2c2177, #4b3bb8 50%, #1d4f93); box-shadow: none; }
.calc-hero::after { content: ''; position: absolute; right: -50px; top: -60px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 70%); pointer-events: none; }
.calc-hero .lbl { font-size: 12px; font-weight: 650; opacity: .85; }
.calc-hero .val { font-family: var(--font-display); font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-top: 0; font-variant-numeric: tabular-nums; }
.calc-hero .val .cur { font-size: .6em; opacity: .75; margin-right: 3px; vertical-align: 4px; }
.calc-hero .sub { font-size: 11.5px; opacity: .85; margin-top: 2px; }
.calc-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 6px; }
.calc-stat { padding: 6px 9px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.calc-stat .lbl { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); line-height: 1.25; }
.calc-stat b { display: block; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 1px; line-height: 1.25; overflow-wrap: anywhere; }
.calc-stat small { display: block; font-size: 10px; line-height: 1.3; color: var(--muted); margin-top: 1px; overflow-wrap: anywhere; }
.calc-split-bar { display: flex; height: 9px; gap: 2px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.calc-split-bar span { height: 100%; transition: width .5s var(--ease); }
.calc-split-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.calc-split-legend span { display: inline-flex; align-items: center; gap: 6px; }
.calc-split-legend i { width: 10px; height: 10px; border-radius: 3px; }
.calc-notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.calc-notes li { display: flex; gap: 6px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.calc-notes i { color: var(--brand); margin-top: 1px; }

.calc-extra { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.calc-extra.single { grid-template-columns: minmax(0, 1fr); }
.calc-extra [hidden], .calc-extra[hidden] { display: none; }
.calc-extra .chart-box { height: 230px; }
.calc-extra .card-head { padding: 12px 16px 0; }
.calc-extra .card-body-x { padding: 8px 16px 12px; }
.calc-table-wrap { max-height: 320px; overflow: auto; padding-top: 4px; }
.calc-table-wrap .table-x th, .calc-table-wrap .table-x td { padding-top: 4px; padding-bottom: 4px; font-size: 12px; }

@media (max-width: 1200px) {
  .calc-layout { grid-template-columns: minmax(0, 1fr); }
  .calc-nav { position: static; max-height: none; display: flex; gap: 4px; overflow-x: auto; padding: 8px; scrollbar-width: thin; }
  .calc-nav-label { display: none; }
  .calc-link { flex: none; }
  .calc-extra { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .calc-body { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; }
  .calc-results { margin-top: 8px; padding-left: 0; border-left: 0; }
  .calc-hero .val { font-size: 24px; }
}
.calc-tables { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.calc-seg.tabs { display: flex; width: 100%; }
.calc-seg.tabs button { flex: 1; justify-content: center; height: 38px; font-size: 13.5px; }
.calc-field[hidden], .calc-group[hidden] { display: none; }
.calc-field.is-disabled { opacity: .6; }
.calc-field.is-disabled .range-x { pointer-events: none; }
.table-x td.sub-row, .table-x tr.sub-row td { color: var(--muted); font-size: 12.5px; }

/* =====================================================================
   Compact density — matches the calculators page across the app
   ===================================================================== */
:root { --sidebar-w: 224px; --topbar-h: 56px; --radius-lg: 14px; }
.sidebar { padding: 14px 12px; }
.sidebar .brand { padding: 2px 8px 14px; }
.brand-mark { width: 32px; height: 32px; font-size: 16px; border-radius: 10px; }
.nav-label { padding: 10px 10px 4px; }
.nav-item { padding: 7px 10px; margin: 1px 0; font-size: 13.5px; gap: 10px; }
.nav-item i { font-size: 16px; }
.nav-item.active::before { left: -12px; top: 7px; bottom: 7px; }
.topbar { padding: 0 20px; gap: 10px; }
.page-title { font-size: 18px; }
.page-sub { font-size: 12px; }
.page { padding: 6px 20px 32px; }
.fy-switch a { width: 26px; height: 26px; }
.fy-switch .fy-label { padding: 0 8px; font-size: 12.5px; }

.btn-x { height: 34px; padding: 0 13px; font-size: 13px; gap: 6px; }
.btn-x.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-x.lg { height: 40px; font-size: 14px; }
.icon-btn { width: 34px; height: 34px; }
.icon-btn.sm { width: 26px; height: 26px; }
.segmented { padding: 3px; }
.segmented button, .segmented a { height: 30px; padding: 0 12px; font-size: 12.5px; }
.segmented .seg-thumb { top: 3px; bottom: 3px; }

.card-x.pad { padding: 14px 16px; }
.card-head { padding: 12px 16px 0; gap: 10px; }
.card-head h3 { font-size: 14px; }
.card-body-x { padding: 10px 16px 14px; }
.section-title { margin: 20px 0 10px; }
.section-title h2 { font-size: 15.5px; }
.grid-auto, .grid-2, .grid-3, .grid-dash { gap: 12px; }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.person-tiles { gap: 10px; margin-bottom: 12px; }

.kpi { padding: 12px 14px; }
.kpi-icon { width: 32px; height: 32px; font-size: 15px; border-radius: 10px; margin-bottom: 8px; }
.kpi-label { font-size: 12px; }
.kpi-value { font-size: 22px; }
.kpi-foot { margin-top: 4px; font-size: 11.5px; }
.pill { padding: 2px 8px; font-size: 11px; }
.delta { padding: 1px 6px; font-size: 11px; }

.month-strip { gap: 5px; padding: 4px 6px; grid-template-columns: repeat(12, minmax(56px, 1fr)); }
.month-chip { padding: 7px 4px 6px; border-radius: 10px; }
.month-chip .m { font-size: 13px; }
.month-chip .bar { margin-top: 3px; }

.settle { padding: 14px 16px; }
.settle-amount { margin: 12px 0 2px; }
.settle-amount .big { font-size: 28px; }
.breakdown { margin-top: 10px; }
.breakdown li { padding: 6px 0; font-size: 12.5px; }
.cat-bars { gap: 9px; }
.cat-bars .track { height: 6px; }
.ring { width: 108px; height: 108px; }
.ring circle { stroke-width: 10; }
.ring .center b { font-size: 22px; }
.empty { padding: 28px 16px; }

.hero { padding: 18px 20px; border-radius: 18px; margin: 10px 0 4px; }
.hero h2 { font-size: 26px; margin: 6px 0 2px; }
.hero-sub { font-size: 13px; }
.hero-flows { margin-top: 14px; gap: 10px; }
.flow { padding: 10px 12px; min-width: 210px; }
.flow .amt { font-size: 22px; }
.flow .dir { width: 34px; height: 34px; font-size: 16px; }
.hero-total { margin-top: 12px; }

.field { margin-bottom: 12px; gap: 5px; }
.input-x, .select-x { height: 38px; font-size: 13.5px; }
.dlg-body { padding: 18px 20px 6px; }
.dlg-foot { padding: 10px 20px 16px; }

.chart-box { height: 220px; }
.table-x th { padding: 7px 10px; }
.table-x td { padding: 7px 10px; }

/* Planner grid */
.sheet-toolbar { padding: 10px 14px; }
.sheet-scroll { max-height: calc(100vh - 140px); }
.sheet th, .sheet td { height: 38px; }
.sheet thead th { height: 46px; }
.ci { height: 38px; }
.rich .ci, .split-cell .ci { height: 46px; }
.rich { min-height: 46px; }
.sheet tr.tall td { height: 48px; }
.sheet tr.load-row td { height: 54px; }
.lbl-in { padding-top: 4px; padding-bottom: 4px; min-height: 38px; }
.lbl-static { min-height: 38px; padding-top: 4px; padding-bottom: 4px; }
.sec .sec-in { padding: 10px 16px 8px; }
.sec-ico { width: 28px; height: 28px; font-size: 14px; }
.add-row-btn { height: 34px; }

@media (max-width: 991px) {
  .page { padding: 6px 14px 32px; }
  .topbar { padding: 0 14px; }
}

.delta { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.good { color: var(--good, #16a34a); }
.delta.bad { color: var(--bad, #dc2626); }
.calc-stat small.delta { font-size: 10.5px; }
.calc-stat small.delta.good { color: var(--good); }
.calc-stat small.delta.bad { color: var(--bad); }

.calc-table-wrap.summary { max-height: none; overflow: visible; }
.calc-table-wrap.summary .table-x { width: 100%; table-layout: auto; }
.calc-table-wrap.summary td:not(:first-child), .calc-table-wrap.summary th:not(:first-child) { text-align: right; }
.calc-table-wrap.summary .delta { display: block; font-size: 10.5px; white-space: normal; line-height: 1.25; }

.calc-pair.even .calc-num, .calc-pair.even .calc-num:first-child, .calc-pair.even .calc-num:last-child { flex: 1 1 50%; width: auto; padding: 0 8px; }
.calc-pair.even .calc-num input, .calc-pair.even .calc-num:first-child input { flex: 1 1 0; width: 0; min-width: 0; }
.calc-pair.even .calc-num > span { flex: none; }
.calc-pair.even .cur { align-self: center; padding-left: 10px; color: var(--muted); font-weight: 600; }
.calc-pair.even .calc-num > span:first-child { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* Cell notes: tiny single-line preview on top of the cell (full text on hover via title) */
.sheet td.has-note { position: relative; }
.cell-note {
  position: absolute; top: 2px; left: 6px; right: 6px; z-index: 1;
  font: 600 9px/1.2 var(--font); color: var(--muted); text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.sheet td.has-note::after { content: ''; position: absolute; top: 0; right: 0; border: 4px solid transparent; border-top-color: var(--warn-mark); border-right-color: var(--warn-mark); pointer-events: none; }
.sheet td.has-note .ci { padding-top: 11px; }
.sheet td.has-note.has-chk .cell-note { left: 28px; }
.note-input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.4; font-family: var(--font); }
.sheet td.has-note .stepper .ci { padding-top: 0; }

/* ================= Journal ================= */

.j-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .j-layout { grid-template-columns: 1fr; } }

.j-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.j-toolbar .input-wrap { flex: 1 1 220px; max-width: 320px; }
.j-toolbar .spacer { flex: 1; }

.j-month { display: flex; align-items: baseline; gap: 10px; padding: 14px 18px 8px; }
.j-month h3 { font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.j-month .tot { margin-left: auto; font-size: 12.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

.j-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto 26px 26px; gap: 14px; align-items: center; padding: 11px 18px; border-top: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.j-row:hover { background: var(--surface-2); }
.j-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; }
.j-ico.expense  { color: var(--brand);  background: var(--brand-soft); }
.j-ico.warranty { color: var(--good);   background: var(--good-soft); }
.j-ico.service  { color: var(--u1);     background: var(--u1-soft); }
.j-ico.hospital { color: var(--bad); background: var(--bad-soft); }
.j-ico.other    { color: var(--warn);   background: var(--warn-soft); }
.j-title { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.j-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: 3px; font-size: 12px; color: var(--muted); }
.j-meta .dot { opacity: .5; }
.j-date { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.j-amt { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; min-width: 84px; }
.j-amt.none { color: var(--muted); font-weight: 600; }
@media (max-width: 640px) { .j-row { grid-template-columns: 40px 1fr auto; } .j-date, .j-row .row-act, .j-row .avatar { display: none; } }

/* attention side panel */
.att-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.att-item:first-child { border-top: 0; padding-top: 4px; }
.att-item .t { font-weight: 650; font-size: 13.5px; }
.att-item .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.att-days { margin-left: auto; text-align: right; flex: none; }
.att-days b { display: block; font-family: var(--font-display); font-size: 20px; line-height: 1; }
.att-days span { font-size: 10.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.att-days.warn b { color: var(--warn); } .att-days.bad b { color: var(--bad); }

/* category breakdown bars */
.cat-bar { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; margin: 9px 0; }
.cat-bar .track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.cat-bar .track i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.cat-bar b { font-variant-numeric: tabular-nums; }

/* add / edit entry dialog */
.j-dlg { width: min(640px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.j-dlg::backdrop { background: rgba(16, 19, 28, .45); backdrop-filter: blur(3px); }
.j-dlg header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.j-dlg header h3 { font-size: 16px; font-weight: 800; }
.j-dlg header .icon-btn { margin-left: auto; }
.j-dlg .body { padding: 18px 20px 4px; max-height: min(70vh, 640px); overflow: auto; }
.j-dlg footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .f-row { grid-template-columns: 1fr; } }
.type-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.type-pick label { cursor: pointer; }
.type-pick input { position: absolute; opacity: 0; }
.type-pick span { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 12.5px; font-weight: 650; color: var(--text-2); transition: all .15s; }
.type-pick i { font-size: 18px; color: var(--muted); }
.type-pick input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.type-pick input:checked + span i { color: var(--brand); }
.type-pick input:focus-visible + span { box-shadow: 0 0 0 4px var(--brand-soft); }
.extra-box { border: 1px dashed var(--border-2); border-radius: var(--radius); padding: 14px 14px 0; margin-bottom: 16px; background: var(--surface-2); }
.extra-box h5 { font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); margin-bottom: 12px; display: flex; gap: 6px; align-items: center; }
.drop { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px dashed var(--border-2); border-radius: var(--radius); color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.drop i { font-size: 22px; color: var(--brand); }
  
.j-row[hidden], .j-group[hidden] { display: none; }
.j-row .row-act { opacity: 0; transition: opacity .15s; }
.j-row:hover .row-act, .j-row:focus-within .row-act { opacity: 1; }
@media (hover: none) { .j-row .row-act { opacity: 1; } }
.avatar.joint { --av: var(--s-joint); }
.drop { cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.j-dlg.closing { opacity: 0; transform: scale(.98); transition: opacity .15s, transform .15s; }
.file-list { display: grid; gap: 6px; margin-bottom: 10px; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.file-item a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-item small { color: var(--muted); }
.att-item[data-open] { cursor: pointer; }
@media print { .j-toolbar, .j-row .row-act { display: none !important; } }

/* ---- Compact, uniform KPI tiles (all pages): icon at the left, text stacked beside it ---- */
.card-x.kpi {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-content: center; align-items: center;
  min-height: 84px; padding: 10px 14px;
}
.card-x.kpi > .kpi-icon { grid-column: 1; grid-row: 1 / span 3; align-self: center; margin: 0; }
.card-x.kpi > :not(.kpi-icon) { grid-column: 2; min-width: 0; }
.card-x.kpi .kpi-label { font-size: 12px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-x.kpi .kpi-value { font-size: 20px; line-height: 1.15; margin-top: 0; }
.card-x.kpi .kpi-foot { margin-top: 2px; font-size: 11.5px; line-height: 1.3; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-x.kpi::after { width: 90px; height: 90px; right: -30px; top: -30px; }
.grid-auto:has(> .kpi) { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
@media (max-width: 640px) { .grid-auto:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); } .card-x.kpi { padding: 10px 12px; column-gap: 10px; } }

.j-ico.insurance { color: var(--s-extra); background: var(--brand-soft); }
.type-note { display: flex; align-items: center; gap: 8px; margin: -6px 0 14px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
.type-note b { color: var(--text); }
.j-dlg .ctx-menu { z-index: 10; }

.toggle-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, background .15s; }
.toggle-row:hover { border-color: var(--border-2); }
.toggle-row:has(input:checked) { border-color: var(--good); background: var(--good-soft); }
.toggle-row input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--good); flex: none; }
.toggle-row span { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.toggle-row small { color: var(--muted); font-size: 12px; }
.toggle-row[hidden] { display: none; }

/* ---- Journal: compact rows (more entries per screen) ---- */
.pill.accent { background: var(--brand-soft); color: var(--brand); }
.j-meta .sep { opacity: .5; }
.j-row { grid-template-columns: 32px minmax(0, 1fr) auto auto 26px 26px; gap: 12px; padding: 6px 14px; }
.j-ico { width: 32px; height: 32px; border-radius: 9px; font-size: 15px; }
.j-title { font-size: 13.5px; line-height: 1.3; }
.j-meta { flex-wrap: nowrap; overflow: hidden; gap: 6px; margin-top: 1px; font-size: 11.5px; line-height: 1.3; white-space: nowrap; }
.j-meta > * { flex: none; }
.j-meta .pill { padding: 0 7px; height: 18px; font-size: 10.5px; gap: 4px; }
.j-meta .pill i { font-size: 10.5px; }
.j-month { padding: 10px 14px 6px; }
.j-amt { min-width: 76px; font-size: 13.5px; }
.att-item { padding: 9px 0; }
