/* ============================================================
   Campus Blood Connect — Main Stylesheet
   Mobile-first, medical-grade design system
   ============================================================ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  --primary:        #dc2626;
  --primary-dark:   #991b1b;
  --primary-light:  #fee2e2;
  --primary-50:     #fff5f5;
  --secondary:      #1e40af;
  --secondary-light:#dbeafe;
  --success:        #16a34a;
  --success-light:  #dcfce7;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #dc2626;
  --info:           #0891b2;
  --info-light:     #cffafe;

  --text:           #1f2937;
  --text-light:     #6b7280;
  --text-lighter:   #9ca3af;
  --bg:             #f9fafb;
  --bg-alt:         #f3f4f6;
  --white:          #ffffff;
  --border:         #e5e7eb;
  --border-dark:    #d1d5db;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.10), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl:  0 20px 25px rgba(0,0,0,.10), 0 10px 10px rgba(0,0,0,.04);

  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full:9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Fira Code', 'Consolas', monospace;

  --transition: 0.2s ease;
  --transition-slow: 0.4s ease;

  --nav-height: 64px;
  --container-max: 1200px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select, button { font-family: inherit; font-size: 1rem; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}
h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
p  { margin-bottom: .75rem; color: var(--text-light); }
p:last-child { margin-bottom: 0; }
strong { font-weight: 600; color: var(--text); }
small  { font-size: .8125rem; }

/* ── Layout Utilities ─────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 1rem; }
.container-md { max-width: 768px; margin: 0 auto; padding: 0 1rem; }

.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1  { gap: .25rem; }
.gap-2  { gap: .5rem; }
.gap-3  { gap: .75rem; }
.gap-4  { gap: 1rem; }
.gap-6  { gap: 1.5rem; }
.gap-8  { gap: 2rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-1    { flex: 1; }

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

.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

.p-2 { padding: .5rem; }
.p-3 { padding: .75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }

.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-sm   { font-size: .875rem; }
.text-xs   { font-size: .75rem; }
.text-lg   { font-size: 1.125rem; }
.text-xl   { font-size: 1.25rem; }
.text-2xl  { font-size: 1.5rem; }
.text-3xl  { font-size: 1.875rem; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.text-primary  { color: var(--primary) !important; }
.text-success  { color: var(--success) !important; }
.text-warning  { color: var(--warning) !important; }
.text-muted    { color: var(--text-light); }
.text-white    { color: var(--white) !important; }

.hidden { display: none !important; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.absolute { position: absolute; }
.sticky  { position: sticky; }
.top-0   { top: 0; }
.z-10    { z-index: 10; }
.z-50    { z-index: 50; }
.overflow-hidden { overflow: hidden; }
.rounded    { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.border { border: 1px solid var(--border); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }

/* ── Navigation ───────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  height: var(--nav-height);
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: .5rem;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 800;
  font-size: 1.125rem;
  color: var(--primary);
  white-space: nowrap;
  text-decoration: none;
}
.navbar-brand .logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem;
  flex-shrink: 0;
}
.navbar-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
}
.navbar-nav a {
  display: flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .75rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.navbar-nav a:hover,
.navbar-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
}
.navbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.btn-emergency-nav {
  display: flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  background: var(--primary);
  color: white !important;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .875rem;
  transition: background var(--transition), transform var(--transition);
  animation: pulse-red 2s infinite;
}
.btn-emergency-nav:hover {
  background: var(--primary-dark) !important;
  color: white !important;
  transform: scale(1.03);
}
.notif-bell {
  position: relative;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--text-light);
  transition: background var(--transition), color var(--transition);
  font-size: 1.1rem;
  text-decoration: none;
}
.notif-bell:hover { background: var(--bg-alt); color: var(--text); }
.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: .625rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  line-height: 1;
  border: 2px solid var(--white);
}
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: .5rem;
  cursor: pointer;
  border: none;
  background: none;
  border-radius: var(--radius);
}
.hamburger span {
  width: 22px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
/* X state when menu is open */
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.mobile-menu {
  display: flex;
  position: fixed;
  inset: var(--nav-height) 0 0 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 1rem;
  z-index: 99;
  overflow-y: auto;
  flex-direction: column;
  gap: .25rem;
  /* Slide in from left — hidden by default */
  transform: translateX(-100%);
  transition: transform .28s ease;
  /* Hidden from assistive tech and pointer events when closed */
  visibility: hidden;
  /* Max width so it doesn't cover full screen on tablets */
  max-width: 320px;
}
.mobile-menu.open {
  transform: translateX(0);
  visibility: visible;
}
/* On desktop, ensure it's never accidentally visible */
@media (min-width: 768px) {
  .mobile-menu { display: none !important; }
}
.mobile-menu a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition);
}
.mobile-menu a:hover { background: var(--bg-alt); }
.mobile-menu .btn-emergency-nav {
  justify-content: center;
  margin-top: .5rem;
}
/* Mobile menu backdrop */
.mobile-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,.4);
  z-index: 98;
  backdrop-filter: blur(2px);
}

