/* ============================================================
   BudgetFlow — Modern Sleek Glassmorphic Design System
   Cross-platform: MacBook Pro, Samsung Galaxy S24 Ultra, iPad, iPhone
   ============================================================ */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Dark Theme (Default) */
  --bg-base: #070b14;
  --bg-mesh-1: rgba(99, 102, 241, 0.16);
  --bg-mesh-2: rgba(16, 185, 129, 0.12);
  --bg-mesh-3: rgba(236, 72, 153, 0.10);

  --surface-1: rgba(15, 23, 42, 0.78);
  --surface-2: rgba(30, 41, 59, 0.65);
  --surface-3: rgba(51, 65, 85, 0.45);
  --surface-solid: #0f172a;
  --surface-input: rgba(15, 23, 42, 0.85);

  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.35);

  /* Countdown Status Colors */
  --green-accent: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --green-border: rgba(16, 185, 129, 0.35);
  --green-text: #34d399;

  --amber-accent: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.13);
  --amber-border: rgba(245, 158, 11, 0.38);
  --amber-text: #fbbf24;

  --red-accent: #f43f5e;
  --red-bg: rgba(244, 63, 94, 0.13);
  --red-border: rgba(244, 63, 94, 0.42);
  --red-text: #fb7185;

  --overdue-accent: #ef4444;
  --overdue-bg: rgba(220, 38, 38, 0.20);
  --overdue-border: rgba(239, 68, 68, 0.60);
  --overdue-text: #fca5a5;

  --paid-bg: rgba(100, 116, 139, 0.10);
  --paid-border: rgba(100, 116, 139, 0.20);
  --paid-text: #94a3b8;

  --none-accent: #8b5cf6;
  --none-bg: rgba(139, 92, 246, 0.08);
  --none-border: rgba(139, 92, 246, 0.25);
  --none-text: #c4b5fd;

  --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, 0.55);
  --shadow-md: 0 10px 25px -8px rgba(0, 0, 0, 0.4);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

body.theme-light {
  --bg-base: #f1f5f9;
  --bg-mesh-1: rgba(99, 102, 241, 0.12);
  --bg-mesh-2: rgba(16, 185, 129, 0.10);
  --bg-mesh-3: rgba(236, 72, 153, 0.08);

  --surface-1: rgba(255, 255, 255, 0.86);
  --surface-2: rgba(248, 250, 252, 0.92);
  --surface-3: rgba(226, 232, 240, 0.65);
  --surface-solid: #ffffff;
  --surface-input: #ffffff;

  --border-subtle: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.20);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --green-bg: rgba(16, 185, 129, 0.11);
  --green-border: rgba(16, 185, 129, 0.42);
  --green-text: #047857;

  --amber-bg: rgba(245, 158, 11, 0.13);
  --amber-border: rgba(245, 158, 11, 0.48);
  --amber-text: #b45309;

  --red-bg: rgba(244, 63, 94, 0.10);
  --red-border: rgba(244, 63, 94, 0.44);
  --red-text: #be123c;

  --overdue-bg: rgba(239, 68, 68, 0.15);
  --overdue-border: rgba(220, 38, 38, 0.60);
  --overdue-text: #991b1b;

  --paid-bg: rgba(148, 163, 184, 0.14);
  --paid-border: rgba(148, 163, 184, 0.28);
  --paid-text: #64748b;

  --none-bg: rgba(139, 92, 246, 0.08);
  --none-border: rgba(139, 92, 246, 0.28);
  --none-text: #6d28d9;

  --shadow-lg: 0 20px 45px -12px rgba(15, 23, 42, 0.12);
  --shadow-md: 0 8px 20px -6px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 12% 10%, var(--bg-mesh-1) 0%, transparent 42%),
    radial-gradient(circle at 88% 18%, var(--bg-mesh-2) 0%, transparent 40%),
    radial-gradient(circle at 50% 88%, var(--bg-mesh-3) 0%, transparent 45%);
  background-attachment: fixed;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Glass Surfaces & Shared Buttons
   ============================================================ */
