/* ============================================
           MODERN UI REFRESH — Inline enhancements
           ============================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  margin: 0;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 260px;
  height: 100vh;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}
.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.sidebar-header span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  padding: 16px 20px 8px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.nav-link.active {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  border-left-color: #60a5fa;
}
.nav-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-btn-daily {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.sidebar-btn-daily:hover {
  background: rgba(255, 255, 255, 0.2);
}
.sidebar-btn-weekly {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
}
.sidebar-btn-weekly:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.mobile-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.6);
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  margin-top: 8px;
}

/* Main Content */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
  padding: 32px;
}
.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Brand Header */
.brand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.brand-text h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}
.brand-logo img {
  height: 48px;
  width: auto;
}

/* Instructions */
.instructions {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 0.85rem;
  color: #1e40af;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-group input,
.form-group select {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: var(--transition);
  outline: none;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group input::placeholder {
  color: var(--text-muted);
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.btn-primary,
.btn-secondary,
.btn-warning,
.btn-info,
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border-light);
  border-color: var(--text-muted);
}
.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  background: #b45309;
}
.btn-info {
  background: var(--info);
  color: #fff;
}
.btn-info:hover {
  background: #0e7490;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
}

/* Area Sections */
.area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.area:hover {
  box-shadow: var(--shadow);
}
.area h2 {
  margin: 0;
  padding: 16px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: -0.01em;
}
.area-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Area Colors */
.area-common-area h2 {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}
.area-comfort-rooms h2 {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
}
.area-loading-bay h2 {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
.area-offices h2 {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}
.area-building-facilities h2 {
  background: linear-gradient(135deg, #10b981, #059669);
}
.area-electrical-room h2 {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
}
.area-roof h2 {
  background: linear-gradient(135deg, #92400e, #78350f);
}
.area-building-perimeter h2 {
  background: linear-gradient(135deg, #475569, #334155);
}

/* Table */
.area table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}
.area thead th {
  background: var(--border-light);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.area thead th:first-child {
  text-align: left;
  padding-left: 16px;
  min-width: 110px;
}
.area tbody tr {
  transition: background 0.15s;
}
.area tbody tr:hover {
  background: rgba(37, 99, 235, 0.02);
}
.area tbody td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  text-align: center;
}
.area tbody td:first-child {
  padding-left: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  font-size: 0.82rem;
}
.area tbody tr:last-child td {
  border-bottom: none;
}

/* Radio Buttons */
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
input[type="radio"][value="NOT OK"] {
  accent-color: var(--danger);
}
input[type="radio"][value="N/A"] {
  accent-color: var(--text-muted);
}

/* Inputs in table */
.area tbody input[type="text"],
.area tbody input[type="date"] {
  width: 100%;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
  background: var(--surface);
  min-width: 70px;
}
.area tbody input[type="text"]:focus,
.area tbody input[type="date"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.area tbody input[type="date"]:disabled {
  background: var(--border-light);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}
.area tbody input[type="date"].active {
  border-color: var(--danger);
  background: var(--danger-light);
}
.area tbody input[type="date"].has-value {
  border-color: var(--success);
  background: var(--success-light);
}

/* Photo Cells - Before & After */
.photo-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  min-width: 80px;
}
.photo-cell .photo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}
.photo-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.photo-trigger:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.photo-cell.has-photo .photo-trigger {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
}
.photo-cell.has-photo .photo-trigger:hover {
  background: #bbf7d0;
}
.photo-preview-wrapper {
  display: none;
  align-items: center;
  gap: 4px;
}
.photo-preview {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.photo-preview:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow);
}
.photo-remove {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.photo-remove:hover {
  background: #b91c1c;
  transform: scale(1.1);
}
.photo-empty {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 400;
}
.photo-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Uploadcare hidden */
.uploadcare--widget__button,
.uploadcare--widget__button:hover,
.uploadcare--widget__button:focus {
  display: none !important;
}

/* Admin Badge */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--warning-light);
  color: var(--warning);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  margin-left: 8px;
  border: 1px solid #fde68a;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s;
}
.modal-overlay.active {
  display: flex;
  opacity: 1;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  transition: transform 0.2s;
}
.modal-overlay.active .modal {
  transform: translateY(0);
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.modal-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 20px;
  line-height: 1.5;
}
.modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 20px;
  outline: none;
  transition: var(--transition);
}
.modal-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  animation: slideIn 0.3s ease;
  transition:
    opacity 0.3s,
    transform 0.3s;
}
.toast.success {
  border-left: 4px solid var(--success);
}
.toast.error {
  border-left: 4px solid var(--danger);
}
.toast.warning {
  border-left: 4px solid var(--warning);
}
.toast.info {
  border-left: 4px solid var(--info);
}
@keyframes slideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* View Sections */
.view-section {
  display: none;
}
.view-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Analysis */
.analysis-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.summary-card h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
}
.big-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.big-number.small {
  font-size: 1.3rem;
}
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}
.location-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.location-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.location-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.location-rate {
  font-size: 1.3rem;
  font-weight: 800;
}
.progress-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.location-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 500;
}
.area-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.area-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light);
}
.area-row:last-child {
  border-bottom: none;
}
.area-row.muted {
  color: var(--text-muted);
}
.area-rate {
  font-weight: 600;
}
.analysis-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.analysis-empty h3 {
  color: var(--text);
  margin-bottom: 8px;
}

