[hidden] { display: none !important; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: #f3f4f6;
  color: #1f2a37;
}

/* ---- Login gate (shared look with the inquiry page) ---- */
.auth-gate {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.auth-card h1 { margin: 0; color: #a3231f; font-size: 22px; }
.auth-sub { margin: 0 0 8px; color: #6b7280; font-size: 14px; }
.auth-card input {
  font-family: inherit; font-size: 15px; padding: 12px 14px;
  border: 1px solid #d1d5db; border-radius: 8px; text-align: center;
}
.auth-card input:focus { outline: none; border-color: #a3231f; }
.auth-card button {
  font-family: inherit; font-size: 16px; font-weight: 700; padding: 12px;
  border: none; border-radius: 8px; background: #a3231f; color: #fff; cursor: pointer;
}
.auth-card button:hover { background: #8c1d1a; }
.auth-card button:disabled { opacity: 0.6; cursor: default; }

.message { font-size: 14px; padding: 8px; border-radius: 6px; }
.message.error { background: #fef2f2; color: #b91c1c; }

/* ---- Header ---- */
.admin-header {
  background: #1f2937; color: #fff; padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.admin-title { font-weight: 800; font-size: 18px; }
.admin-header-right { display: flex; align-items: center; gap: 14px; }
.header-link {
  color: #e5e7eb; text-decoration: none; font-size: 14px; background: none;
  border: 1px solid #374151; border-radius: 6px; padding: 6px 12px; cursor: pointer; font-family: inherit;
}
.header-link:hover { background: #374151; }
.header-link.logout { border-color: #7f1d1d; color: #fca5a5; }
.whoami { font-size: 14px; color: #d1d5db; }

/* ---- Tabs ---- */
.admin-tabs {
  display: flex; gap: 4px; background: #fff; padding: 0 22px;
  border-bottom: 1px solid #e5e7eb; overflow-x: auto;
}
.tab-btn {
  font-family: inherit; font-size: 15px; font-weight: 600; padding: 14px 18px;
  border: none; background: none; color: #6b7280; cursor: pointer; border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab-btn.active { color: #a3231f; border-bottom-color: #a3231f; }

.admin-main { padding: 22px; max-width: 1200px; margin: 0 auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.panel-head h2 { margin: 0; font-size: 20px; color: #1f2937; }
.panel-actions { display: flex; align-items: center; gap: 10px; }
.panel-hint { color: #6b7280; font-size: 13px; margin: 4px 0 16px; }
.panel-hint.inline { margin: 0; }

.pending-badge { background: #fef3c7; color: #92400e; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }

.btn-primary { font-family: inherit; font-weight: 700; background: #a3231f; color: #fff; border: none; border-radius: 8px; padding: 9px 16px; cursor: pointer; }
.btn-primary:hover { background: #8c1d1a; }
.btn-ghost { font-family: inherit; background: #fff; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 14px; cursor: pointer; color: #374151; }
.btn-ghost:hover { border-color: #a3231f; color: #a3231f; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: right; white-space: nowrap; }
.admin-table thead th { background: #f9fafb; color: #6b7280; font-weight: 600; font-size: 13px; border-bottom: 1px solid #e5e7eb; }
.admin-table tbody tr:not(:last-child) td { border-bottom: 1px solid #f3f4f6; }
.admin-table tr.status-pending td { background: #fffbeb; }
.admin-table tr.inactive td { opacity: 0.55; }
.empty { text-align: center; color: #9ca3af; padding: 24px; }

.status-pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-pill.approved { background: #dcfce7; color: #166534; }
.status-pill.blocked { background: #fee2e2; color: #991b1b; }
.status-pill.pending { background: #fef3c7; color: #92400e; }
.role-tag { background: #ede9fe; color: #6d28d9; font-size: 11px; padding: 2px 6px; border-radius: 4px; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.actions-cell button { font-family: inherit; font-size: 12px; font-weight: 700; border: none; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.btn-approve { background: #dcfce7; color: #166534; }
.btn-approve:hover { background: #bbf7d0; }
.btn-block { background: #fee2e2; color: #991b1b; }
.btn-block:hover { background: #fecaca; }
.btn-del { background: #f3f4f6; color: #6b7280; }
.btn-del:hover { background: #e5e7eb; }
.max-input { width: 52px; padding: 4px 6px; border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit; text-align: center; }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 2000; }
.modal-card { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.modal-card h3 { margin: 0 0 4px; color: #a3231f; }
.modal-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.modal-card input[type=text], .modal-card input[type=number] { font-family: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; }
.row-check { flex-direction: row !important; align-items: center; gap: 8px; }
.modal-actions { display: flex; justify-content: flex-start; gap: 10px; margin-top: 6px; }

/* ---- Tracking ---- */
.tracking-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
#map { height: 560px; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.driver-list { display: flex; flex-direction: column; gap: 10px; max-height: 560px; overflow-y: auto; }
.driver-card { background: #fff; border-radius: 10px; padding: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-right: 4px solid #9ca3af; }
.driver-card.online { border-right-color: #16a34a; }
.driver-card.offline { border-right-color: #d1d5db; }
.driver-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.driver-name { font-weight: 700; }
.driver-status { font-size: 12px; color: #6b7280; }
.driver-card.online .driver-status { color: #16a34a; font-weight: 700; }
.driver-meta { font-size: 12px; color: #6b7280; margin-bottom: 8px; }
.driver-cam { width: 100%; border-radius: 8px; }

.car-marker { font-size: 24px; text-align: center; line-height: 30px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.car-marker.offline { filter: grayscale(1) opacity(0.6); }

@media (max-width: 860px) {
  .tracking-layout { grid-template-columns: 1fr; }
  #map { height: 360px; }
  .driver-list { max-height: none; }
}

/* Live stream */
.driver-camera { display: flex; flex-direction: column; gap: 8px; }
.btn-live-stream { font-family: inherit; font-size: 13px; font-weight: 600; padding: 8px 12px; border: 0; border-radius: 8px; background: #a3231f; color: #fff; cursor: pointer; }
.btn-live-stream:hover { background: #8a1d1a; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-close { border: 0; background: transparent; font-size: 18px; line-height: 1; cursor: pointer; color: #6b7280; padding: 4px 8px; }
.stream-card { max-width: 760px; }
.stream-container { display: flex; flex-direction: column; gap: 8px; }
.stream-container video { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 4 / 3; }
.stream-status { font-size: 13px; color: #6b7280; min-height: 18px; }

/* Driver actions: capture / message / siren */
.driver-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.driver-actions .btn-live-stream,
.driver-actions [data-act="capture"] { grid-column: 1 / -1; }
.btn-chip { font-family: inherit; font-size: 12px; font-weight: 600; padding: 7px 8px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #374151; cursor: pointer; }
.btn-chip:hover:not(:disabled) { border-color: #a3231f; color: #a3231f; }
.btn-chip:disabled { opacity: 0.6; cursor: default; }
.btn-chip.active { background: #fef2f2; border-color: #a3231f; color: #a3231f; animation: chip-pulse 1s infinite; }
@keyframes chip-pulse { 50% { opacity: 0.55; } }
.driver-flag { font-size: 12px; border-radius: 6px; padding: 5px 8px; margin-bottom: 8px; }
.driver-flag.queued { background: #fffbeb; color: #92400e; }
.driver-flag.delivered { background: #ecfdf5; color: #065f46; }

/* Recording controls */
.stream-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stream-actions { flex-wrap: wrap; }
.btn-record { font-family: inherit; font-weight: 700; background: #fff; color: #a3231f; border: 1px solid #a3231f; border-radius: 8px; padding: 9px 16px; cursor: pointer; }
.btn-record:disabled { opacity: 0.45; cursor: default; border-color: #d1d5db; color: #9ca3af; }
.btn-record.recording { background: #a3231f; color: #fff; }
.rec-indicator { font-size: 13px; font-weight: 700; color: #a3231f; animation: chip-pulse 1s infinite; }

/* Front / back lens: a two-state selector, not a blind toggle */
.camera-switch { display: inline-flex; border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; }
.cam-opt { font-family: inherit; font-size: 13px; font-weight: 600; padding: 9px 14px; border: 0; background: #fff; color: #6b7280; cursor: pointer; }
.cam-opt:not(:last-child) { border-left: 1px solid #d1d5db; }
.cam-opt:hover:not(.active) { color: #a3231f; }
.cam-opt.active { background: #a3231f; color: #fff; }

/* Message + siren modals */
.modal-card textarea { font-family: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; resize: vertical; }
.modal-card select { font-family: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; }
