/* ============================================================
   StormShield CRM — Design System Stylesheet
   Single source of truth for all visual styling.
   ============================================================ */

/* --- CSS Variables --- */
:root {
  /* === DARK MODE COLOR SYSTEM === */

  /* Backgrounds — layered depth */
  --bg-deep:        #080E17;
  --bg-main:        #0C1520;
  --bg-card:        #111D2C;
  --bg-card-hover:  #152436;
  --bg-surface:     #162638;

  /* Legacy aliases (so existing templates don't break) */
  --navy:           #0D1B2A;
  --navy-light:     #1B2D45;
  --navy-dark:      #060F1A;
  --white:          #111D2C;
  --gray-50:        #0C1520;
  --gray-100:       #111D2C;
  --gray-200:       #162638;
  --gray-300:       #1E3348;
  --gray-500:       #6B7280;
  --gray-700:       #374151;
  --gray-900:       #F1F1EF;

  /* Surfaces — remapped for dark */
  --surface:        #111D2C;
  --surface-raised: #162638;
  --surface-sunken: #0C1520;
  --border:         rgba(255, 255, 255, 0.06);
  --border-strong:  rgba(255, 255, 255, 0.10);
  --border-lit:     rgba(255, 255, 255, 0.10);
  --border-hover:   rgba(255, 255, 255, 0.15);

  /* Brand */
  --amber:          #E8A020;
  --amber-light:    #F4C566;
  --amber-dark:     #C4851A;
  --amber-soft:     rgba(232, 160, 32, 0.15);
  --amber-glow:     rgba(232, 160, 32, 0.06);

  /* Text hierarchy */
  --text-primary:   #F1F1EF;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-tertiary:  rgba(255, 255, 255, 0.3);
  --text-on-navy:   #F1F1EF;
  --text-on-amber:  #080E17;
  --text-muted:     rgba(255, 255, 255, 0.55);

  /* Semantic colors */
  --green:          #34D399;
  --green-dim:      rgba(52, 211, 153, 0.12);
  --red:            #F87171;
  --red-dim:        rgba(248, 113, 113, 0.12);
  --blue:           #60A5FA;
  --blue-dim:       rgba(96, 165, 250, 0.12);
  --purple:         #A78BFA;
  --purple-dim:     rgba(167, 139, 250, 0.12);
  --orange:         #FB923C;
  --orange-dim:     rgba(251, 146, 60, 0.12);

  /* Status (legacy compat) */
  --success:        #34D399;
  --success-bg:     rgba(52, 211, 153, 0.12);
  --warning:        #FB923C;
  --warning-bg:     rgba(251, 146, 60, 0.12);
  --danger:         #F87171;
  --danger-bg:      rgba(248, 113, 113, 0.12);
  --info:           #60A5FA;
  --info-bg:        rgba(96, 165, 250, 0.12);

  /* Font stacks */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --font-display: 'Inter', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* Type scale */
  --text-xs:    0.75rem;
  --text-sm:    0.875rem;
  --text-base:  1rem;
  --text-lg:    1.125rem;
  --text-xl:    1.25rem;
  --text-2xl:   1.5rem;
  --text-3xl:   1.875rem;

  /* Spacing (4px grid) */
  --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;

  /* Touch */
  --touch-min: 44px;

  /* Radius */
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-full: 9999px;

  /* Shadows — subtle on dark bg */
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-xl:  0 10px 15px rgba(0, 0, 0, 0.5), 0 4px 6px rgba(0, 0, 0, 0.3);

  /* Sidebar */
  --sidebar-width: 180px;

  /* Bottom tabs */
  --bottom-tabs-height: 60px;
}

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

/* === DARK MODE GLOBAL === */
html, body {
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface-sunken);
  min-height: 100vh;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  font-weight: 600;
  color: var(--text-primary);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

ul, ol { list-style: none; }

table { border-collapse: collapse; width: 100%; }

/* --- Page transition --- */
.page-content {
  animation: pageFadeIn 200ms ease;
}
@keyframes pageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--amber);
  color: var(--text-on-amber);
  border-color: var(--amber-dark);
}
.btn-primary:hover { background: var(--amber-dark); }

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
  border-color: #DC2626;
}
.btn-danger:hover { background: #DC2626; }

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--gray-100);
  box-shadow: none;
  transform: none;
}

.btn-sm {
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.btn-icon {
  padding: var(--space-2);
  min-width: var(--touch-min);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow 150ms ease, transform 150ms ease;
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-3);
  font-size: var(--text-base); /* 16px prevents iOS zoom */
  color: var(--text-primary);
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(232, 160, 32, 0.2);
}

.form-input::placeholder { color: var(--gray-300); }

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-error .form-input,
.form-error .form-select {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-error-msg {
  font-size: var(--text-sm);
  color: var(--danger);
  margin-top: var(--space-1);
}

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

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table-header {
  background: var(--gray-50);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-header th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
}

.table-row {
  border-bottom: 1px solid var(--border);
  transition: background 100ms ease;
}

.table-row:nth-child(even) { background: var(--gray-50); }
.table-row:hover { background: var(--amber-light); background: rgba(232,160,32,0.08); cursor: pointer; }

.table-cell {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  vertical-align: middle;
}

/* Mobile: hide table, show cards */
@media (max-width: 768px) {
  .table-responsive { overflow-x: auto; }
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1;
}

.badge-success { background: var(--success-bg); color: #16A34A; }
.badge-warning { background: var(--warning-bg); color: #D97706; }
.badge-danger  { background: var(--danger-bg);  color: #DC2626; }
.badge-info    { background: var(--info-bg);    color: #2563EB; }
.badge-neutral { background: var(--gray-100);   color: var(--gray-700); }

/* ============================================================
   STAGE PIPELINE
   ============================================================ */
.stage-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: var(--space-3) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stage-dot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.stage-dot-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--gray-300);
  transition: all 150ms ease;
}

.stage-dot.completed .stage-dot-circle,
.stage-dot.done .stage-dot-circle {
  background: var(--success);
  border-color: var(--success);
  color: var(--white);
}

.stage-dot.current .stage-dot-circle,
.stage-dot.active .stage-dot-circle {
  background: var(--amber);
  border-color: var(--amber-dark);
  color: var(--text-on-amber);
  box-shadow: 0 0 0 4px rgba(232, 160, 32, 0.25);
}

.stage-dot-label {
  font-size: 10px;
  color: var(--gray-500);
  margin-top: var(--space-1);
  white-space: nowrap;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.stage-dot.current .stage-dot-label,
.stage-dot.active .stage-dot-label {
  color: var(--amber-dark);
  font-weight: 600;
}

.stage-line {
  width: 24px;
  height: 2px;
  background: var(--gray-300);
  flex-shrink: 0;
}

.stage-line.completed,
.stage-line.done { background: var(--success); }

@media (max-width: 480px) {
  .stage-dot-label {
    font-size: 8px;
    max-width: 50px;
  }
  .stage-line {
    width: 12px;
  }
  .stage-dot-circle {
    width: 22px;
    height: 22px;
    font-size: 10px;
  }
}

/* ============================================================
   NAVIGATION — SIDEBAR (Desktop)
   ============================================================ */
/* OLD .app-layout removed — see Design Overhaul section below */

/* OLD .sidebar removed — see Design Overhaul section below */

/* OLD .sidebar-logo removed */

/* OLD .sidebar-logo svg removed */

/* OLD .nav-sidebar removed */

/* OLD .nav-item removed — now .sidebar-item */


/* OLD .sidebar-footer removed */

/* OLD .main-content removed */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h1 {
  font-size: var(--text-xl);
}

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

/* ============================================================
   NAVIGATION — BOTTOM TABS (Mobile)
   ============================================================ */
.bottom-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-tabs-height);
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-tabs-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-1);
  color: var(--gray-500);
  font-size: 10px;
  font-weight: 500;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  text-decoration: none;
  transition: color 150ms ease;
}

.tab-item svg {
  width: 22px;
  height: 22px;
}

.tab-item-active {
  color: var(--amber-dark);
  font-weight: 600;
}

.top-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--navy);
  color: var(--text-on-navy);
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-header-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--amber);
}

