/* ==========================================================================
   RUMAH SANDI - DESIGN SYSTEM & STYLESHEET
   Aesthetics: Modern Glassmorphism, Dark/Light Mode, Vibrant Accents, Responsive
   ========================================================================== */

/* --- CSS Variables & Themes --- */
:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-main: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 52, 0.85);
  --bg-card-solid: #131b2e;
  --bg-sidebar: rgba(13, 17, 28, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-strong: rgba(255, 255, 255, 0.15);

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

  /* Accent Colors */
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --success-light: #34d399;
  --success-bg: rgba(16, 185, 129, 0.12);

  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.3);
  --warning-light: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.12);

  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);
  --danger-light: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.12);

  --info: #0ea5e9;
  --info-glow: rgba(14, 165, 233, 0.3);
  --info-bg: rgba(14, 165, 233, 0.12);

  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.12);
  --rose: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.12);

  /* Typography */
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Plus Jakarta Sans', sans-serif;

  /* Shadows & Glass Effects */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px var(--primary-glow);
  --backdrop-blur: blur(16px);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-card-solid: #ffffff;
  --bg-sidebar: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(0, 0, 0, 0.02);
  --border-glass: rgba(0, 0, 0, 0.07);
  --border-glass-strong: rgba(0, 0, 0, 0.14);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 20px -4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 35px -8px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
}

/* --- Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Subtle background glowing ambient orbs */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
}

body::before {
  top: -10%;
  left: 20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0) 70%);
}

body::after {
  bottom: 5%;
  right: 10%;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, rgba(16, 185, 129, 0) 70%);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-glass-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- App Layout --- */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar Navigation --- */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 1.75rem 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-glass);
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 14px var(--primary-glow);
  overflow: hidden;
}

.brand-logo-img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: #ffffff;
  padding: 3px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: var(--transition);
}

.brand-logo-img:hover {
  transform: scale(1.05);
}

.brand-info h1 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--text-primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.075em;
  color: var(--text-muted);
  padding: 0.75rem 0.75rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.925rem;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
  border-color: var(--border-glass);
  transform: translateX(4px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
  color: var(--primary-light);
  font-weight: 600;
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.1);
}

.nav-item .icon {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.725rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary-light);
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background: var(--border-glass);
}

/* --- Main Content Area --- */
.main-wrapper {
  flex: 1;
  margin-left: 280px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2.25rem;
  background: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

.greeting-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.greeting-subtitle {
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* Hide text in cloud badge on mobile, show only emoji */
@media (max-width: 768px) {
  #supabaseStatusBadge .badge-text {
    display: none;
  }
  .topbar-right {
    gap: 0.5rem;
  }
  .user-profile-btn span:nth-child(2) {
    display: none; /* Hide name text on very small screens */
  }
}

@media (max-width: 420px) {
  #supabaseStatusBadge {
    display: none;
  }
}

.content-container {
  flex: 1;
  padding: 2rem 2.25rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* --- View Sections (SPA Tabs) --- */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

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

/* --- UI Component Cards --- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.glass-card:hover {
  border-color: var(--border-glass-strong);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.825rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* --- Stat Metric Cards (Dashboard & Finance) --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.4rem;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.stat-icon.primary { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.stat-icon.success { background: var(--success-bg); color: var(--success-light); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning-light); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger-light); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.15rem;
}

.stat-trend {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.stat-trend.positive { color: var(--success); }
.stat-trend.negative { color: var(--danger); }
.stat-trend.neutral { color: var(--text-muted); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: var(--font-main);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--bg-glass);
  border-color: var(--border-glass-strong);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--success-glow);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--success-glow);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-light);
  border-color: rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Badges & Pills --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
}
.badge-primary { background: rgba(99, 102, 241, 0.18); color: var(--primary-light); }
.badge-success { background: var(--success-bg); color: var(--success-light); }
.badge-warning { background: var(--warning-bg); color: var(--warning-light); }
.badge-danger { background: var(--danger-bg); color: var(--danger-light); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }

/* --- Forms & Inputs --- */
.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  font-family: var(--font-main);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* --- Tables & Lists --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.custom-table th {
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-glass);
}

.custom-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-primary);
  vertical-align: middle;
}

.custom-table tr:hover td {
  background: var(--bg-glass);
}

/* --- Modals & Overlays --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalScale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Mobile Drag Handle */
.modal-drag-handle {
  display: none;
  width: 40px;
  height: 4px;
  background: var(--border-glass-strong);
  border-radius: 99px;
  margin: 0.6rem auto 0;
}

@media (max-width: 768px) {
  .modal-drag-handle {
    display: block;
  }
  .modal-header {
    padding: 0.85rem 1.25rem 1rem;
  }
  .modal-body {
    padding: 1rem 1.25rem;
  }
  .modal-footer {
    padding: 1rem 1.25rem;
  }
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}

.close-modal-btn:hover {
  color: var(--text-primary);
}

