:root {
  --primary: #1B3A5C;
  --primary-light: #2A5580;
  --primary-dark: #0F2440;
  --accent: #C41E3A;
  --accent-light: #E8243F;
  --success: #28A745;
  --success-bg: #D4EDDA;
  --warning: #F0AD4E;
  --warning-bg: #FFF3CD;
  --danger: #DC3545;
  --danger-bg: #F8D7DA;
  --info: #17A2B8;
  --info-bg: #D1ECF1;
  --bg: #F0F2F5;
  --card-bg: #FFFFFF;
  --text: #2D3748;
  --text-light: #718096;
  --border: #E2E8F0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* --- Header --- */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  padding: 0;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-brand .subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-actions .admin-name {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* --- Hamburger Button --- */
.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.25); }
.hamburger-btn span {
  display: block;
  height: 2px;
  width: 100%;
  background: white;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.hamburger-btn.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* --- Sidebar --- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.sidebar {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  z-index: 300;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar.open { right: 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.sidebar-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: background 0.2s;
}
.sidebar-close:hover { background: rgba(255,255,255,0.35); }

.sidebar-nav {
  padding: 0.5rem 0;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 1.25rem;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: left;
}
.sidebar-item:hover {
  background: var(--bg);
  color: var(--primary);
}
.sidebar-item svg { flex-shrink: 0; color: var(--text-light); transition: color 0.15s; }
.sidebar-item:hover svg { color: var(--primary); }

.sidebar-item-danger { color: var(--danger); }
.sidebar-item-danger svg { color: var(--danger); }
.sidebar-item-danger:hover { background: var(--danger-bg); color: var(--danger); }
.sidebar-item-danger:hover svg { color: var(--danger); }

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0.4rem 1.25rem;
}

.sidebar-section-label {
  padding: 0.5rem 1.25rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #218838; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #C82333; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-ghost { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

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

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* --- Cards --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.card-body { padding: 1.5rem; }

/* --- Forms --- */
.form-section {
  margin-bottom: 2rem;
}

.form-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.form-group label .required {
  color: var(--accent);
  margin-left: 2px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group input[type="file"] {
  padding: 0.5rem;
  border-style: dashed;
}

.form-group .hint {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.radio-group {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  cursor: pointer;
}

.radio-group input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* --- Time Slot Picker --- */
.slot-picker {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.slot-option {
  flex: 1;
  min-width: 160px;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}

.slot-option:hover:not(.unavailable) {
  border-color: var(--primary);
  background: rgba(27, 58, 92, 0.03);
}

.slot-option.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.slot-option.unavailable {
  background: #F7F7F7;
  border-color: #E0E0E0;
  color: #AAA;
  cursor: not-allowed;
  text-decoration: line-through;
}

.slot-option .slot-time {
  font-weight: 700;
  font-size: 1rem;
}

.slot-option .slot-status {
  font-size: 0.78rem;
  margin-top: 0.25rem;
}

.slot-option.selected .slot-status { color: rgba(255,255,255,0.85); }

/* --- Disclaimer Banner --- */
.disclaimer {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.disclaimer svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.disclaimer p {
  font-size: 0.9rem;
  font-weight: 500;
  color: #856404;
}

/* --- Success Message --- */
.success-message {
  text-align: center;
  padding: 3rem 2rem;
}

.success-message .check-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.success-message h2 {
  color: var(--success);
  margin-bottom: 0.75rem;
}

.success-message p {
  color: var(--text-light);
  max-width: 480px;
  margin: 0 auto;
}

/* --- Login Page --- */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  padding: 2rem;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.login-card .logo-area {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.login-card .logo-area h1 {
  font-size: 1.3rem;
  color: var(--primary);
}

.login-card .logo-area p {
  font-size: 0.85rem;
  color: var(--text-light);
}

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

.login-card .btn {
  width: 100%;
  justify-content: center;
  margin-top: 0.5rem;
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}

/* --- Admin Dashboard --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-card.clickable-card { cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.stat-card.clickable-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-card.pending .stat-value { color: var(--warning); }
.stat-card.approved .stat-value { color: var(--success); }
.stat-card.denied .stat-value { color: var(--danger); }
.stat-card.completed .stat-value { color: var(--primary); }
.stat-card.today .stat-value { color: var(--info); }

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.5rem;
}

.filter-bar select,
.filter-bar input {
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  background: white;
}

.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-bar input[type="text"] { min-width: 200px; }

/* --- Transport Table --- */
.transport-table {
  width: 100%;
  border-collapse: collapse;
}

.transport-table th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  background: #FAFBFC;
}

.transport-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}

.transport-table tr:hover td { background: #F8F9FA; }

.transport-table .clickable { cursor: pointer; }

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.pending { background: var(--warning-bg); color: #856404; }
.status-badge.approved { background: var(--success-bg); color: #155724; }
.status-badge.denied { background: var(--danger-bg); color: #721C24; }
.status-badge.cancelled { background: #E2E8F0; color: #4A5568; }
.status-badge.completed { background: #E8EAF6; color: var(--primary); }

/* --- Detail Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 750px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.25s;
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-header h2 {
  font-size: 1.15rem;
  color: var(--primary);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--border); }

.modal-body { padding: 1.5rem; }

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

.detail-item {
  padding: 0.5rem 0;
}

.detail-item.full-width { grid-column: 1 / -1; }

.detail-item .detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.detail-item .detail-value {
  font-size: 0.95rem;
  color: var(--text);
}

.modal-actions {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  position: sticky;
  bottom: 0;
  background: white;
}

.modal-actions .admin-notes-input {
  flex: 1;
  min-width: 200px;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
}

/* --- Facility Search --- */
.facility-search {
  padding: 0.65rem 0.85rem 0.65rem 2.2rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 0.65rem center no-repeat;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.facility-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.1);
}

.pac-container {
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  z-index: 10000 !important;
}

.pac-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  cursor: pointer;
}

.pac-item:hover {
  background: var(--bg);
}

.pac-item-selected {
  background: rgba(27, 58, 92, 0.06);
}

/* --- CAD Toggle --- */
.cad-toggle {
  font-size: 0.75rem !important;
  padding: 0.25rem 0.6rem !important;
  min-width: 80px;
  justify-content: center;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-light);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h3 { margin-bottom: 0.5rem; }

/* --- Loading --- */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; text-align: center; gap: 0.75rem; }
  .container, .container-wide { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .slot-picker { flex-direction: column; }
  .modal { max-height: 95vh; }
  .filter-bar { flex-direction: column; }
  .filter-bar input[type="text"] { min-width: unset; width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-actions { flex-direction: column; }
  .modal-actions .admin-notes-input { min-width: unset; width: 100%; }
  .transport-table-wrapper { overflow-x: auto; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .header-brand h1 { font-size: 1.1rem; }
}

/* --- Utilities --- */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.hidden { display: none !important; }

/* --- Viewer Banner --- */
.viewer-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #e8eaf6;
  color: #3949ab;
  border: 1px solid #c5cae9;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.viewer-banner svg { flex-shrink: 0; }

/* --- Facility Dropdown --- */
.facility-group {
  display: flex;
  flex-direction: column;
}
.facility-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: white;
  transition: border-color 0.2s;
}
.facility-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 63, 135, 0.1);
}
.facility-other-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.facility-other-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 63, 135, 0.1);
}
