/* FinApp — data-dense pro design system */

/* =========================================================
   Cross-document page transitions (View Transitions API)
   ========================================================= */

@view-transition {
  navigation: auto;
}

/* Sidebar + topbar are their own named layers — stay frozen while content transitions */
.sidebar {
  view-transition-name: nav-sidebar;
}
.topbar {
  view-transition-name: nav-topbar;
}

::view-transition-old(nav-sidebar),
::view-transition-new(nav-sidebar),
::view-transition-old(nav-topbar),
::view-transition-new(nav-topbar) {
  animation: none;
  mix-blend-mode: normal;
}

/* Main content: fast fade-out, smooth fade+lift on enter */
::view-transition-old(root) {
  animation: 0.13s ease-in both vt-out;
}
::view-transition-new(root) {
  animation: 0.22s ease-out both vt-in;
}

@keyframes vt-out { to   { opacity: 0; } }
@keyframes vt-in  { from { opacity: 0; transform: translateY(5px); } }

/* Fade-in when JS populates empty nav placeholders on first load */
.sidebar:not(:empty) { animation: nav-fill 0.18s ease-out both; }
.topbar:not(:empty)  { animation: nav-fill 0.18s ease-out both; }
@keyframes nav-fill  { from { opacity: 0; } to { opacity: 1; } }

/* =========================================================
   CSS Variables
   ========================================================= */
:root {
  --bg:          #FAFAF9;
  --bg-elev:     #FFFFFF;
  --bg-sub:      #F4F4F2;
  --bg-hover:    #F0EFEC;
  --border:      #E7E5E0;
  --border-strong: #D6D3CC;
  --fg:          #1C1B17;
  --fg-2:        #5C5A52;
  --fg-3:        #8A877E;
  --fg-4:        #B6B3AA;
  --accent:      #5B45D9;
  --accent-soft: #ECE9FB;
  --accent-fg:   #45319F;
  --green:       #047857;
  --green-soft:  #ECFDF5;
  --red:         #B91C1C;
  --red-soft:    #FEF2F2;
  --amber:       #B45309;
  --amber-soft:  #FEF3C7;
  --blue:        #1D4ED8;
  --shadow-sm:   0 1px 2px rgba(15, 14, 10, 0.04);
  --shadow-md:   0 4px 20px -4px rgba(15, 14, 10, 0.08), 0 1px 2px rgba(15, 14, 10, 0.05);
  --shadow-lg:   0 24px 64px -12px rgba(15, 14, 10, 0.18), 0 8px 24px -8px rgba(15, 14, 10, 0.10);
  --radius-sm:   5px;
  --radius:      7px;
  --radius-lg:   10px;
  --font-ui:     'Sora', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono:   'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Legacy compat aliases */
  --bg-secondary: var(--bg-sub);
  --bg-active:    var(--bg-hover);
  --border-subtle: var(--border);
  --text:         var(--fg);
  --text-secondary: var(--fg-2);
  --text-muted:   var(--fg-3);
  --primary:      var(--accent);
  --primary-hover: var(--accent-fg);
  --primary-subtle: var(--accent-soft);
  --nav-width:    240px;
  --transition:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --radius-old:   4px;
  --yellow:       var(--amber);
  --yellow-bg:    var(--amber-soft);
  --green-bg:     var(--green-soft);
  --red-bg:       var(--red-soft);
}

/* =========================================================
   Dark mode
   ========================================================= */
[data-theme="dark"] {
  --bg:          #141413;
  --bg-elev:     #1C1B19;
  --bg-sub:      #111110;
  --bg-hover:    #252420;
  --border:      #2C2A27;
  --border-strong: #3D3B37;
  --fg:          #EFECE7;
  --fg-2:        #A6A29A;
  --fg-3:        #6A6760;
  --fg-4:        #47443F;
  --accent:      #7C68EC;
  --accent-soft: #252050;
  --accent-fg:   #C7C2F0;
  --green:       #34D399;
  --green-soft:  #052E1A;
  --red:         #F87171;
  --red-soft:    #2D1111;
  --amber:       #FCD34D;
  --amber-soft:  #2D2000;
  --blue:        #60A5FA;
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:   0 4px 20px -4px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg:   0 24px 64px -12px rgba(0, 0, 0, 0.7), 0 8px 24px -8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .hero-balance .lead-section {
  background: linear-gradient(135deg, #252050, var(--bg-elev));
}

[data-theme="dark"] .scrim,
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.6); }

[data-theme="dark"] .login-stage {
  background-image:
    radial-gradient(circle at 20% 0%, color-mix(in oklch, var(--accent), black 60%), transparent 50%),
    radial-gradient(circle at 100% 100%, color-mix(in oklch, var(--accent), black 70%), transparent 60%);
}

