:root {
  --vut: #2563eb;      /* azul  - viviendas */
  --at:  #e11d48;      /* rojo  - apartamentos */
  --cluster: #f59e0b;  /* ámbar - agrupaciones */
  --propio: #16a34a;   /* verde - lockers propios */
  --competencia: #9333ea; /* morado - lockers competencia */
  --bg: #0f172a;
  --panel: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
#map { position: absolute; inset: 0; }

/* ---- Login ---- */
.login-body { display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #0f172a, #1e3a8a); }
.login-card { background: #fff; padding: 32px; border-radius: 14px; width: 320px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; font-size: 20px; color: #0f172a; }
.login-card .sub { margin: 0 0 8px; color: #64748b; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #334155; }
.login-card input { padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; }
.login-card button { margin-top: 8px; padding: 11px; border: 0; border-radius: 8px;
  background: #2563eb; color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; }
.login-card button:hover { background: #1d4ed8; }
.error { background: #fee2e2; color: #b91c1c; padding: 8px 10px; border-radius: 8px; font-size: 13px; }

/* ---- Panel ---- */
#panel { position: absolute; top: 14px; left: 14px; width: 270px; z-index: 5;
  background: var(--panel); border-radius: 14px; padding: 16px 16px 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
#panel h1 { margin: 0; font-size: 17px; color: #0f172a; }
.volver-panel { display: block; text-align: center; text-decoration: none;
  background: #0f172a; color: #fff; font-size: 14px; font-weight: 600;
  padding: 9px 12px; border-radius: 9px; margin-bottom: 12px; }
.volver-panel:hover { background: #1e293b; }
#panel .sub { margin: 2px 0 14px; color: #64748b; font-size: 12px; }
.capas { display: flex; flex-direction: column; gap: 8px; }
.capa { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; cursor: pointer; }
.capa b { margin-left: auto; font-variant-numeric: tabular-nums; color: #0f172a; }
.capa .dot { width: 12px; height: 12px; border-radius: 50%; }
.capa.vut .dot { background: var(--vut); }
.capa.at  .dot { background: var(--at); }
.capa.propio .dot { background: var(--propio); }
.capa.competencia .dot { background: var(--competencia); }
.stats { margin: 12px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: #f1f5f9; border-radius: 10px; padding: 8px 10px; }
.stat .v { font-size: 18px; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; color: #64748b; }
.leyenda { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: #475569; margin-top: 4px; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 3px; vertical-align: -1px; }
.leyenda .c-cluster { background: var(--cluster); }
.leyenda .c-vut { background: var(--vut); }
.leyenda .c-at { background: var(--at); }
.fuente { font-size: 10px; color: #94a3b8; margin: 10px 0 0; }

/* ---- Popup ---- */
.maplibregl-popup-content { border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.pop-tipo { display: inline-block; font-size: 10px; font-weight: 700; color: #fff;
  padding: 2px 7px; border-radius: 999px; margin-bottom: 6px; }
.pop-tipo.VUT { background: var(--vut); }
.pop-tipo.AT { background: var(--at); }
.pop-tipo.propio { background: var(--propio); }
.pop-tipo.competencia { background: var(--competencia); }
.pop h3 { margin: 0 0 4px; font-size: 14px; }
.pop .row { color: #475569; margin: 2px 0; }
.pop .kpis { display: flex; gap: 14px; margin-top: 6px; }
.pop .kpis b { color: #0f172a; }

@media (max-width: 520px) {
  #panel { width: calc(100% - 28px); }
}

/* ============ Pantallas de gestión (panel, lockers, usuarios) ============ */
.app-body { background: #f1f5f9; color: #0f172a; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between;
  background: #0f172a; color: #fff; padding: 12px 20px; }
.topbar .brand { font-weight: 700; }
.topbar .brand a { color: #fff; text-decoration: none; }
.topbar .sep { color: #64748b; margin: 0 4px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.whoami { color: #94a3b8; font-size: 13px; }
.btn-ghost { color: #cbd5e1; text-decoration: none; font-size: 14px; padding: 6px 10px;
  border-radius: 8px; border: 1px solid #334155; }
.btn-ghost:hover { background: #1e293b; color: #fff; }

.panel-wrap, .content { max-width: 1000px; margin: 0 auto; padding: 28px 20px; }
.content.narrow { max-width: 640px; }
.panel-wrap h1, .content h1 { margin: 0 0 4px; }
.muted { color: #64748b; }
.small { font-size: 12px; }
.mt { margin-top: 28px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px; margin-top: 22px; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 22px;
  text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.card-link:hover { box-shadow: 0 12px 30px rgba(2,6,23,.12); transform: translateY(-2px); }
.card-ico { font-size: 30px; }
.card h2 { margin: 8px 0 4px; font-size: 18px; }
.card p { margin: 0; color: #64748b; font-size: 13px; }
.card-stats { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; color: #334155; }
.card-stats b { color: #0f172a; }

.content-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.content-head .count { color: #94a3b8; font-weight: 400; font-size: 16px; }
.actions { display: flex; gap: 10px; align-items: center; }
.btn { background: #2563eb; color: #fff; border: 0; border-radius: 9px; padding: 9px 15px;
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { background: #1d4ed8; }
.btn.btn-ghost { background: #fff; color: #334155; border: 1px solid #cbd5e1; }
.btn.btn-ghost:hover { background: #f8fafc; }
.import-form { margin: 0; }

.flash { background: #dcfce7; color: #166534; border: 1px solid #86efac; padding: 10px 14px;
  border-radius: 10px; margin-bottom: 16px; }

.tabla { width: 100%; border-collapse: collapse; margin-top: 16px; background: #fff;
  border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.tabla th, .tabla td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef2f7; font-size: 14px; }
.tabla th { background: #f8fafc; color: #475569; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tabla tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.row-actions a { color: #2563eb; text-decoration: none; }
.row-actions form { margin: 0; }
.link-danger { background: none; border: 0; color: #dc2626; cursor: pointer; font-size: 14px; padding: 0; }
.link-danger:hover { text-decoration: underline; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: #fff; }
.badge.propio { background: var(--propio); }
.badge.competencia { background: var(--competencia); }
.ok { color: #16a34a; font-weight: 700; }
.ko { color: #dc2626; font-weight: 700; }

.form { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 22px; margin-top: 16px; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: #334155; font-weight: 500; }
.field input, .field textarea { padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; font-family: inherit; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.radios { display: flex; gap: 18px; }
.radios label { font-weight: 400; display: flex; align-items: center; gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; margin: 6px 0; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
