/* Estilos compartidos del panel administrativo y la app de campo. */
:root {
  --azul: #3b82f6;
  --azul-oscuro: #082a66;
  --rojo: #ef4444;
  --verde: #22c55e;
  --amarillo: #fbbf24;
  --naranja: #f97316;
  --fondo: #0a0a0d;
  --superficie: #16171d;
  --superficie-2: #1c1e26;
  --superficie-3: #252836;
  --titulo: #f4f6fb;
  --texto: #c7cdd9;
  --tenue: #8b93a7;
  --borde: rgba(255,255,255,0.09);
  --borde-fuerte: rgba(255,255,255,0.18);
  --radio: 12px;
  --sombra: 0 10px 30px rgba(0,0,0,0.45);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--azul); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { color: var(--titulo); line-height: 1.25; }
[hidden] { display: none !important; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14.5px;
  cursor: pointer;
  background: var(--superficie-3);
  color: var(--titulo);
  text-decoration: none;
  transition: background .15s, transform .1s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primario { background: var(--rojo); color: #fff; }
.btn-primario:hover { background: #dc2626; }
.btn-azul { background: var(--azul); color: #fff; }
.btn-azul:hover { background: #2563eb; }
.btn-verde { background: #16a34a; color: #fff; }
.btn-borde { background: transparent; border-color: var(--borde-fuerte); }
.btn-borde:hover { background: var(--superficie-2); }
.btn-fantasma { background: transparent; color: var(--texto); }
.btn-fantasma:hover { background: var(--superficie-2); }
.btn-peligro { background: transparent; color: #f87171; border-color: rgba(248,113,113,.35); }
.btn-peligro:hover { background: rgba(248,113,113,.1); }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn-bloque { width: 100%; }

/* Formularios */
.campo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.campo > label, .etiqueta { font-size: 12.5px; font-weight: 600; color: var(--tenue); letter-spacing: .3px; }
.campo .ayuda { font-size: 12px; color: var(--tenue); }
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* evita zoom automático en iPhone */
  color: var(--titulo);
  background: var(--superficie-2);
  border: 1px solid var(--borde-fuerte);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--rojo); }
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); outline-offset: 0; border-color: transparent; }
input::placeholder, textarea::placeholder { color: #626a7e; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; }

.rejilla { display: grid; gap: 14px; }
.rejilla-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rejilla-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rejilla-4 { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ancho-total { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .rejilla-2, .rejilla-3 { grid-template-columns: 1fr; }
  .rejilla-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--borde-fuerte);
  background: var(--superficie-2);
  color: var(--texto);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit; font-size: 14px;
  cursor: pointer;
  min-height: 38px;
  -webkit-tap-highlight-color: transparent;
}
.chip.activo { background: var(--azul); border-color: var(--azul); color: #fff; }
.chip.activo-rojo { background: var(--rojo); border-color: var(--rojo); color: #fff; }

/* Tarjetas */
.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 18px;
}
.tarjeta + .tarjeta { margin-top: 14px; }
.tarjeta h3 { font-size: 16px; margin-bottom: 12px; }

.insignia {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: var(--superficie-3); color: var(--texto);
  letter-spacing: .3px; white-space: nowrap;
}
.insignia.capitan { background: rgba(251,191,36,.16); color: var(--amarillo); }
.insignia.sargento { background: rgba(59,130,246,.18); color: #93c5fd; }
.insignia.rojo { background: rgba(239,68,68,.16); color: #fca5a5; }
.insignia.verde { background: rgba(34,197,94,.15); color: #86efac; }
.insignia.amarillo { background: rgba(251,191,36,.15); color: #fde68a; }

/* Triage (escala colombiana I–V) */
.triage { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.triage button {
  border: 2px solid transparent; border-radius: 10px; min-height: 48px;
  font: inherit; font-weight: 800; color: #111; cursor: pointer; opacity: .45;
}
.triage button.activo { opacity: 1; border-color: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4) inset; }
.triage .t1 { background: #ef4444; color: #fff; }
.triage .t2 { background: #f97316; }
.triage .t3 { background: #facc15; }
.triage .t4 { background: #22c55e; }
.triage .t5 { background: #3b82f6; color: #fff; }

input.vital-normal { border-color: #22c55e; background: rgba(34,197,94,.10); }
input.vital-fuera { border-color: #ef4444; background: rgba(239,68,68,.12); }
.vital-estado { font-size: 12px; font-weight: 700; min-height: 1.2em; }
.vital-estado.ok { color: #4ade80; }
.vital-estado.mal { color: #f87171; }

/* Modal */
.modal-fondo {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,.7);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto;
  padding: 24px 12px;
}
.modal {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 16px;
  width: 100%; max-width: 760px;
  box-shadow: var(--sombra);
  margin: auto 0;
}
.modal-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--borde); }
.modal-cab h2 { font-size: 18px; }
.modal-cuerpo { padding: 20px; }
.modal-pie { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--borde); }

/* Avisos */
.toasts { position: fixed; z-index: 1000; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); }
.toast {
  background: var(--superficie-3); color: var(--titulo);
  border-left: 4px solid var(--azul);
  padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--sombra); font-size: 14.5px;
  animation: entrar .2s ease-out;
}
.toast.error { border-left-color: var(--rojo); }
.toast.ok { border-left-color: var(--verde); }
@keyframes entrar { from { opacity: 0; transform: translateY(8px); } }

.vacio { text-align: center; color: var(--tenue); padding: 30px 12px; font-size: 14.5px; }
.cargando { text-align: center; padding: 30px; color: var(--tenue); }

/* Tablas */
.tabla-envoltura { overflow-x: auto; border: 1px solid var(--borde); border-radius: var(--radio); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { background: var(--superficie-2); color: var(--tenue); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: rgba(255,255,255,.02); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Formulario de incidente */
.inc-seccion { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; margin-bottom: 12px; }
.inc-seccion > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--rojo); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.inc-seccion .rejilla > * + .chips, .inc-seccion .chips + input { margin-top: 2px; }
.pa-doble { display: flex; align-items: center; gap: 6px; }
.pa-doble span { color: var(--tenue); font-weight: 700; }
.vital-unidad { font-size: 11px; color: var(--tenue); font-weight: 500; }

/* Fotos de las atenciones */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.foto-mini { position: relative; margin: 0; background: var(--superficie-2); border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.foto-mini img { width: 100%; aspect-ratio: 4/3; object-fit: cover; object-position: center bottom; display: block; background: #000; cursor: zoom-in; }
.foto-mini figcaption { font-size: 11px; color: var(--tenue); padding: 6px 8px; line-height: 1.35; }
.foto-mini .insignia { position: absolute; top: 6px; left: 6px; }
.foto-quitar { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(0,0,0,.65); color: #fff; font-size: 14px; cursor: pointer; }

/* Firmas */
.bloque-firma { border-top: 1px solid var(--borde); padding-top: 12px; margin-top: 12px; display: grid; gap: 10px; }
.bloque-firma h4 { font-size: 14.5px; }
.bloque-firma h4 small { font-weight: 400; color: var(--tenue); font-size: 12px; }
.firma-caja { position: relative; height: 170px; background: #fff; border: 2px dashed #94a3b8; border-radius: 12px; overflow: hidden; touch-action: none; }
.firma-caja canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.firma-guia { position: absolute; left: 0; right: 0; bottom: 34px; text-align: center; color: #94a3b8; font-size: 14px; pointer-events: none; border-top: 1px solid #cbd5e1; margin: 0 24px; padding-top: 4px; }
.firma-acciones { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.firma-estado { font-size: 13px; color: #4ade80; font-weight: 600; }

/* Orientación IA en el formulario de atención */
.ia-caja { white-space: pre-wrap; border: 1px dashed #7a6ad8; background: rgba(122, 106, 216, 0.08); border-radius: 10px; padding: 10px 12px; font-size: 0.95em; line-height: 1.45; }

/* Cruces de datos entre personas y atenciones repetidas */
.conflicto { border: 1px solid var(--borde, rgba(255,255,255,.15)); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.conflicto-campo { font-weight: 700; margin-bottom: 6px; }
.conflicto-op { display: flex; gap: 10px; align-items: flex-start; padding: 6px 4px; cursor: pointer; line-height: 1.4; }
.conflicto-op input { margin-top: 4px; flex: none; }
.conflicto-op span { white-space: pre-wrap; word-break: break-word; }
