/* ==========================================================================
   Premium Warm Nordic Minimalist Stylesheet
   Roommate Rent & Utility Tracker (Fully Responsive Mobile + Desktop)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Harmonious Warm Nordic Palette */
  --bg-main: #f8f7f3;        /* Warm Alabaster/Cream background */
  --bg-card: #ffffff;        /* Crisp pure white card face */
  --bg-card-hover: #faf8f5;  /* Subtle warm hover */
  --border-light: #e5e2d9;   /* Organic clay border */
  --border-focus: #4e6551;   /* Soft Sage Green focus border */
  
  --primary: #4e6551;        /* Forest Sage primary brand color */
  --primary-hover: #3d5140;  /* Darker Sage for hover states */
  --primary-glow: #8fa89b;   /* Soft pastel Sage accent */
  --primary-gradient: linear-gradient(135deg, #4e6551, #627c66);
  
  --text-main: #27282a;      /* Charcoal black for comfortable reading */
  --text-muted: #6e7176;     /* Muted earth gray for metadata */
  --text-dark: #121314;      /* Deep black for headings */
  
  /* Harmonious Status Badges (Soft Pastel Contrast) */
  --status-paid: #356743;
  --status-paid-bg: #ecf3ee;
  --status-paid-border: rgba(53, 103, 67, 0.2);
  
  --status-pending: #a27233;
  --status-pending-bg: #faf4eb;
  --status-pending-border: rgba(162, 114, 51, 0.2);
  
  --status-late: #ad3d3d;
  --status-late-bg: #fdf3f3;
  --status-late-border: rgba(173, 61, 61, 0.2);
  
  /* Layout Consts */
  --nav-height: 76px;
  --border-radius-lg: 20px;
  --border-radius-md: 14px;
  --border-radius-sm: 8px;
  
  --font-main: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 8px 24px rgba(78, 101, 81, 0.05), 0 2px 8px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.04);
  --shadow-primary: 0 6px 20px rgba(78, 101, 81, 0.15);
  
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base resets & optimizations
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-main);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
}

/* ==========================================================================
   App Containers (Mobile First + Premium Responsive Desktop Grid)
   ========================================================================== */
.app-container {
  width: 100%;
  max-width: 480px; /* Mobile bounds by default */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--nav-height);
  position: relative;
  background: var(--bg-main);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 20px 12px;
  order: -2; /* Keeps header on top */
}

.app-main {
  flex: 1;
  padding: 12px 20px 32px;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Base Nordic Cards */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  transition: var(--transition-smooth);
}

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

/* Typography styles */
h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 16px;
  padding: 0 4px;
}

.section-title-bar h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* ==========================================================================
   Auth / Access Screen
   ========================================================================== */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  background: var(--bg-main);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 40px 28px;
  border-radius: 28px;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
}

.house-badge {
  width: 76px;
  height: 76px;
  background: var(--primary-gradient);
  color: white;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-primary);
}

.icon-house {
  width: 34px;
  height: 34px;
}

.address-subtext {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
  margin-bottom: 32px;
  font-weight: 500;
}

#pin-input {
  background: var(--bg-main);
  border: 2px solid var(--border-light);
  color: var(--text-dark);
  font-size: 2.2rem;
  letter-spacing: 0.8rem;
  text-align: center;
  padding: 12px;
  border-radius: var(--border-radius-md);
  width: 100%;
  font-family: inherit;
  font-weight: 700;
  outline: none;
  transition: var(--transition-smooth);
}

#pin-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 101, 81, 0.12);
  background: var(--bg-card);
}

.auth-helper {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 14px;
  margin-bottom: 28px;
  line-height: 1.4;
}

/* ==========================================================================
   Header Elements & Month Switcher
   ========================================================================== */
.header-address {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-main);
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.header-address:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-glow);
}

.icon-map {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

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

.role-badge {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.role-badge.admin-role {
  background: #ecf3ee;
  color: var(--primary);
  border-color: rgba(78, 101, 81, 0.2);
}

.month-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  margin: 8px 20px 20px;
  padding: 8px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  order: -2; /* Placed cleanly above tabs */
}

.month-selector .btn-icon {
  background: transparent;
  color: var(--text-main);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.month-selector .btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--primary);
}