/* =========================================================
   Density variants
   ========================================================= */
[data-density="compact"] body { font-size: 13px; }
[data-density="compact"] .tbl tbody td { padding: 9px 12px; }
[data-density="compact"] .page { padding: 22px 28px calc(56px + env(safe-area-inset-bottom) + 24px); }
[data-density="compact"] .kpi { padding: 14px 16px; }
[data-density="compact"] .kpi-val { font-size: 22px; }
[data-density="compact"] .card-h { padding: 12px 14px; }
[data-density="compact"] .card-body { padding: 14px; }

[data-density="comfy"] body { font-size: 15px; }
[data-density="comfy"] .tbl tbody td { padding: 18px 18px; }
[data-density="comfy"] .page { padding: 40px 48px calc(56px + env(safe-area-inset-bottom) + 40px); }
[data-density="comfy"] .kpi { padding: 28px 28px; }
[data-density="comfy"] .kpi-val { font-size: 34px; }
[data-density="comfy"] .card-h { padding: 20px 24px; }
[data-density="comfy"] .card-body { padding: 24px; }

/* =========================================================
   Radius variants
   ========================================================= */
[data-radius="sharp"] { --radius-sm: 0px; --radius: 2px; --radius-lg: 4px; }
[data-radius="sharp"] .btn, [data-radius="sharp"] .input, [data-radius="sharp"] .select { border-radius: 2px; }
[data-radius="sharp"] .pill { border-radius: 2px; }
[data-radius="sharp"] .card { border-radius: 4px; }
[data-radius="sharp"] .modal { border-radius: 4px; }
[data-radius="sharp"] .avatar { border-radius: 4px; }

[data-radius="round"] { --radius-sm: 10px; --radius: 12px; --radius-lg: 16px; }
[data-radius="round"] .btn, [data-radius="round"] .input, [data-radius="round"] .select { border-radius: 999px; }
[data-radius="round"] .card { border-radius: 18px; }
[data-radius="round"] .modal { border-radius: 20px; }

/* =========================================================
   Shell variants
   ========================================================= */
[data-shell="cards"] .page > .card,
[data-shell="cards"] .page > .kpi-row .kpi { box-shadow: 0 8px 24px -8px rgba(15,14,10,.10), 0 1px 2px rgba(15,14,10,.04); }
[data-shell="flat"] .card, [data-shell="flat"] .kpi { box-shadow: none; }
[data-shell="flat"] .topbar { border-bottom: 1px solid var(--border); }
[data-shell="bordered"] .card, [data-shell="bordered"] .kpi { box-shadow: none; border: 1px solid var(--border-strong); }

/* =========================================================
   Base reset
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.005em;
  min-height: 100vh;
  overflow-wrap: break-word;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

input, select, textarea {
  font-family: inherit;
  font-size: 0.9375rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  width: 100%;
  outline: none;
  transition: all var(--transition);
}

input:hover, select:hover, textarea:hover { border-color: var(--fg-3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-sub); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; border: 2px solid var(--bg-sub); }
::-webkit-scrollbar-thumb:hover { background: var(--fg-3); }

/* =========================================================
   App shell
   ========================================================= */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* Legacy: #app without .app class — still use grid */
#app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* =========================================================
   Sidebar
   ========================================================= */
.sidebar {
  background: var(--bg-sub);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}

.sb-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 16px;
  font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em;
}
.sb-brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklch, var(--accent), white 25%));
  display: grid; place-items: center; color: white; font-weight: 700; font-size: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.15), inset 0 1px 0 rgba(255,255,255,.25);
  flex-shrink: 0;
}
.sb-section {
  font-size: 10.5px; font-weight: 500; color: var(--fg-3); text-transform: uppercase;
  letter-spacing: 0.06em; padding: 12px 8px 4px;
}
.sb-link {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 8px; border-radius: 6px;
  color: var(--fg-2); font-weight: 500; font-size: 13px;
  cursor: default; user-select: none;
  white-space: nowrap;
  text-decoration: none;
}
.sb-link > span:not(.kbd):not(.badge) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sb-link:hover { background: var(--bg-hover); color: var(--fg); }
.sb-link.active { background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow-sm); }
.sb-link svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .85; }
.sb-link .kbd { margin-left: auto; font-size: 10.5px; color: var(--fg-4); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; }
.sb-link .badge { margin-left: auto; background: var(--accent-soft); color: var(--accent-fg); padding: 1px 6px; border-radius: 10px; font-size: 10.5px; font-weight: 600; }

