/* CFCRM - Mobile-first CSS. Speed over style. */

:root {
  --primary: #ed8b68;
  --primary-dark: #d2846b;
  --bg: #121212;
  --bg-card: #1e1e1e;
  --bg-input: #2a2a2a;
  --text: #e8e8df;
  --text-muted: #9a9a92;
  --border: #3a3a3a;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--primary); white-space: nowrap; }
.nav-links { display: flex; gap: 0.25rem; overflow-x: auto; }
.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
.nav-links a.active, .nav-links a:hover { color: var(--text); background: var(--bg-input); }
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

/* App container */
.app {
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  max-width: 800px;
  margin: 0 auto;
}

/* Loading spinner */
.loading { display: flex; justify-content: center; padding: 3rem; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.card-title { font-weight: 600; margin-bottom: 0.5rem; }

/* Forms */
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px; /* Prevents iOS zoom on focus */
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }

/* Date inputs - prevent overflow on mobile */
input[type="date"] {
  max-width: 100%;
  min-width: 0;
}

/* Recurring options container */
#est-recurring-options {
  padding: 0.75rem;
}

/* Less padding on small screens to prevent date input overflow */
@media (max-width: 600px) {
  #est-recurring-options {
    padding: 0.5rem;
  }
  #est-recurring-options input[type="date"] {
    font-size: 15px;
    padding: 0.5rem 0.6rem;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn + .btn { margin-left: 0.5rem; }

/* Lists */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.list-item:hover { border-color: var(--primary); }
.list-item-title { font-weight: 500; }
.list-item-sub { font-size: 0.8rem; color: var(--text-muted); }

/* Search */
.search-bar {
  position: relative;
  margin-bottom: 1rem;
}
.search-bar input { padding-left: 0.75rem; }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}
.page-title { font-size: 1.3rem; font-weight: 700; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(237,139,104,0.15); color: var(--primary); }

/* Toast */
.toast-container { position: fixed; bottom: 1rem; right: 1rem; z-index: 999; }
.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-top: 0.5rem;
  font-size: 0.85rem;
  animation: slideIn 0.2s ease;
}
.toast-success { background: var(--success); color: #000; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Offline bar */
.offline-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.4rem;
  padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
  background: var(--warning);
  color: #000;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 998;
}

/* Login page */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
  padding: 2rem;
}
.login-box {
  width: 100%;
  max-width: 360px;
}
.login-title { font-size: 2rem; font-weight: 800; color: var(--primary); text-align: center; margin-bottom: 0.5rem; }
.login-subtitle { color: var(--text-muted); text-align: center; margin-bottom: 2rem; font-size: 0.9rem; }
.login-divider {
  display: flex;
  align-items: center;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.login-divider span { padding: 0 0.75rem; }

/* Tabs - scrollable on mobile */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Utility */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }

/* ---- Schedule View ---- */
.sched-customer-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(237,139,104,0.1);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  gap: 0.5rem;
}
.sched-week { display: flex; flex-direction: column; gap: 0.5rem; }
.sched-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.sched-day-today { border-color: var(--primary); }
.sched-day-holiday { opacity: 0.5; }
.sched-day-weekend { opacity: 0.5; }
.sched-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}
.sched-day-label { font-weight: 600; font-size: 0.9rem; }
.sched-day-stats { display: flex; gap: 0.35rem; }
.sched-timeline { display: flex; flex-direction: column; }
.sched-slot {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
  min-height: 44px;
}
.sched-slot:last-child { border-bottom: none; }
.sched-slot-time {
  font-weight: 600;
  font-size: 0.8rem;
  min-width: 70px;
  color: var(--text-muted);
}
.sched-slot-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  flex: 1;
  font-size: 0.8rem;
  min-width: 0;
}
.sched-slot-booked { background: rgba(237,139,104,0.05); }
.sched-slot-booked .sched-slot-time { color: var(--primary); }
.sched-slot-best-match {
  border-left: 3px solid #ffd700 !important;
  background: rgba(255,215,0,0.08) !important;
}
.sched-slot-best-match:hover {
  background: rgba(255,215,0,0.15) !important;
}
.sched-slot-status-scheduled { border-left: 3px solid var(--success); }
.sched-slot-status-completed { border-left: 3px solid var(--text-muted); background: rgba(0,0,0,0.02); }
.sched-slot-status-requested { border-left: 3px solid var(--warning); background: rgba(245,158,11,0.06); }
.sched-slot-status-reschedule_requested { border-left: 3px solid #f97316; background: rgba(249,115,22,0.06); }
.sched-slot-status-in_progress { border-left: 3px solid var(--info, #3b82f6); background: rgba(59,130,246,0.05); }
.sched-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.25rem;
  flex-shrink: 0;
}
.sched-status-dot-scheduled { background: var(--success); }
.sched-status-dot-completed { background: var(--text-muted); }
.sched-status-dot-requested { background: var(--warning); }
.sched-status-dot-reschedule_requested { background: #f97316; }
.sched-status-dot-in_progress { background: var(--info, #3b82f6); }
.sched-appt-detail { margin: 0.25rem 0; padding: 0.6rem; border-left: 3px solid var(--primary); font-size: 0.85rem; }
.sched-appt-detail a.sched-action-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
}
.sched-appt-detail a.sched-action-link:active { background: var(--bg-input); }
.sched-slot-customer { font-weight: 500; color: var(--text); }
.sched-slot-area {
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}
.sched-slot-avail { color: var(--success); font-weight: 500; }
.sched-slot-bookable { cursor: pointer; }
.sched-slot-bookable:hover { background: rgba(34,197,94,0.08); }
.sched-slot-book-btn { margin-left: auto; cursor: pointer; }
.sched-proximity {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}
.sched-drive {
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 500;
}
.sched-drive-great { background: rgba(34,197,94,0.15); color: var(--success); }
.sched-drive-good { background: rgba(34,197,94,0.1); color: #6dd89e; }
.sched-drive-ok { background: rgba(245,158,11,0.15); color: var(--warning); }
.sched-drive-far { background: rgba(239,68,68,0.15); color: var(--danger); }
.sched-best-match {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  background: rgba(255,215,0,0.2);
  color: #ffd700;
  border: 1px solid rgba(255,215,0,0.4);
}
.sched-day-areas {
  display: flex;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.sched-area-tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  background: var(--bg-input);
  color: var(--text-muted);
  border-radius: 4px;
}
.sched-sort-toggle {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sched-sort-toggle .btn {
  flex: 1;
  font-size: 0.8rem;
}
.sched-quick-picks {
  margin-bottom: 1rem;
}
.sched-quick-pick {
  padding: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.sched-quick-pick:hover {
  background: rgba(255,215,0,0.1);
  border-color: #ffd700;
}
@keyframes highlight-slot {
  0% { background: rgba(255,215,0,0.3); }
  100% { background: transparent; }
}
.sched-history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.sched-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.sched-history-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.sched-efficiency-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.sched-efficiency-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.sched-efficiency-item {
  text-align: center;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1.5px solid;
}
.sched-efficiency-great {
  background: rgba(34,197,94,0.1);
  border-color: var(--success);
}
.sched-efficiency-good {
  background: rgba(34,197,94,0.05);
  border-color: #6dd89e;
}
.sched-efficiency-ok {
  background: rgba(245,158,11,0.1);
  border-color: var(--warning);
}
.sched-efficiency-far {
  background: rgba(239,68,68,0.1);
  border-color: var(--danger);
}
.sched-efficiency-count {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}
.sched-efficiency-great .sched-efficiency-count { color: var(--success); }
.sched-efficiency-good .sched-efficiency-count { color: #6dd89e; }
.sched-efficiency-ok .sched-efficiency-count { color: var(--warning); }
.sched-efficiency-far .sched-efficiency-count { color: var(--danger); }
.sched-efficiency-label {
  font-size: 0.65rem;
  margin-top: 0.25rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Mobile: stack efficiency grid */
@media (max-width: 640px) {
  .sched-efficiency-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Google Places Autocomplete dropdown styling */
.pac-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  z-index: 9999;
}
.pac-item {
  padding: 0.5rem 0.75rem;
  color: var(--text);
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.pac-item:hover, .pac-item-selected { background: var(--bg-input); }
.pac-item-query { color: var(--text); font-weight: 500; }
.pac-matched { color: var(--primary); }
.pac-icon { display: none; }

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1002;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  min-width: 44px;
  min-height: 44px;
}
.lightbox-img {
  max-width: 92vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: var(--radius);
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  z-index: 1001;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.22); }
.lightbox-prev { left: 0.5rem; }
.lightbox-next { right: 0.5rem; }
.lightbox-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  color: #ccc;
  font-size: 0.85rem;
}
.lightbox-download {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
}
.lightbox-download:hover { background: var(--primary-dark); }

/* Sub-tabs (nested inside a main tab) */
.sub-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tab {
  padding: 0.4rem 0.9rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}
.sub-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.sub-tab:hover { color: var(--text); }

/* Rule cards */
.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}
.rule-card:hover { border-color: var(--primary); }
.rule-inactive { opacity: 0.5; }

/* Markdown editor */
.md-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0.35rem;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}
.md-toolbar button {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  min-width: 28px;
  min-height: 28px;
  text-align: center;
}
.md-toolbar button:hover { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.md-editor textarea {
  border: none;
  border-radius: 0;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  min-height: 200px;
  resize: vertical;
}
.md-editor textarea:focus { border: none; box-shadow: none; }

/* Markdown preview */
.md-preview {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 80px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}
.md-preview h1 { font-size: 1.4rem; font-weight: 700; margin: 0.5rem 0; }
.md-preview h2 { font-size: 1.2rem; font-weight: 600; margin: 0.4rem 0; }
.md-preview h3 { font-size: 1rem; font-weight: 600; margin: 0.3rem 0; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0; }
.md-preview a { color: var(--primary); }
.md-preview code { background: var(--bg-card); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.82rem; }
.md-preview pre { background: var(--bg-card); padding: 0.75rem; border-radius: var(--radius); overflow-x: auto; margin: 0.5rem 0; }
.md-preview li { margin-left: 1.2rem; }

/* Variable reference chips */
.var-ref-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.var-chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: rgba(237,139,104,0.12);
  color: var(--primary);
  border: 1px solid rgba(237,139,104,0.25);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
  cursor: pointer;
}
.var-chip:hover { background: rgba(237,139,104,0.25); }

/* ---- Responsive: Small phones ---- */
@media (max-width: 380px) {
  .page-header { flex-wrap: wrap; }
  .page-title { font-size: 1.1rem; }
  .sched-slot { gap: 0.4rem; }
  .sched-slot-time { min-width: 50px; font-size: 0.75rem; }
  .sched-slot-area { max-width: 100px; }
  .btn { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
  .btn-sm { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
  .login-title { font-size: 1.6rem; }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 640px) {
  .nav-links {
    display: none;
    overflow: visible;
  }
  .nav-links.open {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
  .nav-links.open a {
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    border-radius: var(--radius);
  }
  .nav-toggle { display: flex; }
  .app { padding: 0.75rem; padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
  .page-title { font-size: 1.15rem; }
  .card { padding: 0.75rem; }
  .list-item { padding: 0.6rem 0.75rem; }
  .sched-customer-banner { flex-direction: column; align-items: flex-start; }
  .sched-slot-time { min-width: 55px; font-size: 0.75rem; }
  .sched-day-header { padding: 0.4rem 0.6rem; }

  /* Toast centered at bottom on mobile */
  .toast-container { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; }
  .toast { text-align: center; }

  /* Markdown editor smaller */
  .md-editor textarea { min-height: 150px; font-size: 0.8rem; }
  .md-preview { max-height: 200px; }
}

/* ---- Responsive: Tablet ---- */
@media (min-width: 641px) and (max-width: 1024px) {
  .app { max-width: 720px; }
}

/* ---- Responsive: Desktop ---- */
@media (min-width: 1025px) {
  .app { max-width: 900px; }
}

/* ---- Accessibility ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard users */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---- Report Item Picker ---- */
.item-pick {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  background: var(--bg-card);
  overflow: hidden;
}
.item-pick-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.item-pick-header:hover { background: rgba(255,255,255,0.04); }
.item-pick-header input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--primary);
}
.item-pick-title { font-size: 0.9rem; }
.item-pick-body {
  padding: 0 0.75rem 0.75rem;
  border-top: 1px solid var(--border);
}
.item-pick-body textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem;
  font-size: 0.85rem;
  resize: vertical;
}
.correction-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.4rem 0;
  cursor: pointer;
  user-select: none;
}
.correction-toggle input[type="checkbox"] {
  accent-color: #e53e3e;
  width: 16px;
  height: 16px;
}
.correction-label { font-size: 0.8rem; color: #e53e3e; font-weight: 600; }

/* ---- PASS/FAIL Banner ---- */
.inspection-result-banner {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  margin-top: 1rem;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
  letter-spacing: 0.03em;
}
.result-pass {
  background: #064e3b;
  color: #34d399;
  border: 1.5px solid #34d399;
}
.result-fail {
  background: #7f1d1d;
  color: #fca5a5;
  border: 1.5px solid #f87171;
}
.card-correction { border-left: 3px solid #e53e3e !important; }
.card-correction .badge-danger { margin-right: 0.5rem; }

/* Reschedule requested badge */
.badge-reschedule {
  background: rgba(245,158,11,0.2);
  color: var(--warning);
  font-weight: 600;
  animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Workflow page */
.wf-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--primary);
}
.wf-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.wf-time {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}
.wf-customer {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.wf-address {
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  margin-bottom: 0.3rem;
}
.wf-phone {
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: underline;
  display: inline-block;
  margin-bottom: 0.3rem;
}
.wf-notes {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}
.wf-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* Table styles for audit log */
.table-simple {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table-simple thead {
  background: var(--bg-input);
}

.table-simple th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table-simple td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table-simple tbody tr:hover {
  background: rgba(237, 139, 104, 0.05);
}

.table-simple tbody tr:last-child td {
  border-bottom: none;
}
