/* css/styles.css — Odontolab PWA
   Mobile-first 390px, tablet-optimized, touch-friendly. */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a202c;
  --muted: #718096;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --tap: 48px;
  --gap: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }

header.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
header.topbar h1 {
  font-size: 18px; margin: 0; flex: 1;
}

@media (max-width: 600px) {
  header.topbar {
    padding: 8px 12px;
    gap: 8px;
  }
  header.topbar h1 {
    font-size: 16px;
    flex: 1 1 100%;
    order: -1;
  }
  header.topbar .btn {
    font-size: 12px;
    padding: 6px 10px;
  }
  .auth-user-chip {
    font-size: 11px;
    padding: 3px 8px;
  }
}

main { padding: 16px; max-width: 1200px; margin: 0 auto; }

.toolbar {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}

input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
textarea { min-height: 64px; resize: vertical; }

.btn {
  min-height: var(--tap);
  padding: 0 18px;
  font-size: 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-export { background: #16a34a; color: white; border-color: #16a34a; }
.btn-export:hover { background: #15803d; border-color: #15803d; }
.btn-backup { background: #0d9488; color: white; border-color: #0d9488; }
.btn-backup:hover { background: #0f766e; border-color: #0f766e; }
.btn-backup:disabled { opacity: 0.6; cursor: progress; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-tiny { min-height: 28px; padding: 0 8px; font-size: 13px; border-radius: 6px; }

/* Action bar above patient list */
.list-actions { display: flex; justify-content: flex-end; padding: 8px 16px 0; }

/* Paciente list */
.paciente-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.paciente-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  min-height: var(--tap);
  display: flex; flex-direction: column; gap: 4px;
}
.paciente-card:hover { border-color: var(--primary); }
.paciente-name { font-weight: 600; font-size: 17px; }
.paciente-meta { color: var(--muted); font-size: 14px; display: flex; gap: 6px; flex-wrap: wrap; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  padding: 24px;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Form */
.paciente-form { display: flex; flex-direction: column; gap: 18px; }
.paciente-form h2 {
  font-size: 16px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 8px 0 0 0;
}
.paciente-form h3 {
  font-size: 14px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 12px 0 4px 0;
}
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; color: var(--muted); }

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Detail page ---------- */

.detail-top {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 8px;
}
.detail-top h1 { margin: 0; font-size: 22px; flex: 1; min-width: 200px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.patient-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px;
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 800px) {
  .detail-layout { grid-template-columns: repeat(2, 1fr); }
  .card-wide { grid-column: 1 / -1; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin-top: 0; font-size: 18px; }
.card-header-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.card-header-row h2 { margin: 0; font-size: 18px; }
.card-header-row > div { display: flex; gap: 8px; align-items: center; }

/* Key-value rows (used in detail and form grids) */
.kv-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}
@media (min-width: 600px) { .kv-row { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .kv-row { grid-template-columns: repeat(3, 1fr); } }

.kv-item {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color 0.15s, background 0.15s;
}
.kv-item:focus-within {
  border-color: var(--primary);
  background: var(--surface);
}
.kv-item.full { grid-column: 1 / -1; }
.kv-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kv-input {
  border: 0; background: transparent;
  font-size: 15px; padding: 4px 0;
  min-height: 28px; color: var(--text);
  width: 100%;
}
.kv-input:focus { outline: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.badge-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.badge-muted { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.badge-ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* ---------- Anamnesis form ---------- */

.anam-grid {
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
@media (min-width: 600px) { .anam-grid { grid-template-columns: repeat(2, 1fr); } }

.bool-block {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.bool-block-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.bool-block-label {
  font-weight: 500;
  flex: 1;
  min-width: 140px;
}
.bool-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.bool-inline-label {
  font-size: 14px;
  color: var(--text);
}

.btn-toggle {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn-toggle:hover { border-color: var(--border-strong); }
.btn-toggle-active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-toggle-active:hover { background: var(--primary-strong); border-color: var(--primary-strong); }

.check-list {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.check-item {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  user-select: none;
}
.check-item input[type="checkbox"] { width: 18px; height: 18px; }

/* ---------- Visitas list ---------- */

.visita-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.visita-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.visita-card-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.05s ease;
  user-select: none;
}
.visita-card-clickable:hover {
  border-color: var(--primary);
}
.visita-card-clickable:active {
  transform: scale(0.99);
}
.visita-card-clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.visita-top-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
}
.visita-top-right {
  display: flex; gap: 6px; align-items: center;
}
.visita-chevron {
  font-size: 22px; font-weight: 300; line-height: 1; padding: 0 4px;
}
.visita-date { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.visita-motivo { font-weight: 600; font-size: 16px; }
.visita-preview, .visita-cambios { color: var(--muted); }
.visita-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Search box (pacientes list) ---------- */

.search-box {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.search-box input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--bg);
}
.search-box input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  background: var(--surface);
}

/* ---------- Visit detail ---------- */

.visit-detail {
  display: flex; flex-direction: column; gap: 12px;
}

.visit-detail section { margin-bottom: 4px; }
.visit-detail pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  margin: 0;
}

/* ---------- Dentograma (interactive) ---------- */

.dentograma-host {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
}

/* Professional container — subtle warm gradient (mucosa oral) that gives
   the chart a real chart-paper feel without competing with the teeth. */
.dentograma-container {
  background: linear-gradient(to bottom, #FFF8E1 0%, #FFFFFF 100%);
  border-radius: 12px;
  padding: 16px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.05);
}

.dentograma-interactive {
  display: flex; flex-direction: column; gap: 8px;
}
.arch-label {
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 600;
}
.arch-label-top { margin-top: 4px; }
.arch-label-bot { margin-top: 6px; padding-bottom: 2px; }
.arch-sep {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  margin: 8px 0 6px;
  padding: 6px 0;
  letter-spacing: .04em;
}
.arch {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: nowrap;
}
.quad { display: flex; gap: 4px; flex-wrap: nowrap; }

/* ---------- Dentograma tooth buttons (SVG anatomy) ---------- */
.tooth {
  /* Button reset + touch target.  The SVG inside is the actual visual. */
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 2px;
  margin: 0;
  /* width set per tooth-kind below so each gets its natural aspect */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  position: relative;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  min-height: 56px;
}
.tooth:hover {
  transform: scale(1.15);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  z-index: 10;
  background: rgba(255, 255, 255, 0.04);
}
.tooth:active { transform: scale(1.06); }
.tooth:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.tooth .tooth-svg {
  display: block;
  pointer-events: none; /* let the parent receive click events */
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.15));
  transition: filter 0.2s ease;
  /* height is the primary sizing axis; width is set inline per tooth
     by the SVG's viewBox aspect ratio (incisivo ~5:8, molar ~1:1). */
  height: 50px;
  width: auto;
}
.tooth:hover .tooth-svg { filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25)); }

/* Arch direction hint — upper teeth and lower teeth get a tiny shadow
   distinction so the eye can separate the two arches at a glance. */
.tooth-upper .tooth-svg { filter: drop-shadow(0 -1px 1px rgba(0,0,0,0.15)); }
.tooth-lower .tooth-svg { filter: drop-shadow(0  1px 1px rgba(0,0,0,0.15)); }
.tooth:hover.tooth-upper .tooth-svg,
.tooth:hover.tooth-lower .tooth-svg { filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25)); }

/* Each tooth kind has its own natural aspect ratio.  We set the
   button's min-width so the chart lays out cleanly across arches. */
.tooth-incisivo { min-width: 28px; }
.tooth-canino   { min-width: 24px; }
.tooth-premolar { min-width: 36px; }
.tooth-molar    { min-width: 40px; }

/* On narrow screens tighten the size so 8 teeth fit a row. */
@media (max-width: 599px) {
  .tooth { min-height: 48px; padding: 1px; }
  .tooth .tooth-svg { height: 44px; }
}

/* Tablet */
@media (min-width: 600px) {
  .tooth { min-height: 64px; }
  .tooth .tooth-svg { height: 58px; }
}

/* Desktop — bigger touch target + bigger SVG */
@media (min-width: 1000px) {
  .tooth { min-height: 76px; }
  .tooth .tooth-svg { height: 68px; }
}

/* ---------- Legend (estilo formulario físico) ---------- */
.legend {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
  padding: 8px;
  background: #FFFFFF;
  border: 1px solid #1a1a1a;
  border-radius: var(--radius-sm);
}
.legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: #1a1a1a;
  background: #FFFFFF;
  border: 1px solid #ccc;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 2px;
  background: #FFFFFF;
}
.legend-swatch .tooth-svg {
  height: 18px;
  width: auto;
  pointer-events: none;
}

/* Legacy preview class — keep working in case anyone still uses it */
.dentograma { display: flex; flex-direction: column; gap: 8px; background: var(--surface); padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); }
.dentograma .arch { display: flex; gap: 8px; justify-content: center; }
.dentograma .quad { display: flex; gap: 4px; flex-wrap: nowrap; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.modal-header h3 { margin: 0; font-size: 20px; }
.modal-close {
  background: transparent; border: 0; cursor: pointer;
  font-size: 24px; color: var(--muted);
  min-width: 36px; min-height: 36px;
  border-radius: 50%;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.estado-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
@media (min-width: 500px) { .estado-grid { grid-template-columns: repeat(5, 1fr); } }

.estado-btn {
  min-height: 56px;
  border-radius: 4px;
  border: 1.5px solid #1a1a1a;
  background: #FFFFFF;
  font-weight: 700;
  font-size: 11px;
  color: #1a1a1a;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
}
.estado-btn .estado-indicator {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.estado-btn:hover {
  transform: scale(1.05);
  background: #f5f5f5;
}
.estado-btn.selected {
  border-color: #1a1a1a;
  border-width: 2px;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(26,26,26,0.2);
}

.estado-label {
  text-align: center;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Visit form helpers ---------- */

.bucodental-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 600px) { .bucodental-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .bucodental-grid { grid-template-columns: repeat(3, 1fr); } }

.cambios-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.cambios-list li {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.cambios-list li > button { margin-left: auto; }

.cambios-list-host {
  margin-top: 6px;
}

.tratamientos-host {
  display: flex; flex-direction: column; gap: 8px;
}
.tabla-tratamientos {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.tabla-tratamientos th, .tabla-tratamientos td {
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  text-align: left; font-size: 14px;
}
.tabla-tratamientos th { background: var(--bg); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.tabla-tratamientos tr:last-child td { border-bottom: 0; }

.analiticas-host {
  display: flex; flex-direction: column; gap: 8px;
}
.analiticas-row { align-items: end; }

/* Legacy .visita-list (basic version) — kept for backwards compat */
.visita-list li { padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
/* ---------- Auth v1 ---------- */

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  background: #f8fafc;
  padding: 24px;
}

#auth-screen .auth-box {
  background: #ffffff;
  padding: 40px 32px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  width: 360px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

#auth-screen .auth-box h1 {
  text-align: center;
  color: #0d9488;
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 0.5px;
}

#auth-screen .auth-box .auth-tagline {
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  margin: 0 0 24px;
}

#auth-screen .auth-box .auth-title {
  text-align: center;
  font-size: 16px;
  color: #1a202c;
  margin: 0 0 16px;
  font-weight: 600;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#auth-form input {
  width: 100%;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 16px;
}

#auth-form input:focus {
  outline: 2px solid #0d9488;
  outline-offset: 1px;
  border-color: #0d9488;
}

#auth-form button {
  width: 100%;
  padding: 12px;
  background: #0d9488;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
}

#auth-form button:hover { background: #0f766e; }
#auth-form button:disabled { opacity: 0.6; cursor: progress; }

.auth-error {
  color: #dc2626;
  font-size: 14px;
  text-align: center;
  margin: 4px 0 0;
  min-height: 18px;
}
.auth-error.visible { font-weight: 500; }

.auth-toggle {
  color: #0d9488;
  cursor: pointer;
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
  padding: 4px;
  user-select: none;
}
.auth-toggle:hover { color: #0f766e; text-decoration: underline; }

/* Chip de usuario activo en el header */
.auth-user-chip {
  display: inline-flex;
  align-items: center;
  background: #ecfeff;
  color: #0e7490;
  border: 1px solid #a5f3fc;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  margin-left: auto;
}

/* ---------- Auth guard — hide app until auth is verified ---------- */
body.auth-loading .topbar,
body.auth-loading main,
body.auth-loading #app { display: none !important; }
#app:empty::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  border: 4px solid #e2e8f0;
  border-top-color: #0d9488;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Consentimiento del paciente (Ley 15-19 RD) ---------- */

.consent-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 24px;
}

.consent-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 28px;
  width: 520px;
  max-width: 100%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.consent-title {
  margin: 0 0 8px;
  color: #0d9488;
  font-size: 22px;
  font-weight: 700;
}

.consent-subtitle {
  margin: 0 0 20px;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.5;
}

.consent-label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  font-size: 14px;
  line-height: 1.4;
  color: #1a202c;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.consent-label:last-of-type { border-bottom: none; }

.consent-check {
  flex-shrink: 0;
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: #0d9488;
  cursor: pointer;
}

.consent-error {
  color: #dc2626;
  font-size: 13px;
  margin: 8px 0 0;
  min-height: 16px;
}

.consent-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ---------- Password change modal ---------- */

.password-modal .password-modal-content {
  max-width: 440px;
}

.password-modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}

.password-modal-form .field input {
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
.password-modal-form .field input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}
.password-modal-form .field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.password-modal-form .form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: #1a202c;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast-success {
  background: var(--success);
  color: #ffffff;
}
.toast-error {
  background: var(--danger);
  color: #ffffff;
}