/* ============================================================
   MOBILE LAYOUT
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { display: none; }

  /* Stack top-header above main-content instead of side-by-side */
  .app-layout {
    flex-direction: column;
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(var(--bottom-tabs-height) + env(safe-area-inset-bottom, 0) + var(--space-4));
  }

  .bottom-tabs { display: block; }
  .top-header { display: flex; }
  .page-header { display: none; }

  .page-body {
    padding: var(--space-4);
  }

  /* Force all inline 2-col and 3-col grids to stack on mobile.
     Targets inline style="display:grid;grid-template-columns:..."
     used in form layouts (New Job, Contact forms). */
  .page-body [style*="grid-template-columns: 2fr"],
  .page-body [style*="grid-template-columns: 1fr 1fr"],
  .page-body [style*="grid-template-columns:2fr"],
  .page-body [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Job detail overview grid (cards) */
  .page-body [style*="repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
  }

  /* Jobs filter bar: stack controls vertically */
  .page-body > div[style*="flex-wrap:wrap"],
  .page-body > div[style*="flex-wrap"] {
    flex-direction: column;
    gap: var(--space-3);
  }

  .page-body > div[style*="flex-wrap:wrap"] .form-input[style*="width:auto"],
  .page-body > div[style*="flex-wrap"] .form-input[style*="width:auto"],
  .page-body > div[style*="flex-wrap:wrap"] select.form-input,
  .page-body > div[style*="flex-wrap"] select.form-input {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Contacts page: stack header row (search + Add button) */
  .page-body > .flex.items-center {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .page-body > .flex.items-center form {
    max-width: 100%;
  }

  .page-body > .flex.items-center .btn {
    width: 100%;
    text-align: center;
    margin-left: 0 !important;
  }

  /* Body text: ensure readable size (>=16px) on mobile */
  .list-row,
  .activity-desc,
  .note-text,
  .card-body,
  .table-cell,
  .attention-card-title,
  .attention-card-sub {
    font-size: var(--text-base);
  }

  .hidden-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .hidden-desktop { display: none !important; }
}

/* ============================================================
   STAT CARDS (Dashboard KPIs)
   ============================================================ */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: all 150ms ease;
}

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

.stat-card.active {
  border-color: var(--amber);
  background: rgba(232, 160, 32, 0.04);
}

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.stat-card-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ============================================================
   PHOTO GRID
   ============================================================ */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-2);
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--gray-100);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-sync-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.photo-sync-pending {
  background: var(--gray-300);
  color: var(--white);
}

.photo-sync-uploading {
  background: var(--info);
  color: var(--white);
  animation: syncPulse 1.5s ease infinite;
}

.photo-sync-confirmed {
  background: var(--success);
  color: var(--white);
}

.photo-sync-failed {
  background: var(--danger);
  color: var(--white);
}

@keyframes syncPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   SEARCH INPUT
   ============================================================ */
.search-input-wrap {
  position: relative;
}

.search-input-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--gray-500);
  pointer-events: none;
}

.search-input {
  display: block;
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-3) var(--space-3) 40px;
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(232, 160, 32, 0.2);
}

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

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-4);
  color: var(--gray-300);
}

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

.empty-state-msg {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 360px;
  margin-bottom: var(--space-6);
}

/* ============================================================
   LOADING SKELETON
   ============================================================ */
.loading-skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonPulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 16px;
  margin-bottom: var(--space-2);
}

.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }

.skeleton-card {
  height: 120px;
  margin-bottom: var(--space-4);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: var(--text-sm);
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn 300ms ease, toastOut 300ms ease forwards;
  animation-delay: 0ms, 3500ms;
  min-width: 280px;
  max-width: 420px;
}

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

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(50px); }
}

.toast-success {
  background: var(--success);
  color: var(--white);
}

.toast-error {
  background: var(--danger);
  color: var(--white);
}

.toast-info {
  background: var(--info);
  color: var(--white);
}

@media (max-width: 768px) {
  .toast-container {
    top: auto;
    bottom: calc(var(--bottom-tabs-height) + var(--space-4));
    left: var(--space-4);
    right: var(--space-4);
  }
  .toast { min-width: 0; width: 100%; }
}

/* ============================================================
   TABS (Job Detail)
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  transition: all 150ms ease;
  text-decoration: none;
}

.tab:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.tab-active {
  color: var(--amber-dark);
  border-bottom-color: var(--amber);
  font-weight: 600;
}

/* ============================================================
   ATTENTION CARDS (Dashboard alerts)
   ============================================================ */
.attention-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all 150ms ease;
}

.attention-card:hover {
  border-left-color: var(--amber);
  box-shadow: var(--shadow-md);
}

.attention-card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.attention-card-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ============================================================
   ACTIVITY FEED
   ============================================================ */
.activity-feed {
  list-style: none;
}

.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

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

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.activity-body { flex: 1; }

.activity-desc {
  color: var(--text-primary);
  line-height: 1.4;
}

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

/* ============================================================
   JOB CARD (Pipeline items)
   ============================================================ */
.job-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: var(--shadow-sm);
}

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

.job-card-address {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.job-card-contact {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.job-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
}

.job-card-value {
  font-weight: 600;
  color: var(--text-primary);
}

.job-card-days {
  color: var(--text-secondary);
}

/* ============================================================
   PERMIT CARD
   ============================================================ */
.permit-card {
  background: var(--info-bg);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.permit-card-title {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--info);
  margin-bottom: var(--space-3);
}

.permit-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
  font-size: var(--text-sm);
}

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

