/* ════════════════════════════════════════════════════
   MPConnect – style.css  (corrigé + amélioré)
   - Fix : ::root -> :root (variables OK)
   - Fix : .app-container unifiée (plus de conflit)
   - Fix : padding bottom-nav + safe-area
   - Nettoyage : doublons @media supprimés
   - Nettoyage : suppression de "* { max-width:100% }" (trop risqué)
   ════════════════════════════════════════════════════ */

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

/* FIX: c'était ::root */
:root {
  --primary:        #0891B2;
  --primary-dark:   #0E7490;
  --primary-light:  #06B6D4;
  --secondary:      #E0F2FE;
  --background:     #F8FAFC;
  --surface:        #FFFFFF;
  --text-primary:   #1E293B;
  --text-secondary: #64748B;
  --border:         #E2E8F0;
  --success:        #10B981;
  --error:          #EF4444;
  --warning:        #F59E0B;

  /* Bottom nav */
  --bottom-nav-height: 72px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito Sans', 'Segoe UI', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* Responsive media elements (au lieu de "* max-width") */
img, video, svg, canvas {
  max-width: 100%;
  height: auto;
}

/* ── Refonte UI responsive bleu/blanc (background) ───── */
body::before {
  content: '';
  position: fixed;
  inset: -30vmax;
  background:
    radial-gradient(circle at 10% 10%, rgba(8, 145, 178, .12) 0%, transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(6, 182, 212, .08) 0%, transparent 42%);
  z-index: -1;
  pointer-events: none;
}

/* ── App Layout ───────────────────────────────────────── */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  width: 100%;
  max-width: 1160px;
  margin: 0 auto;

  /* FIX: laisse de la place au menu fixe + safe-area */
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

/* ── Auth ─────────────────────────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 0% 0%, rgba(224, 242, 254, .95) 0%, rgba(248, 250, 252, .92) 45%),
    linear-gradient(180deg, #f8fcff 0%, #f8fafc 100%);
}

.auth-header {
  padding: 2.5rem 1.5rem 1.5rem;
  text-align: center;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 4px 12px rgba(8,145,178,.25));
}

.logo-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
}

.logo-title {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 2px;
}

.logo-subtitle {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Onglets Auth ─────────────────────────────────────── */
.auth-tabs {
  display: flex;
  gap: 0;
  padding: 0 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: .875rem .5rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all .25s ease;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Formulaires Auth ─────────────────────────────────── */
.auth-form {
  display: none;
  padding: 0 1.5rem 2rem;
  animation: fadeIn .25s ease;
}

.auth-form.active { display: block; }

.auth-form h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: .375rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: .9375rem;
  margin-bottom: 1.5rem;
}

/* ── Sélecteur type utilisateur ───────────────────────── */
.user-type-selector {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.user-type-option { flex: 1; cursor: pointer; }

.user-type-option input[type="radio"] { display: none; }

.user-type-card {
  padding: 1rem .75rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all .25s ease;
}

.user-type-option input[type="radio"]:checked + .user-type-card {
  border-color: var(--primary);
  background: var(--secondary);
}

.user-type-icon {
  display: flex;
  justify-content: center;
  margin-bottom: .5rem;
}

.user-type-card span {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Éléments de formulaire ───────────────────────────── */
.form-group { margin-bottom: .875rem; }

.form-group label {
  display: block;
  margin-bottom: .375rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .875rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}

.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(8,145,178,.12);
}

.form-group input::placeholder { color: var(--text-secondary); }

.form-help {
  margin-top: .375rem;
  font-size: .8125rem;
  color: var(--text-secondary);
}

/* ── Boutons ──────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  padding: .9375rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .15s, box-shadow .2s;
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(8,145,178,.3);
}
.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  background: #94A3B8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: .9375rem;
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
  text-decoration: none;
}

.btn-secondary:hover { background: var(--secondary); }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  padding: .375rem .5rem;
  border-radius: 6px;
  transition: background .2s;
}
.btn-link:hover { background: var(--secondary); }

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--primary);
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--primary); color: white; }

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-copy:hover { background: var(--primary-dark); }

/* ── Pied de page Auth ────────────────────────────────── */
.auth-footer {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: .8125rem;
}

/* ── Header ───────────────────────────────────────────── */
.app-header {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .875rem 1.25rem;
  width: 100%;
  margin: 0 auto;
}

.logo-small {
  display: flex;
  align-items: center;
  gap: .625rem;
}

.header-title {
  display: flex;
  flex-direction: column;
}

.header-title span {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.header-title small {
  font-size: .7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Contenu principal ────────────────────────────────── */
.main-content {
  flex: 1;
  padding: clamp(1rem, 2.2vw, 2rem);
  width: 100%;
  margin: 0 auto;
}

.welcome-section { margin-bottom: 2rem; }

.welcome-section h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.user-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: .125rem;
}

.user-email {
  font-size: .875rem;
  color: var(--text-secondary);
  margin-top: .125rem;
}

/* ── Code Patient Card ────────────────────────────────── */
.patient-code-card {
  margin-top: 1rem;
  padding: 1.25rem;
  background: var(--secondary);
  border-radius: 16px;
  text-align: center;
  border: 1px solid rgba(8,145,178,.2);
}

.code-label {
  font-size: .8125rem;
  color: var(--text-secondary);
  margin-bottom: .375rem;
}

.code-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 6px;
  margin-bottom: .375rem;
}

.code-hint {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: .875rem;
}

/* ── Stats Grid ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .875rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface);
  padding: 1.25rem .75rem;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  border: 1px solid rgba(8, 145, 178, .08);
}

.stat-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: .25rem;
}

.stat-label {
  font-size: .75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ── Actions rapides ──────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  text-decoration: none;
  color: var(--text-primary);
  width: 100%;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

.action-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(8,145,178,.15);
  transform: translateY(-1px);
}

.action-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary);
  border-radius: 12px;
  flex-shrink: 0;
}

.action-content { flex: 1; min-width: 0; }

.action-content h3 {
  font-size: .9375rem;
  font-weight: 700;
  margin-bottom: .125rem;
}

.action-content p {
  font-size: .8125rem;
  color: var(--text-secondary);
}

.action-arrow {
  font-size: 1.5rem;
  color: var(--text-secondary);
  line-height: 1;
}

/* ── En-tête de section ───────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .875rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.section-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

/* ── Cartes Patients / Consultations ──────────────────── */
.patients-list, .antecedents-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1rem;
}

.patient-card {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .9375rem 1rem;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
  cursor: pointer;
  transition: box-shadow .2s, transform .15s;
  border: 1px solid rgba(8, 145, 178, .08);
}

.patient-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
  transform: translateY(-1px);
  border-color: var(--border);
}