.sb-foot {
  margin-top: auto; padding: 8px;
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--border); padding-top: 12px;
}

/* =========================================================
   Main area
   ========================================================= */
.main { display: flex; flex-direction: column; min-width: 0; }

/* =========================================================
   Topbar
   ========================================================= */
.topbar {
  height: 44px; min-height: 44px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; padding: 0 18px; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.crumb { color: var(--fg-3); font-size: 12.5px; }
.crumb b { color: var(--fg); font-weight: 600; }
.crumb-sep { color: var(--fg-4); margin: 0 6px; }

.tb-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tb-period {
  display: flex; align-items: center; gap: 4px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-elev);
  font-size: 12px; font-weight: 500;
}
.tb-period button {
  appearance: none; background: none; border: 0;
  color: var(--fg-3); cursor: default; padding: 0 4px;
  font-size: 13px; line-height: 1;
}
.tb-period button:hover { color: var(--fg); }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  appearance: none; border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--fg);
  font-size: 12.5px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background .08s;
  white-space: nowrap; flex-shrink: 0;
  font-family: inherit;
}
.btn:hover { background: var(--bg-hover); }
.btn svg { width: 13px; height: 13px; }
.btn.primary, .btn.btn-primary, .btn-primary {
  background: var(--accent); color: white;
  border-color: color-mix(in oklch, var(--accent), black 12%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn.primary:hover, .btn.btn-primary:hover, .btn-primary:hover {
  background: color-mix(in oklch, var(--accent), black 8%);
}
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.sm, .btn-sm { padding: 3px 7px; font-size: 11.5px; }
.btn.icon { padding: 4px; width: 26px; justify-content: center; }
.btn.secondary, .btn-secondary {
  background: var(--bg-hover); color: var(--fg);
  border: 1px solid var(--border);
}
.btn.secondary:hover, .btn-secondary:hover { background: var(--bg-sub); }
.btn.danger, .btn-danger {
  background: transparent; color: var(--red);
  border: 1px solid var(--red);
}
.btn.danger:hover, .btn-danger:hover { background: var(--red-soft); }

/* =========================================================
   Page content
   ========================================================= */
.page { padding: 22px 28px calc(56px + env(safe-area-inset-bottom) + 24px); }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; gap: 16px; }
.page-h h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 2px; }
.page-h .sub { color: var(--fg-3); font-size: 12.5px; }
#page-actions { flex-direction: column; align-items: flex-end; gap: 4px; }

/* legacy page header */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2rem; flex-wrap: wrap; gap: 1.25rem;
}
.page-header h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg); }

/* =========================================================
   Cards
   ========================================================= */
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card-h {
  padding: 12px 14px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
  gap: 10px; flex-wrap: nowrap;
}
.card-h h3 { margin: 0; font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; min-width: 0; }
.card-h .h-sub { color: var(--fg-3); font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card-body { padding: 14px; }
.card-h--toggle { cursor: pointer; user-select: none; }
.card-h--toggle:hover { background: var(--bg-hover); }
.reimb-chevron { pointer-events: none; color: var(--fg-3); transition: transform 0.2s ease; }
.card-collapse { display: grid; grid-template-rows: 1fr; overflow: hidden; transition: grid-template-rows 0.25s ease; }
.card-collapse.collapsed { grid-template-rows: 0fr; }
.card-collapse > div { min-height: 0; }

/* =========================================================
   KPIs
   ========================================================= */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow: hidden;
}
.kpi-lbl { font-size: 11px; font-weight: 500; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-val { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { color: var(--fg-3); font-size: 11.5px; display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }

/* =========================================================
   Tables
   ========================================================= */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl thead th {
  text-align: left; font-weight: 500; color: var(--fg-3);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev); position: sticky; top: 0;
}
.tbl tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl td.nowrap { white-space: nowrap; }
.tbl tbody tr:hover { background: var(--bg-sub); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }
.tbl td.shrink { width: 1px; white-space: nowrap; }

/* generic table (for non-.tbl tables) */
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  text-align: left; padding: 8px 12px;
  color: var(--fg-3); font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--bg-elev);
}
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-sub); }

/* =========================================================
   Pills
   ========================================================= */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1.5px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-sub); color: var(--fg-2);
  white-space: nowrap; cursor: default;
}
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--fg-3); }
.pill.shared { background: var(--accent-soft); color: var(--accent-fg); border-color: color-mix(in oklch, var(--accent), white 70%); }
.pill.shared .dot { background: var(--accent); }
.pill.personal { background: var(--bg-sub); color: var(--fg-2); }
.pill.green { background: var(--green-soft); color: var(--green); border-color: color-mix(in oklch, var(--green), white 75%); }
.pill.red { background: var(--red-soft); color: var(--red); border-color: color-mix(in oklch, var(--red), white 75%); }
.pill.amber { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in oklch, var(--amber), white 75%); }
.pill:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--fg); }
.pill.active { background: var(--accent); border-color: var(--accent); color: white; }
.pill.active:hover { background: var(--accent-fg); }
.pill.green.active, .pill.red.active, .pill.amber.active { }