.permit-label { color: var(--text-secondary); }
.permit-value { font-weight: 600; color: var(--text-primary); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
  padding: var(--space-4);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-8);
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-logo h1 {
  font-size: var(--text-2xl);
  color: var(--navy);
}

.login-logo .sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ============================================================
   CONTACT CARD (on job detail)
   ============================================================ */
.contact-info-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.contact-info-item {
  font-size: var(--text-sm);
}

.contact-info-label {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.contact-info-value {
  color: var(--text-primary);
  font-weight: 500;
}

.contact-info-value a {
  color: var(--info);
}

@media (max-width: 640px) {
  .contact-info-card { grid-template-columns: 1fr; }
}

/* ============================================================
   NOTES
   ============================================================ */
.notes-list {
  max-height: 400px;
  overflow-y: auto;
}

.note-item {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

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

.note-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.note-text {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ============================================================
   STAT GRID (Dashboard — used by route templates)
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
}

.stat-grid .stat-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-4);
  text-align: center;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
}

.stat-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ============================================================
   DATA TABLE (Jobs list desktop)
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--border);
  background: var(--gray-50);
  white-space: nowrap;
}

.data-table tbody td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
  background: rgba(232, 160, 32, 0.06);
}

/* ============================================================
   DETAIL GRID (Contact detail)
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

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

/* ============================================================
   CARD LIST / CARD LINK (Contacts, Jobs list)
   ============================================================ */
.card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.card-link {
  transition: box-shadow 150ms ease, border-color 150ms ease;
}

.card-link:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--amber);
  text-decoration: none;
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
}

/* ============================================================
   LIST ROW (Dashboard items, Activity items)
   ============================================================ */
.list-row {
  transition: background 100ms ease;
}

.list-row:hover {
  background: var(--gray-50);
}

/* ============================================================
   MOBILE — INLINE GRID OVERRIDES (375px-safe)
   ============================================================ */
@media (max-width: 480px) {
  /* Dashboard stat grid: 2 columns on small phones */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .stat-grid .stat-card {
    padding: var(--space-3);
  }

  .stat-value {
    font-size: var(--text-xl);
  }

  /* Job detail: cards grid must stack */
  .page-body [style*="repeat(auto-fit"] {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Job detail: inline 2-col detail grids (auto 1fr) must stack */
  .page-body [style*="grid-template-columns:auto 1fr"],
  .page-body [style*="grid-template-columns: auto 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Toast positioning above bottom tabs */
  .toast-container {
    left: var(--space-3);
    right: var(--space-3);
  }

  /* Reduce page body padding on very narrow screens */
  .page-body {
    padding: var(--space-3);
  }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm     { font-size: var(--text-sm); }
.text-xs     { font-size: var(--text-xs); }
.text-muted  { color: var(--text-secondary); }
.text-bold   { font-weight: 600; }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1   { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.w-full { width: 100%; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ================================================================
   Measurement Upload & Report Display
   ================================================================ */

.meas-upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.meas-upload-zone:hover, .meas-upload-zone-active {
  border-color: var(--amber);
  background: var(--warning-bg);
}
.meas-upload-icon { margin-bottom: var(--space-3); }
.meas-upload-text { font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); }
.meas-upload-hint { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-1); }

.meas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-3);
}
.meas-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.meas-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}
.meas-value {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.meas-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-2) var(--space-3);
}

.spinner {
  width: 20px; height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   Estimate Builder
   ================================================================ */

.est-section {
  margin-bottom: var(--space-4);
}
.est-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}
.est-section-header h3 {
  font-size: var(--text-lg);
  margin: 0;
  color: var(--text-primary);
}

.est-table {
  width: 100%;
}
.est-table th {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid var(--border);
}
.est-table td {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.est-inline-input {
  font-size: var(--text-base) !important;
  padding: var(--space-1) var(--space-2) !important;
}

.est-controls {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  align-items: end;
  margin: var(--space-4) 0;
  padding: var(--space-4);
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
}
.est-slider-group {
  flex: 1;
  min-width: 160px;
}
.est-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-strong);
  border-radius: 3px;
  outline: none;
  margin-top: var(--space-2);
}
.est-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  background: var(--amber);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.est-slider::-moz-range-thumb {
  width: 24px; height: 24px;
  background: var(--amber);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--white);
}

.est-totals {
  margin: var(--space-4) 0;
}
.est-totals-grid {
  max-width: 400px;
  margin-left: auto;
}
.est-totals-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: var(--text-base);
  color: var(--text-primary);
}
.est-totals-separator {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}
.est-totals-grand {
  border-top: 2px solid var(--navy);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--navy);
}

.est-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

/* Mobile estimate item cards */
.est-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.est-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.est-item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.est-item-card-name {
  font-weight: 600;
  font-size: var(--text-base);
}
.est-item-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: var(--space-2);
  align-items: center;
}
.est-item-card-field { display: flex; flex-direction: column; gap: 2px; }
.est-item-card-field label { font-size: var(--text-xs); color: var(--text-secondary); font-weight: 500; }
.est-item-card-total { font-weight: 600; }

@media (max-width: 640px) {
  .est-item-card-body {
    grid-template-columns: 1fr 1fr;
  }
  .est-controls {
    flex-direction: column;
  }
}

/* ================================================================
   Modal overlay
   ================================================================ */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: var(--text-lg); }
.modal-body {
  padding: var(--space-4);
}

/* Badge variants for confidence */
.badge-success { background: var(--success-bg); color: #166534; }
.badge-warning { background: var(--warning-bg); color: #92400E; }
.badge-danger { background: var(--danger-bg); color: #991B1B; }
.badge-neutral { background: var(--gray-100); color: var(--gray-700); }

/* ================================================================
   Proposal Preview & eSign Pages
   ================================================================ */

.proposal-preview,
.sign-proposal {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  max-width: 800px;
}

.proposal-header {
  text-align: center;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--navy);
}

.proposal-company {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--navy);
}

.proposal-license,
.proposal-contact {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.proposal-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.proposal-title-bar h2 {
  font-size: var(--text-xl);
  margin: 0;
  color: var(--navy);
}

.proposal-date {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.proposal-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  font-size: var(--text-base);
  line-height: 1.6;
}

.proposal-section {
  margin-bottom: var(--space-5);
}

.proposal-section h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 var(--space-2) 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.proposal-section p {
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
}

.proposal-category-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.proposal-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-3);
}

.proposal-table thead th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 1px solid var(--border);
}

.proposal-table tbody td {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}

.proposal-totals {
  margin-top: var(--space-4);
  border-top: 2px solid var(--border);
  padding-top: var(--space-3);
  max-width: 360px;
  margin-left: auto;
}