/* Print */
@media print {
  .sidebar,
  .mobile-menu-btn,
  .btn-group,
  .sidebar-footer,
  .history-section,
  .instructions,
  .photo-cell .photo-trigger,
  .photo-cell .photo-remove,
  .photo-cell .photo-empty,
  .photo-cell .photo-label {
    display: none !important;
  }
  .photo-cell .photo-preview-wrapper {
    display: flex !important;
  }
  .photo-cell .photo-preview {
    width: 50px;
    height: 50px;
  }
  .main-content {
    margin-left: 0;
    padding: 0;
  }
  .area {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body {
    background: #fff;
  }
  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* Responsive */
@media (max-width: 1100px) {
  .area table {
    font-size: 0.75rem;
  }
  .area thead th,
  .area tbody td {
    padding: 6px 4px;
  }
  .area thead th:first-child,
  .area tbody td:first-child {
    padding-left: 8px;
    font-size: 0.75rem;
  }
  .photo-cell {
    min-width: 60px;
  }
  .photo-trigger {
    font-size: 0.6rem;
    padding: 3px 6px;
  }
  .photo-preview {
    width: 28px;
    height: 28px;
  }
  .area tbody input[type="text"],
  .area tbody input[type="date"] {
    font-size: 0.7rem;
    padding: 4px 6px;
    min-width: 50px;
  }
  input[type="radio"] {
    width: 14px;
    height: 14px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  .mobile-menu-btn {
    display: block;
  }
  .mobile-toggle {
    display: block;
  }
  .brand-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .area table {
    font-size: 0.7rem;
    display: block;
    overflow-x: auto;
  }
  .area thead th,
  .area tbody td {
    padding: 4px 3px;
  }
  .area thead th:first-child,
  .area tbody td:first-child {
    padding-left: 6px;
    font-size: 0.7rem;
    min-width: 80px;
  }
  .analysis-grid {
    grid-template-columns: 1fr;
  }
  .photo-cell {
    min-width: 50px;
  }
  .photo-trigger {
    font-size: 0.55rem;
    padding: 2px 5px;
  }
  .photo-preview {
    width: 24px;
    height: 24px;
  }
  .photo-remove {
    width: 16px;
    height: 16px;
    font-size: 0.5rem;
  }
  .btn-group {
    flex-direction: column;
  }
  .btn-group button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .area table {
    font-size: 0.65rem;
  }
  .area thead th {
    font-size: 0.55rem;
    padding: 4px 2px;
  }
  .area tbody td {
    padding: 3px 2px;
  }
  .area tbody td:first-child {
    font-size: 0.65rem;
    min-width: 60px;
  }
  .photo-trigger {
    font-size: 0.5rem;
    padding: 2px 4px;
  }
  .photo-preview {
    width: 20px;
    height: 20px;
  }
  .area tbody input[type="text"],
  .area tbody input[type="date"] {
    font-size: 0.6rem;
    padding: 3px 4px;
    min-width: 40px;
  }
  input[type="radio"] {
    width: 12px;
    height: 12px;
  }
}

/* ── GLOBAL RESET / VARIABLES ── */
:root {
  --primary: #1a3a5c;
  --primary-light: #2a5a8c;
  --primary-dark: #0f2a44;
  --accent: #e67e22;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --text: #1e2a3a;
  --text-muted: #6b7a8a;
  --bg: #f4f7fc;
  --card-bg: #ffffff;
  --border: #dce4ec;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--primary-dark);
  color: #fff;
  overflow-y: auto;
  z-index: 1000;
  padding: 0;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 0;
}
.sidebar-header span {
  font-size: 0.75rem;
  opacity: 0.6;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0 8px;
}
.nav-section-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 20px 4px;
  opacity: 0.4;
  font-weight: 600;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.nav-link:hover,
.nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--accent);
}
.nav-link .nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.sidebar-btn span {
  font-size: 1rem;
}
.mobile-toggle {
  display: none;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 6px;
  margin-top: 4px;
}
.mobile-toggle:hover {
  color: #fff;
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1100;
  background: var(--primary-dark);
  color: #fff;
  border: none;
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  transition: var(--transition);
}
.mobile-menu-btn:hover {
  background: var(--primary);
}

/* ── MAIN ── */
.main-content {
  margin-left: 260px;
  padding: 24px 32px 60px;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* ── BRAND HEADER ── */
.brand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 20px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.brand-text h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  color: var(--primary);
}
.brand-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.brand-logo img {
  height: 48px;
  max-width: 120px;
  object-fit: contain;
}

/* ── CARDS ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  transition: var(--transition);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── FORM GRID ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px 20px;
  align-items: end;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-group input,
.form-group select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: #fff;
  transition: var(--transition);
  width: 100%;
  font-family: var(--font);
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(26, 58, 92, 0.25);
}
.btn-secondary {
  background: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: #c8d2dc;
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #1e8449;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(39, 174, 96, 0.3);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #c0392b;
}
.btn-info {
  background: #3498db;
  color: #fff;
}
.btn-info:hover {
  background: #2980b9;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(52, 152, 219, 0.3);
}
.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  background: #d68910;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

/* ── VIEW SECTIONS ── */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}
.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── ANALYSIS ── */
.analysis-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: end;
}
.analysis-filters .form-group {
  min-width: 180px;
  flex: 1 1 180px;
}
.analysis-filters .btn-group {
  flex: 0 0 auto;
  margin-top: 0;
}

