:root,
:root[data-theme="emerald"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #059669;
  --primary-dark: #047857;
  --primary-soft: #ecfdf5;
  --primary-soft-text: #065f46;
  --accent: #0284c7;
  --accent-soft: #f0f9ff;
  --gold: #d97706;
  --gold-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #94a3b8;
  --sidebar-title: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(16, 185, 129, 0.18);
  --sidebar-active: #34d399;
  --brand-gradient: linear-gradient(135deg, #10b981, #047857);
  --table-hover: #f8fafc;
  --total-row-bg: #f1f5f9;
  --total-row-border: #cbd5e1;
  --input-bg: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
}

:root[data-theme="ocean"] {
  --bg: #f0f5fa;
  --surface: #ffffff;
  --surface-alt: #f5f9fd;
  --border: #dbe6f2;
  --text: #0f172a;
  --text-muted: #5b6e84;
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-soft: #e0f2fe;
  --primary-soft-text: #075985;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --sidebar-bg: #0b192c;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #94a3b8;
  --sidebar-title: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.09);
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(56, 189, 248, 0.18);
  --sidebar-active: #38bdf8;
  --brand-gradient: linear-gradient(135deg, #0ea5e9, #1d4ed8);
  --table-hover: #f0f7ff;
  --total-row-bg: #e8f1fb;
  --total-row-border: #bfd6ee;
  --input-bg: #ffffff;
}

:root[data-theme="gold"] {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-alt: #faf7f2;
  --border: #e7dfd3;
  --text: #1c1917;
  --text-muted: #78716c;
  --primary: #b45309;
  --primary-dark: #92400e;
  --primary-soft: #fef3c7;
  --primary-soft-text: #78350f;
  --accent: #0f766e;
  --accent-soft: #f0fdfa;
  --sidebar-bg: #1c1917;
  --sidebar-text: #d6d3d1;
  --sidebar-muted: #a8a29e;
  --sidebar-title: #fef3c7;
  --sidebar-border: rgba(255, 255, 255, 0.09);
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(245, 158, 11, 0.2);
  --sidebar-active: #fbbf24;
  --brand-gradient: linear-gradient(135deg, #f59e0b, #b45309);
  --table-hover: #fdfaf3;
  --total-row-bg: #f5efe4;
  --total-row-border: #d6c8b4;
  --input-bg: #ffffff;
}

:root[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #f0fdfa;
  --primary-soft-text: #115e59;
  --sidebar-bg: #ffffff;
  --sidebar-text: #475569;
  --sidebar-muted: #64748b;
  --sidebar-title: #0f172a;
  --sidebar-border: #e2e8f0;
  --sidebar-hover: #f1f5f9;
  --sidebar-active-bg: #f0fdfa;
  --sidebar-active: #0f766e;
  --brand-gradient: linear-gradient(135deg, #14b8a6, #0f766e);
  --table-hover: #f8fafc;
  --total-row-bg: #f1f5f9;
  --total-row-border: #cbd5e1;
  --input-bg: #ffffff;
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-alt: #182234;
  --border: #263349;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-soft: rgba(16, 185, 129, 0.16);
  --primary-soft-text: #6ee7b7;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.16);
  --sidebar-bg: #080d1a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-title: #f8fafc;
  --sidebar-border: #1e293b;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: rgba(16, 185, 129, 0.18);
  --sidebar-active: #34d399;
  --brand-gradient: linear-gradient(135deg, #10b981, #047857);
  --table-hover: #1a263b;
  --total-row-bg: #182338;
  --total-row-border: #334155;
  --input-bg: #0f172a;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.text-muted { color: var(--text-muted); }
.text-pos { color: var(--primary); font-weight: 600; }
.text-neg { color: var(--danger); font-weight: 600; }
.text-gold { color: var(--gold); font-weight: 600; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, #064e3b 0%, #0f172a 55%, #020617 100%);
}
.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.auth-brand h1 { margin: 0; font-size: 1.35rem; }
.auth-brand p { margin: 2px 0 0; font-size: 0.84rem; color: var(--text-muted); }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}
.brand-mark.has-custom-logo {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 2px;
}
.brand-mark .app-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 9px;
  display: block;
}
.topbar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 0.85rem;
}
.auth-form label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.auth-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.auth-form input:focus { border-color: var(--primary); }
.auth-hint {
  background: var(--primary-soft);
  color: #065f46;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin: 0 0 14px;
}
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  margin: 0 0 14px;
}
.auth-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.auth-bio-section {
  margin-top: 16px;
}
.auth-bio-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-bottom: 12px;
}
.auth-bio-divider::before,
.auth-bio-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-bio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.auth-bio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}
.auth-bio-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  transform: translateY(-1px);
}
.auth-bio-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.bio-device-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bio-device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.bio-device-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.bio-device-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* App Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 248px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 30;
  transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1), padding 0.22s ease;
  overflow: visible;
}
.sidebar-collapse-btn {
  position: absolute;
  right: -13px;
  top: 25px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
  z-index: 40;
  transition: transform 0.22s ease, background 0.15s ease, color 0.15s ease;
}
.sidebar-collapse-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
.sidebar-collapse-btn svg {
  transition: transform 0.22s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 14px;
  min-width: 0;
}
.brand-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.brand-title { font-weight: 700; color: var(--sidebar-title); font-size: 1.04rem; line-height: 1.2; }
.brand-sub { font-size: 0.74rem; color: var(--sidebar-muted); margin-top: 2px; }

