/* ============================================
   SERVICE TRACKER - Mobile-First Stylesheet
   ============================================ */

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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --success: #16a34a;
  --success-light: #dcfce7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans Thai', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 70px; /* space for bottom nav */
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ── Container ── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

/* ── Top Navbar ── */
.navbar {
  background: var(--gray-900);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}
.nav-brand a {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}
.nav-brand a:hover { text-decoration: none; }
.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.nav-user-name { font-weight: 600; }
.nav-user-role {
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  text-transform: capitalize;
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--gray-500);
  color: var(--gray-300);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
}
.btn-logout:hover { background: var(--gray-700); color: #fff; }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}
.nav-links {
  display: flex;
  gap: 4px;
}
.nav-links a {
  color: var(--gray-300);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  white-space: nowrap;
}
.nav-links a:hover { background: var(--gray-700); color: #fff; text-decoration: none; }
.nav-links a.active { background: var(--primary); color: #fff; }
.nav-logout-link { display: none; }

@media (max-width: 640px) {
  .nav-user { display: none; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--gray-900);
    flex-direction: column;
    padding: 8px;
    gap: 2px;
    box-shadow: var(--shadow-lg);
  }
  .nav-links.show { display: flex; }
  .nav-logout-link { display: block; color: var(--danger) !important; }
}

/* ── Bottom Navigation (mobile) ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--gray-200);
  z-index: 100;
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  color: var(--gray-500);
  font-size: 0.72rem;
  border-radius: var(--radius-sm);
}
.bottom-nav-item:hover { text-decoration: none; color: var(--primary); }
.bottom-nav-item.active { color: var(--primary); font-weight: 600; }
.bottom-nav-icon { font-size: 1.25rem; line-height: 1; }
.bottom-nav-label { margin-top: 2px; }

@media (min-width: 641px) {
  .bottom-nav { display: none; }
  body { padding-bottom: 0; }
}

/* ── Page Header ── */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.page-header-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-subtitle { color: var(--gray-500); font-size: 0.95rem; margin-top: 2px; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--gray-300);
}
.stat-card.stat-received { border-left-color: var(--primary); }
.stat-card.stat-progress { border-left-color: var(--warning); }
.stat-card.stat-parts { border-left-color: #f97316; }
.stat-card.stat-customer { border-left-color: #8b5cf6; }
.stat-card.stat-completed { border-left-color: var(--success); }
.stat-number { font-size: 1.6rem; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }

/* 4-column stats for ops dashboard */
.stats-grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 500px) {
  .stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
}
/* 6-column stats for ops dashboard (all statuses) */
.stats-grid-6 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.stats-grid-6 .stat-card { padding: 10px 8px; }
.stats-grid-6 .stat-number { font-size: 1.3rem; }
.stats-grid-6 .stat-label { font-size: 0.7rem; }
@media (min-width: 500px) {
  .stats-grid-6 { grid-template-columns: repeat(6, 1fr); }
}

/* ── Alert Cards ── */
.alert-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.alert-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}
.alert-card.alert-danger { border-left: 4px solid var(--danger); }
.alert-card.alert-warning { border-left: 4px solid var(--warning); }
.alert-icon { font-size: 1.8rem; }
.alert-info .alert-number { font-size: 1.5rem; font-weight: 700; }
.alert-info .alert-label { font-size: 0.85rem; color: var(--gray-500); }

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-700);
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.filter-btn {
  background: #fff;
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Search Bar ── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-bar .form-input { flex: 1; min-width: 160px; }
.search-bar .form-select { min-width: 130px; }

/* ── Job Cards / List ── */
.job-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.job-card {
  display: block;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.1s;
  color: inherit;
  border-left: 4px solid transparent;
}
.job-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}
.job-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}
.job-number {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gray-900);
}
.job-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}
.job-card-body { font-size: 0.88rem; }
.job-info-row { display: flex; justify-content: space-between; align-items: center; }
.job-info-row.secondary { color: var(--gray-500); font-size: 0.82rem; margin-top: 3px; }
.job-customer { font-weight: 500; }

