/* ============================================================
   Superior Pet Waste Removal — Back Office
   Design System: Nunito, friendly greens, pet brand warmth
   ============================================================ */

:root {
  /* Brand — greens */
  --color-primary:        #4caf6e;
  --color-primary-dark:   #2d7a4f;
  --color-primary-mid:    #3d9960;
  --color-primary-light:  #e8f7ee;

  /* Brand — accents */
  --color-sky:            #d0eeff;
  --color-sky-dark:       #78c4f5;
  --color-yellow:         #ffe066;
  --color-yellow-dark:    #f5c400;
  --color-orange:         #ff9a3c;
  --color-red:            #ff5a5a;
  --color-pink:           #ffb3c6;
  --color-purple:         #c9b8f5;

  /* Surfaces */
  --color-bg:             #f6fbf7;
  --color-surface:        #ffffff;
  --color-surface-2:      #f6fbf7;
  --color-surface-raised: #f0f9f3;
  --color-border:         #d4e8d8;
  --color-border-light:   #edf7f0;

  /* Text */
  --color-text:           #1e2d1f;
  --color-text-muted:     #4a5f50;   /* darkened from #5a7260 — WCAG AA 4.7:1 on white */
  --color-text-inverse:   #ffffff;

  /* Status */
  --color-status-scheduled:  #78c4f5;
  --color-status-completed:  #4caf6e;
  --color-status-inprogress: #ff9a3c;
  --color-status-cancelled:  #ff5a5a;
  --color-status-pending:    #f5c400;
  --color-status-draft:      #b0bec5;
  --color-status-paid:       #4caf6e;
  --color-status-sent:       #78c4f5;

  /* Semantic tint surfaces (used by badge + icon-button variants) */
  --color-warning:           #f59e0b;
  --color-warning-bg:        #fff3e0;
  --color-warning-text:      #bf4200;
  --color-warning-border:    #f9c06a;
  --color-danger-bg:         #fff0f0;
  --color-danger-text:       #c62828;
  --color-danger-border:     #f5b3b3;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Shape */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-card: 20px;
  --radius-pill: 50px;

  /* Elevation */
  --shadow-sm:  0 1px 3px rgba(30, 45, 31, 0.06);
  --shadow-md:  0 4px 16px rgba(30, 45, 31, 0.10);
  --shadow-lg:  0 8px 32px rgba(30, 45, 31, 0.14);
  --shadow-green: 0 6px 20px rgba(76, 175, 110, 0.35);

  /* Derived / theme-sensitive */
  --color-overlay:      rgba(30, 45, 31, 0.35);
  --color-backdrop:     rgba(30, 45, 31, 0.40);
  --color-focus-ring:   rgba(76, 175, 110, 0.15);
  --color-nav-shadow:   rgba(76, 175, 110, 0.30);
  --color-btn-glow:     rgba(76, 175, 110, 0.45);
  --color-row-stripe:   #fafcfb;
  --color-delta-down-bg: #fff0f0;

  /* Route map */
  --color-route-depot:      #1a4d2e;   /* depot/start pin — darker than stop pins */

  /* Motion */
  --ease-out:        cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast:   150ms;
  --duration-normal: 250ms;
  --duration-slow:   350ms;

  /* Accessibility */
  --touch-min: 44px;
  /* PWA safe area insets */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ── Glassmorphism tokens (research-optimized 2026-04-08) ── */
  --glass-bg:              rgba(255, 255, 255, 0.70);
  --glass-bg-strong:       rgba(246, 251, 247, 0.82);   /* green-tinted, not pure white */
  --glass-bg-sidebar:      rgba(246, 251, 247, 0.80);
  --glass-bg-kpi:          rgba(255, 255, 255, 0.65);   /* more transparent = more glass */
  --glass-bg-nav:          rgba(246, 251, 247, 0.78);
  --glass-bg-modal:        rgba(255, 255, 255, 0.72);
  --glass-border:          rgba(255, 255, 255, 0.65);
  --glass-border-subtle:   rgba(76, 175, 110, 0.15);
  --glass-border-nav:      rgba(0, 0, 0, 0.06);
  --glass-blur:            blur(16px) saturate(180%);
  --glass-blur-nav:        blur(20px) saturate(180%);
  --glass-blur-sidebar:    blur(24px) saturate(160%);
  --glass-blur-kpi:        blur(20px) saturate(180%);
  --glass-blur-modal:      blur(16px) saturate(160%);
  --glass-shadow:
    0 2px 0 rgba(255,255,255,0.9) inset,
    0 -1px 0 rgba(0,0,0,0.03) inset,
    0 4px 16px rgba(30, 80, 45, 0.08),
    0 12px 40px rgba(30, 80, 45, 0.06);
  --glass-shadow-raised:
    0 2px 0 rgba(255,255,255,0.85) inset,
    0 0 0 1px rgba(76, 175, 110, 0.12),
    0 12px 36px rgba(30, 80, 45, 0.14);
  --glass-shadow-kpi:
    0 2px 0 rgba(255,255,255,0.85) inset,
    0 8px 28px rgba(30, 80, 45, 0.10);
  --glass-shadow-nav:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 4px 12px rgba(30, 80, 45, 0.06);
  --glass-shadow-modal:
    0 2px 0 rgba(255,255,255,0.9) inset,
    0 20px 60px rgba(0, 0, 0, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.04);
  --glass-noise-opacity:   0.03;
  --glass-noise-svg:       url("data:image/svg+xml,%3Csvg viewBox='0 0 250 250' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --bg-gradient:
    radial-gradient(ellipse 80% 60% at 15% 15%, rgba(76, 175, 110, 0.10) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 85% 80%, rgba(120, 196, 245, 0.08) 0%, transparent 50%),
    linear-gradient(135deg, #e8f7ee 0%, #d4f0e2 35%, #c8ede0 60%, #d0eeff 100%);

  /* Layout */
  --sidebar-width:         240px;
  --sidebar-width-mobile:  0px;
  --header-height:         64px;
  --content-max:           1200px;

  /* Typography */
  --font-body:   'Nunito', sans-serif;
  --font-size-xs:   0.75rem;
  --font-size-sm:   0.875rem;
  --font-size-md:   1rem;
  --font-size-lg:   1.125rem;
  --font-size-xl:   1.375rem;
  --font-size-2xl:  1.75rem;
  --font-size-3xl:  2.25rem;
}

/* x-cloak — immediately after :root, no exceptions */
[x-cloak] { display: none !important; }

/* ============================================================
   BASE RESET
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  overscroll-behavior: none;
  /* -webkit-overflow-scrolling removed — deprecated since iOS 13, harms compositor layering */
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font-family: var(--font-body);
  font-size: var(--font-size-md);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  @keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

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

  @keyframes slideInRight {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
  }

  @keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-100%); }
    to   { opacity: 1; transform: translateX(0); }
  }

  @keyframes popIn {
    0%   { opacity: 0; transform: scale(0.92); }
    70%  { transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
  }

  @keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
  }

  .main-content {
    animation: fadeIn var(--duration-normal) var(--ease-out);
  }

  .kpi-card {
    animation: slideUp var(--duration-normal) var(--ease-out) both;
  }

  .kpi-card:nth-child(1) { animation-delay: 0ms; }
  .kpi-card:nth-child(2) { animation-delay: 60ms; }
  .kpi-card:nth-child(3) { animation-delay: 120ms; }
  .kpi-card:nth-child(4) { animation-delay: 180ms; }

  .modal-panel {
    animation: slideInRight var(--duration-slow) var(--ease-out);
  }

  .sidebar-mobile-open .sidebar {
    animation: slideInLeft var(--duration-normal) var(--ease-out);
  }
}

