/* ═══════════════════════════════════════════════════════════
   ACOPIO VE — Hoja de estilos principal
   Diseño mobile-first, funcional para señal débil
   ═══════════════════════════════════════════════════════════ */

/* ─── VARIABLES — paleta emergencia ─── */
:root {
  --primary:        #007AFF;   /* Azul funcional (focus, links) */
  --primary-dark:   #0062CC;
  --primary-light:  #4DA3FF;
  --emergency:      #E63946;   /* Rojo emergencia — CTA principal */
  --emergency-dark: #B71C1C;
  --header-bg:      #1C1C1E;   /* Negro carbón para header */
  --accent:         #FF9500;   /* Naranja — parcial */
  --verde:          #27AE60;   /* Verde claro */
  --verde-bg:       #EAFAF1;
  --verde-light:    #2ECC71;
  --amarillo:       #F39C12;   /* Ámbar */
  --amarillo-bg:    #FEF9E7;
  --amarillo-light: #F1C40F;
  --rojo:           #E74C3C;   /* Rojo oscuro */
  --rojo-bg:        #FDEDEC;
  --rojo-light:     #EC7063;
  --bg:             #F4F6F8;
  --surface:        #FFFFFF;
  --border:         rgba(0,0,0,.10);
  --text:           #111111;
  --muted:          rgba(0,0,0,.5);
  --shadow-sm:      0 1px 4px rgba(0,0,0,.08);
  --shadow-md:      0 4px 18px rgba(0,0,0,.12);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.16);
  --radius:         12px;
  --radius-sm:      8px;
  --header-h:       128px;  /* 52px main + 40px stats + 36px quick-filter */
  --sidebar-w:      320px;
  --transition:     0.18s ease;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100dvh;
  height: 100vh;
  touch-action: pan-x pan-y;
}
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea {
  font: inherit;
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; }
a { color: var(--primary); }