/* Summary cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.summary-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  border: 1px solid var(--border);
  text-align: center;
}
.summary-card .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.summary-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2px;
}
.summary-card .value.danger {
  color: var(--danger);
}
.summary-card .value.success {
  color: var(--success);
}
.summary-card .value.warning {
  color: var(--warning);
}

/* Defect table */
.defect-table-wrap {
  overflow-x: auto;
  margin-top: 4px;
}
.defect-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.defect-table thead th {
  background: var(--bg);
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.defect-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.defect-table tbody tr:hover {
  background: rgba(26, 58, 92, 0.02);
}
.defect-table .area-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.defect-table .status-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--danger);
  color: #fff;
}
.defect-table .img-thumb {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg);
}
.defect-table .img-thumb:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.defect-table .img-placeholder {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 6px;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.6rem;
}
.defect-table .img-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}
.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 4px;
}

/* ── CHECKLIST OVERRIDES ── */
.area {
  margin-bottom: 32px;
}
.area h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.area-badge {
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-muted);
  padding: 2px 12px;
  border-radius: 20px;
}
.area table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.area thead th {
  background: var(--bg);
  padding: 10px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.area tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.area tbody tr:hover {
  background: rgba(26, 58, 92, 0.015);
}
.area input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.area input[type="text"],
.area input[type="date"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  width: 100%;
  min-width: 80px;
  font-family: var(--font);
  background: #fff;
  transition: var(--transition);
}
.area input[type="text"]:focus,
.area input[type="date"]:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.08);
}
.area input[type="date"]:disabled {
  background: #f4f6f8;
  color: #999;
  cursor: not-allowed;
  opacity: 0.6;
}
.area input[type="date"].active {
  border-color: var(--warning);
  background: #fff8e7;
}
.area .photo-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.area .photo-trigger {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  font-family: var(--font);
}
.area .photo-trigger:hover {
  background: var(--border);
}
.area .photo-preview-wrapper {
  display: none;
  position: relative;
  align-items: center;
}
.area .photo-preview-wrapper .photo-preview {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg);
}
.area .photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  font-size: 0.6rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: var(--transition);
}
.area .photo-remove:hover {
  transform: scale(1.15);
}
.area .photo-cell.has-photo .photo-remove {
  display: flex;
}
.area .photo-empty {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}
.toast {
  background: var(--primary-dark);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(0);
  opacity: 1;
}
.toast.success {
  background: var(--success);
}
.toast.error {
  background: var(--danger);
}
.toast.warning {
  background: var(--warning);
  color: #1e2a3a;
}
.toast.info {
  background: var(--primary-light);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 36px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--primary);
}
.modal-text {
  color: var(--text-muted);
  margin: 0 0 18px;
  font-size: 0.95rem;
}
.modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
  font-family: var(--font);
}
.modal-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.1);
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ── PRINT STYLES ── */
@media print {
  .sidebar,
  .mobile-menu-btn,
  .btn,
  .btn-group,
  .no-print {
    display: none !important;
  }
  .main-content {
    margin: 0 !important;
    padding: 20px !important;
  }
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }
  .brand-header {
    border-bottom-color: #333 !important;
  }
  .defect-table thead th {
    background: #f0f0f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .defect-table .area-badge,
  .defect-table .status-badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .summary-card {
    border: 1px solid #ddd !important;
  }
  .defect-table .img-thumb {
    max-width: 60px;
    max-height: 60px;
  }
  .area table {
    font-size: 0.7rem;
  }
  .area .photo-trigger,
  .area .photo-remove {
    display: none !important;
  }
  .area .photo-preview-wrapper {
    display: flex !important;
  }
  .area .photo-empty {
    display: none !important;
  }
  .area input[type="radio"] {
    accent-color: #000;
  }
  .area input[type="date"]:disabled {
    background: #f4f6f8 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .main-content {
    margin-left: 0;
    padding: 16px 16px 40px;
  }
  .mobile-toggle {
    display: block;
  }
  .brand-text h1 {
    font-size: 1.2rem;
  }
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .analysis-filters .form-group {
    flex: 1 1 100%;
    min-width: unset;
  }
  .defect-table thead th,
  .defect-table tbody td {
    padding: 8px 10px;
    font-size: 0.75rem;
  }
  .defect-table .img-thumb {
    width: 36px;
    height: 36px;
  }
  .modal {
    padding: 24px 20px;
  }
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
  .brand-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .brand-logo img {
    height: 36px;
  }
  .area table {
    font-size: 0.7rem;
  }
  .area thead th,
  .area tbody td {
    padding: 4px 6px;
  }
  .area input[type="text"],
  .area input[type="date"] {
    font-size: 0.7rem;
    padding: 4px 6px;
    min-width: 50px;
  }
  .area .photo-trigger {
    font-size: 0.6rem;
    padding: 2px 6px;
  }
  .area .photo-preview-wrapper .photo-preview {
    width: 32px;
    height: 32px;
  }
  .defect-table {
    font-size: 0.7rem;
  }
  .defect-table thead th,
  .defect-table tbody td {
    padding: 6px 8px;
  }
}