/* =========================================================
   Avatars
   ========================================================= */
.avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; color: white; font-size: 10px; font-weight: 600; flex-shrink: 0; background: var(--fg-2); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 32px; height: 32px; font-size: 11.5px; }
.avatar.xl { width: 52px; height: 52px; font-size: 16px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -6px; box-shadow: 0 0 0 1.5px var(--bg-elev); }

/* =========================================================
   Progress / Bar
   ========================================================= */
.bar { position: relative; height: 6px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; }
.bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 999px; }
.bar > span.over { background: var(--red); }
.bar > span.warn { background: var(--amber); }

/* =========================================================
   Hero balance strip
   ========================================================= */
.hero-balance {
  display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-elev); overflow: hidden; margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}
.hero-balance > .section {
  padding: 22px 26px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.hero-balance > .section:last-child { border-right: 0; }
.hero-balance .lbl { font-size: 11.5px; font-weight: 500; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.06em; display: flex; align-items: center; gap: 6px; }
.hero-balance .lead-section { background: linear-gradient(135deg, var(--accent-soft), var(--bg-elev)); }
.hero-balance .num-hero { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 38px; font-weight: 600; letter-spacing: -0.025em; line-height: 1; color: var(--accent-fg); }
.hero-balance .arrow-row { display: flex; align-items: center; gap: 10px; }
.hero-balance .arrow-row .who { font-size: 12.5px; color: var(--fg-2); font-weight: 500; }
.hero-balance .arrow-row .arrow { color: var(--accent); display: inline-flex; }
.hero-balance .actions { display: flex; gap: 8px; margin-top: 6px; }
.hero-balance .num-side { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.hero-balance .num-side.bad { color: var(--red); }

/* =========================================================
   Day-grouped activity feed
   ========================================================= */
.day-feed { display: flex; flex-direction: column; }
.day-feed .day { border-bottom: 1px solid var(--border); }
.day-feed .day:last-child { border-bottom: 0; }
.day-feed .day-h {
  display: flex; align-items: baseline; gap: 12px;
  padding: 14px 20px 10px;
  background: var(--bg-sub); border-bottom: 1px solid var(--border);
}
.day-feed .day-h .label { font-size: 12.5px; font-weight: 600; color: var(--fg); }
.day-feed .day-h .meta { font-size: 11.5px; color: var(--fg-3); }
.day-feed .day-h .total { margin-left: auto; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--fg-2); font-weight: 500; }
.day-feed .day-row {
  display: grid; grid-template-columns: auto 1fr auto auto auto;
  align-items: center; gap: 14px;
  padding: 11px 20px; border-bottom: 1px solid var(--border);
}
.day-feed .day-row:last-child { border-bottom: 0; }
.day-feed .day-row:hover { background: var(--bg-sub); }
.day-feed .day-row .desc-col { display: flex; flex-direction: column; min-width: 0; }
.day-feed .day-row .desc { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-feed .day-row .merch { font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-feed .day-row .cat-tag { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-2); }
.day-feed .day-row .payer { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.day-feed .day-row .amt { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13.5px; font-weight: 500; }

/* =========================================================
   Category grid
   ========================================================= */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cat-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-sm); cursor: default;
  transition: border-color .12s;
}
.cat-card:hover { border-color: var(--border-strong); }

/* =========================================================
   Modal / Sheet
   ========================================================= */
.scrim, .modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 14, 10, 0.36);
  backdrop-filter: blur(2px); z-index: 100;
  display: none; align-items: center; justify-content: center;
}
.scrim.open, .modal-overlay.open { display: flex; animation: fadeIn .12s; }
.modal {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  width: min(560px, calc(100% - 32px));
  max-height: calc(100vh - 64px); overflow-y: auto;
  display: flex; flex-direction: column;
  animation: modalIn .14s ease-out;
  padding: 0;
}
.modal.lg { width: min(820px, calc(100% - 32px)); }
/* Legacy modal with padding (when no modal-h/modal-body used) */
.modal-overlay .modal { padding: 2rem; }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-h h2 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-foot, .modal-footer {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--bg-sub);
}
/* legacy modal h2 inside padding-modal */
.modal-overlay .modal h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 1.25rem; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }

/* =========================================================
   Forms
   ========================================================= */
.field, .form-group {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 1rem;
}
.field label, .form-group label {
  font-size: 11.5px; color: var(--fg-2); font-weight: 500;
  display: block; margin-bottom: 0.25rem;
}
.input, .select {
  appearance: none; -webkit-appearance: none;
  height: 30px; padding: 0 9px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--bg-elev); color: var(--fg);
  font-size: 13px; font-family: inherit; outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent), white 80%); }
.input.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A877E' stroke-width='2' stroke-linecap='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center; padding-right: 26px;
}
.seg { display: inline-flex; padding: 2px; background: var(--bg-sub); border: 1px solid var(--border); border-radius: 7px; }
.seg button { appearance: none; border: 0; background: transparent; padding: 3px 10px; border-radius: 5px; font-size: 12px; font-weight: 500; color: var(--fg-2); cursor: default; }
.seg button.active { background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow-sm); }
.checkbox { display: inline-flex; align-items: center; gap: 7px; cursor: default; user-select: none; font-size: 12.5px; }
.checkbox input { width: 14px; height: 14px; accent-color: var(--accent); }

/* =========================================================
   Login screen
   ========================================================= */
.login-stage {
  min-height: 100vh; background: var(--bg);
  display: grid; place-items: center; padding: 24px;
  background-image:
    radial-gradient(circle at 20% 0%, color-mix(in oklch, var(--accent), white 88%), transparent 50%),
    radial-gradient(circle at 100% 100%, color-mix(in oklch, var(--accent), white 92%), transparent 60%);
}
.login-card {
  width: min(420px, 100%); background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 36px 32px 28px; text-align: center;
}
.login-mark {
  width: 46px; height: 46px; margin: 0 auto 20px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklch, var(--accent), white 30%));
  display: grid; place-items: center; color: white; font-weight: 700; font-size: 20px;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.2);
}
.login-card h1 { font-size: 20px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.015em; }
.login-card .sub { color: var(--fg-3); font-size: 13px; margin-bottom: 24px; }
.gbtn {
  width: 100%; height: 40px; border: 1px solid var(--border-strong);
  background: var(--bg-elev); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; color: var(--fg);
  box-shadow: var(--shadow-sm); transition: background .08s;
  text-decoration: none;
}
.gbtn:hover { background: var(--bg-hover); }
.gbtn svg { width: 16px; height: 16px; }
.legal { font-size: 11px; color: var(--fg-3); margin-top: 18px; line-height: 1.5; }

/* =========================================================
   Toasts
   ========================================================= */
#toast-container {
  position: fixed; bottom: calc(56px + env(safe-area-inset-bottom) + 12px); right: 22px;
  display: flex; flex-direction: column; gap: 8px; z-index: 999;
}
.toast {
  background: var(--fg); color: var(--bg-elev);
  padding: 8px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 200;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .18s;
  min-width: 220px;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.toast.info { background: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* =========================================================
   Drop zone
   ========================================================= */
.drop {
  border: 1.5px dashed var(--border-strong); border-radius: 10px;
  padding: 28px; text-align: center; background: var(--bg-sub);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--bg-elev); display: grid; place-items: center; color: var(--fg-2); border: 1px solid var(--border); }

/* =========================================================
   Step indicator
   ========================================================= */
.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.step { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-3); }
.step .n { width: 18px; height: 18px; border-radius: 50%; background: var(--bg-sub); border: 1px solid var(--border); display: grid; place-items: center; font-size: 10.5px; font-weight: 600; }
.step.active { color: var(--fg); }
.step.active .n { background: var(--accent); color: white; border-color: var(--accent); }
.step.done .n { background: var(--green); color: white; border-color: var(--green); }
.step-line { flex: 1; height: 1px; background: var(--border); }

/* =========================================================
   Utilities
   ========================================================= */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.muted { color: var(--fg-3); }
.tiny { font-size: 11px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.spacer { flex: 1; }
.lead { flex: 1; border-bottom: 1px dotted var(--border-strong); margin: 0 8px 4px; }
.empty { text-align: center; padding: 40px 20px; color: var(--fg-3); }

/* =========================================================
   Legacy / Backward-compat aliases
   ========================================================= */

/* .panel ≡ .card */
.panel {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 1.5rem; margin-bottom: 1.5rem;
}
.panel:hover { box-shadow: var(--shadow-md); }
.panel h2 {
  font-size: 11px; font-weight: 600; margin-bottom: 1rem;
  color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.05em;
}

/* .progress-bar-bg ≡ .bar */
.progress-bar-bg { background: var(--bg-hover); border-radius: 999px; height: 6px; overflow: hidden; }
/* .progress-bar-fill ≡ .bar > span */
.progress-bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s ease; }