.patient-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--primary);
  font-size: 1.125rem;
  flex-shrink: 0;
}

.patient-info { flex: 1; min-width: 0; }

.patient-name {
  font-weight: 600;
  margin-bottom: .125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-code {
  font-size: .8125rem;
  color: var(--text-secondary);
}

/* ── Antécédents ──────────────────────────────────────── */
.antecedent-card {
  padding: .9375rem 1rem;
  background: var(--surface);
  border-left: 4px solid var(--primary);
  border-radius: 0 12px 12px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
  border-right: 1px solid rgba(8, 145, 178, .08);
  border-top: 1px solid rgba(8, 145, 178, .08);
  border-bottom: 1px solid rgba(8, 145, 178, .08);
}

.antecedent-card.medical     { border-left-color: #0891B2; }
.antecedent-card.chirurgical { border-left-color: #F59E0B; }
.antecedent-card.familial    { border-left-color: #8B5CF6; }

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

.antecedent-type {
  display: inline-block;
  padding: .2rem .7rem;
  background: var(--secondary);
  color: var(--primary);
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.antecedent-date { font-size: .8125rem; color: var(--text-secondary); }

.antecedent-title {
  font-weight: 600;
  font-size: 1.0625rem;
  margin-bottom: .25rem;
}

.antecedent-traitement { font-size: .8125rem; color: var(--text-secondary); }

/* ── Navigation du bas ────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;

  display: flex;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);

  border-top: 1px solid var(--border);
  padding: .375rem .5rem;
  z-index: 200;
  box-shadow: 0 -2px 8px rgba(0,0,0,.06);

  /* safe area */
  padding-bottom: calc(.375rem + env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .375rem .25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .6875rem;
  font-weight: 500;
  border-radius: 10px;
  transition: color .2s, background .2s;
}

.nav-item:hover,
.nav-item.active {
  color: var(--primary);
  background: var(--secondary);
}

.nav-item svg { flex-shrink: 0; }

/* ── Modales ──────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  padding: 1rem;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 600px) {
  .modal { align-items: center; }
}

.modal.active { display: flex; }

.modal-content {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
  border: 1px solid rgba(8, 145, 178, .08);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

@media (min-width: 600px) {
  .modal-content { border-radius: 20px; }
}

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

.modal-header h3 { font-size: 1.125rem; font-weight: 700; }

.close-modal {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary);
  border: none;
  font-size: 1.375rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: background .2s, color .2s;
  line-height: 1;
}

.close-modal:hover { background: var(--primary); color: white; }

.modal-content form { padding: 1.25rem 1.5rem; }

/* ── Statuts badges ───────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  margin-top: .375rem;
}

.status-pending   { background: #FEF3C7; color: #92400E; }
.status-confirmed { background: #D1FAE5; color: #065F46; }
.status-cancelled { background: #FEE2E2; color: #991B1B; }
.status-completed { background: #DBEAFE; color: #1E40AF; }

/* ── En-tête de page ──────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: 1.25rem 1.5rem .875rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.btn-back {
  width: 38px;
  height: 38px;
  border: none;
  background: var(--secondary);
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.btn-back:hover { background: var(--primary); color: white; }

.page-header h1 { font-size: 1.375rem; font-weight: 700; }

/* ── Carte patient large ──────────────────────────────── */
.patient-card-large {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.75rem;
  margin: 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.07);
  border: 1px solid rgba(8, 145, 178, .08);
}

.patient-avatar-large {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  margin: 0 auto 1.25rem;
}

.patient-info-large h2 {
  font-size: 1.375rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1rem;
}

.patient-info-large p {
  margin-bottom: .625rem;
  font-size: .9375rem;
}

.patient-info-large strong { color: var(--text-secondary); font-weight: 600; }

.code-badge {
  display: inline-block;
  padding: .25rem .875rem;
  background: var(--secondary);
  color: var(--primary);
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: 3px;
  border-radius: 8px;
  margin-left: .375rem;
}

/* ── QR Scanner ───────────────────────────────────────── */
.qr-scanner-container { padding: 2rem 1.5rem; }

.scanner-info {
  text-align: center;
  margin-bottom: 2rem;
}

.scanner-info h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: .875rem 0 .375rem;
}

.scanner-info p { color: var(--text-secondary); font-size: .9375rem; }

.video-container {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 1.5rem;
  border-radius: 16px;
  overflow: hidden;
  display: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}

#qr-video { width: 100%; height: auto; display: block; }

.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-area {
  width: 180px;
  height: 180px;
  border: 3px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  animation: pulseBorder 2s infinite;
}

@keyframes pulseBorder {
  0%, 100% { border-color: var(--primary); }
  50%      { border-color: var(--primary-light); }
}

.scanner-actions {
  display: flex;
  flex-direction: column;
  gap: .875rem;
  max-width: 400px;
  margin: 0 auto;
}

.result-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
  border: 1px solid rgba(8, 145, 178, .08);
}

.result-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  background: var(--success);
}

.result-card h3 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.patient-details {
  text-align: left;
  padding: 1.125rem;
  background: var(--background);
  border-radius: 12px;
  margin-bottom: 1.25rem;
}

.patient-details p { margin-bottom: .625rem; }
.patient-details strong { color: var(--text-secondary); font-weight: 600; }

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: .75rem;
  color: var(--text-secondary);
}

