:root {
  --bg: #0b1220;
  --card: #111c2e;
  --card-2: #16233a;
  --line: rgba(148, 163, 184, .18);
  --text: #e5edf8;
  --muted: #93a4bd;
  --green: #22c55e;
  --blue: #38bdf8;
  --amber: #f59e0b;
  --slate: #64748b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */

.login {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(56, 189, 248, .18), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(34, 197, 94, .14), transparent 60%),
    linear-gradient(160deg, #0b1220 0%, #0d1729 55%, #0b1220 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(17, 28, 46, .92);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 22px 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  backdrop-filter: blur(8px);
}

.logo {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: linear-gradient(150deg, #1d4ed8, #0ea5e9);
  box-shadow: 0 10px 24px rgba(14, 165, 233, .35);
  margin-bottom: 14px;
}

.login h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.4px; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.login label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

.login input {
  width: 100%;
  margin-top: 6px;
  height: 50px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: #0b1525;
  color: var(--text);
  padding: 0 14px;
  font-size: 17px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.login input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .18);
}

.login button[type=submit] {
  width: 100%;
  height: 52px;
  margin-top: 6px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(140deg, #0ea5e9, #2563eb);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .2px;
  box-shadow: 0 12px 26px rgba(37, 99, 235, .35);
  cursor: pointer;
}

.login button[type=submit]:disabled { opacity: .6; }

.error {
  color: #fca5a5;
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .25);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin: 12px 0 0;
}

.login-foot {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ---------- App ---------- */

#app { position: fixed; inset: 0; }

#map { position: absolute; inset: 0; background: #0b1220; }

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 1200;
  padding: calc(8px + env(safe-area-inset-top)) 12px 26px;
  background: linear-gradient(180deg, rgba(7, 12, 22, .94) 0%, rgba(7, 12, 22, .78) 58%, transparent 100%);
  pointer-events: none;
}

.topbar button { pointer-events: auto; }

.topbar-row { display: flex; align-items: center; gap: 10px; }
.topbar-row.second { margin-top: 8px; }

.brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  min-width: 0;
}

.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .16);
  flex: none;
}

.brand .mi-auto { color: var(--text); white-space: nowrap; }
.brand .sep { opacity: .5; }