/* .badge ≡ .pill (inline badge) */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500;
  padding: 2px 7px; border-radius: 999px;
  background: var(--bg-sub); color: var(--fg-2);
}

/* Amount colors */
.amount-expense { color: var(--red); font-weight: 500; font-variant-numeric: tabular-nums; }
.amount-income  { color: var(--green); font-weight: 500; font-variant-numeric: tabular-nums; }
.amount-transfer { color: var(--fg-3); font-weight: 500; font-variant-numeric: tabular-nums; }

/* Empty state */
.empty-state { text-align: center; padding: 2rem; color: var(--fg-3); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }

/* Chart wrap */
.chart-wrap { height: 280px; position: relative; margin-top: 0.5rem; }

/* Table wrap */
.table-wrap { overflow-x: auto; }

/* Filters */
.filters { display: flex; gap: 8px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filters select, .filters input { max-width: 180px; font-size: 0.875rem; }

/* Month selector (legacy) */
.month-selector {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 500;
}
.month-selector button {
  background: none; border: none; color: var(--fg-3);
  font-size: 1.125rem; padding: 0 4px; border-radius: 4px;
  transition: all var(--transition); line-height: 1;
}
.month-selector button:hover { background: var(--bg-hover); color: var(--fg); }
.month-selector span { font-weight: 500; min-width: 7rem; text-align: center; font-size: 0.875rem; color: var(--fg); }

/* person pills */
.person-pills { display: flex; gap: 6px; flex-wrap: wrap; }

/* progress list */
.progress-list { display: flex; flex-direction: column; gap: 0.875rem; }
.progress-item { }
.progress-header { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 0.875rem; }
.progress-header .cat-name { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--fg); }

/* card-label / card-value (old dashboard) */
.card-label { font-size: 11px; font-weight: 500; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.card-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.card-value.green { color: var(--green); }
.card-value.red { color: var(--red); }

/* select inline */
select.cat-select { font-size: 0.8125rem; padding: 0.25rem 0.5rem; max-width: 180px; border-color: var(--border); }
select.cat-select:hover { border-color: var(--fg-3); background: var(--bg-hover); }

/* description truncation */
.tx-desc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* import preview */
.import-preview { max-height: 400px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); margin: 0.75rem 0; }
.import-preview table { font-size: 0.8125rem; }
.import-preview td, .import-preview th { padding: 6px 10px; }
.row-duplicate td { opacity: 0.35; text-decoration: line-through; }

/* floating tooltip */
.floating-note-tooltip {
  position: fixed; z-index: 450;
  max-width: min(320px, calc(100vw - 24px));
  padding: 8px 12px; font-size: 0.8125rem; line-height: 1.45;
  color: var(--fg); background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  pointer-events: none; opacity: 0; transition: opacity 0.12s ease;
}
.floating-note-tooltip:not([hidden]) { opacity: 1; }
.cat-note-tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* grid-2 layout */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }

/* cards (old 3-col) */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }

/* tab bar */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 8px 14px; font-size: 12.5px; font-weight: 500; color: var(--fg-3);
  background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer; white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  font-family: inherit;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-pane[hidden] { display: none; }

/* budget table */
.budget-table input[type=number] { max-width: 140px; text-align: right; font-variant-numeric: tabular-nums; }
.bcat-name { font-weight: 500; font-size: 12.5px; }
@media (max-width: 768px) {
  #budget-by-cat .tbl { table-layout: fixed; }
  #budget-by-cat .tbl tbody td,
  #reimb-body .tbl tbody td { padding: 4px 4px; font-size: 9px; }
  #budget-by-cat .tbl thead th,
  #reimb-body .tbl thead th { padding: 4px 4px; font-size: 8px; }
  #budget-by-cat .bcat-name { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #budget-by-cat .tbl td:first-child { padding-left: 8px; }
  #budget-by-cat .tbl td:last-child { padding-right: 8px; }
  #budget-by-cat .pill { min-width: 30px; font-size: 9px; padding: 1px 5px; }
  #reimb-body .day-row { display: flex; flex-direction: column; gap: 2px; }
  #reimb-body .day-row .amt { align-self: flex-end; }
  #reimb-body .tbl th:nth-child(2),
  #reimb-body .tbl th:nth-child(3),
  #reimb-body .tbl td:nth-child(2),
  #reimb-body .tbl td:nth-child(3) { display: none; }
  .day-feed .day-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 16px; }
  .day-feed .day-row .amt { align-self: flex-start; }
  .day-feed .day-row .cat-tag, .day-feed .day-row .payer { display: none; }
  #budget-by-cat .pill,
  #budget-by-cat .bar,
  #budget-by-cat [style*="width:36%"],
  #budget-by-cat .tbl th:nth-child(2),
  #budget-by-cat .tbl td:nth-child(2) { display: none; }
  .kpi { padding: 8px 10px; gap: 2px; }
  .kpi-lbl { font-size: 8px; letter-spacing: 0.01em; }
  .kpi-val { font-size: 2px; }
  .kpi-sub { font-size: 9px; }
  .hero-balance .num-hero { font-size: 22px; }
  .hero-balance > .section { padding: 14px 16px; }
  .hero-balance .num-side { font-size: 18px; }
}
@media (max-width: 480px) {
  #budget-by-cat .tbl tbody td,
  #reimb-body .tbl tbody td { padding: 5px 6px; font-size: 10px; }
  #budget-by-cat .tbl thead th,
  #reimb-body .tbl thead th { padding: 5px 6px; font-size: 9px; }
  #budget-by-cat .bcat-name { font-size: 10px; }
}