.empty-state p { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.empty-state small { font-size: .875rem; }

/* ── États de chargement ──────────────────────────────── */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-style: italic;
}

.error {
  padding: .875rem 1rem;
  background: #FEE2E2;
  color: #991B1B;
  border-radius: 10px;
  font-size: .9rem;
}

.success-msg {
  padding: .875rem 1rem;
  background: #D1FAE5;
  color: #065F46;
  border-radius: 10px;
  font-size: .9rem;
}

/* ── Animations ───────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Typo (titres) ────────────────────────────────────── */
h1, h2, h3, h4, h5, h6,
.logo-title,
.section-header h2,
.patient-name,
.conv-name,
.stat-value {
  font-family: 'Outfit', 'Nunito Sans', sans-serif;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 400px) {
  .stats-grid { gap: .5rem; }
  .stat-card { padding: .875rem .5rem; }
  .stat-value { font-size: 1.5rem; }
  .stat-label { font-size: .7rem; }
  .code-value { font-size: 2rem; letter-spacing: 4px; }
  .patient-avatar { width: 40px; height: 40px; font-size: 1rem; }
}

@media (max-width: 767px) {
  .code-value {
    font-size: clamp(2rem, 9vw, 2.7rem);
    letter-spacing: .28rem;
    word-break: break-all;
  }

  .main-content {
    padding-bottom: 6rem;
  }

  .modal-content form {
    padding: 1rem;
  }

  .patient-card > button {
    width: 100%;
  }
}

@media (min-width: 768px) {
  .main-content { max-width: 1000px; }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }

  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .patients-list,
  .antecedents-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 820px;
    border-radius: 18px 18px 0 0;
  }
}

@media (min-width: 1100px) {
  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}