/* User avatar in nav */
.nav-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem;
  text-decoration: none;
  border: 2px solid var(--primary-light);
  transition: border-color var(--transition);
}
.nav-avatar:hover { border-color: var(--primary); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .9375rem;
  border: 2px solid transparent;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition),
              box-shadow var(--transition);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:active { transform: scale(.97); }
.btn-sm { padding: .375rem .875rem; font-size: .8125rem; }
.btn-lg { padding: .875rem 2rem; font-size: 1.0625rem; border-radius: var(--radius-lg); }
.btn-xl { padding: 1.125rem 2.5rem; font-size: 1.125rem; border-radius: var(--radius-lg); }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
  box-shadow: 0 4px 12px rgba(220,38,38,.3);
}
.btn-secondary {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}
.btn-secondary:hover { background: #1e3a8a; border-color: #1e3a8a; color: white; }
.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover { background: #15803d; border-color: #15803d; color: white; }
.btn-danger {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-danger:hover { background: var(--primary-dark); color: white; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: white;
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-alt); }
.btn-white {
  background: white;
  color: var(--primary);
  border-color: white;
  font-weight: 700;
}
.btn-white:hover { background: var(--primary-light); }
.btn:disabled, .btn[aria-busy="true"] {
  opacity: .6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Emergency button with pulse */
.btn-emergency {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-size: 1.0625rem;
  padding: .875rem 2rem;
  border-radius: var(--radius-lg);
  font-weight: 800;
  box-shadow: 0 4px 20px rgba(220,38,38,.4);
  animation: pulse-red 2.5s infinite;
}
.btn-emergency:hover {
  background: var(--primary-dark);
  color: white;
  animation: none;
  box-shadow: 0 6px 24px rgba(220,38,38,.5);
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-body { padding: 1.25rem; }
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.card-header h3, .card-header h4 { margin: 0; }
.card-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.card:hover { box-shadow: var(--shadow-md); transition: box-shadow var(--transition); }

/* Stat card */
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-icon.red   { background: var(--primary-light); }
.stat-icon.blue  { background: var(--secondary-light); }
.stat-icon.green { background: var(--success-light); }
.stat-icon.yellow{ background: var(--warning-light); }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: .8125rem; color: var(--text-light); margin-top: .25rem; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.125rem; }
.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .375rem;
}
.form-label .required { color: var(--primary); margin-left: .125rem; }
.form-control {
  width: 100%;
  padding: .625rem .875rem;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: .9375rem;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220,38,38,.15);
}
.form-control::placeholder { color: var(--text-lighter); }
.form-control:disabled { background: var(--bg-alt); cursor: not-allowed; }
.form-control.is-invalid { border-color: var(--primary); }
.form-control.is-valid   { border-color: var(--success); }
.form-hint { font-size: .8125rem; color: var(--text-light); margin-top: .3rem; }
.form-error { font-size: .8125rem; color: var(--primary); margin-top: .3rem; display: none; }
.form-control.is-invalid + .form-error { display: block; }
.form-control.is-invalid + .form-hint + .form-error { display: block; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .875rem center;
  padding-right: 2.25rem;
}

/* Range input */
input[type="range"].form-range {
  width: 100%; height: 6px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--border);
  accent-color: var(--primary);
  cursor: pointer;
  padding: 0;
}

/* File input */
.file-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .5rem;
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 2rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}
.file-input-wrapper:hover { border-color: var(--primary); background: var(--primary-50); }
.file-input-wrapper input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .6rem;
  border-radius: var(--radius-full);
  font-size: .75rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.badge-red    { background: var(--primary-light); color: var(--primary-dark); }
