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

:root {
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-1: #0f172a;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── DEMO BOX ────────────────────────────── */

/* ── PASSWORD RULES ──────────────────────── */

.password-rules {
  list-style: none;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.password-rules li {
  font-size: 0.75rem;
  color: var(--text-3);
  padding-left: 1.25rem;
  position: relative;
  transition: color 0.15s;
}

.password-rules li::before {
  content: '✗';
  position: absolute;
  left: 0;
  color: var(--text-3);
  transition: color 0.15s;
}

.password-rules li.valid {
  color: #16a34a;
}

.password-rules li.valid::before {
  content: '✓';
  color: #16a34a;
}

/* ── DEMO BOX ────────────────────────────── */

.demo-box {
  margin-top: 1.25rem;
  padding: 0.875rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.demo-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 0.5rem;
}

.demo-credentials {
  display: flex;
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--text-2);
  margin-bottom: 0.625rem;
}

.demo-credentials span {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-family: monospace;
}

/* ── AUTH ────────────────────────────────── */

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0f4ff 0%, #f8fafc 100%);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-icon {
  width: 52px;
  height: 52px;
  background: var(--primary-light);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 0.875rem;
}

.auth-logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-1);
}

.auth-logo p {
  font-size: 0.8125rem;
  color: var(--text-2);
  margin-top: 0.25rem;
}

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1.5rem;
  gap: 3px;
}

.tab {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
}

.tab.active {
  background: var(--bg-card);
  color: var(--text-1);
  box-shadow: var(--shadow);
}

/* ── HEADER ──────────────────────────────── */

.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.header-icon {
  width: 32px;
  height: 32px;
  background: var(--primary-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.header-title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text-1);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.header-user {
  font-size: 0.8125rem;
  color: var(--text-2);
}

.header-count {
  font-size: 0.75rem;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.625rem;
  font-weight: 500;
}

/* ── MAIN ────────────────────────────────── */

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── STATS ───────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem 1.375rem;
  border-left: 4px solid transparent;
  box-shadow: var(--shadow);
}

.stat-card.stat-reported  { border-left-color: #94a3b8; }
.stat-card.stat-verified  { border-left-color: var(--primary); }
.stat-card.stat-scheduled { border-left-color: #7c3aed; }
.stat-card.stat-repaired  { border-left-color: #16a34a; }

.stat-skeleton {
  border-left-color: var(--border);
  min-height: 76px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e8edf5 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

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

.stat-count {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1;
  letter-spacing: -0.025em;
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--text-2);
  margin-top: 0.375rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── CONTROLS ────────────────────────────── */

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.filters {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── CARD ────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── TABLE ───────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.6875rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

.td-id {
  color: var(--text-3);
  font-size: 0.8rem;
  font-weight: 500;
}

.td-location {
  font-weight: 500;
}

.td-actions {
  display: flex;
  gap: 0.375rem;
}

/* ── BADGES ──────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.severity-low      { background: #dcfce7; color: #15803d; }
.severity-medium   { background: #fef3c7; color: #b45309; }
.severity-high     { background: #ffedd5; color: #c2410c; }
.severity-critical { background: #fee2e2; color: #b91c1c; }

.status-reported  { background: #f1f5f9; color: #475569; }
.status-verified  { background: #eff6ff; color: #1d4ed8; }
.status-scheduled { background: #ede9fe; color: #6d28d9; }
.status-repaired  { background: #dcfce7; color: #15803d; }

.image-preview-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.image-preview {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.btn-remove-image {
  font-size: 0.75rem;
  color: #ef4444;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.btn-remove-image:hover { text-decoration: underline; }

.row-thumbnail {
  width: 36px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-right: 0.4rem;
}

.ai-hint {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
}

.ai-processing {
  background: #fef9c3;
  color: #854d0e;
  cursor: default;
  animation: ai-pulse 2s ease-in-out infinite;
}

.ai-verified {
  background: #eff6ff;
  color: #1d4ed8;
}

.ai-verified-block {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 220px;
}

.ai-rationale-text {
  font-size: 0.7rem;
  color: #475569;
  line-height: 1.4;
  margin: 0;
  font-style: italic;
}

.ai-overridden {
  background: #fef2f2;
  color: #dc2626;
}

.ai-override-warning {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  color: #92400e;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

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

/* ── STATES ──────────────────────────────── */

.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 4rem 2rem;
  color: var(--text-2);
  font-size: 0.875rem;
  text-align: center;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.cold-start-hint {
  font-size: 0.75rem;
  color: var(--text-3);
  max-width: 280px;
  line-height: 1.5;
}

/* ── PAGINATION ──────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--border);
}

.pag-info {
  font-size: 0.8rem;
  color: var(--text-2);
  margin-right: auto;
}

/* ── BUTTONS ─────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

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

.btn-outline {
  background: #fff;
  color: var(--text-1);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text-1); }

.btn-icon-edit {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary);
  transition: all 0.15s;
  font-family: inherit;
}
.btn-icon-edit:hover { background: var(--primary-light); border-color: var(--primary); }

.btn-icon-delete {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--danger);
  transition: all 0.15s;
  font-family: inherit;
}
.btn-icon-delete:hover { background: var(--danger-light); border-color: var(--danger); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm   { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── FORMS ───────────────────────────────── */

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-1);
  margin-bottom: 0.375rem;
}

.label-optional {
  color: var(--text-3);
  font-weight: 400;
  font-size: 0.8125rem;
}

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

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text-1);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

textarea { resize: vertical; }

.error-msg {
  background: var(--danger-light);
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}

/* ── MODAL ───────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--bg-card);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h2 {
  font-size: 1.0625rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  padding: 0.375rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text-1); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

/* ── TOASTS ──────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  font-size: 0.875rem;
  color: var(--text-1);
  max-width: 320px;
  animation: toast-in 0.2s ease;
  transition: opacity 0.3s;
}

.toast-success { border-left-color: #16a34a; }
.toast-error   { border-left-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}

/* ── RESPONSIVE ──────────────────────────── */

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .hide-tablet { display: none; }
}

@media (max-width: 600px) {
  .header-user { display: none; }
  .main-content { padding: 1.25rem 1rem 3rem; }
  .controls { flex-direction: column; align-items: stretch; }
  .filters { flex-direction: column; }
  .filters select { width: 100%; }
  .hide-mobile { display: none; }
  .form-row { grid-template-columns: 1fr; }
}