.proposal-total-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: var(--text-base);
}

.proposal-total-row span:last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.proposal-grand-total {
  border-top: 2px solid var(--navy);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  font-size: var(--text-lg);
  font-weight: 700;
}

.proposal-grand-total span:last-child {
  color: var(--navy);
}

.proposal-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  margin: var(--space-6) 0;
}

.proposal-sig-block {
  text-align: center;
}

.proposal-sig-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.proposal-sig-line {
  border-bottom: 1px solid var(--gray-700);
  margin-bottom: var(--space-2);
  height: 40px;
}

.proposal-sig-name {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.proposal-sig-date {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.proposal-footer {
  text-align: center;
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.proposal-footer p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-style: italic;
}

/* eSign form & accepted state */
.sign-form-section {
  margin-top: var(--space-6);
  padding: var(--space-5);
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  border: 2px solid var(--amber);
}

.sign-form-section h3 {
  font-size: var(--text-lg);
  color: var(--navy);
  margin: 0 0 var(--space-2) 0;
  border: none;
  padding: 0;
}

.sign-accepted {
  margin-top: var(--space-6);
  padding: var(--space-5);
  background: var(--success-bg);
  border-radius: var(--radius-md);
  border: 2px solid var(--success);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.sign-accepted-icon {
  font-size: 40px;
  color: var(--success);
  line-height: 1;
}

.sign-accepted-text {
  font-size: var(--text-base);
  line-height: 1.5;
}

/* ================================================================
   Mobile refinements for Phase 2 components (375px safe)
   ================================================================ */
@media (max-width: 640px) {
  .proposal-parties {
    grid-template-columns: 1fr;
  }
  .proposal-signatures {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .proposal-preview,
  .sign-proposal {
    padding: var(--space-4);
  }
  .proposal-table thead th,
  .proposal-table tbody td {
    padding: var(--space-1) var(--space-2);
  }
  .est-actions {
    flex-direction: column;
  }
  .est-actions .btn {
    width: 100%;
  }
  .modal-content {
    margin: var(--space-2);
  }
  .meas-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
   WEATHER CENTER — Phase 6 Design Polish
   ============================================================ */

/* --- Global design refinements --- */
.card {
  border-color: rgba(0,0,0,0.06);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}

.stat-card {
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

/* Tighter page header */
.page-header h1 {
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
}

/* --- Weather Center map container --- */
.wc-map-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 150ms ease, transform 150ms ease;
  background: var(--gray-100);
}
.wc-map-container #weather-map,
.wc-map-container #storm-detail-map {
  border-radius: var(--radius-lg);
}

/* Floating map controls */
.wc-map-controls {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.wc-map-controls .wc-ctrl-btn {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: all 150ms ease;
  color: var(--text-primary);
}
.wc-map-controls .wc-ctrl-btn:hover {
  background: var(--gray-50);
  box-shadow: var(--shadow-lg);
}
.wc-map-controls .wc-ctrl-btn.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

/* --- Weather Center layout (desktop: map left, panel right) --- */
.wc-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-4);
  min-height: 600px;
}

/* --- Storm timeline panel --- */
.wc-panel {
  display: flex;
  flex-direction: column;
  max-height: 700px;
}
.wc-panel-scroll {
  overflow-y: auto;
  flex: 1;
}

/* Storm list items */
.wc-storm-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 150ms ease;
  text-decoration: none;
  color: inherit;
}
.wc-storm-item:hover {
  background: rgba(232, 160, 32, 0.04);
  text-decoration: none;
}
.wc-storm-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.wc-storm-info {
  flex: 1;
  min-width: 0;
}
.wc-storm-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: 2px;
}
.wc-storm-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Activity feed */
.wc-feed-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.wc-feed-time {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  min-width: 54px;
}
.wc-feed-msg {
  color: var(--text-primary);
  line-height: 1.4;
}

/* Quick stats bar */
.wc-stats-bar {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.wc-stats-bar .wc-stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.wc-stats-bar .wc-stat-num {
  font-weight: 700;
  font-size: var(--text-lg);
}
.wc-stats-bar .wc-stat-label {
  opacity: 0.7;
  font-size: var(--text-xs);
}

/* Severity badge colors */
.severity-severe  { background: #FEE2E2; color: #DC2626; }
.severity-significant { background: #FEF3C7; color: #D97706; }
.severity-minor   { background: #DBEAFE; color: #2563EB; }
.severity-extreme { background: #FEE2E2; color: #991B1B; }
.severity-moderate { background: #FEF3C7; color: #B45309; }

/* Leaflet popup polish */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-xl) !important;
  padding: 0 !important;
}
.leaflet-popup-content {
  margin: var(--space-3) var(--space-4) !important;
  font-family: var(--font-sans) !important;
  font-size: var(--text-sm) !important;
  line-height: 1.5 !important;
}
.leaflet-popup-tip {
  box-shadow: var(--shadow-md) !important;
}

/* Lead cluster icons */
.lead-cluster-icon .lead-cluster {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-size: var(--text-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--white);
  box-shadow: var(--shadow-lg);
}

/* --- Mobile: full-screen map with slide-up panel --- */
@media (max-width: 768px) {
  .wc-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .wc-map-container #weather-map {
    height: 55vh !important;
  }
  .wc-panel {
    max-height: none;
  }
  .wc-stats-bar {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .wc-map-controls {
    top: var(--space-2);
    right: var(--space-2);
  }
}

@media (max-width: 480px) {
  .wc-map-container #weather-map {
    height: 45vh !important;
  }
}

/* Weather Center filter pill buttons */
.wc-quick-date {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-lit);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
}
.wc-quick-date:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}
.wc-quick-date.active {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber);
  font-weight: 600;
}

/* ===== DESIGN OVERHAUL: Layout Shell (Component Specs 1 & 2) ===== */

.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--gray-50, #F8FAFC);
}

.sidebar {
  width: 220px;
  background: var(--navy);
  color: var(--text-on-navy, rgba(255,255,255,0.85));
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  box-shadow: 4px 0 20px rgba(11, 22, 33, 0.15);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-brand-link {
  display: block;
  text-decoration: none;
}
.sidebar-logo {
  height: 36px;
  width: auto;
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}
.sidebar-item:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
}
.sidebar-item.active {
  color: var(--amber);
  background: rgba(232, 160, 32, 0.1);
  font-weight: 600;
}
.sidebar-item.active .sidebar-icon {
  filter: none;
}

.sidebar-item-subtle {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
}
.sidebar-item-subtle:hover {
  color: rgba(255, 255, 255, 0.7);
}

.sidebar-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-icon svg {
  stroke: currentColor;
}

