:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --steel: #1b3a6b;
  --gold: #d4af37;
  --gold-2: #f0c75e;
  --ink: #0a1626;
  --paper: #f4f6fb;
  --line: #23385f;
  --ok: #2e9e5b;
  --warn: #e0a800;
  --bad: #d64545;
  --muted: #8ea3c4;
  --text: #e8eefb;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--navy);
  color: var(--text);
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  background: #0e213f; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); }

/* ---------- Login ---------- */
#login {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, var(--steel), var(--navy));
}
.login-card {
  width: 360px; background: var(--navy-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.badge {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%;
  background: linear-gradient(160deg, var(--gold-2), var(--gold));
  display: grid; place-items: center; color: var(--ink); font-weight: 800; font-size: 26px;
  box-shadow: 0 0 0 4px rgba(212,175,55,.2);
}
/* Official Town of Havana wordmark on a light chip */
.logo-chip { background: #fff; border-radius: 12px; padding: 12px 16px; display: inline-flex;
  align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.logo-chip img { display: block; height: 76px; width: auto; }
.login-card .logo-chip { display: flex; margin: 0 auto 16px; width: max-content; }
.logo-chip.small { padding: 5px 9px; border-radius: 8px; }
.logo-chip.small img { height: 28px; }

/* Havana PD patch/badge (transparent PNG, sits directly on the theme) */
.hpd-badge-logo { display: flex; justify-content: center; margin: 0 auto 12px; }
.hpd-badge-logo img { display: block; height: 118px; width: 118px; object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.45)); }
.topbar-badge { height: 44px; width: 44px; object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }

.login-card h1 { font-size: 18px; text-align: center; margin: 0 0 2px; letter-spacing: .5px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 20px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 18px; }

/* ---------- App shell ---------- */
#app { display: none; grid-template-rows: auto 1fr; height: 100%; }
header.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: linear-gradient(90deg, var(--navy-2), var(--steel));
  border-bottom: 2px solid var(--gold);
}
.topbar .mini-badge {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(160deg, var(--gold-2), var(--gold));
  color: var(--ink); font-weight: 800; display: grid; place-items: center;
}
.topbar h1 { font-size: 16px; margin: 0; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }

nav.tabs { display: flex; gap: 4px; padding: 0 12px; background: var(--navy-2); border-bottom: 1px solid var(--line); }
nav.tabs button {
  background: transparent; color: var(--muted); border: none; padding: 12px 16px;
  border-bottom: 3px solid transparent; font-size: 14px;
}
nav.tabs button.active { color: var(--gold-2); border-bottom-color: var(--gold); }

main { overflow: auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; }

.btn { background: var(--gold); color: var(--ink); border: none; border-radius: 6px; padding: 9px 14px; font-weight: 700; }
.btn.secondary { background: transparent; color: var(--gold-2); border: 1px solid var(--gold); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 5px 9px; font-size: 12px; }

.card { background: var(--navy-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 220px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.ok { background: rgba(46,158,91,.18); color: #6fe0a0; }
.pill.warn { background: rgba(224,168,0,.18); color: #f2ce5b; }
.pill.bad { background: rgba(214,69,69,.2); color: #ff9b9b; }

/* ---------- Map ---------- */
#map { height: 62vh; min-height: 420px; border-radius: 12px; border: 1px solid var(--line); }
.map-wrap { position: relative; }
.legend { position: absolute; z-index: 500; right: 12px; top: 12px; background: rgba(11,37,69,.9);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.legend div { margin: 3px 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

/* Live unit marker: bright status dot + high-contrast name chip */
.unit-icon { background: none; border: none; }
.unit-marker { display: flex; align-items: center; gap: 5px; white-space: nowrap;
  transform: translate(-9px, -9px); }
.unit-dot { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.6); flex: 0 0 auto; }
.unit-name { background: rgba(8,20,38,.92); color: #fff; border: 2px solid var(--gold);
  border-radius: 7px; padding: 3px 8px; font-size: 12px; font-weight: 800;
  letter-spacing: .2px; text-shadow: 0 1px 2px rgba(0,0,0,.8);
  box-shadow: 0 2px 8px rgba(0,0,0,.55); }

.alert-bar { background: rgba(214,69,69,.15); border: 1px solid var(--bad); color: #ffb3b3;
  border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; display: none; }
.alert-bar.show { display: block; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.muted { color: var(--muted); }
.right { text-align: right; }
.hidden { display: none; }
.code-box { font-size: 34px; letter-spacing: 8px; font-weight: 800; color: var(--gold-2); text-align: center; padding: 10px; }
dialog { background: var(--navy-2); color: var(--text); border: 1px solid var(--gold); border-radius: 12px; padding: 20px; width: 380px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog label { display:block; font-size:12px; color:var(--muted); margin:10px 0 4px; }
dialog input, dialog select { width: 100%; }
.dialog-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:18px; }