/* --- Custom Confirmation & Alert Dialogs --- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}

.dialog-overlay.active {
  display: flex;
}

.dialog-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg), 0 0 35px rgba(0, 0, 0, 0.5);
  animation: modalScale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.dialog-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, #a855f7 100%);
}

.dialog-card.danger::before {
  background: linear-gradient(90deg, #ef4444 0%, #f43f5e 100%);
}
.dialog-card.warning::before {
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}
.dialog-card.success::before {
  background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

.dialog-icon-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.25rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass-strong);
}

.dialog-card.danger .dialog-icon-circle {
  background: var(--danger-bg);
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 20px var(--danger-glow);
}
.dialog-card.warning .dialog-icon-circle {
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.3);
  box-shadow: 0 0 20px var(--warning-glow);
}
.dialog-card.success .dialog-icon-circle {
  background: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 20px var(--success-glow);
}

.dialog-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.dialog-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.dialog-actions .btn {
  flex: 1;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-glass-strong);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: var(--transition);
}

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

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-danger { border-left: 4px solid var(--danger); }
.toast.toast-info { border-left: 4px solid var(--info); }

/* --- Module Specific Styles --- */

/* 1. Roadmap Styles */
.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.roadmap-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary) 0%, #a855f7 100%);
  transition: width 0.6s ease;
}

.progress-bar-fill.completed {
  background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

.milestone-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  transition: var(--transition);
}

.milestone-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.milestone-item.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* 2. Notes Styles */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.note-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top-width: 4px;
}

.note-card.amber { border-top-color: var(--warning); }
.note-card.blue { border-top-color: var(--info); }
.note-card.emerald { border-top-color: var(--success); }
.note-card.rose { border-top-color: var(--rose); }
.note-card.purple { border-top-color: var(--purple); }

.note-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.25rem 0;
}

.note-item.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* 3. Family Members Styles */
.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.member-avatar-large {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-glass);
  border: 2px solid var(--border-glass-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  box-shadow: var(--shadow-sm);
}

.member-info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border-glass);
  font-size: 0.85rem;
}

.member-info-row:last-child {
  border-bottom: none;
}

/* 4. Portfolio Styles */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.portfolio-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* --- Mobile Bottom Navigation --- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card-solid);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-top: 1px solid var(--border-glass-strong);
  z-index: 900;
  padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.68rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  flex: 1;
  text-align: center;
}

.mobile-nav-item:active {
  transform: scale(0.92);
}

.mobile-nav-item.active {
  color: var(--primary-light);
  font-weight: 700;
  background: rgba(99, 102, 241, 0.12);
}

.mobile-nav-item .icon {
  font-size: 1.3rem;
  line-height: 1;
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sidebar-close-btn {
  display: none;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  margin-left: auto;
}

/* --- Responsive Breakpoints & Mobile Optimization --- */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }
  .main-wrapper {
    margin-left: 240px;
  }
  .content-container {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  body {
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: 1000;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.85);
  }

  .sidebar-close-btn {
    display: flex;
  }

  .main-wrapper {
    margin-left: 0;
    padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .topbar {
    padding: 0.85rem 1rem;
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  }

  .greeting-title {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
  }

  .greeting-subtitle {
    display: none;
  }

  .content-container {
    padding: 1rem 0.85rem;
  }

  .glass-card {
    padding: 1.15rem;
    border-radius: var(--radius-md);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stat-card {
    padding: 0.85rem;
    gap: 0.75rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .stat-trend {
    font-size: 0.68rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .form-control {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom */
    padding: 0.75rem 0.85rem;
    min-height: 46px;
  }

  .btn {
    min-height: 44px;
    padding: 0.65rem 1rem;
  }

  /* Modal Bottom Sheet on Mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    max-height: 85vh;
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .roadmap-grid, .notes-grid, .family-grid, .portfolio-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Mobile Table to Card Transformation */
  .custom-table thead {
    display: none;
  }

  .custom-table, .custom-table tbody, .custom-table tr, .custom-table td {
    display: block;
    width: 100%;
  }

  .custom-table tr {
    margin-bottom: 0.85rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow-sm);
  }

  .custom-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px dashed var(--border-glass);
    text-align: right;
  }

  .custom-table td:last-child {
    border-bottom: none;
    padding-top: 0.6rem;
    justify-content: flex-end;
  }

  .login-card {
    padding: 1.75rem 1.25rem;
  }
}

@media (max-width: 420px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .greeting-title {
    max-width: 140px;
  }
}

/* ==========================================================================
   LOGIN SCREEN & AUTHENTICATION STYLES
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  position: relative;
  overflow: hidden;
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, #a855f7 50%, var(--success) 100%);
}

.login-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-header .brand-icon-lg {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 24px var(--primary-glow);
}

.brand-logo-img-lg {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  object-fit: contain;
  background: #ffffff;
  padding: 6px;
  margin: 0 auto 1.25rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35), 0 0 20px var(--primary-glow);
  display: block;
  transition: var(--transition);
}

.brand-logo-img-lg:hover {
  transform: scale(1.04);
}

.login-header h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(to right, var(--text-primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-toggle-btn {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.password-toggle-btn:hover {
  color: var(--text-primary);
}

.login-helper-box {
  background: rgba(99, 102, 241, 0.08);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  font-size: 0.775rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.45;
}

.login-helper-box strong {
  color: var(--primary-light);
}

/* User Dropdown in Topbar */
.user-menu-container {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass-strong);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.user-profile-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary-light);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem 0;
  display: none;
  flex-direction: column;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.user-dropdown.show {
  display: flex;
}

.user-dropdown-header {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-glass);
}

.user-dropdown-header .user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.user-dropdown-header .user-role {
  font-size: 0.725rem;
  color: var(--primary-light);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1rem;
  font-size: 0.825rem;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.dropdown-item.danger {
  color: var(--danger-light);
}
.dropdown-item.danger:hover {
  background: var(--danger-bg);
}