.glass-card {
  background: var(--surface-1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border-color: rgba(129, 140, 248, 0.5);
  color: #ffffff;
  box-shadow: 0 6px 20px -6px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  border-color: rgba(165, 180, 252, 0.7);
}

.btn-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: rgba(52, 211, 153, 0.45);
  color: #ffffff;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.35);
  color: var(--red-text);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.24);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.icon-btn.danger:hover {
  color: var(--red-text);
  border-color: var(--red-border);
  background: var(--red-bg);
}

.field-input, .field-select {
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
  width: 100%;
}

.field-input:focus, .field-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}

/* ============================================================
   PIN Lock & Multi-User Profile Gate
   ============================================================ */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-base);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.22) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.16) 0%, transparent 45%);
}

.lock-container {
  width: 100%;
  max-width: 460px;
  padding: 28px 24px;
  text-align: center;
}

.lock-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 6px;
}

.lock-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.lock-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.lock-subtitle {
  margin: 0 0 22px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.18s ease;
}

.profile-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.profile-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.16);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.profile-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.profile-hint {
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: var(--surface-3);
  padding: 2px 7px;
  border-radius: 999px;
}

.pin-prompt {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 10px;
  min-height: 24px;
}

.pin-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: scale(1.1);
}

.pin-error {
  color: var(--red-text);
  font-size: 0.84rem;
  font-weight: 600;
  min-height: 20px;
  margin-bottom: 10px;
}

.pin-dots.shake {
  animation: shake 0.36s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 0 auto 18px;
}

.key-btn {
  height: 54px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.key-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.key-btn:active {
  transform: scale(0.94);
  background: var(--accent-primary);
  color: #fff;
}

.key-btn.action {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.lock-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* ============================================================
   App Shell & Header
   ============================================================ */
.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: 18px 20px 96px;
}

.top-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  margin-bottom: 16px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-cluster img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.brand-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.user-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-secondary);
}

.sync-badge.online {
  background: var(--green-bg);
  color: var(--green-text);
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.month-select {
  width: auto;
  min-width: 155px;
  font-weight: 600;
}

/* ============================================================
   5-Day Alert Banner & Day-of-Month Simulator Strip
   ============================================================ */
.alert-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  box-shadow: 0 8px 25px -10px rgba(244, 63, 94, 0.35);
}

.alert-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red-accent);
  box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.7);
  animation: pulse 1.8s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(244, 63, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

.alert-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--red-text);
}

.alert-desc {
  font-size: 0.82rem;
  color: var(--text-primary);
}

.countdown-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
}

.countdown-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.day-pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.16);
  color: var(--accent-primary-hover);
  font-weight: 700;
  font-size: 0.8rem;
}

.day-simulator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

.day-slider {
  width: 140px;
  accent-color: var(--accent-primary);
}

/* ============================================================
   Desktop Navigation Tabs & Mobile Bottom Nav
   ============================================================ */
.nav-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px;
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.nav-tab {
  flex: 1;
  min-width: 140px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.16s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

.nav-tab.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.24), rgba(79, 70, 229, 0.18));
  border-color: rgba(129, 140, 248, 0.4);
  color: var(--text-primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--surface-1);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border-subtle);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.bottom-nav-btn.active {
  color: var(--accent-primary-hover);
  background: rgba(99, 102, 241, 0.12);
}

/* ============================================================
   KPI Summary Cards & Income Section
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-positive { color: var(--green-text); }
.kpi-negative { color: var(--red-text); }

.income-panel {
  padding: 20px;
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.income-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.income-box {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.income-box label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.currency-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 10px;
}

.currency-input-wrap:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}

.currency-prefix {
  color: var(--text-secondary);
  font-weight: 700;
}

.currency-input-wrap input {
  border: none;
  background: transparent;
  padding: 9px 2px;
  font-size: 1.05rem;
  font-weight: 700;
  width: 100%;
  outline: none;
}

.extra-income-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.extra-income-row {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 8px;
  align-items: center;
}

/* ============================================================
   Color Legend Strip
   ============================================================ */