.badge-blue   { background: var(--secondary-light); color: var(--secondary); }
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: #92400e; }
.badge-gray   { background: var(--bg-alt); color: var(--text-light); }
.badge-purple { background: #ede9fe; color: #7c3aed; }

/* Blood group badges */
.bg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: .875rem;
  flex-shrink: 0;
}
.bg-Ap  { background: #fee2e2; color: #991b1b; }
.bg-Am  { background: #fde8d8; color: #92400e; }
.bg-Bp  { background: #dbeafe; color: #1e40af; }
.bg-Bm  { background: #e0e7ff; color: #3730a3; }
.bg-ABp { background: #ede9fe; color: #6d28d9; }
.bg-ABm { background: #fce7f3; color: #be185d; }
.bg-Op  { background: #dcfce7; color: #166534; }
.bg-Om  { background: #d1fae5; color: #065f46; }

/* Urgency badges */
.urgency-normal   { background: var(--success-light); color: var(--success); }
.urgency-urgent   { background: var(--warning-light); color: #92400e; }
.urgency-critical {
  background: var(--primary-light);
  color: var(--primary-dark);
  animation: pulse-text 1.5s ease infinite;
}

/* Donor badges */
.donor-badge-active_donor   { background: #dbeafe; color: #1e40af; }
.donor-badge-rare_donor     { background: #ede9fe; color: #7c3aed; }
.donor-badge-emergency_hero { background: #fee2e2; color: #991b1b; }
.donor-badge-none           { background: var(--bg-alt); color: var(--text-lighter); }

/* ── Availability Indicator ───────────────────────────────── */
.availability-dot {
  width: 10px; height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.availability-dot.available   { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.2); }
.availability-dot.unavailable { background: var(--text-lighter); }

/* ── Toggle Switch ────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: .75rem; }
.toggle {
  position: relative;
  width: 48px; height: 26px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-dark);
  border-radius: var(--radius-full);
  transition: background var(--transition);
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-wrap {
  height: 8px;
  background: var(--bg-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #f87171);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}
.progress-bar.green { background: linear-gradient(90deg, #16a34a, #4ade80); }
.progress-bar.blue  { background: linear-gradient(90deg, #1e40af, #60a5fa); }

/* ── Toast Notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 2rem));
  width: calc(100vw - 2rem);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--primary);
  pointer-events: all;
  animation: slideInRight .3s ease;
  position: relative;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.info    { border-left-color: var(--info); }
.toast.error   { border-left-color: var(--primary); }
.toast-icon    { font-size: 1.25rem; flex-shrink: 0; margin-top: .1rem; }
.toast-body .toast-title {
  font-weight: 700;
  font-size: .875rem;
  color: var(--text);
  margin-bottom: .125rem;
}
.toast-body .toast-message { font-size: .8125rem; color: var(--text-light); }
.toast-close {
  position: absolute;
  top: .5rem; right: .5rem;
  background: none; border: none;
  font-size: 1rem;
  color: var(--text-lighter);
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}
.toast-close:hover { color: var(--text); }

/* ── Loading Spinner ─────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner.dark {
  border-color: rgba(220,38,38,.2);
  border-top-color: var(--primary);
}
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

/* ── Page Layout ─────────────────────────────────────────── */
.page-wrapper {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  min-height: calc(100vh - var(--nav-height));
}
.page-header {
  margin-bottom: 1.5rem;
}
.page-header h1 { margin-bottom: .25rem; }
.page-header p  { font-size: 1rem; color: var(--text-light); }
.page-subtitle {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--text-light);
  margin-top: .25rem;
}

/* ── Section ─────────────────────────────────────────────── */
.section { padding: 4rem 0; }
.section-sm { padding: 2.5rem 0; }
.section-title {
  text-align: center;
  margin-bottom: .75rem;
}
.section-subtitle {
  text-align: center;
  font-size: 1.0625rem;
  color: var(--text-light);
  max-width: min(560px, 100%);
  margin: 0 auto 2.5rem;
}

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #1f2937 0%, #111827 60%, #450a0a 100%);
  color: white;
  padding: 5rem 0 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 40%, rgba(220,38,38,.15) 0%, transparent 60%),
              radial-gradient(circle at 20% 80%, rgba(30,64,175,.1) 0%, transparent 50%);
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; }
.hero h1 { color: white; margin-bottom: .75rem; font-size: clamp(2rem,6vw,3.25rem); }
.hero p { color: rgba(255,255,255,.8); font-size: 1.125rem; max-width: 540px; margin: 0 auto 2rem; }
.hero-cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-top: 3.5rem;
  flex-wrap: wrap;
}
.hero-stat-num  { font-size: 2.25rem; font-weight: 800; color: white; line-height: 1; }
.hero-stat-label{ font-size: .875rem; color: rgba(255,255,255,.6); margin-top: .25rem; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .875rem;
  background: rgba(220,38,38,.2);
  border: 1px solid rgba(220,38,38,.4);
  border-radius: var(--radius-full);
  font-size: .875rem;
  color: #fca5a5;
  margin-bottom: 1.25rem;
}

/* ── Alert / Banner ──────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  border-left: 4px solid;
  margin-bottom: 1rem;
}
.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: .05rem; }
.alert-error   { background: var(--primary-light); border-color: var(--primary); color: #991b1b; }
.alert-success { background: var(--success-light); border-color: var(--success); color: #166534; }
.alert-warning { background: var(--warning-light); border-color: var(--warning); color: #92400e; }
.alert-info    { background: var(--info-light);    border-color: var(--info);    color: #164e63; }
.alert-emergency {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  animation: pulse-border 2s infinite;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: .625rem 1.125rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-light);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-btn:hover { color: var(--text); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17,24,39,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn .2s ease;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: min(480px, calc(100vw - 2rem));
  animation: slideUp .25s ease;
  overflow: hidden;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.125rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 1.25rem; color: var(--text-lighter);
  cursor: pointer; transition: color var(--transition);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
}
.modal-close:hover { background: var(--bg-alt); color: var(--text); }
.modal-body   { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .75rem; justify-content: flex-end;
  background: var(--bg);
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  background: #111827;
  color: rgba(255,255,255,.7);
  padding: 2rem 0;
  margin-top: 4rem;
  text-align: center;
  font-size: .875rem;
}
.footer a { color: rgba(255,255,255,.5); transition: color var(--transition); }
.footer a:hover { color: white; }
.footer-links { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: .75rem; }

/* ── Step Indicator (multi-step form) ────────────────────── */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  position: relative;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .375rem;
  position: relative;
  flex: 1;
  max-width: 120px;
}
.step-item::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step-item:last-child::before { display: none; }
.step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-dark);
  background: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem;
  color: var(--text-lighter);
  position: relative; z-index: 1;
  transition: all var(--transition);
}
.step-item.active   .step-circle { border-color: var(--primary); color: var(--primary); }
.step-item.done     .step-circle { border-color: var(--success); background: var(--success); color: white; }
.step-item.active::before        { background: var(--border); }
.step-item.done::before          { background: var(--success); }
.step-label { font-size: .6875rem; font-weight: 600; color: var(--text-lighter); white-space: nowrap; }
.step-item.active .step-label { color: var(--primary); }
.step-item.done   .step-label { color: var(--success); }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; opacity: .5; }
.empty-state h3 { color: var(--text); margin-bottom: .5rem; font-size: 1.125rem; }
.empty-state p  { max-width: min(360px, 100%); margin: 0 auto 1.25rem; }

/* ── Filters bar ─────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.25rem;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .375rem .75rem;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius-full);
  background: white;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.filter-chip.active { border-color: var(--primary); background: var(--primary); color: white; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes pulse-red {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50%     { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
@keyframes pulse-text {
  0%,100% { opacity: 1; }
  50%     { opacity: .7; }
}
@keyframes pulse-border {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.3); }
  50%     { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes slideInRight {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@keyframes heartbeat {
  0%,100% { transform: scale(1); }
  14%     { transform: scale(1.3); }
  28%     { transform: scale(1); }
  42%     { transform: scale(1.3); }
  70%     { transform: scale(1); }
}
.heartbeat { animation: heartbeat 1.5s ease infinite; display: inline-block; }

/* ── Responsive breakpoints ──────────────────────────────── */
@media (min-width: 640px) {
  .container { padding: 0 1.5rem; }
  .sm\:grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .sm\:flex-row { flex-direction: row; }
  .sm\:hidden  { display: none !important; }
}

@media (min-width: 768px) {
  .container { padding: 0 2rem; }
  .grid-2 { gap: 1.25rem; }
  .grid-3 { gap: 1.25rem; }
  .md\:grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
  .md\:grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
  .md\:flex     { display: flex; }
  .md\:hidden   { display: none !important; }
  .md\:flex-row { flex-direction: row !important; }
  .hamburger    { display: none; }
}

/* ── Tablet (768–1023px) ─────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  .hero h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
  .hero-stats { gap: 2rem; }
  .hero-stat-num { font-size: 1.875rem; }
  .stat-card { padding: 1rem; gap: .75rem; }
  .stat-icon { width: 44px; height: 44px; font-size: 1.25rem; }
  .stat-value { font-size: 1.5rem; }
}

/* ── Mobile (≤767px) ─────────────────────────────────────── */
@media (max-width: 767px) {
  .navbar-nav  { display: none; }
  .hamburger   { display: flex; order: -1; }
  .navbar-brand { order: 0; flex: 1; justify-content: center; }
  .navbar-actions { order: 1; gap: .375rem; }
  /* Emergency button takes space in navbar on mobile — use mobile-menu instead */
  .navbar-actions .btn-emergency-nav { display: none; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 3rem 0 2.5rem; }
  .hero-stats { gap: 1.25rem; }
  .hero-stat-num { font-size: 1.75rem; }
  .hero-stat-label { font-size: .8125rem; }
  .hide-mobile { display: none !important; }
  .section { padding: 2.5rem 0; }
  .page-wrapper { padding-top: 1.25rem; padding-bottom: 2rem; }
  /* Tighten stat cards on mobile */
  .stat-card { padding: .875rem; gap: .75rem; }
  .stat-icon { width: 40px; height: 40px; font-size: 1.125rem; }
  .stat-value { font-size: 1.375rem; }
  /* Filters bar wraps nicely */
  .filters-bar { gap: .375rem; }
  /* Profile stats smaller text */
  .profile-stat-num  { font-size: 1.375rem; }
  /* Urgency selector: allow wrap on very small screens */
  .urgency-selector { flex-wrap: wrap; }
  .urgency-option { min-width: calc(50% - .375rem); }
  /* Requests grid: use a safe minimum that fits narrow phones */
  .requests-grid-auto { grid-template-columns: repeat(auto-fill, minmax(min(280px,100%), 1fr)) !important; }
  /* Card padding tighter */
  .card-body { padding: 1rem; }
  .card-header { padding: .875rem 1rem; }
  .card-footer { padding: .75rem 1rem; }
  /* Hero CTA stacks */
  .hero-cta { flex-direction: column; align-items: center; gap: .75rem; }
  .hero-cta .btn { width: min(300px, 90%); justify-content: center; }
}

/* ── Small mobile (≤480px) ───────────────────────────────── */
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .btn-xl { padding: .875rem 1.5rem; font-size: 1rem; }
  .steps .step-label { display: none; }
  .hero-stat-num { font-size: 1.5rem; }
  .hero-stats { gap: 1rem; }
  .bg-selector { grid-template-columns: repeat(4, 1fr); }
  /* Stack urgency options vertically */
  .urgency-option { min-width: 100%; }
  .urgency-selector { flex-direction: column; }
  /* Tighten modals */
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  /* Tighten toast */
  #toast-container { bottom: .75rem; right: .75rem; left: .75rem; width: auto; max-width: 100%; }
  /* Full-width form card */
  .container-sm .card { border-radius: var(--radius-lg); }
}

/* ── Very small (≤375px) ─────────────────────────────────── */
@media (max-width: 375px) {
  .container { padding: 0 .75rem; }
  .navbar { --nav-height: 56px; height: 56px; }
  .page-wrapper { min-height: calc(100vh - 56px); }
  .mobile-menu { inset: 56px 0 0 0; }
  .stat-card { padding: .75rem; gap: .5rem; }
  .bg-selector { grid-template-columns: repeat(4, 1fr); gap: .25rem; }
  .bg-option { padding: .625rem .25rem; font-size: .875rem; }
  .profile-stat-label { font-size: .75rem; }
}

@media (min-width: 1024px) {
  .lg\:grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ── Utility overrides (high specificity) ─────────────────── */
.d-none   { display: none !important; }
.d-flex   { display: flex !important; }
.d-block  { display: block !important; }
.d-grid   { display: grid !important; }
