*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }

:root {
  --azul:    #1a3a5c;
  --azul2:   #2979ff;
  --gris:    #f0f4f8;
  --borde:   #cfd8dc;
  --texto:   #263238;
  --suave:   #6b7a8d;
  --rojo:    #e53935;
  --verde:   #2e7d32;
  --ambar:   #e65100;
  --naranja: #f57c00;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--gris);
  color: var(--texto);
  min-height: 100vh;
}

/* ── Loading / Error ── */
.centrado {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; gap: 1rem; text-align: center; padding: 2rem;
}
.spinner {
  width: 40px; height: 40px; border: 4px solid var(--borde);
  border-top-color: var(--azul2); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid #ccc; border-top-color: var(--azul2);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle;
}
.error-box {
  background: white; border-radius: 12px; padding: 2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.1); max-width: 340px;
}
.error-box h2 { color: #c62828; margin-bottom: .5rem; }
.error-box p  { color: var(--suave); font-size: .9rem; }

#app { display: none; }

/* ── Header ── */
.app-header {
  background: var(--azul); color: white;
  padding: .55rem 1rem;
  min-height: 64px;
  display: flex; align-items: center; gap: .8rem;
}
.app-header h1 { font-size: 1.1rem; font-weight: 700; }

.header-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  background: #ffffff;
  border-radius: 999px;
  border: 1px solid rgba(18,54,90,.18);
  padding: .2rem .5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}

.header-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: 52vw;
  object-fit: contain;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
}

.header-right-stack {
  flex-direction: column;
  align-items: flex-end;
  gap: .25rem;
}

.user-badge {
  background: #ffffff;
  color: #12365a;
  border-radius: 999px;
  border: 1px solid rgba(18,54,90,.18);
  padding: .26rem .78rem;
  font-size: .78rem;
  font-weight: 700;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}

