:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-text: #1c1f26;
  --color-muted: #5a6270;
  --color-border: #e1e4e9;
  --color-primary: #b4272b;
  --color-primary-dark: #8f1f22;
  --color-warning-bg: #fff4e5;
  --color-warning-border: #f0b95a;
  --color-danger: #d92d20;
  --color-orange: #e07a1f;
  --color-green: #1a9e5c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

body {
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-header__title h1 {
  font-size: 1.1rem;
  margin: 0;
}

.app-header__subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--color-muted);
}

.app-header__acciones {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.btn--nav {
  text-decoration: none;
  white-space: nowrap;
  width: auto;
  margin-bottom: 0;
}

.app-banner {
  background: var(--color-warning-bg);
  border-bottom: 1px solid var(--color-warning-border);
  padding: 0.55rem 1.25rem;
  font-size: 0.85rem;
  color: #6b4a12;
  flex-shrink: 0;
}

.app-banner a {
  color: inherit;
  font-weight: 600;
}

.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__stats {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
}

.sidebar__stats span {
  font-weight: 700;
  color: var(--color-text);
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.dashboard__vitales {
  display: contents;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.stat-tile:hover {
  border-color: var(--color-primary);
}

.stat-tile--activo {
  border-color: var(--color-primary);
  background: #fdecea;
}

.stat-tile--total {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: baseline;
  gap: 0.4rem;
  background: var(--color-surface);
}

.stat-tile__icono {
  font-size: 1.1rem;
  line-height: 1;
}

.stat-tile__valor {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.stat-tile--total .stat-tile__valor {
  font-size: 1.5rem;
}

.stat-tile__etiqueta {
  font-size: 0.72rem;
  color: var(--color-muted);
  line-height: 1.2;
}

.stat-tile--vital .stat-tile__valor {
  color: var(--color-danger);
}

.sidebar__filtro {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.campo-filtro {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
}

.campo-filtro select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 400;
  font-family: inherit;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.sidebar__exportar {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.btn--exportar {
  width: auto;
  flex: 1;
  margin-bottom: 0;
  text-align: center;
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.5rem 0.6rem;
  min-height: auto;
}

.lista-reportes {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.lista-reportes li {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  font-size: 0.85rem;
}

.lista-reportes li:hover {
  background: var(--color-bg);
}

.lista-reportes .reporte-item__linea1 {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  gap: 0.5rem;
}

.lista-reportes .reporte-item__lugar {
  color: var(--color-muted);
  font-weight: 400;
  margin-top: 0.15rem;
}

.lista-reportes .reporte-item__hora {
  color: var(--color-muted);
  font-weight: 400;
  white-space: nowrap;
}

.mapa-wrapper {
  position: relative;
  flex: 1;
}

.mapa {
  height: 100%;
  width: 100%;
  cursor: crosshair;
}

.mapa-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  background: rgba(28, 31, 38, 0.85);
  color: white;
  padding: 0.4rem 0.85rem;
  border-radius: 16px;
  font-size: 0.8rem;
  text-align: center;
  max-width: calc(100% - 24px);
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
}

.btn--primary {
  background: var(--color-primary);
  color: white;
}

.btn--primary:hover {
  background: var(--color-primary-dark);
}

.btn--secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  width: 100%;
  margin-bottom: 0.4rem;
}

.btn--icon {
  background: transparent;
  font-size: 1.2rem;
  padding: 0.4rem 0.7rem;
  min-height: 44px;
  min-width: 44px;
}

.btn--block {
  width: 100%;
  margin-top: 0.75rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 900;
}

.panel-form {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  background: var(--color-surface);
  z-index: 901;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
}

.panel-form__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.panel-form__header h2 {
  font-size: 1.05rem;
  margin: 0;
}

.hidden {
  display: none !important;
}

.campo-ayuda {
  font-size: 0.82rem;
  color: var(--color-muted);
  margin: 0 0 0.4rem;
}

.campo-ayuda--sutil {
  margin-top: -0.6rem;
}

.confirmacion {
  text-align: center;
  padding: 1.5rem 0.5rem;
}

.confirmacion__icono {
  font-size: 2.2rem;
  margin: 0 0 0.25rem;
}

.confirmacion h3 {
  margin: 0 0 0.4rem;
}

.confirmacion p {
  color: var(--color-muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

.banner-emergencia {
  background: #fdecea;
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: #7a1f1a;
}

.banner-emergencia p {
  margin: 0 0 0.3rem;
}

.banner-emergencia p:last-child {
  margin-bottom: 0;
}

.banner-emergencia__titulo {
  font-weight: 700;
  font-size: 0.92rem;
}

.banner-emergencia__extra {
  font-size: 0.78rem;
  border-top: 1px solid #f2b8b5;
  padding-top: 0.3rem;
  margin-top: 0.3rem !important;
}

.ubicacion-exacta {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  margin: 0 0 0.85rem;
}

.campo {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.campo select,
.campo input[type="text"],
.campo textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-weight: 400;
  font-family: inherit;
}

.campo--checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.campo--checkbox input {
  width: 16px;
  height: 16px;
}

fieldset.campo {
  border: none;
  padding: 0;
  margin: 0 0 0.85rem;
}

fieldset.campo legend {
  padding: 0;
  margin-bottom: 0.4rem;
}

.tipos-afectacion {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.6rem;
  font-weight: 400;
}

.tipos-afectacion label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.83rem;
  font-weight: 400;
}

.form-error {
  background: #fdecea;
  color: var(--color-danger);
  border: 1px solid #f5c2c0;
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.82rem;
}

.marker-icono {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.marker-icono span {
  transform: rotate(45deg);
  font-size: 0.95rem;
}

.marker-icono--naranja { background: var(--color-orange); }
.marker-icono--verde { background: var(--color-green); }
.marker-icono--rojo { background: var(--color-danger); }

.popup-reporte {
  font-size: 0.85rem;
  max-width: 220px;
}

.popup-reporte h3 {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
}

.popup-reporte ul {
  margin: 0.3rem 0;
  padding-left: 1.1rem;
}

@media (max-width: 720px) {
  .app-layout {
    flex-direction: column;
    height: auto;
  }

  .sidebar {
    width: 100%;
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .mapa {
    height: 60vh;
  }
}

@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
  }

  .app-header__acciones {
    width: 100%;
  }

  .app-header__acciones .btn {
    flex: 1;
  }

  .btn--nav {
    white-space: normal;
    text-align: center;
  }

  .app-banner {
    padding: 0.55rem 1rem;
  }

  .panel-form {
    padding: 0.85rem 1rem 1.25rem;
  }

  .tipos-afectacion {
    grid-template-columns: 1fr;
  }
}

.pagina-contenido {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.seccion {
  margin-bottom: 2rem;
}

.seccion h2 {
  font-size: 1.05rem;
  margin: 0 0 0.7rem;
}

.tabla-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.tabla-emergencias {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  font-size: 0.88rem;
}

.tabla-emergencias th,
.tabla-emergencias td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.tabla-emergencias th {
  background: var(--color-bg);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-muted);
}

.tabla-emergencias tr:last-child td {
  border-bottom: none;
}

.tabla-emergencias .numero {
  font-weight: 700;
  white-space: nowrap;
}

.tabla-emergencias .editable {
  color: var(--color-muted);
  font-style: italic;
  font-weight: 400;
}

.lista-enlaces {
  padding-left: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.lista-enlaces a {
  color: var(--color-primary);
  font-weight: 600;
}

.app-footer {
  padding: 0.6rem 1.25rem;
  font-size: 0.72rem;
  color: var(--color-muted);
  opacity: 0.7;
}

.app-footer a {
  color: inherit;
}