.month-selector .btn-icon svg {
  width: 20px;
  height: 20px;
}

.current-month-display {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
}

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */
.btn {
  font-family: var(--font-main);
  font-weight: 600;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  padding: 14px 24px;
  font-size: 0.95rem;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 10px;
}

.btn-glass {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.btn-glass:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-glow);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-icon-only {
  background: var(--bg-card);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.btn-icon-only:hover {
  background: var(--bg-card-hover);
  color: var(--primary);
}

/* ==========================================================================
   KPI Summary Dashboard Section
   ========================================================================== */
.summary-deck {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.main-sum {
  display: flex;
  flex-direction: column;
  padding: 26px;
  background: var(--primary-gradient);
  color: #ffffff;
  border: none;
}

.main-sum .sum-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 6px;
}

.main-sum .sum-value {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffffff;
}

.sum-progress-bar {
  background: rgba(255, 255, 255, 0.2);
  height: 6px;
  border-radius: 3px;
  margin: 16px 0 8px;
  overflow: hidden;
}

.progress-fill {
  background: #ffffff;
  height: 100%;
  border-radius: 3px;
  box-shadow: 0 2px 10px rgba(255, 255, 255, 0.4);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-sum .sum-helper {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

.summary-duals {
  display: flex;
  gap: 12px;
}

.small-sum {
  flex: 1;
  margin-bottom: 0;
  padding: 18px;
}

.small-sum .sum-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sum-value-small {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-top: 4px;
}

.sum-value-small .per-person {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================================================
   Roommate Ledger List
   ========================================================================== */
.roommate-card {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  padding: 20px;
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.roommate-card:hover {
  box-shadow: var(--shadow-md);
}

.roommate-card.me-card {
  border-left: 4px solid var(--primary);
  background: var(--bg-card-hover);
}

.rm-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.rm-info-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rm-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.rm-lead-indicator {
  font-size: 0.7rem;
  background: #f0eae1;
  color: #8c765c;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.rm-math-breakdown {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.rm-pay-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.rm-due-number {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-dark);
}

.status-badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}

.status-badge.paid {
  color: var(--status-paid);
  background: var(--status-paid-bg);
  border-color: var(--status-paid-border);
}

.status-badge.pending {
  color: var(--status-pending);
  background: var(--status-pending-bg);
  border-color: var(--status-pending-border);
}

.status-badge.late {
  color: var(--status-late);
  background: var(--status-late-bg);
  border-color: var(--status-late-border);
}

.admin-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  width: 100%;
}

.admin-card-actions button {
  flex: 1;
}

.due-deadline-badge {
  background: #fdf3f3;
  border: 1px solid var(--status-late-border);
  color: var(--status-late);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ==========================================================================
   Add Utility Form & Bills List
   ========================================================================== */
.admin-only-section {
  border: 1.5px dashed var(--primary-glow);
  background: rgba(78, 101, 81, 0.02);
}

.admin-shield {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.utility-form, .config-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.utility-form select, 
.utility-form input,
.config-form input {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: 12px 16px;
  color: var(--text-dark);
  border-radius: 12px;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-sm);
}

.utility-form select:focus, 
.utility-form input:focus,
.config-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 101, 81, 0.1);
}

.bills-list-container {
  padding: 10px 18px;
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
}

.bill-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}

.bill-item:last-child {
  border-bottom: none;
}

.bill-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bill-main-line {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-dark);
}

.bill-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.bill-split-value {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bill-amount-text {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-dark);
}

.bill-split-part {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-delete {
  background: #fdf3f3;
  color: var(--status-late);
  border: 1px solid var(--status-late-border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-delete:hover {
  background: #fbe5e5;
}

.btn-delete svg {
  width: 14px;
  height: 14px;
}

.ledger-disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 16px;
  padding: 0 4px;
  font-weight: 500;
}

/* ==========================================================================
   Payment & Zelle Drawer View
   ========================================================================== */
.personal-invoice-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  padding: 18px 20px;
  border-radius: var(--border-radius-md);
  margin: 18px 0 24px;
  box-shadow: var(--shadow-sm);
}

.invoice-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inv-amount {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-dark);
}