/* ============================================================
   LAYOUT — App Shell
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  background: var(--glass-bg-sidebar);
  -webkit-backdrop-filter: var(--glass-blur-sidebar);
  backdrop-filter: var(--glass-blur-sidebar);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 300;
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
  overflow: hidden;
  box-shadow: 2px 0 24px rgba(30, 80, 45, 0.06);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
  min-height: var(--header-height);
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-mid) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: var(--shadow-green), 0 1px 0 rgba(255,255,255,0.3) inset;
}

.sidebar-logo-text {
  font-weight: 900;
  font-size: var(--font-size-sm);
  color: var(--color-primary-dark);
  line-height: 1.2;
}

.sidebar-logo-text span {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow-y: auto;
  min-height: 0;
}

.nav-section-label {
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-3) var(--space-3) var(--space-2);
  margin-top: var(--space-2);
}

.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--font-size-xs);
  font-weight: 800;
  font-family: inherit;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-3) var(--space-3) var(--space-2);
  margin-top: var(--space-2);
  transition: color 0.15s ease;
}
.nav-section-toggle:hover { color: var(--color-text); }
.nav-section-chevron {
  font-size: 0.6rem;
  transition: transform 0.2s ease;
  opacity: 0.5;
}
.nav-section-chevron.open { transform: rotate(90deg); }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  min-height: var(--touch-min);
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-mid) 100%);
  color: var(--color-text-inverse);
  box-shadow: 0 4px 14px var(--color-nav-shadow), 0 1px 0 rgba(255,255,255,0.25) inset;
}

.nav-item.active .nav-icon {
  filter: none;
}

.nav-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: var(--font-size-xs);
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 22px;
  text-align: center;
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.25);
  color: var(--color-text-inverse);
}

.sidebar-footer {
  padding: var(--space-4) var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  min-height: var(--touch-min);
}

.sidebar-user:hover {
  background: var(--color-primary-light);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-mid));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-inverse);
  font-size: var(--font-size-sm);
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 299;
  backdrop-filter: blur(2px);
}

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  /* Subtle translucent wash so cards pop against the gradient bg */
  background: rgba(248, 251, 249, 0.15);
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  height: var(--header-height);
  background: var(--glass-bg-nav);
  -webkit-backdrop-filter: var(--glass-blur-nav);
  backdrop-filter: var(--glass-blur-nav);
  border-bottom: 1px solid var(--glass-border-nav);
  box-shadow: var(--glass-shadow-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: var(--space-4);
}

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--touch-min);
  height: var(--touch-min);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 22px;
  cursor: pointer;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-out);
}

.hamburger:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.breadcrumb-home {
  color: var(--color-primary-dark);
  font-weight: 800;
  white-space: nowrap;
}

.breadcrumb-sep {
  color: var(--color-border);
  font-size: var(--font-size-xs);
}

.breadcrumb-current {
  color: var(--color-text);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.header-greeting {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.header-greeting strong {
  color: var(--color-primary-dark);
}

.header-notif-btn {
  position: relative;
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 20px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.header-notif-btn:hover {
  background: var(--color-primary-light);
}

.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--color-red);
  border-radius: 50%;
  border: 2px solid var(--color-surface);
}

/* Notification dropdown transition */
.notif-enter        { transition: opacity 0.15s var(--ease-out), transform 0.15s var(--ease-out); }
.notif-enter-start  { opacity: 0; transform: translateY(-6px); }
.notif-enter-end    { opacity: 1; transform: translateY(0); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max);
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--font-size-2xl);
  font-weight: 900;
  color: var(--color-primary-dark);
  line-height: 1.15;
}

.page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
  margin-top: var(--space-1);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  min-height: var(--touch-min);
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 800;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-mid) 100%);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-green), 0 1px 0 rgba(255,255,255,0.2) inset;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-mid) 0%, var(--color-primary-dark) 100%);
  box-shadow: 0 8px 28px var(--color-btn-glow), 0 1px 0 rgba(255,255,255,0.2) inset;
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary-dark);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

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

.btn-danger {
  background: var(--color-red);
  color: var(--color-text-inverse);
}

.btn-danger:hover {
  background: #e04444;
  transform: translateY(-1px);
}

/* Ghost danger — outlined red, no fill. Used for destructive actions that
   shouldn't look as alarming as a filled .btn-danger (e.g. Pause). */
.btn-danger-ghost {
  background: none;
  color: var(--color-red);
  border-color: var(--color-red);
}

.btn-danger-ghost:hover {
  background: var(--color-danger-bg);
  transform: translateY(-1px);
}

/* Muted modifier — reduces visual weight further (e.g. irreversible Delete).
   Apply alongside .btn-danger-ghost: class="btn btn-sm btn-danger-ghost btn-muted" */
.btn-muted {
  opacity: 0.55;
}

.btn-muted:hover {
  opacity: 1;
}

.btn-sm {
  min-height: var(--touch-min);
  padding: 0 var(--space-4);
  font-size: var(--font-size-xs);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-icon {
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border-radius: var(--radius-md);
  font-size: 16px;
}

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.kpi-card {
  background: var(--glass-bg-kpi);
  -webkit-backdrop-filter: var(--glass-blur-kpi);
  backdrop-filter: var(--glass-blur-kpi);
  border-radius: var(--radius-card);
  padding: var(--space-5) var(--space-6);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow-kpi);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.kpi-card:hover {
  box-shadow: var(--glass-shadow-raised);
  transform: translateY(-3px);
}

/* Large gradient orb in top-right — vibrant and luminous */
.kpi-card::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  opacity: 0.22;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.kpi-card:hover::before {
  opacity: 0.32;
}

/* Shimmer line along the top */
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  opacity: 0.75;
  pointer-events: none;
}