.nav-list { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 10px;
  font-size: 0.89rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s, padding 0.2s;
  white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-title); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }
.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-pill { display: flex; align-items: center; gap: 10px; padding: 4px; min-width: 0; }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.16);
  color: var(--sidebar-active);
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-meta { min-width: 0; overflow: hidden; white-space: nowrap; }
.user-name { font-size: 0.86rem; color: var(--sidebar-title); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: var(--sidebar-muted); }

/* Collapsed Sidebar (Icons Only) */
.sidebar.collapsed {
  width: 74px;
  padding: 18px 10px;
}
.sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}
.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-meta,
.sidebar.collapsed .logout-label {
  display: none;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 11px 0;
}
.sidebar.collapsed .nav-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #f8fafc;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  z-index: 60;
  pointer-events: none;
}
.sidebar.collapsed .user-pill {
  justify-content: center;
}
.sidebar.collapsed .sidebar-logout-btn {
  padding: 8px 0;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar h2 { margin: 0; font-size: 1.2rem; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge-row { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }

.period-picker { display: flex; gap: 6px; }
.period-picker select,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.alert-banner {
  background: var(--gold-soft);
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
}

.view-container {
  padding: 22px 24px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-alt); border-color: var(--text-muted); }
.btn-ghost { background: var(--sidebar-hover); color: var(--sidebar-text); }
.btn-ghost:hover { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #b45309; }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; border-radius: 7px; }
.btn-block { width: 100%; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge-good { background: var(--primary-soft); color: #047857; }
.badge-warn { background: var(--gold-soft); color: #b45309; }
.badge-bad { background: var(--danger-soft); color: #b91c1c; }
.badge-info { background: var(--accent-soft); color: #0369a1; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Cards & Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
}
.kpi-card.kpi-liability::before { background: var(--danger); }
.kpi-card.kpi-networth::before { background: var(--accent); }
.kpi-card.kpi-gold::before { background: var(--gold); }
.kpi-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 1.55rem; font-weight: 800; margin: 6px 0 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.4px; }
.kpi-sub { font-size: 0.78rem; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-12 { display: grid; grid-template-columns: 5fr 7fr; gap: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 0.98rem; font-weight: 700; }
.card-subtitle { margin: 2px 0 0; font-size: 0.78rem; color: var(--text-muted); }
.card-body { padding: 18px 20px; }

/* Tables */
.table-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--table-hover); }
tr.total-row td {
  background: var(--total-row-bg);
  font-weight: 700;
  border-top: 2px solid var(--total-row-border);
}
tr.section-row td {
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.3px;
}

/* Progress bars */
.progress-track {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.progress-good { background: var(--primary); }
.progress-warn { background: var(--gold); }
.progress-bad { background: var(--danger); }
.progress-info { background: var(--accent); }

/* Tabs */
.subtabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); padding: 0 4px; flex-wrap: wrap; }
.subtab-btn {
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
}
.subtab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.money-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.money-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}
.money-prefix {
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  user-select: none;
}
.money-input-wrap input {
  border: none !important;
  box-shadow: none !important;
  width: 100%;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.money-input-sm .money-prefix {
  padding: 0 7px;
  font-size: 0.76rem;
}
.money-input-sm input {
  padding: 6px 8px;
  font-size: 0.84rem;
}
.form-hint { font-size: 0.76rem; color: var(--text-muted); background: var(--surface-alt); padding: 7px 10px; border-radius: 7px; border: 1px dashed var(--border); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input, .filter-bar select { flex: 1; min-width: 150px; }

/* Charts */
.chart-card-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}
.chart-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
}

/* Interactive Donut Chart */
.interactive-donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.donut-stage {
  position: relative;
  width: 236px;
  height: 236px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.donut-svg {
  overflow: visible;
}
.donut-slice {
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 0 38px;
}
.donut-center-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #64748b;
  text-transform: uppercase;
  line-height: 1.25;
}
.donut-center-value {
  font-size: 0.96rem;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.donut-center-pct {
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.donut-table-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.donut-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.donut-table-row:hover,
.donut-table-row.active {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.donut-row-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-row-name {
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.donut-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.donut-row-rp {
  font-size: 0.76rem;
  color: #94a3b8;
}
.donut-row-amt {
  font-weight: 600;
  color: #0f172a;
  min-width: 82px;
}
.donut-row-pct {
  background: #f1f5f9;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.donut-table-row.active .donut-row-pct {
  background: #e2e8f0;
  color: #0f172a;
}

/* Interactive Cash Flow Combo Chart */
.cf-chart-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cf-hover-bar {
  background: #0f172a;
  color: #f8fafc;
  border-radius: 9px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.79rem;
  min-height: 36px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  flex-wrap: wrap;
}
.cf-hover-bar.visible {
  opacity: 1;
  transform: translateY(0);
}
.cf-hb-month {
  font-weight: 700;
  color: #34d399;
}
.cf-hb-metrics {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.cf-hb-metrics span {
  color: #cbd5e1;
}
.cf-hb-metrics strong {
  color: #ffffff;
  font-weight: 700;
}
.cf-hb-metrics strong.is-neg {
  color: #fda4af;
}
.cf-svg {
  display: block;
  width: 100%;
  height: auto;
}
.cf-band {
  fill: rgba(148, 163, 184, 0.16);
  opacity: 0;
  transition: opacity 0.14s ease;
}
.cf-month-group.active .cf-band {
  opacity: 1;
}
.cf-month-group.active .cf-x-label {
  fill: #0f172a;
  font-weight: 700;
}
.cf-hit {
  cursor: pointer;
}
.cf-dot {
  transition: r 0.14s ease;
}
.cf-dot.active {
  r: 5.2;
}
.cf-dot-halo {
  opacity: 0;
  transition: opacity 0.14s ease;
}
.cf-dot-halo.active {
  opacity: 1;
}
.cf-legend-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 4px;
  font-size: 0.8rem;
  color: #334155;
}
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-dot-circle { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-line-dot {
  position: relative;
  width: 18px;
  height: 2.5px;
  background: #4f46e5;
  border-radius: 2px;
  display: inline-block;
}
.legend-line-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4f46e5;
  border: 1.5px solid #fff;
  transform: translate(-50%, -50%);
}

/* Info Box */
.callout {
  padding: 12px 15px;
  border-radius: 10px;
  font-size: 0.83rem;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.callout-good { background: var(--primary-soft); border-color: #a7f3d0; color: #065f46; }
.callout-info { background: var(--accent-soft); border-color: #bae6fd; color: #075985; }
.callout-gold { background: var(--gold-soft); border-color: #fde68a; color: #92400e; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 20px; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  animation: fadeSlide 0.2s ease;
}
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--primary-dark); }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mobile-only { display: none; }

/* WhatsApp Bot Module */
.wa-qr-box,
.wa-connected-box,
.wa-qr-placeholder {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  background: var(--surface-alt);
}
.wa-connected-box {
  border-style: solid;
  border-color: #a7f3d0;
  background: #ecfdf5;
}
.wa-check-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.wa-qr-img {
  width: 220px;
  height: 220px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px;
}
.wa-chat-window {
  background: #efeae2;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  height: 270px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wa-msg {
  display: flex;
}
.wa-msg-user { justify-content: flex-end; }
.wa-msg-bot { justify-content: flex-start; }
.wa-bubble {
  max-width: 86%;
  padding: 9px 13px;
  border-radius: 11px;
  font-size: 0.83rem;
  line-height: 1.48;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
  word-break: break-word;
}
.wa-msg-user .wa-bubble {
  background: #d9fdd3;
  color: #0f172a;
  border-top-right-radius: 3px;
}
.wa-msg-bot .wa-bubble {
  background: #ffffff;
  color: #0f172a;
  border-top-left-radius: 3px;
}
.wa-bubble code {
  background: rgba(15, 23, 42, 0.07);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.78rem;
}
.wa-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
.wa-chip {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: #334155;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.wa-chip:hover {
  background: var(--primary-soft);
  border-color: #6ee7b7;
  color: #065f46;
}
.wa-input-row {
  display: flex;
  gap: 8px;
}
.wa-input-row input {
  flex: 1;
}

/* Sticky Ledger Card (Jurnal Umum & Daftar Akun) */
.sticky-ledger-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 118px);
  min-height: 460px;
  overflow: hidden;
}
.sticky-ledger-card .card-header,
.sticky-ledger-card .ledger-filter-bar {
  flex-shrink: 0;
  background: var(--surface);
  z-index: 8;
}
.sticky-ledger-card .table-wrap {
  flex: 1;
  overflow: auto;
}
.sticky-ledger-card thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--surface-alt);
  box-shadow: inset 0 -1px 0 var(--border);
}

/* Theme Swatch Selector (Pengaturan) */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.theme-card {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface-alt);
  cursor: pointer;
  text-align: left;
  transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
}
.theme-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}
.theme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.theme-preview {
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  border: 1px solid rgba(148, 163, 184, 0.25);
}
.theme-preview-side {
  width: 28%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 5px;
}
.theme-preview-side span {
  height: 4px;
  border-radius: 2px;
  opacity: 0.75;
}
.theme-preview-main {
  flex: 1;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.theme-preview-bar {
  height: 8px;
  border-radius: 3px;
  width: 60%;
}
.theme-preview-card {
  flex: 1;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.theme-name {
  font-size: 0.84rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.theme-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Logo Uploader (Pengaturan) */
.logo-upload-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.logo-preview-frame {
  width: 82px;
  height: 82px;
  border-radius: 16px;
  border: 2px dashed var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview-frame .brand-mark {
  width: 68px;
  height: 68px;
  font-size: 1.45rem;
  border-radius: 14px;
}
.logo-upload-actions {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.logo-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Interactive Buku Pembantu */
.sub-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.sub-kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.sub-kpi-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.sub-kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  font-weight: 700;
}
.sub-kpi-val {
  font-size: 1.16rem;
  font-weight: 800;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.sub-kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sub-pill-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sub-pill {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.sub-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.sub-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.gold-calc-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gold-calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.gold-quick-grams {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.gold-calc-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.gold-chart-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gold-hover-bar {
  background: #0f172a;
  color: #f8fafc;
  border-radius: 9px;
  padding: 8px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.78rem;
  min-height: 36px;
  flex-wrap: wrap;
}
.gold-hb-date {
  font-weight: 700;
  color: #fbbf24;
}
.gold-hb-metrics {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.gold-hb-metrics span { color: #cbd5e1; }
.gold-hb-metrics strong { color: #ffffff; }
.gold-pt-group .gold-band {
  fill: rgba(217, 119, 6, 0.14);
  opacity: 0;
  transition: opacity 0.14s ease;
}
.gold-pt-group.active .gold-band { opacity: 1; }
.gold-pt-group.active .gold-dot { r: 6.2; }
.gold-pt-group .gold-hit { cursor: pointer; }

.sub-row-main {
  cursor: pointer;
}
.sub-row-main.expanded td {
  background: var(--surface-alt);
  border-bottom-color: transparent;
}
.sub-expand-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-right: 6px;
  transition: transform 0.16s ease, background 0.15s ease;
  vertical-align: middle;
}
.sub-row-main.expanded .sub-expand-caret {
  transform: rotate(90deg);
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}
.sub-drawer-row td {
  padding: 0 14px 14px !important;
  background: var(--surface-alt) !important;
  border-bottom: 1px solid var(--border);
}
.sub-drawer-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.sub-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.action-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  justify-content: flex-end;
}

/* Enhanced Interactive Dashboard & Reports Styles */
.kpi-card-interactive {
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.kpi-card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.kpi-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.kpi-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-soft);
  color: var(--primary);
}
.kpi-card.kpi-liability .kpi-icon-badge { background: var(--danger-soft); color: var(--danger); }
.kpi-card.kpi-networth .kpi-icon-badge { background: var(--accent-soft); color: var(--accent); }
.kpi-card.kpi-gold .kpi-icon-badge { background: var(--gold-soft); color: var(--gold); }

.quick-action-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.quick-action-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.qa-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.14s ease;
}
.qa-pill:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  transform: translateY(-1px);
}

.eq-visual-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.eq-bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  display: flex;
}
.eq-bar-equity { background: var(--primary); transition: width 0.3s ease; }
.eq-bar-debt { background: var(--danger); transition: width 0.3s ease; }
.eq-bar-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
}

.health-hub-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.health-ring-wrap {
  position: relative;
  width: 68px;
  height: 68px;
  flex-shrink: 0;
}
.health-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.1;
}
.health-ring-sub {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ef-sim-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ef-sim-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ef-sim-controls input[type="range"] {
  flex: 1;
  min-width: 160px;
  accent-color: var(--primary);
  cursor: pointer;
}

.ratio-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.ratio-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.ratio-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.ratio-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.ratio-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ratio-icon-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ratio-icon-shield { background: rgba(16, 185, 129, 0.14); color: #059669; }
.ratio-icon-savings { background: rgba(2, 132, 199, 0.14); color: #0284c7; }
.ratio-icon-installment { background: rgba(99, 102, 241, 0.14); color: #4f46e5; }
.ratio-icon-debt { background: rgba(239, 68, 68, 0.13); color: #dc2626; }
.ratio-icon-gold { background: rgba(217, 119, 6, 0.15); color: #d97706; }
:root[data-theme="dark"] .ratio-icon-shield { background: rgba(16, 185, 129, 0.2); color: #34d399; }
:root[data-theme="dark"] .ratio-icon-savings { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
:root[data-theme="dark"] .ratio-icon-installment { background: rgba(129, 140, 248, 0.2); color: #a5b4fc; }
:root[data-theme="dark"] .ratio-icon-debt { background: rgba(248, 113, 113, 0.2); color: #fca5a5; }
:root[data-theme="dark"] .ratio-icon-gold { background: rgba(251, 191, 36, 0.2); color: #fbbf24; }
.ratio-card-name {
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.ratio-card-val {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.clickable-link-row {
  cursor: pointer;
  transition: background 0.14s ease;
}
.clickable-link-row:hover td {
  background: var(--primary-soft) !important;
}

/* Segmented Report Tabs */
.report-tabs-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.report-tab-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: all 0.16s ease;
  box-shadow: var(--shadow);
}
.report-tab-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.report-tab-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.report-tab-title {
  font-weight: 700;
  font-size: 0.9rem;
}
.report-tab-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cf-col-active {
  background: var(--primary-soft) !important;
  font-weight: 700;
}
.cf-month-spotlight {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alloc-pillar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.alloc-pillar-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.alloc-pillar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.alloc-pillar-pct {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .report-tabs-bar,
  .alloc-pillar-grid {
    grid-template-columns: 1fr;
  }
}

/* Dark Theme Deep Adjustments */
:root[data-theme="dark"] .badge-good { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
:root[data-theme="dark"] .badge-warn { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
:root[data-theme="dark"] .badge-bad { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
:root[data-theme="dark"] .badge-info { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; }
:root[data-theme="dark"] .badge-neutral { background: #1e293b; color: #cbd5e1; }
:root[data-theme="dark"] .donut-center-value,
:root[data-theme="dark"] .donut-row-name,
:root[data-theme="dark"] .donut-row-amt,
:root[data-theme="dark"] .cf-legend-center,
:root[data-theme="dark"] .chart-icon { color: #e2e8f0; }
:root[data-theme="dark"] .donut-table-row:hover,
:root[data-theme="dark"] .donut-table-row.active { background: #1e293b; border-color: #334155; }
:root[data-theme="dark"] .donut-row-pct { background: #1e293b; color: #cbd5e1; }
:root[data-theme="dark"] .donut-slice { stroke: #111827; }
:root[data-theme="dark"] .progress-track { background: #263349; }
:root[data-theme="dark"] .callout-good { border-color: rgba(16, 185, 129, 0.35); color: #6ee7b7; }
:root[data-theme="dark"] .callout-info { border-color: rgba(56, 189, 248, 0.35); color: #7dd3fc; }
:root[data-theme="dark"] .callout-gold { border-color: rgba(245, 158, 11, 0.35); color: #fcd34d; }
:root[data-theme="dark"] .alert-banner { border-bottom-color: rgba(245, 158, 11, 0.35); color: #fcd34d; }
:root[data-theme="dark"] .wa-connected-box { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.35); }
:root[data-theme="dark"] .wa-chat-window { background: #0f172a; }
:root[data-theme="dark"] .wa-msg-user .wa-bubble { background: #065f46; color: #ecfdf5; }
:root[data-theme="dark"] .wa-msg-bot .wa-bubble { background: #1e293b; color: #f1f5f9; }
:root[data-theme="dark"] .wa-chip { color: #cbd5e1; }
:root[data-theme="dark"] .btn-danger { border-color: rgba(239, 68, 68, 0.35); }
:root[data-theme="dark"] .btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
:root[data-theme="dark"] .cf-month-group.active .cf-x-label { fill: #f8fafc; }

/* Mobile Sidebar Backdrop & Close Button */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(2px);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.sidebar-backdrop.open {
  display: block;
  opacity: 1;
}
.sidebar-mobile-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--sidebar-border);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 1.35rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sidebar-mobile-close:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-title);
}
body.mobile-drawer-open {
  overflow: hidden;
}

.table-wrap {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sub-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sub-kpi-grid-3 { grid-template-columns: 1fr; }
  .gold-calc-result { grid-template-columns: 1fr; }
  .grid-2, .grid-12, .grid-3 { grid-template-columns: 1fr; }
  .sticky-ledger-card {
    height: calc(100vh - 144px);
  }
}

@media (max-width: 768px) {
  .mobile-only { display: inline-flex; }
  .sidebar-collapse-btn { display: none; }
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 264px !important;
    max-width: 84vw;
    height: 100dvh;
    z-index: 50;
    padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom)) !important;
    overflow-y: auto;
    transition: left 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.35);
  }
  .sidebar.open { left: 0; }
  /* Never leak desktop collapsed icon-only state into mobile slide-in drawer */
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .user-meta,
  .sidebar.collapsed .logout-label {
    display: block !important;
  }
  .sidebar.collapsed .sidebar-header {
    justify-content: flex-start;
    padding-left: 4px;
    padding-right: 4px;
  }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    padding: 11px 12px;
  }
  .sidebar.collapsed .nav-item:hover::after {
    display: none;
  }
  .sidebar.collapsed .user-pill {
    justify-content: flex-start;
  }
  .sidebar.collapsed .sidebar-logout-btn {
    padding: 8px 12px;
  }

  /* Compact non-intrusive mobile topbar with iOS notch safe-area */
  .topbar {
    position: relative;
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .topbar-left {
    width: 100%;
    gap: 10px;
  }
  .topbar h2 {
    font-size: 1.05rem;
  }
  .topbar-right {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .period-picker {
    flex: 1;
    min-width: 0;
  }
  .period-picker select {
    flex: 1;
    min-width: 0;
  }
  #quick-add-btn {
    flex-shrink: 0;
  }

  /* Prevent iOS Safari auto-zoom on form fields (<16px) & improve touch targets */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px;
    min-height: 40px;
  }
  .btn {
    min-height: 38px;
  }
  .btn-sm {
    min-height: 34px;
  }
  .sub-pill,
  .qa-pill {
    min-height: 34px;
  }

  .sticky-ledger-card {
    height: auto;
    min-height: 0;
  }
  .view-container {
    padding: 14px 12px max(44px, env(safe-area-inset-bottom));
    gap: 14px;
  }
  .card-header,
  .card-body {
    padding: 14px;
  }
  .kpi-grid { grid-template-columns: 1fr; }
  .sub-kpi-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .ratio-cards-grid { grid-template-columns: 1fr; }
  .modal-overlay {
    padding: 10px;
    align-items: flex-end;
  }
  .modal-box {
    max-height: 90dvh;
    border-radius: 16px 16px 12px 12px;
  }
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 14px;
  }
}

@media (max-width: 480px) {
  .topbar-logo {
    width: 32px;
    height: 32px;
  }
  .kpi-value {
    font-size: 1.32rem;
  }
  th, td {
    padding: 8px 9px;
    font-size: 0.8rem;
  }
  .donut-stage {
    width: 210px;
    height: 210px;
  }
  .donut-table-row {
    padding: 6px 8px;
    font-size: 0.78rem;
  }
  .donut-row-amt {
    min-width: 68px;
  }
  .donut-row-pct {
    min-width: 42px;
    font-size: 0.7rem;
    padding: 2px 5px;
  }
  .cf-hover-bar,
  .gold-hover-bar {
    font-size: 0.74rem;
    padding: 7px 10px;
  }
  .wa-chat-window {
    height: 230px;
  }
  .wa-input-row {
    flex-direction: column;
  }
  .wa-input-row .btn {
    width: 100%;
  }
  .auth-card {
    padding: 24px 20px;
  }
}