/* ─── RESET & BASE ─── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #0b2b4a;
  --primary-light: #1a4a6f;
  --primary-dark: #061b2e;
  --accent: #e87a2d;
  --accent-light: #f5a96a;
  --bg: #f4f7fc;
  --card-bg: #ffffff;
  --text: #1e2a3a;
  --text-muted: #5e6f8d;
  --border: #dce4ed;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
  --transition: 0.25s ease;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --badge-bg: #eef2f7;
  --badge-text: #1e2a3a;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: 250px;
  background: var(--primary);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  padding: 0 0 16px 0;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.sidebar-header span {
  font-size: 0.7rem;
  opacity: 0.6;
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}
.nav-section-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.4;
  padding: 8px 10px 4px;
  font-weight: 600;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
}
.nav-icon {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.mobile-toggle {
  display: none;
  width: 100%;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* ─── MAIN ─── */
.main-content {
  flex: 1;
  margin-left: 250px;
  padding: 24px 32px 60px;
  min-height: 100vh;
}

.container {
  max-width: 1360px;
  margin: 0 auto;
}

/* ─── BRAND HEADER ─── */
.brand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.brand-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.4px;
}
.brand-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.brand-logo img {
  height: 44px;
  width: auto;
  object-fit: contain;
}

/* ─── CARDS ─── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  transition: var(--transition);
}
.card-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── FORM GRID ─── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 20px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}
.form-group input,
.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: #fafcfe;
  transition: var(--transition);
  font-family: var(--font);
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(11, 43, 74, 0.08);
}
.form-group input:disabled {
  background: #f0f2f5;
  opacity: 0.6;
}

/* ─── BUTTONS ─── */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  text-decoration: none;
  background: var(--border);
  color: var(--text);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-light);
}
.btn-secondary {
  background: #e8edf4;
  color: var(--text);
}
.btn-secondary:hover {
  background: #d5dde8;
}
.btn-success {
  background: #1e7b4a;
  color: #fff;
}
.btn-success:hover {
  background: #15643b;
}
.btn-warning {
  background: #d48c2c;
  color: #fff;
}
.btn-warning:hover {
  background: #b8771f;
}
.btn-info {
  background: #2a6f8f;
  color: #fff;
}
.btn-info:hover {
  background: #1e5a75;
}
.btn-danger {
  background: #b13e3e;
  color: #fff;
}
.btn-danger:hover {
  background: #932e2e;
}