.kpi-card.green::before { background: radial-gradient(circle, #4caf6e, #2d7a4f); }
.kpi-card.green::after  { background: linear-gradient(90deg, transparent, #4caf6e, transparent); }
.kpi-card.sky::before   { background: radial-gradient(circle, #78c4f5, #1565c0); }
.kpi-card.sky::after    { background: linear-gradient(90deg, transparent, #78c4f5, transparent); }
.kpi-card.yellow::before{ background: radial-gradient(circle, #ffe066, #f5c400); }
.kpi-card.yellow::after { background: linear-gradient(90deg, transparent, #f5c400, transparent); }
.kpi-card.red::before   { background: radial-gradient(circle, #ff5a5a, #c62828); }
.kpi-card.red::after    { background: linear-gradient(90deg, transparent, #ff5a5a, transparent); }

.kpi-icon {
  font-size: 28px;
  margin-bottom: var(--space-3);
  display: block;
}

.kpi-value {
  font-size: var(--font-size-3xl);
  font-weight: 900;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.kpi-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 700;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: 800;
  margin-top: var(--space-2);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.kpi-delta.up {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.kpi-delta.down {
  background: var(--color-delta-down-bg);
  color: var(--color-red);
}

.kpi-delta.neutral {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}

.section-title {
  font-size: var(--font-size-lg);
  font-weight: 900;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-title .section-emoji {
  font-size: 20px;
}

/* ============================================================
   CARD (generic)
   ============================================================ */
.card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-card);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  transition: box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.card:hover {
  box-shadow: var(--glass-shadow-raised);
  transform: translateY(-1px);
}

.card-body {
  padding: var(--space-5) var(--space-6);
}

.card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* List card spacing — !important ensures it wins over the * { margin: 0 } reset.
   Use this on each child card when the parent container uses x-show.
   Alpine's x-show overrides display:flex → block, silently killing CSS gap.
   Margin-bottom on the child is the safe alternative. (lesson 2026-04-08) */
.list-card-gap {
  margin-bottom: var(--space-3) !important;
}

/* ============================================================
   TEAM MEMBER CARD
   Used in settings.html → Team section. No inline styles needed.
   ============================================================ */

/* Outer card: strips default settings-card padding, keeps border-radius/glass */
.team-member-card {
  padding: 0;
  overflow: hidden;
}

/* Inner row: flex layout for avatar + info + actions */
.team-member-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  min-height: var(--touch-min);
}

/* Avatar circle — 40px, colour set via :style binding (admin vs tech) */
.team-member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--font-size-sm);
  color: var(--color-text-inverse);
  flex-shrink: 0;
}

/* Info column: name row + email/zone row */
.team-member-info {
  flex: 1;
  min-width: 0;
}

.team-member-name-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;   /* defensive: badge/username wrap below name if space is tight */
  overflow: hidden;
}

.team-member-name {
  font-weight: 800;
  font-size: var(--font-size-md);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.team-member-username {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: monospace;
  white-space: nowrap;
  flex-shrink: 0;
}

.team-member-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.team-member-meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  flex-wrap: nowrap;
  min-height: var(--font-size-lg);
  overflow: hidden;
}

.team-member-email {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Zone chips in the meta row */
.team-zone-chip {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-inverse);
  flex-shrink: 0;
  /* bg set via :style binding using zone.color */
}

/* Actions column — buttons wrap on narrow screens */
.team-member-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
}

/* Responsive stacking — 768px matches the primary layout breakpoint already
   used throughout this file. At this width the 4-button actions block (~330px)
   leaves no room for the info column, so we wrap actions to a second line.

   Technique: keep flex-direction:row + enable flex-wrap on the row.
   Avatar (40px, shrink:0) + info (flex:1) consume all available width on
   line 1 because info has flex:1 and min-width:0. Actions get width:100%
   so they are forced onto their own line 2, right-aligned for visual weight. */
@media (max-width: 768px) {
  .team-member-row {
    flex-wrap: wrap;
    align-items: center;
  }

  .team-member-info {
    /* flex:1 min-width:0 already set — ensures it fills line 1 after avatar */
  }

  /* Actions: pushed to line 2, full width, buttons right-aligned */
  .team-member-actions {
    width: 100%;
    flex-shrink: unset;
    justify-content: flex-end;
    min-height: var(--touch-min);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
  }
}

/* ============================================================
   TEAM ZONE LABEL
   ============================================================ */
.team-zone-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

/* ============================================================
   UPCOMING CLEANUP CARDS
   ============================================================ */
.cleanup-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 100%;
  overflow-x: hidden;
}

.cleanup-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
  cursor: pointer;
  max-width: 100%;
  overflow-x: hidden;
}

.cleanup-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(3px);
  border-color: var(--color-primary);
}

/* Inbox conversation card — extracted from .settings-card so the
   stacked inbox list doesn't compound glass blur/shadow the way it did
   when every conv used the shared settings glass panel class. Settings,
   messenger_settings and other settings pages keep .settings-card; only
   inbox.html references .conv-card (Fred feedback 2026-04-13). */
.conv-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.conv-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.cleanup-date-box {
  width: 52px;
  height: 56px;
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cleanup-date-day {
  font-size: var(--font-size-xl);
  font-weight: 900;
  color: var(--color-primary-dark);
  line-height: 1;
}

.cleanup-date-month {
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-primary-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cleanup-info {
  flex: 1;
  min-width: 0;
}

.cleanup-name {
  font-weight: 800;
  font-size: var(--font-size-md);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cleanup-address {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cleanup-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cleanup-time {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ============================================================
   ACTIVITY FEED
   ============================================================ */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
}

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

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.activity-icon.green  { background: var(--color-primary-light); }
.activity-icon.sky    { background: var(--color-sky); }
.activity-icon.yellow { background: var(--color-primary-light); }
.activity-icon.red    { background: var(--color-delta-down-bg); }

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.4;
}

.activity-text .activity-name {
  color: var(--color-primary-dark);
}

.activity-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  margin-top: 2px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-card);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.table-wrapper > table {
  min-width: max-content;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.55);
}

thead {
  background: rgba(255, 255, 255, 0.75);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  backdrop-filter: blur(12px) saturate(1.5);
  border-bottom: 2px solid var(--glass-border-subtle);
  position: sticky;
  top: 0;
  z-index: 2;
}

thead th {
  padding: var(--space-3) var(--space-5);
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--duration-fast) var(--ease-out);
  cursor: pointer;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:nth-child(even) {
  background: var(--color-row-stripe);
}

tbody tr:hover {
  background: var(--color-primary-light);
}

tbody td {
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  vertical-align: middle;
}

td.td-name {
  font-weight: 800;
}

.td-addr {
  max-width: 280px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

td.td-muted {
  color: var(--color-text-muted);
}

td.td-actions {
  white-space: nowrap;
}

td.td-mono, th.td-mono {
  font-family: monospace;
}

.table-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.table-action-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.table-action-btn.danger:hover {
  background: var(--color-delta-down-bg);
  color: var(--color-red);
}

/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 800;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.45);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-completed, .badge-paid, .badge-active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.badge-scheduled, .badge-sent {
  background: var(--color-sky);
  color: #1565c0;
}

.badge-inprogress {
  background: #fff3e0;
  color: #bf4200;   /* darkened from #e65100 — WCAG AA 5.3:1 on #fff3e0 */
}

.badge-pending, .badge-draft {
  background: #fff8d6;
  color: #7a5b00;   /* darkened from #9a7200 — WCAG AA 4.8:1 on #fff8d6 */
}

.badge-cancelled {
  background: #fff0f0;
  color: #c62828;
}

.badge-inactive {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.badge-secondary {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.badge-warning {
  background: #fff3e0;
  color: #bf4200;
}

.badge-red {
  background: #fff0f0;
  color: #c62828;
}

.badge-green {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.badge-sky {
  background: var(--color-sky);
  color: #1565c0;
}

/* form-input — alias for form-control (used across templates) */
.form-input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(76, 175, 110, 0.22);
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  outline: none;
  font-family: var(--font-body);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%235a7260' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 20px;
  padding-right: calc(var(--space-3) + 24px);
}

.form-input:focus {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 3px var(--color-focus-ring), 0 2px 8px rgba(76, 175, 110, 0.12);
}

/* ============================================================
   PAGE TABS — top-level section switcher (e.g. Inbox Conversations/Team)
   ============================================================ */
.page-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-5);
}

.page-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
  min-height: var(--touch-min);
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}

.page-tab:hover {
  color: var(--color-primary-dark);
  background: var(--color-primary-light);
}

.page-tab.active {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary);
}

.page-tab-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--color-red);
  color: var(--color-text-inverse);
  font-size: 9px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  color: var(--color-text-muted);
}

.search-input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0 var(--space-4) 0 calc(var(--space-4) + 22px);
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(76, 175, 110, 0.22);
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  outline: none;
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-input:focus {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 3px var(--color-focus-ring), 0 2px 8px rgba(76, 175, 110, 0.12);
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--color-text);
}

.form-label .required {
  color: var(--color-red);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(76, 175, 110, 0.22);
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  outline: none;
  font-family: var(--font-body);
}

.form-control::placeholder {
  color: var(--color-text-muted);
  font-weight: 600;
}

.form-control:focus {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 3px var(--color-focus-ring), 0 2px 8px rgba(76, 175, 110, 0.12);
}

textarea.form-control {
  min-height: 96px;
  padding: var(--space-3) var(--space-4);
  resize: vertical;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%235a7260' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 20px;
  padding-right: calc(var(--space-3) + 24px);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--color-red);
  font-weight: 700;
  margin-top: var(--space-1);
}

.form-control-error {
  border-color: var(--color-red) !important;
  box-shadow: 0 0 0 3px rgba(255, 90, 90, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ============================================================
   MODAL (slide-in from right)
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 45, 31, 0.30);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}

.modal-panel {
  width: 100%;
  max-width: 520px;
  background: var(--glass-bg-modal);
  -webkit-backdrop-filter: var(--glass-blur-modal);
  backdrop-filter: var(--glass-blur-modal);
  border-left: 1px solid var(--glass-border);
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: var(--glass-shadow-modal), -8px 0 48px rgba(30, 80, 45, 0.12);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  z-index: 1;
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 900;
  color: var(--color-primary-dark);
}

.modal-close {
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: background var(--duration-fast) var(--ease-out);
}

.modal-close:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.modal-body {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  position: sticky;
  bottom: 0;
}

/* ============================================================
   FILTER TABS
   ============================================================ */
.filter-tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 2px solid var(--color-border-light);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  padding-bottom: 0;
  /* -webkit-overflow-scrolling removed — deprecated since iOS 13, harms compositor layering */
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--color-text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
  min-height: var(--touch-min);
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.filter-tab:hover {
  color: var(--color-primary-dark);
  background: var(--color-primary-light);
}

.filter-tab.active {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary);
}

.filter-tab .tab-count {
  font-size: var(--font-size-xs);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-weight: 800;
}

.filter-tab.active .tab-count {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ============================================================
   CALENDAR — Weekly Grid
   ============================================================ */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.cal-week-label {
  font-size: var(--font-size-lg);
  font-weight: 900;
  color: var(--color-text);
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cal-nav-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all var(--duration-fast) var(--ease-out);
}

.cal-nav-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
}

.cal-today-btn {
  padding: 0 var(--space-4);
  min-height: var(--touch-min);
  font-size: var(--font-size-sm);
  font-weight: 800;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  overflow-x: auto;
}

.cal-day {
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.cal-day-header {
  text-align: center;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
}

.cal-day-name {
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cal-day-num {
  font-size: var(--font-size-xl);
  font-weight: 900;
  color: var(--color-text);
  line-height: 1.2;
}

.cal-day-header.today {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.cal-day-header.today .cal-day-name {
  color: rgba(255,255,255,0.85);
}

.cal-day-header.today .cal-day-num {
  color: var(--color-text-inverse);
}

.cal-day-slots {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 200px;
}

.booking-card {
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.booking-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.booking-card.status-completed {
  border-left-color: var(--color-primary);
  background: var(--color-primary-light);
}

.booking-card.status-scheduled {
  border-left-color: var(--color-sky-dark);
  background: var(--color-sky);
}

.booking-card.status-inprogress {
  border-left-color: var(--color-orange);
  background: var(--color-surface-raised);
}

.booking-card.status-cancelled {
  border-left-color: var(--color-red);
  background: var(--color-delta-down-bg);
  opacity: 0.75;
}

.booking-name {
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.booking-time {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.booking-service {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   HTMX INDICATORS
   ============================================================ */
.htmx-indicator {
  display: none;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 700;
}

.htmx-request .htmx-indicator {
  display: inline-flex;
}

.htmx-request.htmx-indicator {
  display: inline-flex;
}

@media (prefers-reduced-motion: no-preference) {
  .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
  }

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

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state-emoji {
  font-size: 48px;
  margin-bottom: var(--space-4);
}

.empty-state-title {
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.empty-state-text {
  font-size: var(--font-size-sm);
  font-weight: 600;
  max-width: 320px;
}

/* ============================================================
   TOAST / NOTIFICATION
   ============================================================ */
.toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-6);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--glass-shadow-raised);
  border-left: 4px solid var(--color-primary);
  font-size: var(--font-size-sm);
  font-weight: 700;
  pointer-events: auto;
  min-width: 280px;
  animation: slideUp var(--duration-normal) var(--ease-out) both;
}

.toast.success { border-left-color: var(--color-primary); background: #f0fbf4; }
.toast.warning { border-left-color: var(--color-yellow-dark); }

/* Error banners — persistent, dismissible, below header */
.error-banner-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-3));
  right: var(--space-6);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 420px;
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: #fff0f0;
  border: 1.5px solid var(--color-red);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: #c62828;
  animation: slideUp var(--duration-normal) var(--ease-out) both;
}

.error-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #c62828;
  min-height: var(--touch-min);
  min-width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-out);
}

.error-banner-close:hover { background: rgba(198, 40, 40, 0.08); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.68);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.pagination-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 700;
  padding: 0 var(--space-4);
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.pagination-btn:hover:not(:disabled) {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.pagination-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.pagination-info {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
  text-align: center;
  flex: 1;
}

/* ============================================================
   INVOICE TABLE EXTRAS
   ============================================================ */
.invoice-amount {
  font-weight: 900;
  font-size: var(--font-size-md);
  color: var(--color-text);
}

.invoice-number {
  font-weight: 800;
  color: var(--color-primary-dark);
  font-size: var(--font-size-sm);
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 900px) {
  /* Sidebar hides off-screen, revealed by hamburger */
  .sidebar {
    width: 200px;
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay {
    display: block;
  }

  .main-area {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
  }

  .header-greeting {
    display: none;
  }
}

@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  .main-content {
    padding: var(--space-4);
  }

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

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cal-grid {
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    padding-bottom: var(--space-4);
  }
}

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

  .modal-panel {
    max-width: 100%;
  }

  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    top: var(--space-4);
  }

  .toast {
    min-width: unset;
  }

  .error-banner-container {
    left: var(--space-4);
    right: var(--space-4);
    max-width: unset;
  }
}

/* ============================================================
   FOCUS RINGS — Accessibility
   ============================================================ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================================
   UTILITY
   ============================================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.divider {
  border: none;
  border-top: 1px solid var(--color-border-light);
  margin: var(--space-4) 0;
}

.text-muted  { color: var(--color-text-muted); }
.text-green  { color: var(--color-primary-dark); }
.text-right  { text-align: right; }
.flex-center { display: flex; align-items: center; justify-content: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 700;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

/* Dog count chip */
.dog-chip {
  background: var(--color-sky);
  color: #1565c0;
}

/* ============================================================
   VIEW TOGGLE (calendar/list switch)
   ============================================================ */
.view-toggle {
  display: inline-flex;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--color-surface);
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  min-height: var(--touch-min);
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.view-toggle-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.view-toggle-btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ============================================================
   WEEK NAVIGATION (calendar header row)
   ============================================================ */
.week-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.week-label {
  font-size: var(--font-size-lg);
  font-weight: 900;
  color: var(--color-text);
  flex: 1;
  min-width: 160px;
}

/* ============================================================
   CALENDAR — Today highlight on day column
   ============================================================ */
.cal-day.today .cal-day-header {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.cal-day.today .cal-day-name {
  color: rgba(255, 255, 255, 0.85);
}

.cal-day.today .cal-day-num,
.today-num {
  color: var(--color-text-inverse);
}

/* Empty calendar slot placeholder */
.cal-empty {
  flex: 1;
  min-height: 60px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-border-light);
  background: transparent;
}

/* booking-card sub-elements (alias for booking-name/time/service) */
.booking-card-time {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.booking-card-name {
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-text);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.booking-card-type {
  margin-top: 3px;
}

.badge-sm {
  padding: 2px 8px;
  font-size: 10px;
}

/* ============================================================
   DETAIL ROWS (booking detail modal)
   ============================================================ */
.detail-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
}

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

.detail-label {
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  width: 80px;
  flex-shrink: 0;
}

/* ============================================================
   THEME OVERRIDES
   ============================================================ */

/* Theme: brand — orange on warm white */
[data-theme="brand"] {
  --bg-gradient: linear-gradient(135deg, #fff3e8 0%, #ffe4d0 35%, #ffd8c0 60%, #ffe8d0 100%);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.90);
  --glass-bg-sidebar: rgba(255, 248, 240, 0.85);
  --glass-border: rgba(255, 200, 150, 0.50);
  --glass-border-subtle: rgba(255, 107, 0, 0.18);
  --glass-shadow: 0 8px 32px rgba(80, 40, 10, 0.10), 0 1px 0 rgba(255,255,255,0.6) inset;
  --glass-shadow-raised: 0 12px 40px rgba(80, 40, 10, 0.14), 0 1px 0 rgba(255,255,255,0.7) inset;
  --glass-shadow-kpi: 0 8px 28px rgba(80, 40, 10, 0.12);
  --color-primary:        #FF6B00;
  --color-primary-dark:   #CC5500;
  --color-primary-mid:    #E06000;
  --color-primary-light:  #FFF3E8;
  --color-bg:             #FEF9F4;
  --color-surface:        #ffffff;
  --color-surface-raised: #FFF5EB;
  --color-border:         #E8D5C4;
  --color-border-light:   #F5EDE4;
  --color-text:           #1a1a1a;
  --color-text-muted:     #6B5A4E;
  --color-overlay:        rgba(80, 40, 10, 0.30);
  --color-backdrop:       rgba(80, 40, 10, 0.40);
  --color-focus-ring:     rgba(255, 107, 0, 0.18);
  --color-nav-shadow:     rgba(255, 107, 0, 0.28);
  --color-btn-glow:       rgba(255, 107, 0, 0.40);
  --color-row-stripe:     #FFF8F2;
  --color-delta-down-bg:  #fff0f0;
  --shadow-green:         0 6px 20px rgba(255, 107, 0, 0.30);
}

/* Theme: bold — dark mode with orange primary */
[data-theme="bold"] {
  --bg-gradient: linear-gradient(135deg, #0a0a0a 0%, #111111 40%, #141820 70%, #0f1118 100%);
  --glass-bg: rgba(26, 26, 26, 0.80);
  --glass-bg-strong: rgba(30, 30, 30, 0.92);
  --glass-bg-sidebar: rgba(20, 20, 20, 0.88);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-border-subtle: rgba(255, 140, 0, 0.20);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255,255,255,0.04) inset;
  --glass-shadow-raised: 0 12px 40px rgba(0, 0, 0, 0.60), 0 1px 0 rgba(255,255,255,0.06) inset;
  --glass-shadow-kpi: 0 8px 28px rgba(0, 0, 0, 0.50);
  --color-primary:        #FF8C00;
  --color-primary-dark:   #CC7000;
  --color-primary-mid:    #E07D00;
  --color-primary-light:  #2a2218;
  --color-bg:             #0f0f0f;
  --color-surface:        #1a1a1a;
  --color-surface-raised: #222222;
  --color-border:         #333333;
  --color-border-light:   #2a2a2a;
  --color-text:           #f0f0f0;
  --color-text-muted:     #999999;
  --color-text-inverse:   #1a1a1a;
  --color-overlay:        rgba(0, 0, 0, 0.55);
  --color-backdrop:       rgba(0, 0, 0, 0.65);
  --color-focus-ring:     rgba(255, 140, 0, 0.25);
  --color-nav-shadow:     rgba(255, 140, 0, 0.30);
  --color-btn-glow:       rgba(255, 140, 0, 0.45);
  --color-row-stripe:     #1f1f1f;
  --color-delta-down-bg:  #2a1a1a;
  --shadow-green:         0 6px 20px rgba(255, 140, 0, 0.35);
  --shadow-sm:            0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow-md:            0 4px 16px rgba(0, 0, 0, 0.40);
  --shadow-lg:            0 8px 32px rgba(0, 0, 0, 0.55);
}

/* ============================================================
   THEME PICKER WIDGET
   ============================================================ */
.theme-picker {
  position: fixed;
  bottom: var(--space-6);
  left: var(--space-6);
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px) saturate(1.8);
  -webkit-backdrop-filter: blur(12px) saturate(1.8);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-3);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.14);
}

[data-theme="bold"] .theme-picker {
  background: rgba(30, 30, 30, 0.72);
  border-color: rgba(255, 255, 255, 0.10);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
}

.theme-picker-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.theme-picker-swatches {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.theme-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
  outline: none;
  flex-shrink: 0;
}

.theme-swatch:hover {
  transform: scale(1.18);
}

.theme-swatch.active {
  border-color: var(--color-text);
  transform: scale(1.12);
}

.theme-swatch[data-theme-target="default"] { background: #4caf6e; }
.theme-swatch[data-theme-target="brand"]   { background: #FF6B00; }
.theme-swatch[data-theme-target="bold"]    { background: #1a1a1a; border-color: #555; }

.detail-value {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text);
}

/* ============================================================
   FILTER TAB COUNTS (invoices page)
   ============================================================ */
.filter-tab-count {
  font-size: var(--font-size-xs);
  background: var(--color-bg);
  color: var(--color-text-muted);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-weight: 800;
}

.filter-tab.active .filter-tab-count {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.filter-tab-count.outstanding {
  background: #fff3e0;
  color: #e65100;
}

.filter-tab-count.paid {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

/* ============================================================
   FONT SIZE BASE ALIAS
   ============================================================ */
.font-size-base {
  font-size: var(--font-size-md);
}

/* ============================================================
   TODAY'S ROUTE
   ============================================================ */
.route-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.route-stop {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: var(--space-4) var(--space-5);
  transition: box-shadow var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}

.route-stop:hover {
  box-shadow: var(--glass-shadow-raised);
}

.route-stop-done {
  opacity: 0.55;
}

.route-stop-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 900;
  flex-shrink: 0;
  margin-top: 2px;
}

.route-stop-done .route-stop-num {
  background: var(--color-border);
  color: var(--color-text-muted);
}

.route-stop-info {
  flex: 1;
  min-width: 0;
}

.route-stop-name {
  font-size: var(--font-size-md);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.route-stop-gate {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}

.route-stop-address {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.route-stop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.route-stop-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-shrink: 0;
  align-items: flex-end;
}

.route-map-btn {
  white-space: nowrap;
}

.route-progress {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--glass-shadow);
}

.route-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.route-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width var(--duration-normal) var(--ease-out);
}

.route-progress-label {
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ============================================================
   MAP VIEW
   ============================================================ */

.map-container {
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.map-toolbar-title {
  font-size: var(--font-size-md);
  font-weight: 800;
  color: var(--color-text);
  flex: 1;
}

.route-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  border-bottom: 2px solid var(--color-border);
}

.route-tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
  margin-bottom: -2px;
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
}

.route-tab:hover {
  color: var(--color-text);
}

.route-tab.active {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary-dark);
}

.geocode-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.geocode-badge.missing {
  background: var(--color-yellow);
  color: #5a4000;
}

/* ============================================================
   SETTINGS PAGE
   ============================================================ */
.settings-section {
  margin-bottom: var(--space-10);
}

.settings-section-header {
  margin-bottom: var(--space-4);
}

.settings-section-title {
  font-size: var(--font-size-lg);
  font-weight: 900;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.settings-section-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
}

.settings-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  box-shadow: var(--glass-shadow);
}

/* ============================================================
   INTEGRATION CARDS
   ============================================================ */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.integration-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--glass-shadow);
  transition: box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.integration-card:hover {
  box-shadow: var(--glass-shadow-raised);
  transform: translateY(-1px);
}

.integration-card.connected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.integration-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-border);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  font-weight: 900;
  flex-shrink: 0;
}