/* ─── HEADER ─── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 0 2px 20px rgba(0,0,0,.35);
}

/* Fila principal */
.header-main {
  height: 52px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* Fila de estadísticas */
#header-stats {
  height: 40px;
  display: flex;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.hstat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-right: 1px solid rgba(255,255,255,.08);
  cursor: default;
  transition: background var(--transition);
}
.hstat:last-child { border-right: none; }
.hstat:hover { background: rgba(255,255,255,.05); }
.hstat-num {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  color: rgba(255,255,255,.9);
  letter-spacing: -.5px;
}
.hstat-lbl {
  font-size: .52rem;
  color: rgba(255,255,255,.45);
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 600;
}
.hstat-verde .hstat-num { color: #2ECC71; }
.hstat-amar  .hstat-num { color: #F1C40F; }
.hstat-rojo  .hstat-num { color: #E74C3C; }
.hstat-verde       { border-bottom: 2px solid #2ECC71; }
.hstat-amar        { border-bottom: 2px solid #F1C40F; }
.hstat-rojo        { border-bottom: 2px solid #E74C3C; }
.hstat-actualizacion { border-bottom: 2px solid rgba(255,255,255,.2); }
.hstat-ts          { font-size: .82rem !important; color: rgba(255,255,255,.6) !important; }

/* ── Quick filter bar (3rd header row) ── */
#quick-filter-bar {
  height: 36px; padding: 0 10px;
  display: flex; align-items: center; gap: 6px;
  border-top: 1px solid rgba(255,255,255,.08);
  overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
}
#quick-filter-bar::-webkit-scrollbar { display: none; }

.qf-select {
  height: 26px; padding: 0 8px; font-size: .72rem; font-weight: 500;
  border-radius: 13px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.85);
  outline: none; cursor: pointer; flex-shrink: 0; min-width: 130px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,.5)'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
  padding-right: 22px;
}
.qf-select option { background: #1a2332; color: white; }

.qf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px; border-radius: 13px;
  font-size: .72rem; font-weight: 600;
  color: rgba(255,255,255,.65); border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08); cursor: pointer;
  transition: all .15s; flex-shrink: 0; user-select: none;
  white-space: nowrap; line-height: 1;
}
.qf-chip:hover { background: rgba(255,255,255,.15); }
.qf-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.qf-chip[data-active="1"][data-cap="disponible"] {
  background: rgba(46,204,113,.2); border-color: #2ECC71; color: #2ECC71;
}
.qf-chip[data-active="1"][data-cap="parcial"] {
  background: rgba(241,196,15,.2); border-color: #F1C40F; color: #F1C40F;
}
.qf-chip[data-active="1"][data-cap="lleno"] {
  background: rgba(231,76,60,.2); border-color: #E74C3C; color: #E74C3C;
}
.qf-chip-clear { color: rgba(255,255,255,.5); font-size: .68rem; }
.qf-chip-clear:hover { color: white; }

.header-left { display: flex; align-items: center; gap: 10px; }

.logo-wrap {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.logo-wrap svg { display: block; }

.header-titles { display: flex; flex-direction: column; gap: 1px; }
.header-titles h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.3px;
  line-height: 1;
  color: white;
}
.h1-ve {
  color: var(--emergency);
  font-style: italic;
}
.subtitle {
  font-size: .65rem;
  color: rgba(255,255,255,.55);
  white-space: nowrap;
}

.header-right { display: flex; align-items: center; gap: 6px; overflow: hidden; }

/* ─── BOTONES ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), transform .1s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #1a1100;
}
.btn-primary:hover { background: #FFD54F; }

/* Botón de acción principal — emergencia */
.btn-cta {
  background: var(--emergency);
  color: white;
  font-weight: 700;
  letter-spacing: -.1px;
  box-shadow: 0 2px 10px rgba(230,57,70,.4);
}
.btn-cta:hover { background: var(--emergency-dark); box-shadow: 0 2px 14px rgba(230,57,70,.5); }

.btn-ghost {
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.85);
  border: 1.5px solid rgba(255,255,255,.18);
}
.btn-ghost:hover { background: rgba(255,255,255,.18); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: rgba(21,101,192,.08); }

.btn-sm { padding: 5px 10px; font-size: .8rem; }
.full-width { width: 100%; justify-content: center; }

.btn-icon-only {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: background var(--transition);
}
.btn-icon-only:hover { background: var(--bg); }
#header .btn-icon-only { color: rgba(255,255,255,.8); }
#header .btn-icon-only:hover { background: rgba(255,255,255,.15); }

.filtros-badge {
  background: #EF5350;
  color: white;
  font-size: .65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* ─── LAYOUT PRINCIPAL ─── */
#app-layout {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  display: flex;
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: transform var(--transition), box-shadow var(--transition);
  z-index: 200;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.sidebar-header h2 { font-size: 1rem; font-weight: 600; }

.sidebar-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: none; }
.stat-num {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.stat-lbl { font-size: .58rem; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .3px; }
.stat-verde .stat-num    { color: var(--verde); }
.stat-amarillo .stat-num { color: var(--amarillo); }
.stat-rojo .stat-num     { color: var(--rojo); }

.filter-section { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }

.sidebar-footer {
  padding: 0 14px 12px;
}

/* ─── LISTA DE CENTROS EN SIDEBAR ─── */
#lista-centros {
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.lista-header {
  padding: 10px 14px 6px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.lista-header h3 { font-size: .875rem; font-weight: 600; color: var(--muted); }

.lista-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px 11px 11px;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  user-select: none;
}
.lista-item:hover { background: var(--bg); }
.lista-item.active { background: rgba(230,57,70,.04); }

/* Borde izquierdo = semáforo */
.lista-item[data-cap="disponible"] { border-left-color: var(--verde); }
.lista-item[data-cap="parcial"]    { border-left-color: var(--amarillo); }
.lista-item[data-cap="lleno"]      { border-left-color: var(--rojo); }

.lista-info { flex: 1; min-width: 0; }
.lista-nombre {
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.lista-sub { font-size: .72rem; color: var(--muted); margin-top: 2px; }

.lista-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--muted);
  font-size: .875rem;
}

/* ─── MAPA ─── */
#map-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* Google Maps overrides */
.gm-style .gm-style-iw-c {
  padding: 0 !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border) !important;
  overflow: hidden !important;
}
.gm-style .gm-style-iw-d {
  overflow: hidden !important;
  max-height: none !important;
}
.gm-style .gm-style-iw-tc { display: none; }   /* sin flechita */
.gm-style-iw-chr {
  position: absolute !important;
  top: 4px !important;
  right: 4px !important;
}
.gm-style-iw-chr button {
  width: 22px !important;
  height: 22px !important;
}
.gmnoprint a, .gmnoprint span, .gm-style-cc { font-size: .6rem !important; }

/* ─── LOADING ─── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
}
.loading-overlay p { color: var(--muted); font-size: .875rem; }

.error-icon { font-size: 2.5rem; margin-bottom: 4px; }
#error-state { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#error-msg { color: var(--muted); font-size: .875rem; text-align: center; max-width: 220px; }
#loading-state { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── OFFLINE BANNER ─── */
.offline-banner {
  position: absolute;
  top: 8px; left: 50%; transform: translateX(-50%);
  background: #333;
  color: white;
  font-size: .8rem;
  padding: 6px 14px;
  border-radius: 20px;
  z-index: 20;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

/* ─── FAB (mobile) ─── */
.fab {
  display: none;
  position: absolute;
  bottom: 90px; right: 16px;
  width: auto;
  height: 48px;
  border-radius: 24px;
  padding: 0 18px;
  gap: 8px;
  background: var(--emergency);
  color: white;
  box-shadow: 0 4px 20px rgba(230,57,70,.45);
  align-items: center; justify-content: center;
  z-index: 50;
  transition: transform .15s, box-shadow .15s;
  font-size: .9rem;
  font-weight: 700;
}
.fab:hover { transform: scale(1.04); box-shadow: 0 6px 24px rgba(230,57,70,.55); }
.fab:active { transform: scale(.93); }

/* ─── PANEL DETALLE ─── */
.panel-centro {
  position: fixed;
  background: var(--surface);
  z-index: 500;
  overflow: hidden;
  transition: transform var(--transition), opacity var(--transition);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lg);
}