.admin-badge {
  font-size: 0.6rem;
  background: #d48c2c;
  color: #fff;
  padding: 2px 12px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ─── CHECKLIST TABLE ─── */
.area {
  margin-bottom: 28px;
}
.area h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.area-badge {
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 2px 12px;
  border-radius: 20px;
}

.area table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.area table th {
  background: #eef2f7;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 10px 8px;
  text-align: center;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.area table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}
.area table tr:hover {
  background: #f8faff;
}
.area table td:first-child {
  text-align: left;
  font-weight: 500;
  padding-left: 12px;
}

.area table input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.area table input[type="text"],
.area table input[type="date"] {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  width: 100%;
  max-width: 130px;
  font-family: var(--font);
  background: #fafcfe;
  transition: var(--transition);
}
.area table input[type="text"]:focus,
.area table input[type="date"]:focus {
  outline: none;
  border-color: var(--primary-light);
}
.area table input[type="date"]:disabled {
  background: #f0f2f5;
  opacity: 0.5;
}
.area table input[type="date"].active {
  border-color: var(--accent);
  background: #fff8f0;
}
.area table input[type="date"].has-value {
  border-color: #1e7b4a;
  background: #f0faf4;
}

/* ─── PHOTO CELL ─── */
.photo-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 70px;
  position: relative;
}
.photo-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafcfe;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: var(--font);
  transition: var(--transition);
  color: var(--text);
  white-space: nowrap;
}
.photo-trigger:hover {
  background: #eef2f7;
  border-color: var(--primary-light);
}
.photo-trigger .trigger-icon {
  font-size: 0.9rem;
}
.photo-trigger .trigger-text {
  font-size: 0.7rem;
}
.photo-preview-wrapper {
  display: none;
  align-items: center;
  gap: 6px;
  position: relative;
}
.photo-preview {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  background: #f0f2f5;
}
.photo-preview:hover {
  transform: scale(1.04);
  border-color: var(--primary-light);
}
.photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: #b13e3e;
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.photo-remove:hover {
  background: #932e2e;
}
.photo-empty {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.photo-cell.has-photo .photo-empty {
  display: none;
}
.photo-cell.has-photo .photo-preview-wrapper {
  display: flex;
}
.photo-cell.has-photo .photo-remove {
  display: flex;
}

/* ─── VIEW SECTIONS ─── */
.view-section {
  display: none;
}
.view-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ─── ANALYSIS / DEFECT SUMMARY ─── */
.analysis-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: end;
}
.analysis-filters .form-group {
  flex: 1 1 180px;
}
.analysis-filters .btn-group {
  flex: 0 0 auto;
  margin-top: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.summary-card .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  font-weight: 600;
}
.summary-card .value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2px;
}
.summary-card .value.danger {
  color: #b13e3e;
}
.summary-card .value.success {
  color: #1e7b4a;
}

.defect-table-wrap {
  overflow-x: auto;
}
.defect-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.defect-table th {
  background: #eef2f7;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 10px 10px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.defect-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.defect-table tr:hover {
  background: #f8faff;
}

.defect-table .img-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  background: #f0f2f5;
  display: block;
}
.defect-table .img-thumb:hover {
  transform: scale(1.06);
  border-color: var(--primary-light);
}
.defect-table .img-placeholder {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* ─── STATUS BADGE — NO HIGHLIGHT ─── */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  letter-spacing: 0.3px;
}
.status-badge.defect {
  border-color: #b13e3e;
  color: #b13e3e;
}
.status-badge.ok {
  border-color: #1e7b4a;
  color: #1e7b4a;
}
.status-badge.na {
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.area-badge-sm {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--badge-bg);
  color: var(--badge-text);
}

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.empty-state .icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}
.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 4px;
}
.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ─── TOAST ─── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.35s ease;
  transition:
    opacity 0.3s,
    transform 0.3s;
  border-left: 4px solid rgba(255, 255, 255, 0.2);
}
.toast.success {
  background: #1e7b4a;
}
.toast.error {
  background: #b13e3e;
}
.toast.warning {
  background: #b8771f;
}
.toast.info {
  background: var(--primary-light);
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(60px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 440px;
  width: 100%;
  padding: 28px 32px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}
.modal-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
  font-family: var(--font);
}
.modal-input:focus {
  outline: none;
  border-color: var(--primary-light);
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: end;
}
.modal-actions .btn {
  padding: 8px 20px;
  font-size: 0.8rem;
}

/* ─── INSTRUCTIONS ─── */
.instructions {
  background: #f0f6fe;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.85rem;
  border-left: 4px solid var(--primary);
  color: var(--text);
}

/* ─── PRINT ─── */
@media print {
  body {
    background: #fff !important;
  }
  .sidebar,
  .mobile-menu-btn,
  .no-print,
  .btn-group,
  #loadHistoryBtn,
  #updateEntryBtn,
  #submitBtn,
  .photo-trigger,
  .photo-remove,
  .photo-empty,
  .mobile-toggle,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 16px !important;
  }
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }
  .area table {
    font-size: 0.7rem !important;
  }
  .area table th,
  .area table td {
    padding: 4px 6px !important;
  }
  .defect-table .img-thumb {
    width: 60px !important;
    height: 60px !important;
  }
  .defect-table th,
  .defect-table td {
    padding: 6px 8px !important;
    font-size: 0.7rem !important;
  }

  /* Hide CONDUCTED BY column in print preview */
  .defect-table .col-conducted,
  .defect-table td.col-conducted,
  .defect-table th.col-conducted {
    display: none !important;
  }

  /* Hide conducted by in print header meta */
  .print-conducted-hidden {
    display: none !important;
  }

  .brand-header {
    border-bottom-color: #222 !important;
    margin-bottom: 14px !important;
  }
  .summary-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
  }
  .summary-card {
    border: 1px solid #ccc !important;
    padding: 8px 12px !important;
  }
  .summary-card .value {
    font-size: 1.2rem !important;
  }
  #print-header {
    display: block !important;
    text-align: center !important;
    padding: 10px 0 !important;
    border-bottom: 2px solid #333 !important;
    margin-bottom: 16px !important;
  }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-menu-btn {
    display: block;
  }
  .mobile-toggle {
    display: block;
  }
  .main-content {
    margin-left: 0;
    padding: 16px 14px 40px;
  }
  .brand-header {
    flex-direction: column;
    align-items: start;
    padding-top: 40px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .analysis-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .analysis-filters .btn-group {
    flex: 1;
  }
  .area table {
    font-size: 0.7rem;
  }
  .area table input[type="text"],
  .area table input[type="date"] {
    max-width: 80px;
    font-size: 0.65rem;
    padding: 3px 4px;
  }
  .area table td {
    padding: 4px 3px;
  }
  .photo-preview {
    width: 36px;
    height: 36px;
  }
  .photo-trigger {
    padding: 2px 6px;
    font-size: 0.6rem;
  }
  .photo-trigger .trigger-text {
    display: none;
  }
  .defect-table .img-thumb {
    width: 50px !important;
    height: 50px !important;
  }
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .card {
    padding: 14px 14px;
  }
}