.sidebar-label {
  white-space: nowrap;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 8px 12px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.sidebar-user {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}
.sidebar-signout {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  font-size: 0.8rem;
}
.sidebar-signout:hover {
  color: rgba(255, 255, 255, 0.7);
}

.main-content {
  flex: 1;
  margin-left: 220px;
  min-height: 100vh;
  background: var(--surface-sunken, var(--gray-50, #F8FAFC));
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Inter', system-ui, sans-serif;
  margin: 0;
}

.page-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.page-body {
  padding: 24px 32px;
}

/* Mobile more-menu */
.more-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 8999;
}
.more-menu {
  position: fixed;
  bottom: 72px;
  left: 0;
  right: 0;
  background: var(--surface, var(--white));
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  z-index: 9000;
  padding: var(--space-4, 16px);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}
.more-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
  padding: var(--space-3, 12px);
  text-decoration: none;
  color: var(--text-primary);
  font-size: var(--text-base, 1rem);
  min-height: 44px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.more-menu-item:hover {
  background: var(--gray-50, #F8FAFC);
}
.more-menu-item-danger {
  color: var(--danger);
}
.more-menu-divider {
  border-top: 1px solid var(--border);
  margin: var(--space-2, 8px) 0;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .page-header { padding: 16px 20px; }
  .page-body { padding: 16px 20px; padding-bottom: 80px; }
}

/* ===== DESIGN OVERHAUL: Component Specs 3-9 ===== */

/* Cards */
.card {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-md);
}
a.card:hover, .card[onclick]:hover, .card.card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.card-body {
  padding: 20px;
}
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--gray-50, #F8FAFC);
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-change {
  font-size: 0.8rem;
  margin-top: 4px;
  font-weight: 500;
}
.stat-change-up { color: var(--success); }
.stat-change-down { color: var(--danger); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  min-height: 44px;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1;
}
.btn-primary {
  background: var(--amber);
  color: var(--navy);
}
.btn-primary:hover {
  background: var(--amber-light, #F0B040);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(232, 160, 32, 0.3);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}
.btn-secondary {
  background: var(--white);
  color: var(--text-primary);
  border: 1px solid var(--border-strong, #CDD5DE);
}
.btn-secondary:hover {
  background: var(--gray-50, #F8FAFC);
  border-color: var(--gray-300, #D1D5DB);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--gray-100, #F1F5F9);
  color: var(--text-primary);
}
.btn-danger {
  background: var(--danger-bg, rgba(239, 68, 68, 0.08));
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
  background: var(--danger);
  color: var(--white);
}
.btn-sm { padding: 6px 14px; font-size: 0.8rem; min-height: 36px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}
.badge-success { background: rgba(34, 197, 94, 0.1); color: #16A34A; }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #D97706; }
.badge-danger  { background: rgba(239, 68, 68, 0.1); color: #DC2626; }
.badge-info    { background: rgba(59, 130, 246, 0.1); color: #2563EB; }
.badge-neutral { background: rgba(107, 125, 146, 0.1); color: #4B5563; }
.badge-severe  { background: rgba(245, 158, 11, 0.1); color: #D97706; }
.badge-extreme { background: rgba(239, 68, 68, 0.1); color: #DC2626; }
.badge-moderate { background: rgba(59, 130, 246, 0.1); color: #2563EB; }

/* Form Inputs */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border-strong, #CDD5DE);
  border-radius: 8px;
  background: var(--white);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
  box-sizing: border-box;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(232, 160, 32, 0.15);
  outline: none;
}
.form-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}
.form-error {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 4px;
}

/* Weather Stats Bar */
.weather-stats {
  display: flex;
  gap: 24px;
  padding: 12px 20px;
  background: var(--navy);
  border-radius: 10px;
  margin-bottom: 16px;
}
.weather-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.weather-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--amber);
}
.weather-stat-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

/* Storm Timeline Cards */
.storm-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.storm-card {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}
.storm-card:hover {
  border-color: var(--amber);
  box-shadow: 0 2px 12px rgba(232, 160, 32, 0.08);
  transform: translateY(-1px);
}
.storm-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.storm-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.storm-indicator-severe { background: #F59E0B; }
.storm-indicator-extreme { background: #EF4444; }
.storm-indicator-moderate { background: #3B82F6; }
.storm-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  flex: 1;
}
.storm-card-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-left: 16px;
}

/* Utility classes */
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-amber { color: var(--amber); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none; }
.bg-amber { background: var(--amber); }
.bg-amber-soft { background: var(--amber-soft, rgba(232, 160, 32, 0.08)); }

/* ===== Additional CSS for dashboard/jobs overhaul ===== */

/* Stat card accent borders */
.stat-card-accent-indigo { border-top: 3px solid #6366f1; }
.stat-card-accent-success { border-top: 3px solid #22c55e; }
.stat-card-accent-warning { border-top: 3px solid #f97316; }
.stat-card-accent-info { border-top: 3px solid #06b6d4; }

/* List row styles */
.list-row-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3, 12px);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}
.list-row-link:hover {
  background: var(--gray-50, #F8FAFC);
}
.list-row-bordered {
  border-bottom: 1px solid var(--border);
}
.list-row-bordered:last-child {
  border-bottom: none;
}

/* Text utilities */
.text-muted { color: var(--text-muted, var(--text-secondary)); }
.text-right { text-align: right; }

/* Spacing extras */
.mt-5 { margin-top: 20px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.p-0 { padding: 0; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.border-top { border-top: 1px solid var(--border); }

/* Flex extras */
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.min-w-200 { min-width: 200px; }
.items-start { align-items: flex-start; }

/* Form select auto-width */
.form-select-auto {
  width: auto;
  min-width: 140px;
}

/* Clickable table rows */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--gray-50, #F8FAFC); }

/* Card form container */
.card-form-container { max-width: 720px; margin: 0 auto; }

/* Storm indicator inline override (for dashboard mini indicators) */
.storm-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== Bulk cleanup: utility classes for inline style removal ===== */

/* Grid layouts */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3, 12px); }
.grid-2-1-1 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--space-3, 12px); }
@media (max-width: 768px) {
  .grid-2col, .grid-2-1-1 { grid-template-columns: 1fr; }
}

/* Section headings */
.section-heading { font-size: 1rem; font-weight: 600; margin: 0 0 12px 0; color: var(--text-primary); }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Form extras */
.form-checkbox { width: 20px; height: 20px; accent-color: var(--amber); }
.form-textarea-tall { min-height: 80px; }
.mb-0 { margin-bottom: 0; }

/* Search autocomplete */
.search-autocomplete { position: relative; margin-bottom: 12px; }
.dropdown-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface, var(--white));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.dropdown-results-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.dropdown-results-item:hover {
  background: var(--gray-50, #F8FAFC);
}

/* Text base */
.text-base { font-size: 1rem; }

/* ===== Job Detail page components ===== */

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab-nav-item {
  padding: 12px 16px;
  text-decoration: none;
  font-size: 1rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted, var(--text-secondary));
  transition: color 0.15s ease, border-color 0.15s ease;
  min-height: 44px;
}
.tab-nav-item:hover {
  color: var(--text-primary);
}
.tab-nav-item-active {
  border-bottom-color: var(--primary, var(--amber));
  color: var(--primary, var(--amber));
  font-weight: 600;
}

/* Detail grid (key-value pairs) */
.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  font-size: 1rem;
}
.detail-label {
  color: var(--text-muted, var(--text-secondary));
  font-weight: 500;
}

/* Detail overview grid */
.detail-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
@media (max-width: 768px) {
  .detail-overview-grid { grid-template-columns: 1fr; }
}

/* Note items */
.note-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.note-item:last-child {
  border-bottom: none;
}

/* Card header dark variant */
.card-header-dark {
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
}

/* Spacing extras */
.my-4 { margin-top: 16px; margin-bottom: 16px; }
.text-lg { font-size: 1.2em; }

/* ===== Third pass: remaining component CSS ===== */

/* Filter checkbox labels */
.filter-checkbox-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  cursor: pointer;
}

/* Form label extra-small */
.form-label-xs {
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

/* Weather map container */
.weather-map-container { height: 550px; border-radius: 8px; overflow: hidden; }

/* Date input */
.form-input-date { min-height: 36px; width: 140px; }

/* Card link reset */
.card-link-reset { text-decoration: none; color: inherit; }
.card-link-reset:hover { color: inherit; }

/* Flex extras */
.flex-shrink-0 { flex-shrink: 0; }
.flex-col { flex-direction: column; }
.flex-2 { flex: 2; }
.items-end { align-items: flex-end; }
.gap-1 { gap: 4px; }

/* Spacing extras */
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.mr-3 { margin-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }

/* Max-width */
.max-w-600 { max-width: 600px; }
.max-w-400 { max-width: 400px; }

/* Text secondary */
.text-secondary { color: var(--text-secondary); }

/* ===== Fourth pass: modals, empty states, detail labels ===== */

/* Empty/loading states */
.empty-state {
  padding: 16px;
  text-align: center;
  color: var(--text-muted, var(--text-secondary));
}

/* Modal system */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  width: 100%;
  max-width: 500px;
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl, 0 20px 60px rgba(0,0,0,0.15));
}
.modal-card-lg { max-width: 600px; max-height: 90vh; overflow-y: auto; }
.modal-card-sm { max-width: 450px; }

/* Justify end */
.justify-end { justify-content: flex-end; }

/* Checkbox card (opt-in style) */
.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 12px;
  background: var(--surface, var(--white));
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border);
  transition: background 0.15s ease;
}
.checkbox-card:hover {
  background: var(--gray-50, #F8FAFC);
}

/* ===== Login page enhancements ===== */

.login-logo-img {
  display: block;
  margin: 0 auto 8px;
  height: 56px;
  width: auto;
}

.alert {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  text-align: center;
}
.alert-danger {
  background: var(--danger-bg, rgba(239, 68, 68, 0.08));
  color: var(--danger);
}
.alert-success {
  background: rgba(34, 197, 94, 0.08);
  color: var(--success);
}

/* Text size extra-small */
.text-xs { font-size: 0.75rem; }

/* ===== Fifth pass: settings, integration items, misc ===== */

.settings-grid { display: grid; gap: 16px; max-width: 800px; }
.p-5 { padding: 20px; }
.grid { display: grid; }
.inline-block { display: inline-block; }

/* Integration items */
.integration-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  transition: background 0.15s ease;
}
.integration-item:hover {
  background: var(--gray-50, #F8FAFC);
}

/* Misc utilities */
.cursor-pointer { cursor: pointer; }
.m-0 { margin: 0; }
.min-w-120 { min-width: 120px; }
.overflow-x-auto { overflow-x: auto; }
.border-bottom { border-bottom: 1px solid var(--border); }
.section-title { margin: 0 0 12px 0; font-size: 1.125rem; font-weight: 600; }

/* ============================================================
   DARK MODE COMPONENT OVERRIDES
   These replace the previous light-mode component specs.
   ============================================================ */

/* === Layout Shell === */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-main);
}

.main-content {
  flex: 1;
  margin-left: 180px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-main);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  min-height: 54px;
  background: var(--bg-main);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  margin: 0;
}

.page-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

@media (max-width: 768px) {
  .sidebar { display: none !important; }
  .main-content { margin-left: 0; }
  .page-header { padding: 14px 16px; }
  .page-body { padding: 16px; padding-bottom: 80px; }
}

/* === Sidebar === */
.sidebar {
  width: 180px;
  background: var(--bg-deep);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}
.sidebar-brand-name span,
.sidebar-brand-name .brand-accent {
  color: var(--amber);
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.1s ease;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: visible;
}
.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}
.sidebar-item.active {
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 600;
}

.sidebar-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-icon svg { stroke: currentColor; }

.sidebar-label { white-space: nowrap; }

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 12px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

.sidebar-user-role {
  font-size: 10px;
  color: var(--text-tertiary);
}

.sidebar-signout {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-left: auto;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-signout:hover {
  color: var(--text-secondary);
}

/* === Search Box === */
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-lit);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-tertiary);
  width: 200px;
  cursor: text;
  transition: border-color 0.1s;
}
.search-box:focus-within {
  border-color: var(--amber);
}
.search-box-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  width: 100%;
  min-height: auto;
  padding: 0;
}
.search-box-input::placeholder {
  color: var(--text-tertiary);
}
.search-kbd {
  font-size: 9px;
  background: var(--bg-surface);
  border: 1px solid var(--border-lit);
  border-radius: 3px;
  padding: 0 5px;
  color: var(--text-tertiary);
  margin-left: auto;
  flex-shrink: 0;
}