.qr-switch-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.qr-switch-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.sliding-toggle-wrapper {
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  display: flex;
  padding: 4px;
}

.btn-toggle {
  flex: 1;
  padding: 12px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.btn-toggle.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-primary);
}

.qr-code-viewer {
  position: relative;
  min-height: 280px;
}

.qr-box {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qr-box.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.qr-frame {
  width: 190px;
  height: 190px;
  background: white;
  border-radius: var(--border-radius-md);
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid var(--border-light);
}

.svg-qr {
  width: 100%;
  height: 100%;
  color: var(--text-dark);
}

.hidden-img-placeholder {
  position: absolute;
  inset: 14px;
  width: calc(100% - 28px);
  height: calc(100% - 28px);
  object-fit: contain;
  background: white;
  z-index: 2;
}

.hidden-img-placeholder.hide-me {
  display: none !important;
}

.qr-details {
  text-align: center;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.qr-handle-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.qr-handle-value {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-dark);
  letter-spacing: 0.01em;
}

.zelle-inline-handle {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.instruction-card {
  line-height: 1.5;
}

.instruction-card h3 {
  margin-bottom: 12px;
}

.auto-pay-steps {
  list-style-position: inside;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-main);
}

.auto-pay-steps li::marker {
  color: var(--primary);
  font-weight: 700;
}

/* ==========================================================================
   Calendar & Settings Configurations
   ========================================================================== */
.calendar-card {
  text-align: center;
  padding: 36px 24px;
}

.calendar-hero-icon {
  font-size: 3.2rem;
  margin-bottom: 16px;
}

.calendar-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-top: 8px;
  margin-bottom: 24px;
  font-weight: 500;
}

.feed-copy-box {
  display: flex;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 6px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

#calendar-feed-url {
  background: transparent;
  border: none;
  color: var(--text-dark);
  flex: 1;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0 12px;
  outline: none;
  font-weight: 500;
}

.guide-tabs {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-top: 1px solid var(--border-light);
  padding-top: 24px;
}

.guide-section h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-dark);
}

.guide-section p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.settings-read-only {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.read-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 14px;
}

.read-group:last-child {
  border-bottom: none;
}

.read-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.read-value {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-dark);
}

.admin-unlock-block {
  margin-top: 30px;
  text-align: center;
  border-top: 1px dashed var(--border-light);
  padding-top: 24px;
}

.admin-unlock-block p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.form-divider {
  border: none;
  border-top: 1px dashed var(--border-light);
  margin: 12px 0;
}

/* ==========================================================================
   Tab Navigation & Transitions
   ========================================================================== */
.tab-view {
  display: none;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.app-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-light);
  display: flex;
  padding: 0 12px;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.02);
}

.nav-item {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-family: inherit;
}