.integration-logo.venmo  { background: #008CFF; }
.integration-logo.zelle  { background: #6B2D8B; }
.integration-logo.stripe { background: #635BFF; }
.integration-logo.square { background: #1a1a1a; }
.integration-logo.gcal   { background: #4285F4; }

.integration-info {
  flex: 1;
  min-width: 0;
}

.integration-name {
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 2px;
}

.integration-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  line-height: 1.4;
}

.integration-status {
  flex-shrink: 0;
}

/* ============================================================
   NOTIFICATION TOGGLES
   ============================================================ */
.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border-light);
  flex-wrap: wrap;
}

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

.notif-info {
  flex: 1;
  min-width: 200px;
}

.notif-title {
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 2px;
}

.notif-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
}

.notif-toggles {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  flex-shrink: 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
}

.toggle-input {
  display: none;
}

.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  position: relative;
  transition: background var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-text-inverse);
  top: 2px;
  left: 2px;
  transition: transform var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-sm);
}

.toggle-input:checked + .toggle-track {
  background: var(--color-primary);
}

.toggle-input:checked + .toggle-track::after {
  transform: translateX(16px);
}

/* ============================================================
   SPW TOGGLE — 2FA and other prominent settings toggles
   52×28 pill, always visible on mint-green and white surfaces
   ============================================================ */