/* === Cards (Dark) === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.card-header h3, .card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body { padding: 0; }

/* === Buttons (Dark) === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  min-width: fit-content;
  transition: all 0.1s ease;
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--amber);
  color: var(--bg-deep);
  font-weight: 700;
  font-size: 12px;
  border: none;
  padding: 8px 16px;
  letter-spacing: 0.2px;
}
.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  border: 1px solid var(--border-lit);
  padding: 7px 14px;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
}
.btn-danger:hover {
  background: var(--red);
  color: var(--bg-deep);
}

.btn-sm { padding: 6px 12px; font-size: 11px; }

/* === Badges (Dark) === */
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-dim);   color: var(--blue); }
.badge-amber  { background: var(--amber-soft);  color: var(--amber); }
.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-orange { background: var(--orange-dim); color: var(--orange); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-success { background: var(--green-dim); color: var(--green); }
.badge-warning { background: var(--orange-dim); color: var(--orange); }
.badge-danger  { background: var(--red-dim);    color: var(--red); }
.badge-info    { background: var(--blue-dim);   color: var(--blue); }
.badge-neutral { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }
.badge-id {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
}

/* === Forms (Dark) === */
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

.form-input, .form-select, .form-textarea,
input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], input[type="date"], input[type="password"],
select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-lit);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.15s ease;
  min-height: 44px;
  box-sizing: border-box;
}