.legend-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.legend-chip.green { background: var(--green-bg); color: var(--green-text); border: 1px solid var(--green-border); }
.legend-chip.amber { background: var(--amber-bg); color: var(--amber-text); border: 1px solid var(--amber-border); }
.legend-chip.red { background: var(--red-bg); color: var(--red-text); border: 1px solid var(--red-border); }
.legend-chip.overdue { background: var(--overdue-bg); color: var(--overdue-text); border: 1px solid var(--overdue-border); }
.legend-chip.paid { background: var(--paid-bg); color: var(--paid-text); border: 1px solid var(--paid-border); }

/* ============================================================
   Category Cards & Entry Rows (with Strict Color Rules)
   ============================================================ */
.categories-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.categories-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.category-card {
  padding: 18px;
  border-radius: var(--radius-xl);
}

.category-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.category-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.category-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category-name-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 4px 8px;
  color: var(--text-primary);
  width: auto;
  max-width: 280px;
  transition: all 0.15s ease;
}

.category-name-input:hover {
  border-color: var(--border-subtle);
  background: var(--surface-2);
}

.category-name-input:focus {
  border-color: var(--accent-primary);
  background: var(--surface-input);
  outline: none;
}

.category-badge {
  font-size: 0.74rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-secondary);
  font-weight: 600;
}

.category-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-total {
  font-weight: 800;
  font-size: 1.05rem;
}

.category-progress {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin-bottom: 14px;
}

.category-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.entries-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.entry-row {
  display: grid;
  grid-template-columns: 34px minmax(220px, 2.2fr) 120px 125px 135px auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  border-left-width: 5px;
  background: var(--surface-2);
  transition: opacity 0.2s ease, transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

/* Status Color Classes */
.entry-row.status-green {
  background: var(--green-bg);
  border-color: var(--green-border);
  border-left-color: var(--green-accent);
}

.entry-row.status-amber {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  border-left-color: var(--amber-accent);
}

.entry-row.status-red {
  background: var(--red-bg);
  border-color: var(--red-border);
  border-left-color: var(--red-accent);
}

.entry-row.status-overdue {
  background: var(--overdue-bg);
  border-color: var(--overdue-border);
  border-left-color: var(--overdue-accent);
}

.entry-row.status-none {
  background: var(--none-bg);
  border-color: var(--none-border);
  border-left-color: var(--none-accent);
}

.entry-row.status-paid {
  background: var(--paid-bg);
  border-color: var(--paid-border);
  border-left-color: #64748b;
  opacity: 0.56;
}

.entry-row.status-paid .entry-name-input {
  text-decoration: line-through;
  color: var(--paid-text);
}

.paid-checkbox-label {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.paid-checkbox {
  width: 22px;
  height: 22px;
  accent-color: var(--green-accent);
  cursor: pointer;
  border-radius: 6px;
}

.entry-name-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.entry-name-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 7px;
  font-weight: 600;
  font-size: 0.92rem;
  width: 100%;
  outline: none;
}

.entry-name-input:hover {
  border-color: var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
}

.entry-name-input:focus {
  border-color: var(--accent-primary);
  background: var(--surface-input);
}

.entry-submeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-left: 7px;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.tracker-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  font-weight: 600;
  font-size: 0.72rem;
}

.category-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 0.73rem;
  font-weight: 600;
}

.entry-amount-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 8px;
}

.entry-amount-input {
  border: none;
  background: transparent;
  padding: 7px 2px;
  font-size: 0.9rem;
  font-weight: 700;
  width: 100%;
  text-align: right;
  outline: none;
}

.due-box {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.8rem;
}

.due-box label {
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.due-day-input {
  border: none;
  background: transparent;
  width: 48px;
  font-weight: 700;
  text-align: center;
  outline: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  text-align: center;
}

.status-pill.green { background: var(--green-bg); color: var(--green-text); border: 1px solid var(--green-border); }
.status-pill.amber { background: var(--amber-bg); color: var(--amber-text); border: 1px solid var(--amber-border); }
.status-pill.red { background: var(--red-bg); color: var(--red-text); border: 1px solid var(--red-border); }
.status-pill.overdue { background: var(--overdue-bg); color: var(--overdue-text); border: 1px solid var(--overdue-border); }
.status-pill.paid { background: var(--paid-bg); color: var(--green-text); border: 1px solid var(--green-border); }
.status-pill.none { background: var(--none-bg); color: var(--none-text); border: 1px solid var(--none-border); }

.entry-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.add-entry-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
}