.spw-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
}

.spw-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.spw-toggle-track {
  display: block;
  width: 52px;
  height: 28px;
  border-radius: 14px;
  background: #c8d8cc;
  border: 2px solid #a8bfae;
  position: relative;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.spw-toggle-track::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  top: 2px;
  left: 2px;
  transition: transform var(--duration-fast) var(--ease-out);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.spw-toggle.is-on .spw-toggle-track {
  background: var(--color-primary);
  border-color: var(--color-primary-dark);
}

.spw-toggle.is-on .spw-toggle-track::after {
  transform: translateX(24px);
}

.spw-toggle input[type="checkbox"]:focus-visible ~ .spw-toggle-track {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================================
   RESPONSIVE — Routes & Settings
   ============================================================ */
@media (max-width: 640px) {
  .route-stop {
    flex-wrap: wrap;
  }

  .route-stop-actions {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: flex-end;
  }

  .integrations-grid {
    grid-template-columns: 1fr;
  }

  .notif-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ─── Alert flash banners ──────────────────────────────────────────────────── */
.alert-success {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border: 1px solid var(--color-primary);
}

.alert-info {
  background: var(--color-sky);
  color: #1a5276;
  border: 1px solid var(--color-sky-dark);
}

.alert-error {
  background: #ffeaea;
  color: #8b0000;
  border: 1px solid var(--color-red);
}

/* ─── Dashboard two-column layout ──────────────────────────────────────────── */
.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

@media (max-width: 768px) {
  .dash-two-col {
    grid-template-columns: 1fr;
  }
}

/* ─── Integration meta text ────────────────────────────────────────────────── */
.integration-meta {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* ============================================================
   CHAT UI — iMessage-inspired, shared between inbox + tech
   ============================================================ */

/* ── Layout: split pane (inbox) ──────────────────────────────── */
.chat-layout {
  display: flex;
  height: calc(100vh - 240px);
  height: calc(100dvh - 240px);
  min-height: 420px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow-raised);
}

/* ── Sidebar: group/conversation list ────────────────────────── */
.chat-sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.chat-sidebar-header {
  padding: var(--space-4) var(--space-4) var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-sidebar-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-text);
}

.chat-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── Group list items ────────────────────────────────────────── */
.chat-group-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 64px;
  border-bottom: 1px solid var(--color-border-light);
  position: relative;
}

.chat-group-item:hover {
  background: rgba(76, 175, 110, 0.06);
}

.chat-group-item.active {
  background: var(--color-primary-light);
}

.chat-group-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

.chat-group-item.unread .chat-group-name {
  font-weight: 800;
}

.chat-group-item.unread .chat-group-preview {
  color: var(--color-text);
  font-weight: 600;
}

/* ── Avatars ─────────────────────────────────────────────────── */
.chat-av {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}

.chat-av-sm {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

.chat-av-dm   { background: var(--color-primary); }
.chat-av-team { background: var(--color-orange); }

/* ── Group item text ─────────────────────────────────────────── */
.chat-group-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-group-top {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.chat-group-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--color-text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-group-time {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.chat-group-preview {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* ── Unread badge ────────────────────────────────────────────── */
.chat-unread {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
}

/* ── Conversation pane ───────────────────────────────────────── */
.chat-conv {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-surface);
}

.chat-conv-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  min-height: 56px;
  background: var(--color-surface);
}

.chat-conv-header-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--color-text);
}

.chat-conv-header-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

.chat-conv-back {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  min-height: 44px;
  min-width: 44px;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 2;
}

/* ── Message area ────────────────────────────────────────────── */
.chat-msg-area {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background:
    radial-gradient(circle at 20% 80%, rgba(76,175,110,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(76,175,110,0.02) 0%, transparent 50%),
    var(--color-surface);
}

/* ── Empty / placeholder states ──────────────────────────────── */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-8);
  gap: var(--space-2);
}

