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

:root {
  --primary: #c0392b;
  --primary-dark: #a93226;
  --primary-light: #fdecea;
  --secondary: #e74c3c;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Typography ────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }
p  { color: var(--gray-600); }

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

/* ─── Header / Navbar ───────────────────────────────────────────────── */
.navbar {
  background: var(--primary);
  color: var(--white);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
}
.navbar-brand .brand-icon {
  width: 40px; height: 40px;
  background: var(--white);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.navbar-brand .brand-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 3px;
}
.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.navbar-time {
  font-size: 0.85rem;
  opacity: 0.85;
  font-family: monospace;
}
.navbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ─── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 11px 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--white);
  color: var(--white);
}
.btn-outline:hover { background: rgba(255,255,255,0.15); }

/* ─── Card ──────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-body { padding: 24px; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); }

/* ─── Forms ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 9px 13px;
  font-size: 0.9rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-800);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
}
.form-control::placeholder { color: var(--gray-400); }
select.form-control { cursor: pointer; }

/* ─── Stat Cards ────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.yellow { background: var(--warning-light); }
.stat-icon.purple { background: #f3e8ff; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 0.8rem; color: var(--gray-500); margin-top: 2px; }

/* ─── Tables ────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--primary);
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody tr { border-bottom: 1px solid var(--gray-100); }
tbody tr:hover { background: var(--primary-light); }
tbody td { padding: 11px 14px; color: var(--gray-700); vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-blue   { background: var(--primary-light); color: var(--primary); }
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-gray   { background: var(--gray-100);      color: var(--gray-600); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }

/* ─── Tabs ──────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.tab-btn {
  flex: 1;
  padding: 9px 16px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Alert / Toast ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--white);
  border-radius: var(--radius);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  animation: slideIn 0.25s ease;
  font-size: 0.875rem;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.info    { border-color: var(--primary); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; color: var(--gray-700); }
.toast-close { background: none; border: none; color: var(--gray-400); cursor: pointer; padding: 2px; font-size: 1rem; }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(120%); }
}
.toast.removing { animation: fadeOut 0.25s ease forwards; }

/* ─── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--primary-light);
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ─── Login Page ────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #c0392b 0%, #922b21 50%, #6e1f17 100%);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.login-header {
  background: var(--primary);
  padding: 32px 24px;
  text-align: center;
  color: var(--white);
}
.login-logo {
  width: 80px; height: 80px;
  background: var(--white);
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.login-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 6px;
}
.login-header h1 { color: var(--white); font-size: 1.4rem; margin-bottom: 4px; }
.login-header p  { color: rgba(255,255,255,0.85); font-size: 0.875rem; }
.login-body { padding: 32px 24px; }
.login-tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
}
.login-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
}
.login-tab.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.forgot-link {
  color: var(--primary);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
}

/* ─── Dashboard ─────────────────────────────────────────────────────── */
.page-content {
  padding: 24px 16px;
  max-width: 900px;
  margin: 0 auto;
}
.page-header { margin-bottom: 24px; }
.page-header h2 { color: var(--gray-900); }
.page-header p  { color: var(--gray-500); font-size: 0.9rem; margin-top: 4px; }

/* ─── Admin ─────────────────────────────────────────────────────────── */
.admin-content {
  padding: 24px 16px;
  max-width: 1280px;
  margin: 0 auto;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
}
.filter-row .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state p { font-size: 0.9rem; }

/* ─── Staff Summary Cards ───────────────────────────────────────────── */
.staff-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.staff-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.staff-card-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--gray-800);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.staff-card-name .avatar-sm {
  width: 30px; height: 30px;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
}
.staff-card-stat { font-size: 0.8rem; color: var(--gray-600); margin-bottom: 4px; }
.staff-card-stat span { font-weight: 600; color: var(--gray-800); }

/* ─── 2-col form grid (collapses on mobile) ─────────────────────────── */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { padding: 0 14px; }
  .navbar-time { display: none; }
  h1 { font-size: 1.4rem; }

  /* Form grids → single column */
  .form-grid-2 { grid-template-columns: 1fr; }

  /* Tighter card padding */
  .card-body { padding: 16px; }
  .card-header { padding: 12px 16px; }

  /* Tabs — smaller so 5 tabs don't overflow as badly */
  .tab-btn { padding: 8px 10px; font-size: 0.8rem; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Filters */
  .filter-row { flex-direction: column; }
  .filter-row .form-group { min-width: 100%; }
  .filter-download-wrap { margin-left: 0 !important; width: 100%; }
  .filter-download-wrap .btn { width: 100%; justify-content: center; }

  /* Toast — stretch to near full width */
  .toast-container { right: 12px; left: 12px; }
  .toast { min-width: 0; max-width: none; width: 100%; }

  /* Service inline update row */
  #upd_deliveredFields > div { width: 100%; }
  #upd_deliveredFields input,
  #upd_deliveredFields select { width: 100% !important; }
}

@media (max-width: 480px) {
  /* Navbar — hide redundant items to prevent overflow */
  .navbar { padding: 0 12px; }
  .navbar-right { gap: 8px; }
  .nav-username { display: none; }       /* hide name text next to avatar */
  .btn-profile-nav { display: none; }    /* hide "👤 Profile" button — avatar already links */

  /* Page padding — reclaim a few px on small screens */
  .page-content  { padding: 16px 12px; }
  .admin-content { padding: 16px 12px; }
  .profile-wrap  { padding: 16px 12px 48px; }

  /* Page header */
  .page-header h2 { font-size: 1.15rem; }
}