.header-sub {
  font-size: .76rem;
  color: #e9f1ff;
  font-weight: 600;
  letter-spacing: .01em;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

@media (max-width: 480px) {
  .app-header {
    min-height: 58px;
    padding: .45rem .75rem;
  }

  .header-logo {
    height: 38px;
    max-width: 50vw;
  }
}

/* ── Tabs ── */
.tabs {
  display: flex; background: white;
  border-bottom: 2px solid #eceff1;
}
.tab-btn {
  flex: 1; padding: .75rem .3rem;
  border: none; background: none; cursor: pointer;
  font-size: .82rem; color: var(--suave); font-weight: 500;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: color .2s, border-color .2s; white-space: nowrap;
}
.tab-btn.active { color: var(--azul2); border-bottom-color: var(--azul2); }
.count-badge {
  background: var(--azul2); color: white; border-radius: 10px;
  padding: .05rem .4rem; font-size: .7rem; margin-left: .2rem;
}

/* ── Botones base ── */
.btn-primary {
  padding: .7rem 1rem; background: var(--azul);
  color: white; border: none; border-radius: 8px;
  font-size: .95rem; font-weight: 700; cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover   { background: var(--azul2); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-sec {
  padding: .7rem 1rem; background: #eceff1; color: var(--texto);
  border: none; border-radius: 8px; font-size: .95rem;
  font-weight: 600; cursor: pointer; transition: background .2s;
}
.btn-sec:hover { background: #cfd8dc; }

/* ── Banners ── */
.banner {
  border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .6rem; font-size: .9rem;
}
.banner-edit { background: #fff8e1; border: 1px solid #ffe082; color: #6d4c00; }
.banner-ok   { background: #e8f5e9; border: 1px solid #a5d6a7; color: #1b5e20; }
.banner-err  { background: #fce4ec; border: 1px solid #f48fb1; color: #880e4f; }
.banner button {
  margin-left: auto; background: none; border: none;
  cursor: pointer; font-size: .85rem; text-decoration: underline; color: inherit;
}

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; cursor: zoom-out; padding: 1rem;
}
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; object-fit: contain; }

/* ── Tabla compartida (zona / admin) ── */
.tabla-wrap { overflow-x: auto; border-radius: 10px; box-shadow: 0 1px 6px rgba(0,0,0,.06); }
table { width: 100%; border-collapse: collapse; background: white; font-size: .86rem; }
thead th {
  background: var(--azul); color: white; padding: .7rem 1rem;
  text-align: left; font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #eceff1; transition: background .15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f5f9ff; }
td { padding: .65rem 1rem; vertical-align: middle; }
.badge {
  display: inline-block; width: 28px; height: 28px; line-height: 28px;
  border-radius: 50%; font-weight: 700; font-size: .82rem; text-align: center; color: white;
}
.ratings-cell { display: flex; gap: .35rem; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.thumb:hover { opacity: .8; }
.no-foto {
  width: 48px; height: 48px; background: #eceff1; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.obs-cell { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--suave); font-size: .8rem; }
.fecha-cell { white-space: nowrap; color: var(--suave); font-size: .78rem; }
.empty-row td { text-align: center; color: var(--suave); padding: 2rem; }

/* ── Modal compartido ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal-box {
  background: white; border-radius: 14px; padding: 2rem;
  width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-box h3 { color: var(--azul); margin-bottom: 1rem; }
.modal-box input {
  width: 100%; border: 1.5px solid var(--borde); border-radius: 8px;
  padding: .7rem 1rem; font-size: 1rem; margin-bottom: 1rem;
  outline: none; font-family: inherit; transition: border-color .2s;
}
.modal-box input:focus { border-color: var(--azul2); }
.modal-btns { display: flex; gap: .7rem; }
.modal-result {
  margin-top: 1rem; background: var(--gris);
  border-radius: 8px; padding: .8rem; font-size: .85rem;
}
.modal-result strong { display: block; margin-bottom: .3rem; color: var(--azul); }
.modal-result code { word-break: break-all; font-size: .78rem; }

/* ── Miscelánea ── */
.empty-msg { text-align: center; color: var(--suave); padding: 3rem 0; font-size: .95rem; }
.divider { border: none; border-top: 1px solid #eceff1; margin: 1.3rem 0; }

/* ── Acceso pills (salidas / encuentros) ── */
.badge-facil    { background: #e8f5e9; color: var(--verde); }
.badge-moderado { background: #fff8e1; color: var(--ambar); }
.badge-dificil  { background: #fce4ec; color: var(--rojo);  }
.acceso-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.acceso-opt { cursor: pointer; }
.acceso-opt input[type="radio"] { display: none; }
.acceso-pill {
  display: flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .55rem .4rem; border-radius: 30px; text-align: center;
  font-size: .85rem; font-weight: 600; border: 2px solid transparent;
  transition: all .15s; cursor: pointer; white-space: nowrap;
}
.acceso-facil    { background: #e8f5e9; color: var(--verde); }
.acceso-moderado { background: #fff8e1; color: var(--ambar); }
.acceso-dificil  { background: #fce4ec; color: var(--rojo);  }
.acceso-opt input:checked + .acceso-pill { border-color: currentColor; box-shadow: 0 0 0 3px rgba(0,0,0,.08); }

/* ── Debug panel ── */
#dbg-badge {
  position: fixed; bottom: 5rem; right: .8rem; z-index: 9999;
  background: #b71c1c; color: white; border: none; border-radius: 20px;
  padding: .35rem .8rem; font-size: .78rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
#dbg-panel {
  position: fixed; bottom: 8rem; right: .8rem; z-index: 9998;
  width: min(92vw, 420px); max-height: 55vh;
  background: #1a237e; border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
  display: none; flex-direction: column; overflow: hidden;
}
.dbg-header {
  background: #283593; color: white; padding: .5rem .8rem;
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem; flex-shrink: 0;
}
.dbg-body {
  overflow-y: auto; padding: .4rem .6rem;
  font-family: monospace; font-size: .72rem; color: #e8eaf6;
  flex: 1; max-height: 100%;
}
.dbg-entry { margin-bottom: .4rem; line-height: 1.4; }
.dbg-entry.dbg-error .dbg-ctx { color: #ef9a9a; }
.dbg-entry.dbg-warn  .dbg-ctx { color: #ffe082; }
.dbg-time { color: #7986cb; margin-right: .4rem; }
.dbg-ctx  { font-weight: 700; margin-right: .3rem; }
.dbg-msg  { white-space: pre-wrap; word-break: break-all; }
