:root {
  --army-gold: #FFCC01;
  --black: #000000;
  --blue: #0000FF;
  --navy: #1b2a41;
  --navy-deep: #12203a;
  --gold: #c9a227;
  --gold-soft: #e8d48b;
  --paper: #f7f6f2;
  --ink: #22252a;
  --muted: #6b7280;
  --line: #e2e0d8;
  --good: #2e7d32;
  --warn: #b4530a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Public Sans", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--black);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header mirrors the layout below it: the brand sits centered over the
   card column, the tagline centered over the map. */
.topbar {
  background: var(--black);
  color: #fff;
  padding: 0.4rem 1rem 0.3rem 0; /* no left pad: zones align to panel/map */
  display: flex;
  align-items: center;
  flex: none;
}

.brand-zone {
  width: 380px;
  flex: none;
  display: flex;
  justify-content: center;
}

.tagline-zone {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.brand { display: flex; align-items: center; gap: 0.7rem; }

.brand-logo { height: 52px; display: block; }

.brand-name { font-weight: 800; font-size: 1.9rem; letter-spacing: 0.02em; }

.brand-gold { color: var(--army-gold); }

.tagline { color: #b9c2d0; font-size: 1rem; letter-spacing: 0.01em; }

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.panel {
  width: 380px;
  flex: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--black);
  /* Thin, dark scrollbar so it recedes into the background instead of
     forming a bright slab between the cards and the map. */
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}

.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-button { display: none; height: 0; }
.panel::-webkit-scrollbar-corner { background: transparent; }

.panel::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 4px;
}

.panel::-webkit-scrollbar-thumb:hover { background: #4f4f4f; }

/* The map is a card too: same corners, border, and shadow, floating on the
   dark background with a margin buffer. */
#map {
  flex: 1;
  min-width: 0;
  margin: 1rem 1rem 1rem 0.25rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(18, 32, 58, 0.06);
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(18, 32, 58, 0.06);
}

.card h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  color: var(--navy);
  letter-spacing: 0.01em;
}

.hint { margin: 0 0 0.8rem; font-size: 0.8rem; color: var(--muted); }

label { display: block; font-size: 0.8rem; font-weight: 600; margin: 0.7rem 0 0.25rem; }

input[type="text"], input[inputmode], select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

input:focus, select:focus { outline: 2px solid var(--army-gold); border-color: var(--army-gold); }

.autocomplete { position: relative; }

.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 14px rgba(18, 32, 58, 0.12);
  max-height: 14rem;
  overflow-y: auto;
}

.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.6rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.suggest button:hover, .suggest button.hi { background: var(--paper); }

.badge {
  float: right;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--navy-deep);
  background: var(--gold-soft);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  margin-top: 0.1rem;
}

.iso-row { margin-top: 0.5rem; }
.iso-row label { margin-bottom: 0.1rem; }
.mode-btn.wide { width: 100%; margin-top: 0.4rem; }
#fairzone-status { margin: 0.35rem 0 0; }

.commute-result { text-align: center; margin-top: 0.3rem; }
.commute-main { font-size: 1.35rem; font-weight: 800; color: var(--navy); }
.commute-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.commute-traffic { font-size: 0.85rem; font-weight: 600; color: var(--warn); margin-top: 0.35rem; }

.basemap-toggle {
  width: auto !important;
  padding: 0 9px !important;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
}

.mha-line { margin-top: 0.35rem; font-size: 0.85rem; color: var(--navy); font-weight: 600; }
.mha-code { color: var(--muted); font-weight: 400; }

.dep-row { display: flex; gap: 1rem; margin-top: 0.7rem; }
.radio { font-weight: 400; font-size: 0.9rem; display: flex; align-items: center; gap: 0.3rem; margin: 0; }

.bah-result { text-align: center; margin-top: 1rem; padding-top: 0.8rem; border-top: 1px dashed var(--line); }
.bah-amount { font-size: 2.1rem; font-weight: 800; color: var(--navy); }
.bah-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.mode-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }

.mode-btn {
  flex: 1;
  padding: 0.4rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.mode-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  font-weight: 600;
}

input[type="range"] { width: 100%; accent-color: var(--army-gold); }

.slider-scale {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.slider-value {
  text-align: center;
  font-weight: 700;
  color: var(--navy);
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
}

.range-edit {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0;
}

.range-edit input {
  width: 4.2rem;
  padding: 0.2rem 0.3rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.budget-result { text-align: center; margin-top: 0.9rem; }
.budget-amount { font-size: 1.9rem; font-weight: 800; color: var(--navy); }
.budget-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.budget-delta { margin-top: 0.4rem; font-size: 0.85rem; font-weight: 600; }
.budget-delta.keep { color: var(--good); }
.budget-delta.pay { color: var(--warn); }

.anchor-note {
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.bb-row { display: flex; gap: 0.75rem; margin-bottom: 0.9rem; }
.bb-field { flex: 1; }
.bb-field label { margin-top: 0; }

.school-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.85rem;
}

.school-row:last-child { border-bottom: none; }
.school-row a { color: var(--navy); font-weight: 600; text-decoration: none; }
.school-row a:hover { text-decoration: underline; }
.school-meta { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

.lv-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.35rem;
}

.lv-E { background: #2e7d32; }
.lv-M { background: #b4530a; }
.lv-H { background: #6d28d9; }
.lv-C { background: #607d8b; }

.link-row { display: flex; flex-direction: column; gap: 0.5rem; }

.listing-link {
  display: block;
  text-align: center;
  padding: 0.55rem;
  border: 1px solid var(--navy);
  border-radius: 6px;
  color: var(--navy);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}

.listing-link:hover { background: var(--navy); color: #fff; }

.about-card { position: relative; }
.about-logo { display: block; width: 56px; margin: 0 auto 0.4rem; }
.about-card p { margin: 0 0 0.5rem; font-size: 0.85rem; }

.about-close {
  display: none;
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.about-close:hover { color: var(--navy); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.65);
  transition: opacity 0.25s ease;
}

.modal-backdrop.fading { opacity: 0; }

/* First-visit welcome state: the about card floats centered over the page,
   then settles back into its normal panel slot on dismiss. */
.about-card.modalized {
  position: fixed;
  z-index: 50;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.about-card.modalized .about-close { display: block; }

.about-card.modalized.closing {
  transform: translate(-50%, 30%) scale(0.5);
  opacity: 0;
}

.about-card ol {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.panel-footer { font-size: 0.7rem; color: var(--muted); padding: 0 0.25rem; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  #map {
    order: 1;
    flex: none;
    height: 42vh;
    height: 42dvh;
    min-height: 250px;
    margin: 0.75rem 0.75rem 0;
  }
  .panel {
    order: 2;
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 0.75rem;
  }
  .topbar { padding: 0.5rem 0.85rem; justify-content: center; }
  .brand-zone { width: auto; }
  .tagline-zone { display: none; }
  .brand-logo { height: 40px; }
  .brand-name { font-size: 1.45rem; }
  .bah-amount { font-size: 1.8rem; }
  .suggest button { padding: 0.65rem 0.6rem; }
  .mode-btn, .listing-link { padding: 0.65rem 0.5rem; }
}