.chat-empty-state-icon {
  font-size: 2.5rem;
  opacity: 0.5;
  margin-bottom: var(--space-2);
}

.chat-empty-state-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text);
}

.chat-empty-state-desc {
  font-size: 0.82rem;
  max-width: 240px;
  line-height: 1.5;
}

/* ── Date separator ──────────────────────────────────────────── */
.chat-date-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) 0;
  margin: var(--space-2) 0;
}

.chat-date-sep span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-muted);
  background: rgba(76,175,110,0.08);
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

/* ── Message rows ────────────────────────────────────────────── */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  animation: chatFadeIn 0.2s ease;
}

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

.chat-msg-sent { align-self: flex-end; align-items: flex-end; }
.chat-msg-recv { align-self: flex-start; align-items: flex-start; }

/* Tighter spacing for consecutive messages from same sender */
.chat-msg-grouped { margin-top: 1px; }

/* ── Sender label (group chats) ──────────────────────────────── */
.chat-msg-sender {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  padding: 0 var(--space-2);
  margin-bottom: 2px;
  margin-top: var(--space-2);
}

/* ── Bubbles ─────────────────────────────────────────────────── */
.chat-bub {
  padding: 8px 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
}

/* Sent (mine) — brand green */
.chat-bub-sent {
  background: var(--color-primary);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

/* Received (theirs) — soft surface */
.chat-bub-recv {
  background: var(--color-surface-raised);
  color: var(--color-text);
  border: 1px solid var(--color-border-light);
  border-radius: 18px 18px 18px 4px;
}

/* System messages */
.chat-bub-system {
  background: none;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-style: italic;
  text-align: center;
  align-self: center;
  max-width: 100%;
  padding: 4px 12px;
}

/* First in group — full round top corners */
.chat-bub-sent.first { border-radius: 18px 18px 4px 18px; }
.chat-bub-recv.first { border-radius: 18px 18px 18px 4px; }

/* Middle of group — small radius both sides */
.chat-bub-sent.mid { border-radius: 18px 4px 4px 18px; }
.chat-bub-recv.mid { border-radius: 4px 18px 18px 4px; }

/* Last in group — tail corner */
.chat-bub-sent.last { border-radius: 18px 4px 18px 18px; }
.chat-bub-recv.last { border-radius: 4px 18px 18px 18px; }

/* Solo message (not grouped) */
.chat-bub-sent.solo { border-radius: 18px 18px 4px 18px; }
.chat-bub-recv.solo { border-radius: 18px 18px 18px 4px; }

/* Deleted */
.chat-msg-deleted .chat-bub {
  opacity: 0.45;
  font-style: italic;
}

/* ── Message meta (time + delete) ────────────────────────────── */
.chat-msg-time {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  padding: 2px var(--space-2) 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-msg-sent .chat-msg-time { justify-content: flex-end; }

.chat-msg-del-btn {
  cursor: pointer;
  color: var(--color-red);
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 0.68rem;
  padding: 2px 4px;
  border-radius: 4px;
}

.chat-msg:hover .chat-msg-del-btn { opacity: 0.5; }
.chat-msg-del-btn:hover { opacity: 1 !important; background: rgba(255,90,90,0.08); }

/* ── Input bar ───────────────────────────────────────────────── */
.chat-input-bar {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
  background: var(--color-surface);
}

.chat-input-field {
  flex: 1;
  resize: none;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  border: 1.5px solid var(--color-border);
  border-radius: 22px;
  padding: 10px 16px;
  background: var(--color-surface);
  color: var(--color-text);
  max-height: 120px;
  transition: border-color 0.2s;
  outline: none;
}

.chat-input-field:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(76,175,110,0.12);
}

.chat-input-field::placeholder {
  color: var(--color-text-muted);
  opacity: 0.6;
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--color-primary-dark);
  transform: scale(1.05);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-send-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Arrow icon via CSS */
.chat-send-btn::after {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  border-right: 2.5px solid #fff;
  border-top: 2.5px solid #fff;
  transform: rotate(45deg) translateX(-1px);
}

/* ── New DM modal ────────────────────────────────────────────── */
.chat-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.chat-modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  width: min(360px, 90vw);
  box-shadow: var(--shadow-lg);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.chat-modal h3 {
  margin: 0 0 var(--space-4);
  font-size: 1rem;
  font-weight: 800;
}

.chat-dm-user {
  padding: var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: background 0.15s;
  min-height: 48px;
}

.chat-dm-user:hover {
  background: var(--color-primary-light);
}

.chat-dm-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  flex: 1;
}

