:root {
  --navy: #0A1F44;
  --teal: #00B7C3;
  --ink: #1A2233;
  --gray: #E5E7EB;
  --white: #FFFFFF;
  --bluegray: #8A94A6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Montserrat, Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--white);
  display: flex; flex-direction: column;
  min-width: 320px;
}

/* ---------- top bar ---------- */
.topbar {
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
img.lockup { height: 34px; width: 34px; display: block; }
.brand-name { color: var(--white); font-weight: 700; font-size: 17px; letter-spacing: 1px; white-space: nowrap; }
.score-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.score-tabs button, .dim-tabs button {
  font-family: inherit; font-size: 12px; font-weight: 600;
  background: transparent; color: var(--gray);
  border: 1px solid rgba(255,255,255,.25); border-radius: 4px;
  padding: 6px 10px; cursor: pointer;
}
.score-tabs button.active { background: var(--teal); color: var(--navy); border-color: var(--teal); }
.search-wrap { margin-left: auto; }
#search {
  font-family: inherit; font-size: 13px; padding: 7px 10px;
  border: none; border-radius: 4px; width: 220px; max-width: 50vw;
}

/* ---------- dimension sub-bar ---------- */
.subbar {
  background: var(--ink); color: var(--gray);
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; flex-wrap: wrap;
}
.subbar.hidden { display: none; }
.subbar-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.dim-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.dim-tabs button { font-size: 11px; padding: 4px 8px; }
.dim-tabs button.active { background: var(--gray); color: var(--navy); border-color: var(--gray); }

/* ---------- map ---------- */
#mapwrap { position: relative; flex: 1; min-height: 420px; }
#map { position: absolute; inset: 0; background: #f6f7f9; }

.layer-toggles {
  position: absolute; top: 10px; left: 10px; z-index: 5;
  background: var(--white); border: 1px solid var(--gray); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 1px 4px rgba(10,31,68,.12);
}
.layer-toggles label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.legend {
  position: absolute; bottom: 26px; left: 10px; z-index: 5;
  background: var(--white); border: 1px solid var(--gray); border-radius: 6px;
  padding: 8px 10px; font-size: 11px; box-shadow: 0 1px 4px rgba(10,31,68,.12);
}
.legend .lg-title { font-weight: 700; margin-bottom: 5px; }
.legend .lg-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.legend .swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.08); }

.inset {
  position: absolute; bottom: 26px; z-index: 5;
  width: 180px; height: 120px;
  background: #f6f7f9; border: 1px solid var(--gray); border-radius: 6px;
  overflow: hidden; box-shadow: 0 1px 4px rgba(10,31,68,.12);
}
#insetAK { right: 56px; }
#insetHI { right: 246px; width: 210px; }
.inset-label {
  position: absolute; top: 3px; left: 6px; z-index: 2;
  font-size: 10px; font-weight: 700; color: var(--bluegray); letter-spacing: 1px;
  pointer-events: none;
}
@media (max-width: 640px) {
  .inset { width: 120px; height: 84px; }
  #insetAK { right: 50px; }
  #insetHI { right: 180px; width: 140px; }
}

/* ---------- hover / click card ---------- */
.card {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  width: 330px; max-width: calc(100vw - 20px);
  max-height: calc(100% - 40px); overflow-y: auto;
  background: var(--white); border: 1px solid var(--gray); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(10,31,68,.18);
  padding: 14px;
  font-size: 12px;
}
.card.hidden { display: none; }
.card-close {
  position: absolute; top: 6px; right: 8px; border: none; background: none;
  font-size: 18px; cursor: pointer; color: var(--bluegray);
}
.card h3 { font-size: 15px; margin-bottom: 2px; color: var(--navy); }
.card .mode-banner {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 7px; border-radius: 3px; margin: 4px 0 8px;
}
.mode-OBSERVED { background: var(--navy); color: var(--white); }
.morat-chip {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 1px;
  background: #D7263D; color: #fff; padding: 2px 7px; border-radius: 3px;
  margin: 4px 0 8px 6px; vertical-align: top;
}
.morat-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #D7263D; border: 1px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15);
  margin-right: 2px;
}
.morat-dot.pending { background: #F06292; }
.morat-chip.pending { background: #F06292; }
.mode-MODELED { background: var(--gray); color: var(--ink); }
.policy-badge {
  background: #eef9fa; border: 1px solid var(--teal); color: var(--navy);
  border-radius: 5px; padding: 6px 8px; font-size: 11px; margin: 6px 0;
}
.score-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.score-cell { background: #f6f8fa; border-radius: 5px; padding: 6px 4px; text-align: center; }
.score-cell .sc-val { font-size: 16px; font-weight: 700; color: var(--navy); }
.score-cell .sc-band { font-size: 9px; color: var(--bluegray); }
.score-cell .sc-name { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.conf-chip {
  display: inline-block; font-size: 9px; font-weight: 700; border-radius: 3px;
  padding: 0 4px; margin-left: 3px; vertical-align: middle;
}
.conf-A { background: var(--navy); color: #fff; }
.conf-B { background: var(--teal); color: var(--navy); }
.conf-C { background: var(--gray); color: var(--ink); }
.dim-bars { margin: 8px 0; }
.dim-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.dim-row .dm-name { width: 74px; font-size: 10px; }
.dim-row .dm-bar { flex: 1; height: 7px; background: var(--gray); border-radius: 4px; overflow: hidden; }
.dim-row .dm-fill { height: 100%; background: linear-gradient(90deg, #00B7C3, #1E90FF, #0A1F44); }
.card h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--bluegray); margin: 10px 0 4px; }
.ev, .fac { border-top: 1px solid var(--gray); padding: 6px 0; }
.ev .ev-date { color: var(--bluegray); font-size: 10px; }
.ev .ev-status-rescinded { color: #8a6d00; font-weight: 600; }
.ev a, .fac a { color: var(--teal); text-decoration: none; font-size: 11px; }
.card .updated { color: var(--bluegray); font-size: 10px; margin-top: 8px; }

/* ---------- footer ---------- */
.footer {
  background: var(--navy); color: var(--gray);
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; font-size: 11px;
}
.footer a { color: var(--teal); text-decoration: none; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,31,68,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-inner {
  background: var(--white); border-radius: 10px; max-width: 760px; width: 100%;
  max-height: 85vh; overflow-y: auto; padding: 26px; position: relative; font-size: 13px;
}
.modal-inner h2 { color: var(--navy); margin-bottom: 10px; }
.modal-inner h3 { color: var(--navy); font-size: 14px; margin: 16px 0 6px; }
.modal-inner p { margin: 6px 0; line-height: 1.55; }
.modal-close {
  position: absolute; top: 10px; right: 14px; border: none; background: none;
  font-size: 22px; cursor: pointer; color: var(--bluegray);
}
.disclaimer { font-size: 11px; color: var(--bluegray); }

@media (max-width: 640px) {
  .search-wrap { margin-left: 0; width: 100%; }
  #search { width: 100%; max-width: none; }
  .card { width: calc(100vw - 20px); top: auto; bottom: 26px; max-height: 55%; }
}