/* =========================================================
   Bottom nav (mobile)
   ========================================================= */
#bottom-nav {
  display: flex;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: 56px; padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-elev); border-top: 1px solid var(--border);
  align-items: stretch;
}
#bottom-nav .bn-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; font-size: 10px; font-weight: 500;
  color: var(--fg-3); text-decoration: none; padding: 6px 0;
}
#bottom-nav .bn-tab svg { width: 20px; height: 20px; }
#bottom-nav .bn-tab.active { color: var(--accent); }

/* =========================================================
   FAB — Floating Action Button (mobile)
   ========================================================= */
.fab {
  display: none;
  position: fixed; bottom: calc(56px + 16px + env(safe-area-inset-bottom));
  right: 16px; z-index: 90;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: white;
  border: none; box-shadow: 0 4px 12px rgba(0,0,0,.25);
  font-size: 24px; cursor: default;
  align-items: center; justify-content: center;
}
.fab:hover { background: color-mix(in oklch, var(--accent), black 8%); }
@media (max-width: 768px) { .fab { display: flex; } }

#nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 99; }
#nav-overlay.visible { display: block; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1024px) {
  .app, #app { grid-template-columns: 200px 1fr; }
  .sidebar { width: 200px; }
}

@media (max-width: 768px) {
  .app, #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpi-row { grid-template-columns: 1fr; gap: 6px; }
  .hero-balance { grid-template-columns: 1fr; }
  .hero-balance > .section { border-right: 0; border-bottom: 1px solid var(--border); }
  .hero-balance > .section:last-child { border-bottom: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 16px 16px calc(56px + env(safe-area-inset-bottom) + 16px); }
  #nav-toggle { display: none !important; }
  .topbar { padding-left: 16px; }
  .table-wrap { overflow-x: auto; }
  .filters { display: none; }
  .filters.open { display: flex; flex-direction: column; }
  #filters-toggle { display: inline-flex !important; }
  .page:has(.table-cards-mobile) .table-cards-mobile { margin-left: -20px; margin-right: -20px; width: auto; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .page { padding: 12px 12px calc(56px + env(safe-area-inset-bottom) + 12px); }
  .page-h { flex-direction: column; align-items: flex-start; }
  .day-feed .day-row .cat-tag, .day-feed .day-row .payer { display: none; }
  #toast-container { bottom: 1rem; right: 0.75rem; left: 0.75rem; }
  .toast { min-width: 0; width: 100%; }
  .chart-wrap { height: 200px; }
  .filters { flex-direction: column; }
  .filters select, .filters input { max-width: 100%; }
  .person-pills { flex-wrap: wrap; }

  /* mobile modal → bottom sheet */
  .modal-overlay { padding-top: 0; align-items: flex-end; }
  .modal {
    width: 100%; border-radius: 12px 12px 0 0;
    max-height: 92vh; overflow-y: auto;
  }
  .modal-footer { flex-direction: column-reverse; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}

/* =========================================================
   Onboarding Tour
   ========================================================= */

#tour-overlay {
  position: fixed; inset: 0; z-index: 9100;
  background: rgba(0,0,0,0.48);
  animation: fadeIn .2s ease;
}

#tour-frame {
  position: fixed; z-index: 9200; display: none;
  border: 2px solid var(--accent);
  border-radius: calc(var(--radius) + 8px);
  box-shadow: 0 0 0 4px rgba(91, 69, 217, 0.18);
  pointer-events: none;
  transition: top .18s ease, left .18s ease, width .18s ease, height .18s ease;
}
[data-theme="dark"] #tour-frame {
  box-shadow: 0 0 0 4px rgba(124, 104, 236, 0.22);
}