/* ── Status Badges ── */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.large {
  padding: 4px 16px;
  font-size: 0.9rem;
  border-radius: 16px;
}
.status-received { background: var(--primary-light); color: var(--primary-dark); }
.status-in-progress { background: var(--warning-light); color: #92400e; }
.status-waiting-parts { background: #fce7f3; color: #9d174d; }
.status-waiting-customer { background: #e0e7ff; color: #3730a3; }
.status-completed { background: var(--success-light); color: #166534; }

/* ── Flags ── */
.flag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}
.flag-return { background: #fce7f3; color: #9d174d; }
.flag-overdue { font-size: 0.85rem; }
.flag-photo { font-size: 0.85rem; }
.flag-photo-ok {
  font-size: 0.75rem;
  background: var(--success-light);
  color: var(--success);
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  white-space: nowrap;
}
.job-card.job-has-photo {
  border-left: 3px solid var(--success);
}

/* ── Forms ── */
.form-row { margin-bottom: 12px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--gray-800);
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-input::placeholder { color: var(--gray-400); }

/* ── Status Option Buttons (radio styled as buttons) ── */
.status-buttons {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.status-option {
  flex: 1;
  min-width: 100px;
}
.status-option input[type="radio"] { display: none; }
.status-option-label {
  display: block;
  text-align: center;
  padding: 10px 8px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s;
  color: var(--gray-600);
}
.status-option input:checked + .status-option-label {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}
.status-option.current .status-option-label {
  border-color: var(--gray-400);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  gap: 6px;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }

.btn-full { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ── File Upload ── */
.file-input { display: none; }
.file-upload-label { cursor: pointer; display: block; }
.file-upload-btn {
  display: block;
  text-align: center;
  padding: 16px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  color: var(--gray-500);
  font-size: 0.95rem;
  transition: all 0.15s;
}
.file-upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ── Photo Preview ── */
.photo-preview-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.preview-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--gray-200);
}

/* ── Batch Photo Capture ── */
.batch-counter {
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
}
.batch-counter.batch-pending {
  background: var(--warning-light);
  color: #92400e;
}
.batch-counter.batch-ready {
  background: var(--success-light);
  color: #166534;
}
.batch-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  min-height: 0;
}
.batch-photo-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--gray-200);
  background: var(--gray-50);
  aspect-ratio: 1;
}
.batch-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.batch-photo-number {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}
.batch-photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: #fff;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  cursor: pointer;
  line-height: 1;
}
.btn-disabled-look {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Photo Grid ── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.photo-item {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}
.photo-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.15s;
}
.photo-item img:hover { opacity: 0.85; }
.photo-caption {
  padding: 6px 8px 0;
  font-size: 0.8rem;
  color: var(--gray-700);
}
.photo-meta {
  padding: 4px 8px 6px;
  font-size: 0.72rem;
  color: var(--gray-400);
}
.photo-item .btn { margin: 4px 8px 8px; }

/* ── Lightbox ── */
.lightbox {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

/* ── Detail Grid ── */
.detail-grid { margin-bottom: 16px; }
.detail-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.detail-section h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.92rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--gray-500); }
.detail-value { font-weight: 500; text-align: right; }
.detail-value a { color: var(--primary); }
.issue-text {
  font-size: 0.92rem;
  color: var(--gray-700);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ── Timeline ── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item {
  position: relative;
  padding-bottom: 16px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gray-300);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--gray-200);
}
.timeline-dot.status-received { background: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.timeline-dot.status-in-progress { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-light); }
.timeline-dot.status-completed { background: var(--success); box-shadow: 0 0 0 2px var(--success-light); }
.timeline-status { font-weight: 600; font-size: 0.9rem; color: var(--gray-800); }
.timeline-notes { font-size: 0.85rem; color: var(--gray-600); margin-top: 2px; }
.timeline-meta { font-size: 0.78rem; color: var(--gray-400); margin-top: 2px; }

/* ── Admin Tabs ── */
.tab-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  background: var(--gray-200);
  border-radius: var(--radius);
  padding: 3px;
  overflow-x: auto;
}
.tab-btn {
  flex: 1;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--gray-800); }
.tab-btn.active {
  background: #fff;
  color: var(--gray-900);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th {
  text-align: left;
  padding: 10px 8px;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--gray-50); }

/* Responsive table wrapper */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  margin-bottom: 16px;
}
.table-wrap .data-table th:first-child,
.table-wrap .data-table td:first-child { padding-left: 14px; }

/* ── Center Cards (ops dashboard) ── */
.center-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}
.center-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.center-card.has-issues { border-left: 4px solid var(--danger); }
.center-name { font-weight: 600; font-size: 0.95rem; }
.center-stats {
  display: flex;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--gray-500);
}
.center-stat-bad { color: var(--danger); font-weight: 600; }

/* ── Login Page ── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-700) 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}
.login-subtitle {
  text-align: center;
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.login-logo {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 12px;
}

/* ── Flash Messages ── */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: flashIn 0.3s ease;
}
.flash-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.flash-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0 4px;
}
.flash-close:hover { opacity: 1; }
@keyframes flashIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}
.empty-icon { font-size: 3rem; margin-bottom: 10px; }
.empty-state p { font-size: 1rem; margin-bottom: 16px; }

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
  font-size: 0.95rem;
}
.loading::after {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Import Preview ── */
.import-preview {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 0;
}
.import-preview h4 {
  font-size: 0.92rem;
  margin-bottom: 8px;
}
.import-stats {
  display: flex;
  gap: 16px;
  font-size: 0.88rem;
  color: var(--gray-600);
}
.import-stats strong { color: var(--gray-900); }

/* ── Result Badges ── */
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}
.result-badge.created { background: var(--success-light); color: #166534; }
.result-badge.updated { background: var(--primary-light); color: var(--primary-dark); }
.result-badge.skipped { background: var(--gray-100); color: var(--gray-600); }

/* ── User List Items ── */
.user-item, .center-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  gap: 10px;
}
.user-item:last-child, .center-item:last-child { border-bottom: none; }
.user-info { flex: 1; }
.user-name { font-weight: 600; font-size: 0.95rem; }
.user-meta { font-size: 0.82rem; color: var(--gray-500); }
.user-actions { display: flex; gap: 6px; }