.chat-dm-user-role {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* ── Bottom sheet (tech panel) ───────────────────────────────── */
.chat-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chat-sheet {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 600px;
  height: 75vh;
  height: 75dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.25);
  overflow: hidden;
}

.chat-sheet-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  min-height: 52px;
}

.chat-sheet-title {
  font-weight: 800;
  font-size: 1rem;
  flex: 1;
  color: var(--color-text);
}

.chat-sheet-back {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  min-height: 44px;
  min-width: 44px;
  color: var(--color-primary);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.chat-sheet-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color 0.15s;
}

.chat-sheet-close:hover { color: var(--color-text); }

/* ── Sheet group list items ──────────────────────────────────── */
.chat-sheet-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-light);
  min-height: 60px;
  transition: background 0.15s;
}

.chat-sheet-group:hover {
  background: rgba(76,175,110,0.06);
}

/* ── Sheet input ─────────────────────────────────────────────── */
.chat-sheet-input-bar {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-surface);
  align-items: flex-end;
}

/* ── Mobile responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .chat-layout {
    flex-direction: column;
    height: calc(100vh - 180px);
    height: calc(100dvh - 180px);
    border-radius: var(--radius-md);
  }

  .chat-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .chat-hidden-mobile { display: none !important; }
  .chat-conv-back { display: inline-flex; }
  .chat-msg { max-width: 85%; }

  .chat-conv-header {
    padding: var(--space-3) var(--space-4);
  }

  .chat-msg-area {
    padding: var(--space-3) var(--space-4);
  }

  /* When conversation is open on mobile, go full-screen fixed */
  .chat-layout-active {
    position: fixed;
    inset: 0;
    z-index: 50;
    height: 100dvh;
    border-radius: 0;
    border: none;
    padding-top: max(var(--space-4), env(safe-area-inset-top, 12px));
  }
}