#tour-tip {
  position: fixed; z-index: 9300;
  width: 320px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .15s ease-out;
}

.tour-count {
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em;
  color: var(--accent); margin-bottom: 6px; text-transform: uppercase;
}
.tour-ttl {
  font-size: 14px; font-weight: 600; color: var(--fg); line-height: 1.3;
}
.tour-txt {
  font-size: 13px; color: var(--fg-2); line-height: 1.55; margin: 8px 0 0;
}
.tour-btns {
  display: flex; justify-content: space-between;
  align-items: center; margin-top: 14px; gap: 8px;
}

/* Onboarding welcome modal (settings page) */
#onboarding-welcome-overlay {
  position: fixed; inset: 0; z-index: 8000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45);
  animation: fadeIn .2s ease;
  padding: 1rem;
}
#onboarding-welcome-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 440px; width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease-out;
}
#onboarding-welcome-box h2 { margin: 0 0 0.625rem; font-size: 1.1rem; }
#onboarding-welcome-box p  { color: var(--fg-2); font-size: 0.875rem; line-height: 1.6; margin: 0 0 1.25rem; }
.onboarding-emoji { font-size: 2rem; margin-bottom: 0.75rem; }

/* "Continue to dashboard" button in settings */
#btn-continue-dashboard {
  display: none;
  margin-top: 1.5rem;
}

/* Table mobile cards */
@media (max-width: 768px) {
  .table-cards-mobile { overflow-x: visible; margin-left: 0; margin-right: 0; padding: 0; }
  .table-cards-mobile table { display: block; width: 100%; }
  .table-cards-mobile thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .table-cards-mobile tbody { display: block; }
  .table-cards-mobile tbody tr {
    display: block; background: var(--bg-sub); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 8px;
  }
  .table-cards-mobile td {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
    gap: 6px; padding: 6px 0; border: none; text-align: right;
  }
  .table-cards-mobile td::before {
    content: attr(data-label); font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--fg-3); font-weight: 600; flex: 0 0 auto;
    text-align: left; max-width: 42%;
  }
  .table-cards-mobile td:has(.progress-bar-bg) { flex-direction: column; align-items: stretch; }
  .table-cards-mobile td:has(.progress-bar-bg)::before { max-width: none; align-self: flex-start; }
  .table-cards-mobile .tx-desc { max-width: none; white-space: normal; text-overflow: unset; overflow: visible; }
  .table-cards-mobile tr.table-card-empty td { display: block; text-align: center; justify-content: center; }
  .table-cards-mobile tr.table-card-empty td::before { content: none; display: none; }
  .table-cards-mobile td .cat-select, .table-cards-mobile td select { max-width: 100%; flex: 1 1 auto; min-width: 0; }
  .table-cards-mobile td input[type="text"], .table-cards-mobile td input[type="number"] { flex: 1 1 auto; min-width: 0; }
  .table-cards-mobile .table-card-actions { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; margin-left: auto; }
  .table-cards-mobile .table-card-cell-main { flex: 1 1 auto; min-width: 0; text-align: right; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
  .table-cards-mobile .tx-table td:nth-child(3),
  .table-cards-mobile .tx-table td:nth-child(4),
  .table-cards-mobile .tx-table th:nth-child(3),
  .table-cards-mobile .tx-table th:nth-child(4) { display: none; }
}

/* =========================================================
   Skeleton loading
   ========================================================= */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-sub) 25%, var(--bg-hover) 50%, var(--bg-sub) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.3s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
  user-select: none;
  pointer-events: none;
  display: inline-block;
  line-height: 1;
  vertical-align: middle;
}
.skeleton-hero { height: 32px; width: 160px; border-radius: 6px; }
.skeleton-kpi { height: 20px; width: 90px; border-radius: 4px; }
.skeleton-line { height: 11px; width: 100%; border-radius: 3px; margin-bottom: 6px; }
.skeleton-line:last-child { width: 65%; margin-bottom: 0; }
.skeleton-line.short { width: 40%; }
.skeleton-line.wide { width: 80%; }
.skeleton-line.tiny { width: 25%; }
.skeleton-bar { height: 6px; border-radius: 999px; width: 100%; }
.skeleton-pill { height: 16px; width: 36px; border-radius: 2px; }
.skeleton-num { height: 14px; width: 65px; border-radius: 3px; }
.skeleton-cell { height: 13px; width: 100%; border-radius: 3px; }
.skeleton-icon { width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0; }
.skeleton-avatar { width: 22px; height: 22px; border-radius: 4px; flex-shrink: 0; }