.panel-drag-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 0;
}

.panel-scroll {
  overflow-y: auto;
  height: 100%;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.panel-title-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1rem; font-weight: 700; }

.panel-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.p-stale-banner {
  background: rgba(241,196,15,.12); border: 1px solid rgba(241,196,15,.4);
  color: #d4ac0d; border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: .8rem; line-height: 1.4;
}

/* ── Botones ENTREGA / NECESIDAD ── */
.btn-evt-entrega  { background: rgba(46,204,113,.15); color: #27AE60; border: 1.5px solid rgba(46,204,113,.4); font-weight: 700; }
.btn-evt-entrega:hover  { background: rgba(46,204,113,.25); }
.btn-evt-necesidad { background: rgba(231,76,60,.15); color: #E74C3C; border: 1.5px solid rgba(231,76,60,.4); font-weight: 700; }
.btn-evt-necesidad:hover { background: rgba(231,76,60,.25); }
.evt-btns { margin-bottom: 8px; }
.evt-offline-aviso {
  background: rgba(241,196,15,.12); border: 1px solid rgba(241,196,15,.4);
  color: #d4ac0d; border-radius: var(--radius-sm); padding: 8px 12px; font-size: .8rem;
}

.info-row { display: flex; gap: 10px; align-items: flex-start; }
.info-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.info-label { font-size: .78rem; color: var(--muted); margin-bottom: 3px; }

.tags-wrap { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag {
  background: var(--bg);
  color: var(--text);
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.tag-necesita { background: rgba(231,76,60,.15); color: #E74C3C; border-color: rgba(231,76,60,.4); }
.tag-exceso   { background: rgba(46,204,113,.15); color: #27AE60; border-color: rgba(46,204,113,.4); }

/* ── Sección movimientos en panel ── */
.p-mov-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}
.p-mov-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 8px;
}
.btn-reg-mov {
  font-size: .72rem; font-weight: 600; padding: 3px 10px;
  border-radius: 12px; border: 1px solid var(--primary);
  color: var(--primary); background: transparent; cursor: pointer;
  transition: background .15s;
}
.btn-reg-mov:hover { background: rgba(21,101,192,.08); }
.p-mov-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.p-mov-empty { font-size: .78rem; }
.mov-item {
  border-radius: 8px; padding: 8px 10px; font-size: .75rem;
  border-left: 3px solid transparent;
}
.mov-item.entrada { background: rgba(46,204,113,.08); border-color: #2ECC71; }
.mov-item.salida  { background: rgba(231,76,60,.08);  border-color: #E74C3C; }
.mov-item-tipo { font-weight: 700; font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.mov-item.entrada .mov-item-tipo { color: #27AE60; }
.mov-item.salida  .mov-item-tipo { color: #C0392B; }
.mov-item-desc { color: var(--text-primary); margin-bottom: 2px; line-height: 1.3; }
.mov-item-meta { color: var(--text-secondary); font-size: .68rem; }

/* ── Radio pills en modal movimiento ── */
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-pill { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); transition: background .15s; }
.radio-pill:hover { background: var(--bg-secondary); }
.radio-pill input[type=radio] { accent-color: var(--primary); width: 15px; height: 15px; }
.radio-pill span { font-size: .83rem; }

.panel-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-foot .btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.panel-foot .btn-ghost:hover { background: rgba(21,101,192,.06); }

/* ─── BADGES (semáforo) ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-verde    { background: var(--verde-bg);    color: var(--verde); }
.badge-amarillo { background: var(--amarillo-bg); color: var(--amarillo); }
.badge-rojo     { background: var(--rojo-bg);     color: var(--rojo); }
.badge-rg       { background: #e8f0fe; color: #1a73e8; font-size: 10px; }

/* ─── LEAFLET CUSTOM MARKERS ─── */
.marker-icon {
  width: 28px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid white;
  box-shadow: var(--shadow-md);
  transition: transform .15s;
}
.marker-icon::after {
  content: '';
  width: 10px; height: 10px;
  background: white;
  border-radius: 50%;
}
.marker-verde    { background: var(--verde-light); }
.marker-amarillo { background: var(--amarillo-light); }
.marker-rojo     { background: var(--rojo-light); }

/* ─── FORMULARIOS ─── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: .84rem; font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.req { color: var(--rojo); }

.check-group { display: flex; flex-direction: column; gap: 6px; }
.check-wrap { flex-direction: row; flex-wrap: wrap; gap: 6px; }
.check-label {
  display: flex; align-items: center; gap: 7px;
  cursor: pointer;
  user-select: none;
}
.check-label input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.check-grid .check-label {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: .8rem;
  transition: border-color var(--transition), background var(--transition);
}
.check-grid .check-label:has(input:checked) {
  border-color: var(--primary);
  background: rgba(21,101,192,.06);
}

.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-label {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  flex: 1; min-width: 80px;
  text-align: center;
  transition: border-color var(--transition);
}
.radio-label:has(input:checked) { border-color: var(--primary); }
.radio-label input { display: none; }
.radio-desc { font-size: .7rem; color: var(--muted); }

.loc-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.loc-controls .btn-ghost {
  background: var(--bg);
  color: var(--primary);
  border: 1.5px solid var(--border);
}
.loc-hint {
  background: #E3F2FD;
  color: var(--primary-dark);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: .82rem;
  border: 1.5px solid #90CAF9;
  margin-top: 6px;
}
.mt-sm { margin-top: 6px; }

/* ─── MODALES ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-sm { max-width: 420px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h2 { font-size: 1rem; font-weight: 700; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Bloquea scroll del body cuando un modal está abierto (fix iOS keyboard) */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-foot .btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.modal-foot .btn-ghost:hover { background: var(--bg); color: var(--text); }

.form-section-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form-section-label:first-child { margin-top: 0; }

/* ─── TOAST ─── */
#toast-wrap {
  position: fixed;
  bottom: 24px; right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  max-width: 320px;
}

.toast {
  background: #333;
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  box-shadow: var(--shadow-md);
  animation: slide-in .25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast-ok { background: var(--verde); }
.toast-err { background: var(--rojo); }
.toast-warn { background: var(--amarillo); color: white; }

@keyframes slide-in {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── WHATSAPP BUTTON ─── */
.btn-wa {
  background: #25D366;
  color: white;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-wa:hover { background: #1ebe5d; }

/* ─── REPORTAR BUTTON ─── */
.btn-reportar {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  font-size: .82rem;
}
.btn-reportar:hover { background: var(--rojo-bg); color: var(--rojo); border-color: var(--rojo); }

/* ─── PANEL FOOT ROW ─── */
.panel-foot-row {
  display: flex;
  gap: 8px;
}

/* ─── SIDEBAR ACTIONS ─── */
.sidebar-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.sidebar-actions .btn { flex: 1; justify-content: center; }

/* ─── LISTA HEADER MEJORADO ─── */
.lista-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
}
.lista-header { padding: 0; }
.lista-header h3 { font-size: .875rem; font-weight: 600; color: var(--muted); }

.btn-sort {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1.5px solid var(--primary);
  cursor: pointer;
  background: transparent;
  transition: background var(--transition);
  white-space: nowrap;
}
.btn-sort:hover { background: rgba(0,122,255,.07); }

/* ─── BÚSQUEDA ─── */
.search-wrap {
  padding: 0 14px 10px;
}
.search-wrap input {
  background: var(--bg);
  border-color: var(--border);
  font-size: .84rem;
  padding: 7px 10px;
}
.search-wrap input:focus { border-color: var(--primary); background: var(--surface); }

/* ─── INDICADORES EN LISTA ─── */
.lista-stale {
  color: var(--amarillo);
  font-size: .75rem;
  vertical-align: middle;
}
.lista-reporte {
  font-size: .75rem;
  vertical-align: middle;
}
.lista-dist {
  display: inline-block;
  background: rgba(0,122,255,.10);
  color: var(--primary);
  font-size: .7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

/* ─── CONTROLES DEL MAPA ─── */
#map-type-control {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-ctrl-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: .8rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.map-ctrl-btn:hover { background: var(--bg); }
.map-ctrl-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── BANNER SÍSMICO ─── */
.sismo-banner {
  display: flex; align-items: center; gap: 10px;
  background: #B71C1C; color: #fff;
  padding: 9px 14px; font-size: .85rem; line-height: 1.35;
  position: relative; z-index: 110;
}
.sismo-banner.hidden { display: none; }
.sismo-banner-text { flex: 1; }
.sismo-banner-text strong { display: block; font-size: .9rem; }
.sismo-banner-close {
  background: none; border: none; color: rgba(255,255,255,.75);
  font-size: 1.1rem; cursor: pointer; padding: 2px 4px; line-height: 1; flex-shrink: 0;
}
.sismo-banner-close:hover { color: #fff; }

/* ─── BADGE VERIFICADO ─── */
.badge-verificado {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #e8f8f0;
  color: #1a7f4a;
  border: 1.5px solid #1a7f4a;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  letter-spacing: .02em;
}
.lista-verif {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: #1a7f4a;
  color: white;
  border-radius: 50%;
  font-size: .65rem;
  font-weight: 800;
  vertical-align: middle;
  margin-right: 2px;
}

/* ─── BANNER DE SELECCIÓN EN MAPA ─── */
.selecting-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28,28,30,.92);
  color: white;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: .84rem;
  font-weight: 600;
  z-index: 20;
  display: flex;
  align-items: center;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  gap: 4px;
}

/* ─── LEYENDA DEL MAPA ─── */
#map-leyenda {
  position: absolute;
  bottom: 28px;
  left: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
  font-size: .75rem;
  z-index: 10;
  min-width: 170px;
}
.leyenda-titulo {
  font-weight: 700;
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.leyenda-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  color: var(--text);
}
.leyenda-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0,0,0,.15);
}

/* ─── UTILIDADES ─── */
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .82rem; }
.mb-md { margin-bottom: 12px; }

/* ─── RESPONSIVE: MOBILE ─── */
@media (max-width: 768px) {
  .subtitle { display: none; }
  .btn { padding: 5px 8px; font-size: .78rem; }
  #btn-nuevo { display: none; }
  .btn-desktop { display: none; }
  .btn-mobile-only { display: inline; }
  /* Operadores: mostrar texto en móvil también */
  /* Leyenda: oculta en móvil para no tapar el mapa */
  #map-leyenda { display: none; }
  /* Stats: mostrar etiquetas pequeñas en móvil */
  .hstat-lbl { display: block; font-size: .48rem; }
  /* Quick filter: ocultar select de estado en móvil (está en sidebar) */
  #qf-estado { display: none; }
  .hstat-num { font-size: .95rem; font-weight: 800; }

  /* Sidebar como drawer desde la derecha */
  .sidebar {
    position: fixed;
    top: var(--header-h); bottom: var(--tab-bar-h); right: 0;
    width: min(var(--sidebar-w), 90vw);
    transform: translateX(100%);
    border-right: none;
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  #map-wrap { width: 100%; }

  /* Panel detalle como bottom sheet */
  .panel-centro {
    left: 0; right: 0; bottom: var(--tab-bar-h);
    height: 65dvh;
    height: 65vh;
    transform: translateY(calc(100% + var(--tab-bar-h)));
  }
  .panel-centro.open { transform: translateY(0); }

  .fab { display: flex; }

  /* Lista centros compacta en mobile */
  #lista-centros { display: none; }
  /* Botones del panel en columna en móvil */
  .panel-foot-row { flex-direction: column; }
  .panel-foot-row .btn { width: 100%; }

  .form-row { grid-template-columns: 1fr; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 95dvh;
    max-height: 95vh;
  }
}

/* ─── RESPONSIVE: DESKTOP ─── */
@media (min-width: 769px) {
  .btn-mobile-only { display: none; }
  .btn-desktop { display: inline; }

  /* ── Header simplificado: solo 1 fila ── */
  :root { --header-h: 56px; }
  #header-stats   { display: none; }
  #quick-filter-bar { display: none; }
  #btn-filtros    { display: none; }
  #btn-cerrar-sidebar { display: none; }

  /* ── Sidebar siempre visible, sin título redundante ── */
  .sidebar-header { padding: 12px 14px 8px; border-bottom: none; }
  .sidebar-header h2 { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

  /* ── Panel detalle como panel lateral derecho ── */
  .panel-centro {
    top: var(--header-h);
    right: 0; bottom: 0;
    width: 360px;
    border-radius: 0;
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    box-shadow: var(--shadow-lg);
  }
  .panel-centro.open { transform: translateX(0); }
  .panel-drag-handle { display: none; }
  .panel-scroll { height: 100%; display: flex; flex-direction: column; }
  .panel-body { flex: 1; overflow-y: auto; }

  /* Con panel abierto, el mapa se encoge */
  #map-wrap.panel-open { margin-right: 360px; }

  /* ── Sidebar actions más visibles ── */
  .sidebar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }
  .sidebar-actions .btn { justify-content: center; }
}

/* ─── CHAT ENTRE CENTROS ─── */
.btn-chat {
  position: fixed;
  bottom: 24px; right: 16px;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(0,122,255,.45);
  z-index: 500;
  transition: transform .15s, box-shadow .15s;
}
.btn-chat:hover { transform: scale(1.08); box-shadow: 0 6px 22px rgba(0,122,255,.55); }
.btn-chat.hidden { display: none; }
.chat-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #E74C3C;
  color: white;
  font-size: .62rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 18px;
  text-align: center;
  line-height: 1.5;
}
.chat-wrap {
  position: fixed;
  bottom: 86px; right: 16px;
  width: 330px; height: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  z-index: 499;
  animation: modal-in .18s ease;
}
.chat-wrap.hidden { display: none; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 9px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .88rem;
  flex-shrink: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
}
.chat-messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 82%;
  padding: 7px 11px;
  border-radius: 14px;
  font-size: .82rem;
  line-height: 1.45;
  word-break: break-word;
}
.chat-msg-mine {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-msg-other {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg-meta {
  font-size: .68rem;
  color: var(--muted);
  margin-top: 3px;
}
.chat-msg-mine .chat-msg-meta { color: rgba(255,255,255,.6); text-align: right; }
.chat-input-row {
  display: flex; gap: 6px; padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row input { margin: 0; padding: 7px 10px; font-size: .84rem; }
.chat-empty {
  color: var(--muted); font-size: .82rem;
  text-align: center; padding: 24px 16px;
  line-height: 1.5;
}
.chat-role {
  display: inline-block;
  font-size: .58rem; font-weight: 700;
  padding: 1px 5px; border-radius: 8px;
  text-transform: uppercase; letter-spacing: .05em;
  vertical-align: middle; margin-right: 2px;
}
.chat-role-admin    { background: rgba(230,57,70,.12); color: var(--emergency); }
.chat-role-operador { background: rgba(0,122,255,.10); color: var(--primary); }
.chat-locked {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: .78rem; color: var(--muted);
  text-align: center; flex-shrink: 0;
}
@media (max-width: 768px) {
  .chat-wrap {
    bottom: 0; right: 0; left: 0; width: 100%;
    height: 70dvh; height: 70vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .btn-chat { bottom: 72px; right: 12px; }
}

/* ─── SKELETON LOADING ─── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    rgba(0,0,0,.06) 25%,
    rgba(0,0,0,.12) 50%,
    rgba(0,0,0,.06) 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 5px;
}
.skeleton-card {
  padding: 12px 12px 12px 15px;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid rgba(0,0,0,.07);
  display: flex; flex-direction: column; gap: 7px;
}
.sk-line { height: 11px; }
.sk-a { width: 68%; }
.sk-b { width: 44%; }
.sk-c { width: 28%; }

/* ─── WIZARD REGISTRO ─── */
.wizard-progress {
  display: flex; gap: 5px; margin-top: 6px;
}
.wizard-dot {
  flex: 1; height: 3px; border-radius: 3px;
  background: var(--border);
  transition: background .2s;
}
.wizard-dot.done   { background: var(--verde); }
.wizard-dot.active { background: var(--emergency); }
.wizard-step-label {
  font-size: .75rem; color: var(--muted);
  margin-top: 4px; font-weight: 500;
}
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.cap-btns {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px;
}
.cap-btn {
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 6px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; font-size: .82rem;
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.cap-btn strong { font-size: .85rem; }
.cap-btn small  { font-size: .72rem; color: var(--muted); line-height: 1.3; }
.cap-btn:hover { background: var(--bg); }
.cap-btn.selected-disp { border-color: var(--verde); background: var(--verde-bg); }
.cap-btn.selected-parc { border-color: var(--amarillo); background: var(--amarillo-bg); }
.cap-btn.selected-llen { border-color: var(--rojo); background: var(--rojo-bg); }
.cap-btn .cap-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 5px;
}

/* ─── ANIMACIONES DE MODAL ─── */
.modal:not(.hidden) .modal-box {
  animation: modal-in .22s ease;
}
@keyframes modal-in {
  from { transform: scale(.96) translateY(6px); opacity: 0; }
  to   { transform: scale(1) translateY(0);     opacity: 1; }
}
@media (max-width: 768px) {
  .modal:not(.hidden) .modal-box {
    animation: sheet-in .25s ease;
  }
  @keyframes sheet-in {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
  }
}

/* ─── AUTOCOMPLETE DIRECCIÓN ─── */
.ac-wrap { position: relative; }

.ac-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.ac-input-wrap input {
  padding-right: 32px;
}

.ac-spinner {
  position: absolute;
  right: 10px;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
  pointer-events: none;
}

.ac-lista {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 1100;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.ac-lista li {
  padding: 9px 12px;
  font-size: .82rem;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  line-height: 1.35;
  transition: background var(--transition);
  outline: none;
}
.ac-lista li:last-child { border-bottom: none; }
.ac-lista li:hover,
.ac-lista li:focus { background: var(--bg); }

/* ─── POPUP GOOGLE MAPS ─── */
.popup-content {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.popup-ubicacion {
  font-size: .7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.popup-nombre {
  font-weight: 700;
  font-size: .92rem;
  line-height: 1.3;
  color: var(--text);
}
.popup-dir {
  font-size: .76rem;
  color: var(--muted);
  line-height: 1.4;
}
.popup-insumos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.popup-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .68rem;
  padding: 2px 7px;
  color: var(--text);
  white-space: nowrap;
}
.popup-tag-more {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
}
.popup-contacto {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .76rem;
  color: var(--muted);
}
.popup-ic { font-size: .85rem; flex-shrink: 0; }
.popup-btn {
  width: 100%;
  padding: 7px;
  background: var(--emergency);
  color: white;
  font-size: .8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  margin-top: 2px;
}
.popup-btn:hover { background: var(--emergency-dark); }

/* ─── TOOLTIP DE MARCADOR ─── */
.tooltip-centro {
  background: rgba(28,28,30,.88);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 9px;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tooltip-centro::before { display: none; }

/* ─── OPERADORES ─── */

/* Badge en header cuando hay sesión activa */
.op-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: .76rem;
  color: rgba(255,255,255,.9);
  max-width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.op-badge span { overflow: hidden; text-overflow: ellipsis; }
.op-badge button {
  flex-shrink: 0;
  color: rgba(255,255,255,.6);
  font-size: .85rem;
  padding: 0 2px;
  line-height: 1;
  transition: color var(--transition);
}
.op-badge button:hover { color: white; }

/* Modal operadores */
.modal-sm .modal-body { padding: 20px 24px; }
.op-desc { margin-bottom: 16px; line-height: 1.55; font-size: .88rem; }
.op-desc p + p { margin-top: 4px; }
.op-desc strong { color: var(--text); }

/* Botones de operador en panel */
.op-controles {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,.04);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}
.op-controles-titulo {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}
.btn-op-verificar {
  background: #1a7f4a;
  color: white;
  font-size: .8rem;
  font-weight: 600;
}
.btn-op-verificar:hover { background: #15673c; }
.btn-op-limpiar {
  background: var(--bg);
  color: var(--muted);
  border: 1.5px solid var(--border);
  font-size: .8rem;
}
.btn-op-limpiar:hover { background: var(--rojo-bg); color: var(--rojo); border-color: var(--rojo); }

/* Modo operador: borde verde sutil en el panel */
body.op-mode .panel-centro { border-left: 2px solid #1a7f4a; }

/* Campos extra visibles solo en modo operador */
.op-only { display: none; }
body.op-mode .op-only { display: block; }

.op-edit-divider {
  font-size: .72rem;
  font-weight: 700;
  color: #1a7f4a;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 0 6px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

/* Botón eliminar */
.btn-op-eliminar {
  background: transparent;
  color: var(--rojo);
  border: 1.5px solid var(--rojo);
  font-size: .8rem;
  font-weight: 600;
  opacity: .8;
}
.btn-op-eliminar:hover { background: var(--rojo-bg); opacity: 1; }

/* Botón confirmar eliminación */
.btn-emergency {
  background: var(--emergency);
  color: white;
  font-weight: 700;
}
.btn-emergency:hover { background: var(--emergency-dark); }

/* Caja de confirmación */
.op-confirm {
  margin-top: 8px;
  padding: 10px;
  background: var(--rojo-bg);
  border: 1px solid var(--rojo);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: var(--rojo);
}

/* Input de código OTP */
#op-code-input {
  font-variant-numeric: tabular-nums;
  background: var(--bg);
}

/* ─── MAPLIBRE GL — ajustes de z-index y marcadores ─── */
.maplibregl-canvas-container { z-index: 0; }
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right { z-index: 2; }

/* Pin SVG personalizado */
.mbx-pin {
  width: 28px;
  height: 36px;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
}
.mbx-pin:hover { transform: scale(1.15) translateY(-2px); }

/* Popup MapLibre — reemplaza estilos de borde blanco */
.maplibregl-popup-content {
  padding: 0 !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  overflow: hidden;
}
.maplibregl-popup-close-button {
  right: 8px !important;
  top: 6px !important;
  font-size: 18px !important;
  color: rgba(0,0,0,.4) !important;
  line-height: 1 !important;
  z-index: 1;
}

/* ─── BOTONES CÓMO LLEGAR ─── */
.nav-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 16px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
  letter-spacing: .01em;
}
.btn-nav:hover  { opacity: .85; }
.btn-nav:active { transform: scale(.96); }
.btn-nav-waze  { background: #34a9e0; color: white; }
.btn-nav-gmaps { background: #4285F4; color: white; }

/* ─── FOTOS DEL CENTRO ─── */
.p-fotos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.p-foto-img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1.5px solid var(--border);
  transition: transform .15s;
}
.p-foto-img:hover { transform: scale(1.05); }

/* ═══════════════════════════════════════════════════════════
   TAB BAR — navegación principal móvil
   ═══════════════════════════════════════════════════════════ */
:root { --tab-bar-h: calc(56px + env(safe-area-inset-bottom, 0px)); }

#tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-bar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 900;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: .62rem;
  font-weight: 600;
  color: var(--muted);
  position: relative;
  transition: color var(--transition);
  padding: 6px 4px;
  letter-spacing: .02em;
}
.tab-btn span:not(.tab-badge) { line-height: 1; }
.tab-btn svg { transition: transform .15s; }
.tab-btn.tab-active { color: var(--emergency); }
.tab-btn.tab-active svg { transform: scale(1.1); }
.tab-btn:hover:not(.tab-active) { color: var(--text); }

.tab-badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 22px);
  background: var(--emergency);
  color: white;
  font-size: .58rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* ─── Ajustar vistas para acomodar tab bar ─── */
#app-layout { bottom: var(--tab-bar-h); }
#app-layout.view-hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   VISTAS DE TABS — Recursos y Difundir
   ═══════════════════════════════════════════════════════════ */
#view-recursos,
#view-difundir {
  position: fixed;
  top: var(--header-h);
  bottom: var(--tab-bar-h);
  left: 0; right: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--bg);
  display: none;
}
#view-recursos.view-active,
#view-difundir.view-active { display: block; }

/* ─── FEED HEADER ─── */
.recursos-header {
  padding: 14px 14px 10px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--border);
}
.recursos-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.recursos-header h2 {
  font-size: 1rem;
  font-weight: 700;
}
.rec-refresh-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  color: var(--primary);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background .15s;
}
.rec-refresh-btn:hover { background: rgba(0,122,255,.08); }
.recursos-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.recursos-chips::-webkit-scrollbar { display: none; }
.rec-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 13px;
  border-radius: 14px;
  font-size: .75rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}
.rec-chip.active                 { background: #1C1C1E;   border-color: #1C1C1E;   color: white; }
.rec-chip-medico.active          { background: #E63946;   border-color: #E63946;   color: white; }
.rec-chip-refugio.active         { background: #007AFF;   border-color: #007AFF;   color: white; }
.rec-chip-agua.active            { background: #17A2B8;   border-color: #17A2B8;   color: white; }
.rec-chip-comida.active          { background: #FF9500;   border-color: #FF9500;   color: white; }
.rec-chip-servicios.active       { background: #6F42C1;   border-color: #6F42C1;   color: white; }

/* ─── LISTA DE RECURSOS ─── */
.recursos-list {
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.recursos-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
}
.rec-empty-icon { font-size: 2.5rem; margin-bottom: 10px; }

/* ─── TARJETA DE RECURSO ─── */
.recurso-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.recurso-card:hover { box-shadow: var(--shadow-sm); }

.rec-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 8px;
}
.rec-tipo-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.rec-tipo-medico    { background: rgba(230,57,70,.1); }
.rec-tipo-refugio   { background: rgba(0,122,255,.1); }
.rec-tipo-agua      { background: rgba(23,162,184,.1); }
.rec-tipo-servicios { background: rgba(111,66,193,.1); }
.rec-tipo-comida    { background: rgba(255,149,0,.1); }

.rec-card-content { flex: 1; min-width: 0; }
.rec-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.rec-tipo-badge {
  font-size: .63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 8px;
  flex-shrink: 0;
}
.rec-badge-medico    { background: rgba(230,57,70,.12);  color: #C0392B; }
.rec-badge-refugio   { background: rgba(0,122,255,.12);  color: #0062CC; }
.rec-badge-agua      { background: rgba(23,162,184,.12); color: #138496; }
.rec-badge-servicios { background: rgba(111,66,193,.12); color: #5a32a3; }
.rec-badge-comida    { background: rgba(255,149,0,.12);  color: #CC7700; }

.rec-time {
  font-size: .65rem;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.rec-titulo {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 3px;
}
.rec-desc {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Barra de expiración */
.rec-expiry {
  margin: 0 12px 0;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.rec-expiry-fill {
  height: 100%;
  border-radius: 2px;
}
.rec-expiry-ok   { background: var(--verde); }
.rec-expiry-warn { background: var(--amarillo); }
.rec-expiry-crit { background: var(--rojo); }
.rec-expiry-label {
  padding: 3px 12px 6px;
  font-size: .62rem;
  color: var(--muted);
}

/* Pie de tarjeta */
.rec-card-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,.018);
}
.rec-loc-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  color: var(--primary);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background .15s;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.rec-loc-btn:hover { background: rgba(0,122,255,.08); }
.rec-loc-static {
  font-size: .72rem;
  color: var(--muted);
  padding: 4px 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.rec-actions {
  display: flex;
  gap: 5px;
  margin-left: auto;
  flex-shrink: 0;
}
.rec-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  line-height: 1;
}
.rec-action-btn:hover { background: var(--bg); }
.rec-action-btn.confirmed {
  color: var(--verde);
  border-color: var(--verde);
  background: var(--verde-bg);
}
.rec-view-btn { cursor: default; border-color: transparent; background: transparent; }

/* ═══════════════════════════════════════════════════════════
   VISTA DIFUNDIR
   ═══════════════════════════════════════════════════════════ */
.difundir-view {
  padding: 16px 14px 24px;
}
.difundir-view h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.difundir-subtitle {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.difundir-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 14px;
  margin-bottom: 12px;
}
.difundir-card h3 {
  font-size: .875rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.difundir-card p {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.4;
}
.difundir-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.difundir-btns .btn {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg);
  font-size: .8rem;
}
.difundir-btns .btn:hover { background: var(--border); }
.difundir-btns .btn-wa-dif {
  background: #25D366;
  color: white;
  border-color: #25D366;
}
.difundir-btns .btn-wa-dif:hover { background: #1ebe5a; }

/* Desktop: ocultar tab bar, expandir vistas al fondo */
@media (min-width: 769px) {
  #tab-bar { display: none; }
  #app-layout { bottom: 0; }
  #view-recursos, #view-difundir { bottom: 0; }
}