@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
  .defect-table th,
  .defect-table td {
    padding: 4px 4px !important;
    font-size: 0.6rem !important;
  }
  .defect-table .img-thumb {
    width: 36px !important;
    height: 36px !important;
  }
  .area table th,
  .area table td {
    padding: 3px 2px !important;
    font-size: 0.6rem !important;
  }
  .area table input[type="radio"] {
    width: 14px;
    height: 14px;
  }
}

/* ─── MOBILE-FIRST OVERRIDES FOR ANALYSIS ─── */
.analysis-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
}
.analysis-filters .form-group {
  flex: 1 1 160px;
  min-width: 130px;
}
.analysis-filters .btn-group {
  flex: 0 0 auto;
  margin-top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.analysis-filters .btn-group .btn {
  font-size: 0.78rem;
  padding: 8px 14px;
  white-space: nowrap;
}

/* ─── DEFECT TABLE - MOBILE SCROLL ─── */
.defect-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}
.defect-table {
  min-width: 720px;
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}
.defect-table th,
.defect-table td {
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light, #eef2f7);
  white-space: nowrap;
}
.defect-table th {
  background: var(--border-light, #eef2f7);
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted, #5e6f8d);
  position: sticky;
  top: 0;
  z-index: 2;
}
.defect-table .img-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border, #dce4ed);
  cursor: pointer;
  background: #f0f2f5;
  display: block;
  flex-shrink: 0;
}
.defect-table .img-placeholder {
  font-size: 0.65rem;
  color: var(--text-muted, #5e6f8d);
}
.defect-table .img-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}
.defect-table .area-badge-sm {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 500;
  background: var(--badge-bg, #eef2f7);
  color: var(--badge-text, #1e2a3a);
  white-space: nowrap;
}
.defect-table .status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--border, #dce4ed);
  color: var(--text, #1e2a3a);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.defect-table .status-badge.defect {
  border-color: #b13e3e;
  color: #b13e3e;
}

/* ─── SUMMARY CARDS - MOBILE ─── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dce4ed);
  border-radius: var(--radius-sm, 8px);
  padding: 12px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}
.summary-card .label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted, #5e6f8d);
  font-weight: 600;
  display: block;
}
.summary-card .value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary, #0b2b4a);
  margin-top: 2px;
  display: block;
}
.summary-card .value.danger {
  color: #b13e3e;
}
.summary-card .value.success {
  color: #1e7b4a;
}
.summary-card .value.warning {
  color: #b8771f;
}

/* ─── SHARE MODAL - MOBILE ─── */
.share-modal .modal {
  max-width: 560px;
  padding: 20px 18px;
}
.share-link-box {
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--bg, #f4f7fc);
  border: 1px solid var(--border, #dce4ed);
  border-radius: var(--radius-sm, 8px);
  padding: 4px 4px 4px 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.share-link-box input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-family: var(--font, "Segoe UI", system-ui, sans-serif);
  color: var(--text, #1e2a3a);
  padding: 8px 0;
  outline: none;
  min-width: 100px;
}
.share-link-box input::selection {
  background: var(--primary-light, #1a4a6f);
  color: #fff;
}
.share-link-box .btn {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 0.75rem;
}

/* ─── SHARE HEADER - MOBILE ─── */
.share-report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border, #dce4ed);
}
.share-report-header .report-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary, #0b2b4a);
  margin: 0;
}
.share-report-header .report-title small {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--text-muted, #5e6f8d);
  margin-left: 6px;
}
.share-report-header .report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.75rem;
  color: var(--text-secondary, #475569);
}
.share-report-header .report-meta strong {
  color: var(--text, #1e2a3a);
  font-weight: 600;
}
.share-report-header .brand-logo img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

/* ─── SHARE MODE ─── */
.share-mode .sidebar {
  display: none !important;
}
.share-mode .mobile-menu-btn {
  display: none !important;
}
.share-mode .main-content {
  margin-left: 0 !important;
  padding: 16px !important;
}
.share-mode .brand-header {
  padding-top: 0 !important;
}
.share-mode .analysis-filters,
.share-mode #defect-summary-cards ~ .analysis-filters,
.share-mode
  .no-print
  .btn-group
  .btn:not(.btn-primary):not(.btn-success):not(.btn-info) {
  display: none !important;
}
.share-mode .no-print .btn-group {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px;
}
.share-mode .no-print .btn-group .btn {
  display: inline-flex !important;
  font-size: 0.75rem;
  padding: 8px 14px;
}
.share-mode #defect-summary-cards {
  display: grid !important;
}
.share-mode #defect-results-card {
  display: block !important;
}
.share-mode #defect-empty {
  display: none !important;
}
.share-mode .sidebar-footer,
.share-mode .mobile-toggle {
  display: none !important;
}
.share-mode .toast-container {
  z-index: 9999;
}
.share-mode #analysisBrandHeader {
  display: none !important;
}
.share-mode #shareReportHeader {
  display: flex !important;
}
.share-mode #analysisFiltersCard {
  display: none !important;
}