.nav-icon {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.nav-item span {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active .nav-icon {
  color: var(--primary);
  stroke-width: 2.5;
}

.nav-item.active span {
  font-weight: 800;
}

/* ==========================================================================
   Toast Notification Overlay
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 40px);
  max-width: 330px;
}

.toast {
  background: #27282a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1), toastFadeOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastFadeOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-10px) scale(0.92); }
}

/* Modal and loaders */
.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  gap: 14px;
  font-weight: 500;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Dialog */
.prorate-modal-dialog {
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  margin: auto;
  outline: none;
  max-width: 370px;
  width: calc(100% - 32px);
  background: var(--bg-card);
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.prorate-modal-dialog::backdrop {
  background: rgba(18, 19, 20, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

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

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

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

.modal-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
  font-weight: 500;
}

.formula-box {
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.formula-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.form-lbl {
  color: var(--text-muted);
  font-weight: 500;
}

.form-val {
  font-weight: 700;
  color: var(--text-dark);
}

.formula-emphasis {
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
  margin-top: 2px;
}

.formula-accent .form-val {
  color: var(--primary);
  font-size: 1.1rem;
}

.modal-footer-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 24px;
  font-weight: 500;
}

/* ==========================================================================
   Desktop Responsive Overrides
   ========================================================================== */
@media (min-width: 769px) {
  /* Expand mobile bounds on Desktop */
  .app-container {
    max-width: 1040px;
    padding-bottom: 40px;
    height: auto;
    overflow: visible;
  }
  
  /* Place nav bar at the top instead of bottom floating */
  .app-nav {
    position: static;
    transform: none;
    width: auto;
    max-width: none;
    order: -1; /* Header first, then Nav bar, then Main content */
    height: 60px;
    border-top: none;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    margin-bottom: 24px;
    justify-content: flex-start;
    gap: 8px;
    padding: 0;
    box-shadow: none;
  }
  
  .nav-item {
    flex: none;
    padding: 0 24px;
    height: 100%;
    border-radius: 12px;
    flex-direction: row;
    gap: 8px;
    transition: var(--transition-smooth);
  }
  
  .nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--primary);
  }
  
  .nav-item.active {
    background: var(--bg-card);
    color: var(--primary);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
  }
  
  .nav-item.active .nav-icon {
    filter: none;
  }

  /* Two Column Dashboard Grid layout */
  #tab-dashboard {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 28px;
    align-items: start;
  }
  
  .summary-deck {
    grid-column: 2;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  .section-title-bar {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
  }
  
  #roommates-container {
    grid-column: 1;
    grid-row: 2;
  }
  
  /* Utilities Two Column Grid */
  #tab-bills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
  }
  
  #tab-bills .admin-only-section {
    grid-column: 1;
  }
  
  #tab-bills .glass-card:not(.admin-only-section) {
    grid-column: 2;
  }

  /* Pay tab layout styling */
  #tab-pay {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 28px;
    align-items: start;
  }
  
  #tab-pay .payment-action-card {
    grid-column: 1;
  }
  
  #tab-pay .instruction-card {
    grid-column: 2;
  }
  
  /* Settings grid layout */
  #tab-settings {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 28px;
    align-items: start;
  }
  
  #tab-settings .settings-view-card {
    grid-column: 1;
  }
  
  #tab-settings .admin-only-section {
    grid-column: 2;
  }
  
  #tab-settings .admin-unlock-block {
    grid-column: 1 / 3;
  }
}

/* ==========================================================================
   Mobile Phone Viewport Optimizations (Portrait Screen <= 480px)
   ========================================================================== */
@media (max-width: 480px) {
  /* Reduce excessive padding in the main container */
  .app-main {
    padding: 8px 12px 24px;
  }
  
  .app-header {
    padding: 18px 12px 8px;
  }
  
  .header-address {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  
  /* Month switcher compact */
  .month-selector {
    margin: 8px 12px 16px;
    padding: 6px;
  }
  
  .current-month-display {
    font-size: 1rem;
  }
  
  .month-selector .btn-icon {
    width: 34px;
    height: 34px;
  }
  
  /* Reduce card paddings to maximize available horizontal space */
  .glass-card {
    padding: 16px 14px;
    border-radius: var(--border-radius-md);
    margin-bottom: 16px;
  }
  
  .roommate-card {
    padding: 14px 12px;
    margin-bottom: 10px;
  }
  
  /* Utilities & Forms slim inputs */
  .utility-form select, 
  .utility-form input,
  .config-form input {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  
  .bills-list-container {
    padding: 8px 12px;
  }
  
  .bill-item {
    padding: 12px 0;
  }
  
  /* Pay / Zelle view fixes */
  .personal-invoice-strip {
    padding: 12px 14px;
    margin: 12px 0 16px;
  }
  
  .inv-amount {
    font-size: 1.45rem;
  }
  
  .sliding-toggle-wrapper {
    padding: 2px;
  }
  
  .btn-toggle {
    padding: 10px 6px;
    font-size: 0.8rem;
  }
  
  .qr-code-viewer {
    min-height: 270px;
  }
  
  .qr-frame {
    width: 170px;
    height: 170px;
    padding: 10px;
  }
  
  .qr-details {
    margin-top: 12px;
  }
  
  .btn {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
  
  .btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  
  /* Apple / Google Calendar instructions layout adjustments */
  .guide-tabs {
    padding-top: 16px;
    gap: 14px;
  }
  
  .guide-section p {
    font-size: 0.75rem;
  }
  
  /* Ensure the navigation bar strictly matches the container bounds */
  .app-nav {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
  }
}