/* ============================================================
   GLASS FALLBACKS & ACCESSIBILITY
   ============================================================ */

/* Mobile: KPI cards fall back to solid (save GPU) */
@media (max-width: 768px) {
  .kpi-card {
    background: var(--color-surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: var(--shadow-md);
  }
}

/* ============================================================
   START POINT PICKER — "Starting from" header control
   ============================================================ */
.start-point-picker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.start-point-picker-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.start-point-select {
  min-height: var(--touch-min);
  padding: 0 calc(var(--space-3) + 24px) 0 var(--space-4);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%235a7260' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 20px;
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-primary-dark);
  cursor: pointer;
  appearance: none;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  max-width: 180px;
}

.start-point-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* ============================================================
   START POINT MODAL ROW — row in the manage modal list
   ============================================================ */
.start-point-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  min-height: var(--touch-min);
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}

.start-point-row.is-default {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.start-point-row-info {
  flex: 1;
  min-width: 0;
}

.start-point-row-label {
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.start-point-row-address {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.start-point-row-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Browsers without backdrop-filter */
@supports not (backdrop-filter: blur(1px)) {
  .header, .kpi-card, .modal-panel, .sidebar, .toast {
    background: rgba(255, 255, 255, 0.92);
  }
}

/* Reduced transparency preference */
@media (prefers-reduced-transparency: reduce) {
  .header, .kpi-card, .modal-panel, .sidebar, .toast {
    background: var(--color-surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ============================================================
   GEOCODIO ADDRESS AUTOCOMPLETE
   ============================================================ */

.geocodio-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 500;
}

.geocodio-dropdown-item {
  padding: var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--duration-fast) var(--ease-out);
  min-height: var(--touch-min);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

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

.geocodio-dropdown-item:hover,
.geocodio-dropdown-item.is-selected {
  background: var(--color-primary-light);
}

.geocodio-dropdown-item-address {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  font-weight: 700;
}

.geocodio-dropdown-item-accuracy {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin-top: var(--space-1);
}

.geocodio-loading {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-style: italic;
}

.geocodio-warning {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-warning-bg);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  color: var(--color-text);
}

/* ============================================================
   Role-aware mobile action bar (PWA only, mobile only)
   Styles shared between tech.html (techs) and base.html (admins).
   ============================================================ */
.mobile-action-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #1e2d1f;
  border-top: 1px solid rgba(76, 175, 110, 0.25);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  padding: var(--space-2) var(--space-3) calc(var(--space-2) + env(safe-area-inset-bottom));
}

.mobile-action-bar-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: var(--space-4);
  max-width: 600px;
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.mab-btn {
  flex: 1;
  min-height: 52px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  position: relative;
}
.mab-btn:hover { color: rgba(255, 255, 255, 0.85); background: rgba(255,255,255,0.05); }
.mab-btn.active { color: var(--color-primary); }
.mab-btn.shift-active { color: var(--color-primary); }
.mab-btn:disabled { color: rgba(255, 255, 255, 0.25); cursor: not-allowed; }
.mab-btn-icon { font-size: 1.35rem; line-height: 1; }
.mab-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  background: var(--color-red);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Bar visible only when: mobile viewport + launched as PWA */
@media (max-width: 768px) {
  html.pwa-mode .header { min-height: calc(var(--header-height) + env(safe-area-inset-top)); height: auto; padding-top: env(safe-area-inset-top); }
  html.pwa-mode .mobile-action-bar { display: flex; }
  /* Keep main-area content above the bar */
  html.pwa-mode .main-area { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  /* Hide the header hamburger in PWA — the "More" tab now opens the drawer */
  html.pwa-mode .hamburger { display: none !important; }
  /* Push the notifications banner above the bar so it doesn't overlap */
  html.pwa-mode #push-banner { bottom: calc(88px + env(safe-area-inset-bottom)) !important; }
  html.pwa-mode .chat-layout-active {
    bottom: calc(72px + env(safe-area-inset-bottom));
    height: auto;
  }
}