/* ============================================================
   Final Remaining Box (Bottom Summary)
   ============================================================ */
.final-summary-box {
  margin-top: 22px;
  padding: 22px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.90), rgba(30, 27, 75, 0.75));
}

body.theme-light .final-summary-box {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(238, 242, 255, 0.92));
}

.final-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.final-stat {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

.final-stat.highlight {
  border-color: var(--green-border);
  background: var(--green-bg);
}

.final-stat.highlight.negative {
  border-color: var(--red-border);
  background: var(--red-bg);
}

.final-stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.final-stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  margin-top: 4px;
}

/* ============================================================
   Due Date Unified List View Filters
   ============================================================ */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-pill {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.filter-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.filter-pill.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

/* ============================================================
   Analytics & Pie Chart View
   ============================================================ */
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 20px;
  align-items: start;
}

.chart-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pie-wrapper {
  position: relative;
  width: 280px;
  height: 280px;
  flex: 0 0 280px;
  margin: 14px auto;
}

.pie-svg {
  width: 280px;
  height: 280px;
  display: block;
}

.pie-slice {
  cursor: pointer;
  transition: stroke-width 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}

.pie-slice:hover, .pie-slice.active {
  filter: brightness(1.15);
  stroke-width: 40;
}

.pie-center-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 24px;
}

.pie-center-title {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
}

.pie-center-amount {
  font-size: 1.45rem;
  font-weight: 800;
  margin-top: 2px;
}

.pie-center-pct {
  font-size: 0.8rem;
  color: var(--accent-primary-hover);
  font-weight: 600;
}

.breakdown-card {
  padding: 22px;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.breakdown-item:hover, .breakdown-item.active {
  border-color: var(--accent-primary);
}

.breakdown-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.breakdown-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.breakdown-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  border-radius: 999px;
}

/* ============================================================
   Connect, Phone Notifications & Backup Hub
   ============================================================ */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.hub-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hub-card h3 {
  margin: 0;
  font-size: 1.06rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hub-card p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #0f172a;
  align-self: center;
}

.qr-box svg {
  width: 176px;
  height: 176px;
  display: block;
}

.lan-url-pill {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
  text-align: center;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================================
   Modals & Toasts
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-dialog {
  width: 100%;
  max-width: 480px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.toast-stack {
  position: fixed;
  bottom: 84px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
  font-weight: 600;
  animation: slideUp 0.2s ease;
}

.toast.success { border-left: 4px solid var(--green-accent); }
.toast.error { border-left: 4px solid var(--red-accent); }
.toast.info { border-left: 4px solid var(--accent-primary); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Responsive Breakpoints (iPad & Samsung Galaxy S24 Ultra / iPhone)
   ============================================================ */
@media (max-width: 1023px) {
  .kpi-grid, .final-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .entry-row {
    grid-template-columns: 32px minmax(140px, 1fr) 115px 120px 130px auto;
  }
}

@media (max-width: 767px) {
  .app-shell {
    padding: 12px 12px 92px;
  }
  .top-header {
    padding: 12px 14px;
  }
  .nav-tabs {
    display: none;
  }
  .bottom-nav {
    display: flex;
  }
  .kpi-grid, .final-summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .pie-wrapper, .pie-svg {
    width: 240px;
    height: 240px;
  }
  .pie-wrapper {
    flex-basis: 240px;
  }
  .kpi-value {
    font-size: 1.25rem;
  }
  .entry-row {
    grid-template-columns: 28px 1fr auto;
    grid-template-areas:
      "check name actions"
      "check amount due"
      "status status status";
    gap: 8px;
  }
  .paid-checkbox-label { grid-area: check; align-self: start; padding-top: 4px; }
  .entry-name-col { grid-area: name; }
  .entry-actions { grid-area: actions; }
  .entry-amount-wrap { grid-area: amount; }
  .due-box { grid-area: due; }
  .status-pill { grid-area: status; justify-self: start; }

  .extra-income-row {
    grid-template-columns: 1fr 110px auto;
  }
}