/* ── Quick Lookup Section ── */
.lookup-section {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.lookup-section h2 {
  font-size: 1.1rem;
  color: var(--primary-dark);
  margin-bottom: 10px;
}
.lookup-form {
  display: flex;
  gap: 8px;
}
.lookup-form .form-input { flex: 1; }
.lookup-result {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--primary);
}

/* ── Section Headers (ops page) ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 12px;
}
.section-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-800);
}
.section-badge {
  background: var(--gray-200);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--gray-600);
}

/* ── Misc ── */
.text-muted { color: var(--gray-400); font-size: 0.9rem; }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ── Default setup notice ── */
.setup-notice {
  background: var(--warning-light);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  color: #92400e;
}

/* ── Form Group (admin forms) ── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--gray-800);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.form-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--gray-700);
}

/* ── Sections ── */
.section { margin-bottom: 24px; }
.section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 12px;
}
.users-list-section { margin-top: 20px; }
.users-list-section h3,
.section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--gray-700);
}

/* ── Photo Update Rounds ── */
.photo-round {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.photo-round.round-latest {
  border-color: var(--primary);
  border-width: 2px;
}
.photo-round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--gray-50);
  cursor: pointer;
  gap: 8px;
  user-select: none;
  -webkit-user-select: none;
}
.photo-round-header:hover {
  background: var(--gray-100);
}
.photo-round-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  flex-wrap: wrap;
}
.photo-round-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--gray-500);
  white-space: nowrap;
}
.round-toggle-icon {
  font-size: 0.75rem;
  color: var(--gray-400);
}
.round-latest-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}
.photo-round-body {
  padding: 12px 14px;
  border-top: 1px solid var(--gray-200);
}
.photo-round-body.collapsed {
  display: none;
}
.photo-round-uploader {
  font-size: 0.82rem;
  color: var(--gray-500);
  margin-bottom: 10px;
}

/* Round status bar (used in job upload section) */
.round-status-bar {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.round-status-bar.round-complete {
  background: var(--success-light);
  color: #166534;
}
.round-status-bar.round-incomplete {
  background: var(--warning-light);
  color: #92400e;
}
.round-new-notice {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.85rem;
}

/* Round count badge (in job header) */
.round-count-badge {
  display: inline-block;
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* 3-column alert grid for ops dashboard */
.alert-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (max-width: 500px) {
  .alert-grid-3 {
    grid-template-columns: 1fr;
  }
}
.alert-card.alert-update {
  border-left: 4px solid var(--primary);
}

/* ── Import File Preview Rows ── */
.import-file-row {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.88rem;
}
.import-file-row:last-child { border-bottom: none; }
.import-file-unmatched {
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.import-file-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
}
.import-file-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.import-file-name { font-weight: 500; font-size: 0.85rem; }
.import-file-center { font-size: 0.82rem; color: var(--gray-500); margin-top: 2px; }

/* ── Collapsed Section Toggle ── */
.collapsed-section {
  display: none;
}

/* ── Clickable Stat Cards ── */
.stat-card.stat-clickable {
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
}
.stat-card.stat-clickable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card.stat-clickable:active {
  transform: translateY(0);
  box-shadow: var(--shadow);
}
.alert-card.stat-clickable {
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.alert-card.stat-clickable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ── Clickable Center Table Links ── */
.center-table-link {
  color: var(--gray-900);
  text-decoration: none;
}
.center-table-link:hover {
  color: var(--primary);
  text-decoration: underline;
}
.center-table-num {
  color: var(--gray-800);
  text-decoration: none;
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}
.center-table-num:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  text-decoration: none;
}

/* ── Filter Banner ── */
.filter-banner {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--primary-dark);
  font-weight: 500;
}
.filter-clear-btn {
  background: #fff;
  color: var(--primary-dark);
  border: 1px solid var(--primary);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}
.filter-clear-btn:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}

/* ── Center Dashboard (Agent View) ── */
.center-dashboard {
  margin-bottom: 20px;
}
.center-dashboard h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--gray-700);
}
.center-dashboard .stats-grid-6 {
  margin-bottom: 12px;
}
.center-dashboard .alert-grid {
  margin-bottom: 0;
}

/* ── Print ── */
@media print {
  .navbar, .bottom-nav, .btn, .filter-bar, form { display: none !important; }
  body { padding: 0; background: #fff; }
  .container { max-width: 100%; }
}