/* ─── RESPONSIVE TWEAKS ─── */
@media (max-width: 768px) {
  .analysis-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .analysis-filters .form-group {
    flex: 0 0 100%;
    min-width: unset;
    width: 100%;
  }
  .analysis-filters .btn-group {
    flex: 0 0 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-self: stretch;
    margin-top: 4px;
  }
  .analysis-filters .btn-group .btn {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 0.72rem;
    padding: 8px 6px;
    white-space: nowrap;
    width: 100%;
    min-width: 0;
    text-align: center;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .summary-card {
    padding: 10px 8px;
  }
  .summary-card .value {
    font-size: 1.1rem;
  }
  .defect-table {
    font-size: 0.7rem;
    min-width: 600px;
  }
  .defect-table th,
  .defect-table td {
    padding: 5px 4px;
  }
  .defect-table .img-thumb {
    width: 32px;
    height: 32px;
  }
  .defect-table .area-badge-sm {
    font-size: 0.55rem;
    padding: 1px 6px;
  }
  .defect-table .status-badge {
    font-size: 0.55rem;
    padding: 1px 6px;
  }
  .share-report-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .share-report-header .report-meta {
    font-size: 0.7rem;
    gap: 2px 10px;
  }
  .share-report-header .report-title {
    font-size: 0.95rem;
  }
  .share-report-header .brand-logo img {
    height: 30px;
  }
  .share-link-box {
    flex-wrap: wrap;
    padding: 6px;
  }
  .share-link-box input {
    width: 100%;
    font-size: 0.72rem;
    padding: 6px 8px;
    background: var(--surface, #fff);
    border-radius: var(--radius-sm, 8px);
  }
  .share-link-box .btn {
    width: 100%;
    justify-content: center;
  }
  .share-modal .modal {
    padding: 16px 14px;
  }
  .share-modal .modal-title {
    font-size: 1rem;
  }
  .share-modal .modal-text {
    font-size: 0.8rem;
  }
  .modal-actions .btn {
    font-size: 0.75rem;
    padding: 6px 14px;
  }
  .brand-header {
    flex-direction: column;
    align-items: flex-start;
    padding-top: 36px;
  }
  .brand-text h1 {
    font-size: 1.2rem;
  }
  .brand-logo img {
    height: 34px;
  }
  .card {
    padding: 14px 12px;
  }
  .card-title {
    font-size: 0.9rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .form-group label {
    font-size: 0.7rem;
  }
  .form-group input,
  .form-group select {
    font-size: 0.82rem;
    padding: 8px 10px;
  }
  .btn {
    font-size: 0.78rem;
    padding: 8px 14px;
  }
  .btn-group {
    flex-direction: column;
    gap: 8px;
  }
  .btn-group .btn {
    width: 100%;
    justify-content: center;
  }
  .instructions {
    font-size: 0.75rem;
    padding: 10px 12px;
  }
  .area h2 {
    font-size: 0.9rem;
  }
  .area table {
    font-size: 0.65rem;
  }
  .area table th,
  .area table td {
    padding: 4px 3px;
  }
  .area table input[type="radio"] {
    width: 14px;
    height: 14px;
  }
  .area table input[type="text"],
  .area table input[type="date"] {
    font-size: 0.6rem;
    padding: 3px 4px;
    max-width: 70px;
  }
  .photo-preview {
    width: 28px;
    height: 28px;
  }
  .photo-trigger {
    font-size: 0.55rem;
    padding: 2px 6px;
  }
  .photo-trigger .trigger-text {
    display: none;
  }
  .photo-remove {
    width: 16px;
    height: 16px;
    font-size: 8px;
  }
}

@media (max-width: 480px) {
  .analysis-filters .btn-group {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .analysis-filters .btn-group .btn {
    font-size: 0.65rem;
    padding: 6px 4px;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .summary-card .value {
    font-size: 1rem;
  }
  .summary-card .label {
    font-size: 0.55rem;
  }
  .defect-table {
    font-size: 0.6rem;
    min-width: 480px;
  }
  .defect-table th,
  .defect-table td {
    padding: 4px 3px;
  }
  .defect-table .img-thumb {
    width: 28px;
    height: 28px;
  }
  .defect-table .area-badge-sm {
    font-size: 0.5rem;
    padding: 1px 4px;
  }
  .defect-table .status-badge {
    font-size: 0.5rem;
    padding: 1px 4px;
  }
  .share-report-header .report-title {
    font-size: 0.85rem;
  }
  .share-report-header .report-meta {
    font-size: 0.65rem;
    gap: 2px 6px;
  }
  .share-report-header .brand-logo img {
    height: 26px;
  }
  .brand-text h1 {
    font-size: 1rem;
  }
  .brand-text p {
    font-size: 0.7rem;
  }
  .brand-logo img {
    height: 28px;
  }
  .card {
    padding: 10px 8px;
  }
  .card-title {
    font-size: 0.8rem;
  }
  .area table {
    font-size: 0.55rem;
  }
  .area table th,
  .area table td {
    padding: 3px 2px;
  }
  .area table input[type="radio"] {
    width: 12px;
    height: 12px;
  }
  .area table input[type="text"],
  .area table input[type="date"] {
    font-size: 0.5rem;
    padding: 2px 3px;
    max-width: 50px;
  }
  .photo-preview {
    width: 22px;
    height: 22px;
  }
  .photo-trigger {
    font-size: 0.5rem;
    padding: 1px 4px;
  }
  .photo-remove {
    width: 14px;
    height: 14px;
    font-size: 7px;
    top: -4px;
    right: -4px;
  }
  .modal {
    padding: 14px 12px !important;
  }
  .modal-title {
    font-size: 0.95rem;
  }
  .modal-text {
    font-size: 0.75rem;
  }
  .modal-input {
    font-size: 0.8rem;
    padding: 8px 10px;
  }
  .modal-actions .btn {
    font-size: 0.7rem;
    padding: 6px 12px;
  }
  .btn {
    font-size: 0.7rem;
    padding: 6px 10px;
  }
  .share-link-box input {
    font-size: 0.65rem;
  }
  .share-link-box .btn {
    font-size: 0.65rem;
    padding: 5px 10px;
  }
}

@media print {
  .share-mode .no-print .btn-group {
    display: none !important;
  }
  .share-mode .main-content {
    padding: 12px !important;
  }
  .share-mode .share-report-header {
    border-bottom-color: #333 !important;
  }
  .share-report-header .report-meta {
    font-size: 0.7rem !important;
  }
  .share-mode .summary-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
  .share-mode .defect-table .img-thumb {
    width: 50px !important;
    height: 50px !important;
  }
  .defect-table .img-thumb {
    max-width: 60px;
    max-height: 60px;
  }
  .defect-table .col-conducted {
    display: none !important;
  }
  .defect-table td.col-conducted,
  .defect-table th.col-conducted {
    display: none !important;
  }
  .print-conducted-hidden {
    display: none !important;
  }
}

/* Action buttons inside Load Historical Record */
.action-btn-group {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap; /* Prevent wrapping */
  gap: 8px;
  align-items: center;
  width: 100%; /* Take full width of form group */
  min-width: 0; /* Allow shrinking */
}

.action-btn {
  flex: 0 1 auto; /* Don't grow, allow shrink */
  white-space: nowrap;
  padding: 8px 16px;
  font-size: 0.8rem;
  min-height: 38px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Override for Update button (already has .btn-warning) */
#updateEntryBtn {
  background: var(--warning);
  color: #fff;
}
#updateEntryBtn:hover {
  background: #b8771f;
}

/* ─── extra tweaks for Updated By field ─── */
.updated-by-display {
  background: #f5f7fa;
  color: #1a2332;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  width: 100%;
  cursor: default;
  opacity: 0.85;
}
.updated-by-display:disabled {
  background: #f5f7fa;
  color: #1a2332;
  opacity: 0.85;
}
.updated-by-display::placeholder {
  color: #9aa6b5;
  font-weight: 400;
  opacity: 0.7;
}
.updated-by-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.updated-by-label .badge-updated {
  font-size: 0.6rem;
  background: #dbeafe;
  color: #1e40af;
  padding: 0.1rem 0.5rem;
  border-radius: 12px;
  font-weight: 500;
  margin-left: 0.25rem;
}
.history-section .form-grid .form-group:has(.updated-by-display) {
  grid-column: span 1;
}
@media (max-width: 640px) {
  .history-section .form-grid .form-group:has(.updated-by-display) {
    grid-column: span 2;
  }
}