.icon-btn {
  width: auto;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(17, 28, 46, .7);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  display: grid; place-items: center;
  cursor: pointer;
  flex: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill.en-cola { background: rgba(34, 197, 94, .14); color: #86efac; border-color: rgba(34, 197, 94, .3); }
.pill.en-base { background: rgba(245, 158, 11, .14); color: #fcd34d; border-color: rgba(245, 158, 11, .3); }
.pill.fuera { background: rgba(100, 116, 139, .18); color: #cbd5e1; border-color: rgba(100, 116, 139, .35); }
.pill.sin-senal { background: rgba(239, 68, 68, .12); color: #fca5a5; border-color: rgba(239, 68, 68, .28); }

.mi-base {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #86efac;
  white-space: nowrap;
}

.live i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
  animation: latido 2.4s ease-in-out infinite;
}

.live.off { color: #fca5a5; }
.live.off i { background: #ef4444; box-shadow: none; animation: none; }

@keyframes latido {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

.aviso {
  pointer-events: auto;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 12px;
  border-radius: 12px;
  background: rgba(245, 158, 11, .14);
  border: 1px solid rgba(245, 158, 11, .38);
  color: #fde68a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.aviso span { flex: 1; }

.aviso button {
  border: 0;
  border-radius: 9px;
  background: #f59e0b;
  color: #1c1204;
  font-weight: 800;
  font-size: 12px;
  padding: 8px 11px;
  cursor: pointer;
  flex: none;
}

.aviso.version {
  background: rgba(56, 189, 248, .14);
  border-color: rgba(56, 189, 248, .38);
  color: #bae6fd;
}

.aviso.version button {
  background: #38bdf8;
  color: #04121f;
}

/* ---------- Mapa ---------- */

.leaflet-container {
  font-family: inherit;
  background: #0b1220;
}

.car-marker {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  border: 2px solid #94a3b8;
  background: #334155;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .45);
  transition: background .2s, border-color .2s;
}

.car-marker.en-cola { background: #16a34a; border-color: #86efac; }
.car-marker.en-base { background: #b45309; border-color: #fcd34d; }
.car-marker.fuera { background: #334155; border-color: #64748b; color: #cbd5e1; }
.car-marker.sin-senal { background: #1e293b; border-color: #475569; color: #94a3b8; opacity: .85; }

.car-wrap.yo .car-marker {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, .35), 0 6px 16px rgba(0, 0, 0, .5);
}

.car-wrap.yo::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 36px; height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  border: 2px solid rgba(56, 189, 248, .55);
  animation: onda 2s ease-out infinite;
  pointer-events: none;
}

@keyframes onda {
  0% { transform: scale(1); opacity: .8; }
  100% { transform: scale(2.1); opacity: 0; }
}

.base-label { width: 1px; height: 1px; }

.base-chip {
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, calc(-50% - 34px));
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(9, 16, 29, .82);
  border: 1.5px solid #38bdf8;
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
  pointer-events: none;
}

.base-chip b { font-size: 11px; opacity: .9; }
.base-chip .chip-count { color: #f8fafc; background: rgba(255,255,255,.14); border-radius: 999px; padding: 0 6px; }

.leaflet-popup-content-wrapper {
  background: #111c2e;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.leaflet-popup-tip { background: #111c2e; }
.leaflet-popup-content { margin: 11px 13px; font-size: 13px; line-height: 1.45; }
.leaflet-popup-close-button { color: var(--muted) !important; }

.pop-title { font-weight: 800; font-size: 14px; margin-bottom: 2px; }
.pop-sub { color: var(--muted); font-size: 12px; }

/* ---------- Hoja inferior ---------- */

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1100;
  height: auto;
  max-height: min(46dvh, 430px);
  min-height: 104px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(13, 22, 38, .97), #0b1220 40%);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 40px rgba(0, 0, 0, .45);
  padding-bottom: env(safe-area-inset-bottom);
  transition: height .25s ease;
  overflow: hidden;
}

.sheet.collapsed { height: 104px; }.sheet-handle {
  height: 22px;
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
}

.sheet-handle span {
  width: 38px; height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .45);
}

.sheet-tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 8px;
  flex: none;
}

.sheet-tabs button {
  flex: 1;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(17, 28, 46, .6);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.sheet-tabs button.active {
  background: rgba(56, 189, 248, .12);
  border-color: rgba(56, 189, 248, .4);
  color: #bae6fd;
}

.badge {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .18);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
}

.sheet-tabs button.active .badge { background: rgba(56, 189, 248, .22); color: #e0f2fe; }

.pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 14px;
}

.list { display: flex; flex-direction: column; gap: 7px; }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 26px 10px;
  line-height: 1.5;
}

.queue-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 13px;
  background: rgba(17, 28, 46, .78);
  border: 1px solid var(--line);
}

.queue-row.yo {
  background: rgba(56, 189, 248, .1);
  border-color: rgba(56, 189, 248, .42);
}

.q-pos {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 800;
  flex: none;
}

.queue-row:first-child .q-pos { background: var(--green); color: #052e16; }

.q-main { flex: 1; min-width: 0; }

.q-num {
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-yo {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .4px;
  background: var(--blue);
  color: #082f49;
  border-radius: 5px;
  padding: 2px 5px;
}

.q-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.q-time {
  font-size: 11.5px;
  font-weight: 700;
  color: #cbd5e1;
  flex: none;
}

.base-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 13px;
  background: rgba(17, 28, 46, .78);
  border: 1px solid var(--line);
  cursor: pointer;
}

.base-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, .1);
}

.base-main { flex: 1; min-width: 0; }
.base-name { font-size: 14px; font-weight: 800; }
.base-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.base-cars {
  font-size: 11px;
  font-weight: 800;
  color: #cbd5e1;
  text-align: right;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Botones flotantes ---------- */

.fab {
  position: absolute;
  right: 14px;
  bottom: calc(var(--sheet-h, 320px) + 14px);
  z-index: 1150;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(17, 28, 46, .92);
  color: var(--blue);
  font-size: 20px;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
  cursor: pointer;
  transition: bottom .25s ease;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sheet-h, 320px) + 22px);
  transform: translateX(-50%);
  z-index: 2000;
  max-width: calc(100% - 40px);
  padding: 10px 15px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .97);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .5);
}
