:root {
  --azul: #1d4ed8; --azul-claro: #e8eefc; --verde: #1f6f43; --verde-claro: #e5f4ea;
  --rojo: #b3261e; --rojo-claro: #fbe9e7; --ambar: #8a5a00; --ambar-claro: #fff4d6;
  --texto: #1b1b1f; --tenue: #5f6368; --borde: #d0d5dd; --fondo: #f6f7f9;
  --alto-barra: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texto); background: var(--fondo); }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; }

.barra { position: fixed; inset: 0 0 auto 0; height: calc(var(--alto-barra) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0; display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid var(--borde); z-index: 20; }
.persona-actual { border: 0; background: none; font-size: 1.15rem; font-weight: 700; padding: 8px 10px; border-radius: 10px;
  max-width: 65vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.persona-actual:hover { background: var(--fondo); }
.barra-der { display: flex; gap: 4px; }
.icono-btn { position: relative; border: 0; background: none; font-size: 1.3rem; width: 44px; height: 44px; border-radius: 50%; }
.icono-btn:hover { background: var(--fondo); }
.globo { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--rojo); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; }

#mapa, .sin-mapa { position: fixed; top: calc(var(--alto-barra) + env(safe-area-inset-top)); left: 0; right: 0; bottom: 0; }
.sin-mapa { display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px 24px 40vh; color: var(--tenue); }

.banner { position: fixed; top: calc(var(--alto-barra) + env(safe-area-inset-top) + 8px); left: 8px; right: 8px; z-index: 30;
  background: var(--rojo); color: #fff; border-radius: 12px; padding: 12px 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.2); cursor: pointer; }

.hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: #fff; border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.12); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); max-height: 55vh; overflow: auto; }
@media (min-width: 900px) {
  .hoja { left: 16px; right: auto; bottom: 16px; width: 380px; border-radius: 18px; }
}
.hoja h2 { margin: 4px 0 6px; font-size: 1.15rem; }
.hoja p { margin: 0 0 10px; color: var(--tenue); }
.ficha-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.chip.activo { background: var(--verde-claro); color: var(--verde); }
.chip.detenido, .chip.sin-senal { background: var(--rojo-claro); color: var(--rojo); }
.chip.pendiente { background: var(--ambar-claro); color: var(--ambar); }
.tenue { color: var(--tenue); font-size: .9rem; }
.aviso { background: var(--ambar-claro); color: var(--ambar); border-radius: 10px; padding: 8px 10px; font-size: .9rem; margin-bottom: 8px; }
.acciones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.acciones button { border: 1px solid var(--borde); background: #fff; border-radius: 12px; padding: 10px 4px; font-size: .9rem; }
.acciones button:hover { background: var(--fondo); }

.primario, .secundario, .peligro { display: block; width: 100%; padding: 12px; border-radius: 12px; font-weight: 600; margin-top: 8px; }
.primario { background: var(--azul); color: #fff; border: 0; }
.secundario { background: #fff; color: var(--texto); border: 1px solid var(--borde); }
.peligro { background: #fff; color: var(--rojo); border: 1px solid var(--rojo); }
.error { color: var(--rojo); min-height: 1.2em; font-size: .9rem; margin-top: 6px; }

.velo-panel { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.panel { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; z-index: 41; background: #fff;
  border-radius: 18px 18px 0 0; padding: 0 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .panel { left: 50%; right: auto; width: 560px; transform: translateX(-50%); bottom: 24px; border-radius: 18px; } }
.panel-cab { position: sticky; top: 0; background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 8px; }
.panel-cab h2 { margin: 0; font-size: 1.2rem; }
.panel label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: .95rem; }
.panel input[type=text], .panel input:not([type]), .panel input[type=number], .panel select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; margin-top: 4px; font-weight: 400; }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--fondo); }
.lista li .sub { color: var(--tenue); font-size: .85rem; }
.lista li button { border: 1px solid var(--borde); background: #fff; border-radius: 10px; padding: 6px 10px; font-size: .85rem; white-space: nowrap; }
.lista li.no-visto { background: var(--rojo-claro); margin: 0 -16px; padding: 10px 16px; }
.lista li.clicable { cursor: pointer; }
.etiqueta { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-right: 6px; }
.etiqueta.seguimiento { background: var(--verde-claro); color: var(--verde); }
.etiqueta.alerta { background: var(--rojo-claro); color: var(--rojo); }
.codigo-grande { font: 700 2rem/1.2 ui-monospace, "SFMono-Regular", Menlo, monospace; letter-spacing: .15em; text-align: center;
  background: var(--azul-claro); color: var(--azul); border-radius: 14px; padding: 16px; margin: 10px 0; user-select: all; }
.enlace { word-break: break-all; font-size: .9rem; background: var(--fondo); padding: 8px 10px; border-radius: 8px; }

.editor-zona { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: #fff; border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15); padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .editor-zona { left: 16px; right: auto; bottom: 16px; width: 380px; border-radius: 18px; } }
.editor-zona label { display: block; font-weight: 600; margin: 8px 0; font-size: .95rem; }
.editor-zona input:not([type=radio]):not([type=range]) { width: 100%; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; margin-top: 4px; }
.editor-zona input[type=range] { width: 100%; }
.editor-zona .radio { font-weight: 400; margin: 4px 0; }
.editor-zona small { color: var(--tenue); }
.fila { display: flex; gap: 8px; }
.fila > * { flex: 1; }
.marcador { width: 22px; height: 22px; border-radius: 50%; background: var(--azul); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--azul), 0 2px 8px rgba(0,0,0,.35); }
.marcador.viejo { background: #9aa0a6; box-shadow: 0 0 0 2px #9aa0a6, 0 2px 8px rgba(0,0,0,.35); }