.form-input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(232, 160, 32, 0.2);
}

.form-input::placeholder, input::placeholder, textarea::placeholder {
  color: var(--text-tertiary);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='rgba(255,255,255,0.4)' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* === Login (Dark) === */
.login-page {
  min-height: 100vh;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-lit);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 12px;
}
.login-logo .sub {
  color: var(--text-tertiary);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* === More menu (Dark) === */
.more-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 8999;
}
.more-menu {
  position: fixed;
  bottom: 72px;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  z-index: 9000;
  padding: 16px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}
.more-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 1rem;
  min-height: 44px;
  border-radius: 8px;
}
.more-menu-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.more-menu-item-danger { color: var(--red); }
.more-menu-divider {
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

/* === Tables (Dark) === */
.data-table {
  border-collapse: collapse;
}
.data-table th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
}
.data-table tr:hover td {
  background: var(--bg-card-hover);
}

/* === Bottom tabs (Dark) === */
.bottom-tabs {
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
}
.tab-item {
  color: var(--text-tertiary);
}
.tab-item-active {
  color: var(--amber);
}

/* === Top header mobile (Dark) === */
.top-header {
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

/* === Alert (Dark) === */
.alert {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  text-align: center;
}
.alert-danger {
  background: var(--red-dim);
  color: var(--red);
}

/* === Scrollbar (Dark) === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   Weather Center Phase 6 — Jobs layer, Mobile panel, Demo mode
   ============================================================ */

/* Job marker pins */
.wc-job-marker {
  background: transparent !important;
  border: none !important;
}
.wc-job-pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: var(--shadow-md);
}

/* Demo mode — wider map */
.wc-demo-mode {
  grid-template-columns: 1fr 300px;
}
@media (min-width: 769px) {
  .wc-demo-mode > div:first-child {
    flex: 3;
  }
}

/* Demo stat overlay on map */
.wc-demo-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 800;
  pointer-events: none;
  text-align: center;
}
.wc-demo-stat {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.7), 0 0 40px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 1.5s ease;
  margin-bottom: var(--space-2);
  line-height: 1.3;
}

/* Mobile slide-up panel */
.wc-mobile-panel {
  display: none;
}
@media (max-width: 768px) {
  .wc-desktop-panel {
    display: none !important;
  }
  .wc-mobile-panel {
    display: block;
    position: fixed;
    bottom: var(--bottom-tabs-height, 60px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    z-index: 1100;
    transition: height 300ms ease;
    overflow: hidden;
  }
  .wc-mobile-panel.wc-mobile-collapsed {
    height: 80px;
  }
  .wc-mobile-panel.wc-mobile-half {
    height: 45vh;
  }
  .wc-mobile-panel.wc-mobile-full {
    height: calc(100vh - var(--bottom-tabs-height, 60px) - 20px);
  }
  /* Default (no position class yet) = collapsed */
  .wc-mobile-panel:not(.wc-mobile-half):not(.wc-mobile-full) {
    height: 80px;
  }
  .wc-mobile-handle {
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 8px auto;
    cursor: grab;
  }
  .wc-mobile-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 var(--space-3);
    gap: 0;
  }
  .wc-mobile-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 150ms ease;
  }
  .wc-mobile-tab.active {
    color: var(--amber);
    border-bottom-color: var(--amber);
  }
  .wc-mobile-content {
    overflow-y: auto;
    max-height: calc(100% - 72px);
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   AGENT PORTAL — Table Wrap & Mobile Tweaks
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 480px) {
  /* Agent stat grids: force 2-col on small screens */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Tighter card body padding */
  .card-body {
    padding: var(--space-3);
  }
}

@media (max-width: 375px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
  .stat-grid .stat-card {
    padding: 0.6rem !important;
  }
  .stat-card-value, .stat-card .stat-value {
    font-size: 1.25rem !important;
  }
  .stat-card-label, .stat-card .stat-label {
    font-size: 0.7rem !important;
  }
  .data-table th, .data-table td {
    padding: 8px 6px;
    font-size: 0.8rem;
  }
  .page-body {
    padding: 0.75rem !important;
  }
}

/* ============================================================
   PHASE 7 — MOBILE FIELD-READY CSS
   Proactive fixes for real-phone testing.
   Design reference: ServiceTitan. Quality bar: "Field-ready."
   ============================================================ */

/* --- Global: prevent horizontal overflow on all devices --- */
html, body {
  overflow-x: hidden;
  width: 100%;
}

/* --- Minimum touch targets (Apple HIG: 44x44pt) --- */
.btn, .nav-link, .dropdown-item, [role="button"],
.tab-item, .sidebar-item, .more-menu-item {
  min-height: 44px;
}

/* --- Prevent iOS zoom on input focus (must be >= 16px) --- */
input, select, textarea {
  font-size: 16px;
}

/* --- Safe area insets for notched phones (iPhone X+) --- */
body {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-tabs {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* --- Disable pull-to-refresh interference on scrollable areas --- */
.main-content, .page-body, .scroll-container {
  overscroll-behavior: contain;
}

/* --- Form elements: consistent mobile sizing --- */
@media (max-width: 768px) {
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="password"], input[type="number"], input[type="search"],
  input[type="url"], input[type="date"], select, textarea {
    font-size: 16px !important;
    min-height: 44px;
    padding: 10px 12px;
  }

  /* Buttons: full-width on mobile for easy thumb access */
  .btn-primary, .btn-secondary {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Cards: tighter margins on mobile */
  .card {
    margin-bottom: var(--space-3);
  }

  /* Job list cards: ensure critical info visible without scroll */
  .list-row {
    padding: var(--space-3) var(--space-4);
    min-height: 56px;
    display: flex;
    align-items: center;
  }

  /* Page title on mobile: slightly smaller */
  .page-title {
    font-size: var(--text-lg);
  }

  /* More menu: ensure items are tap-friendly */
  .more-menu-item {
    padding: 14px 20px;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  /* Modal/overlay adjustments */
  .modal-content, .dropdown-menu {
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Tables: horizontal scroll wrapper */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(-1 * var(--space-4));
    padding: 0 var(--space-4);
  }

  /* Stage pipeline: horizontal scroll on mobile */
  .pipeline-stages {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: var(--space-2);
  }

  /* Fix: ensure page body doesn't hide behind bottom tabs */
  .page-body {
    padding-bottom: calc(var(--bottom-tabs-height, 60px) + env(safe-area-inset-bottom, 0) + 16px);
  }
}

/* --- 375px (iPhone SE) specific --- */
@media (max-width: 375px) {
  .page-body {
    padding: 8px !important;
    padding-bottom: calc(var(--bottom-tabs-height, 60px) + env(safe-area-inset-bottom, 0) + 16px) !important;
  }

  .card-header {
    padding: var(--space-3);
  }

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

  /* Bottom tabs: slightly smaller text */
  .tab-item {
    font-size: 10px;
  }

  /* More menu: full width, avoid overflow */
  .more-menu {
    left: 8px !important;
    right: 8px !important;
  }
}

/* --- Offline indicator --- */
.offline-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--amber);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.offline-indicator.visible {
  opacity: 1;
}
.offline-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}
.offline-indicator.syncing .dot {
  animation: offlinePulse 1.5s infinite;
}
@keyframes offlinePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Photo sync status indicators --- */
.photo-sync-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  z-index: 2;
}
.photo-sync-badge.synced {
  background: var(--success);
  color: #fff;
}
.photo-sync-badge.pending {
  background: var(--amber);
  color: #000;
}
.photo-sync-badge.uploading {
  background: var(--info);
  color: #fff;
  animation: offlinePulse 1.5s infinite;
}
.photo-sync-badge.failed {
  background: var(--danger);
  color: #fff;
}

/* --- Camera capture mode --- */
.camera-mode {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  z-index: 10000;
  display: flex;
  flex-direction: column;
}
.camera-mode-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.camera-mode-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.camera-mode-footer {
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}
.camera-thumbnail-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}
.camera-thumbnail-strip img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.camera-capture-btn {
  width: 100%;
  min-height: 56px;
  background: var(--amber);
  color: #000;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.camera-capture-btn:active {
  transform: scale(0.97);
}
.camera-category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
}
.camera-category-chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
  display: flex;
  align-items: center;
}
.camera-category-chip.active {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

/* --- Presentation mode (customer-facing, light theme) --- */
.presentation-mode {
  position: fixed;
  inset: 0;
  background: #FFFFFF;
  color: #111827;
  z-index: 10000;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.presentation-mode .pres-section {
  padding: 24px 20px;
  border-bottom: 1px solid #E5E7EB;
}
.presentation-mode .pres-section:last-child {
  border-bottom: none;
}
.presentation-mode .pres-header {
  text-align: center;
  padding: 40px 20px;
}
.presentation-mode .pres-title {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin: 12px 0 4px;
}
.presentation-mode .pres-subtitle {
  font-size: 15px;
  color: #6B7280;
}
.presentation-mode .pres-section-title {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 12px;
}
.presentation-mode .pres-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #F3F4F6;
  font-size: 15px;
}
.presentation-mode .pres-stat-label {
  color: #6B7280;
}
.presentation-mode .pres-stat-value {
  font-weight: 600;
  color: #111827;
}
.presentation-mode .pres-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.presentation-mode .pres-photo-grid img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 8px;
}
.presentation-mode .pres-exit-btn {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 24px auto;
  padding: 14px;
  background: #F3F4F6;
  color: #374151;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}

/* --- Photo status summary bar --- */
.photo-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.photo-status-bar .count {
  font-weight: 600;
  color: var(--text-primary);
}
.photo-status-bar .synced { color: var(--success); }
.photo-status-bar .pending { color: var(--amber); }
.photo-status-bar .failed { color: var(--danger); }

/* === Photo Sync Status Icons === */
.photo-sync-icon {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  z-index: 2;
}
.photo-sync-icon.synced {
  background: var(--success, #22C55E);
  color: #fff;
}
.photo-sync-icon.uploading {
  background: var(--info, #3B82F6);
  color: #fff;
  animation: pulse-sync 1.5s infinite;
}
.photo-sync-icon.pending {
  background: var(--amber, #E8A020);
  color: #fff;
}
.photo-sync-icon.failed {
  background: var(--danger, #EF4444);
  color: #fff;
  cursor: pointer;
}
@keyframes pulse-sync {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Photo sync summary bar */
.photo-sync-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface-raised, #fff);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--radius-md, 8px);
  font-size: 13px;
  color: var(--text-secondary, #6B7280);
  margin-bottom: 12px;
}
.photo-sync-bar .sync-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}
.photo-sync-bar .sync-stat .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.photo-sync-bar .dot-synced { background: var(--success, #22C55E); }
.photo-sync-bar .dot-pending { background: var(--amber, #E8A020); }
.photo-sync-bar .dot-failed { background: var(--danger, #EF4444); }

/* ============================================================
   PHASE 7 — MOBILE TEXT OVERFLOW FIXES
   Prevent long addresses, names, and values from breaking layout.
   ============================================================ */

/* Global word-break safety net for all cards and page body */
.card-body, .card-header, .page-body, .detail-grid, .list-row {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Job/contact addresses — truncate with ellipsis on single-line displays */
.job-address, .list-row-title, .contact-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Detail grid values — allow wrapping for long text */
.detail-grid span:not(.detail-label) {
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

/* Note items — prevent overflow */
.note-item {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Activity log entries */
.activity-item, .activity-description {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Storm context card text */
#storm-context-body {
  overflow-wrap: break-word;
  word-break: break-word;
}

@media (max-width: 768px) {
  /* Job list: ensure address text doesn't overflow card boundaries */
  .list-row-title {
    font-size: 15px;
    max-width: calc(100vw - 80px);
  }

  /* Detail grid: stack label/value vertically on narrow screens */
  .detail-grid {
    grid-template-columns: 1fr !important;
    gap: 4px !important;
  }
  .detail-grid .detail-label {
    margin-bottom: 0;
  }

  /* Stage badge text — prevent wrapping */
  .stage-badge, .badge {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  /* Table cells — allow wrapping */
  .data-table td {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* Presentation mode button — full width on mobile */
  a[href$="/present"] {
    width: 100%;
    text-align: center;
    margin-left: 0 !important;
    margin-top: 8px;
  }
}

/* Photo recovery banner */
.photo-recovery-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--info-bg, #EFF6FF);
  border: 1px solid var(--info, #3B82F6);
  border-radius: var(--radius-md, 8px);
  color: var(--info, #3B82F6);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}
.photo-recovery-banner .dismiss-btn {
  background: none;
  border: none;
  color: var(--info, #3B82F6);
  cursor: pointer;
  font-size: 18px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Storage low warning */
.storage-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--warning-bg, #FFFBEB);
  border: 1px solid var(--warning, #F59E0B);
  border-radius: var(--radius-md, 8px);
  color: var(--warning, #F59E0B);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}
