/* VHF page styling. Map layers and application logic stay in index.html. */
:root {
  --surface: #fff;
  --surface-soft: #f8fafb;
  --ink: #172d39;
  --muted: #71858e;
  --line: #e2e9ec;
  --accent: #087e85;
  --accent-soft: #e7f5f3;
  --shadow: 0 12px 36px rgba(20, 46, 58, .10);
}

body {
  font-family: "Noto Sans Thai", system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface-soft);
}

button, input, select, textarea { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(8, 126, 133, .35);
  outline-offset: 2px;
}

/* Calm, compact navigation above the existing full-screen map. */
.map-header {
  min-height: 64px;
  justify-content: flex-start;
  padding: max(10px, env(safe-area-inset-top)) 216px 10px max(22px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 4px 20px rgba(20, 46, 58, .06);
  backdrop-filter: blur(18px);
}
.map-title { gap: 11px; color: var(--ink); }
.map-title__icon {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: var(--accent-soft);
  box-shadow: none;
}
.map-title__icon img { width: 31px; height: 31px; }
.map-title__copy { display: grid; gap: 1px; line-height: 1.15; }
.map-title__eyebrow {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .17em;
}
.map-title__name { color: var(--ink); font-size: 18px; font-weight: 750; letter-spacing: -.025em; }

.edit-lock-button, .clear-cache-button, .add-location-button, .map-close-button {
  appearance: none;
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 1px);
  left: auto;
  z-index: 1400;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
  cursor: pointer;
  pointer-events: auto;
}
.map-close-button { right: 22px; }
.edit-lock-button { right: 72px; }
.clear-cache-button { right: 122px; }
.add-location-button { right: 172px; }
.map-close-button svg { width: 19px; height: 19px; }
.edit-lock-button:hover, .clear-cache-button:hover, .add-location-button:hover, .map-close-button:hover {
  border-color: #afd2d1;
  background: var(--accent-soft);
  color: var(--accent);
}
.edit-lock-button.is-unlocked, .add-location-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

/* One quiet toolbar at the bottom; more advanced controls open from it. */
.mobile-float-actions {
  position: fixed;
  right: 50%;
  bottom: max(17px, env(safe-area-inset-bottom));
  width: 272px;
  height: 52px;
  transform: translateX(50%);
  z-index: 1150;
}
.mobile-float-actions::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(216, 229, 231, .9);
  border-radius: 18px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 16px 42px rgba(16, 49, 57, .16);
  backdrop-filter: blur(18px);
}
.mobile-float-button,
.mobile-float-actions #mobileMenuButton,
.mobile-float-actions #mobileLayerButton,
.mobile-float-actions #mobileRadioTableButton,
.mobile-float-actions #mobileCarButton,
.mobile-float-actions #mobileRestoreButton {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 13px;
  box-shadow: none;
  background: transparent;
  color: #45636d;
}
.mobile-float-actions #mobileMenuButton,
.mobile-float-actions #mobileLayerButton,
.mobile-float-actions #mobileRadioTableButton,
.mobile-float-actions #mobileCarButton,
.mobile-float-actions #mobileRestoreButton {
  position: absolute;
  bottom: 4px;
  transform: none;
}
.mobile-float-actions #mobileMenuButton { right: 4px; }
.mobile-float-actions #mobileLayerButton { right: 58px; }
.mobile-float-actions #mobileRadioTableButton { right: 112px; z-index: 1150; opacity: 1; pointer-events: auto; }
.mobile-float-actions #mobileCarButton { right: 166px; }
.mobile-float-actions #mobileRestoreButton { right: 220px; }
.mobile-float-actions #mobilePrincipleFilterButton {
  position: absolute;
  right: 58px;
  bottom: 62px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.mobile-float-button:hover, .mobile-float-actions #mobileLayerButton:hover,
.mobile-float-actions #mobileRadioTableButton:hover,
.mobile-float-actions #mobileCarButton:hover, .mobile-float-actions #mobileRestoreButton:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.mobile-float-actions.is-open .mobile-float-button:not(:where(#mobileMenuButton, #mobileLayerButton, #mobileRadioTableButton, #mobileCarButton, #mobileRestoreButton)):not(.is-active):not(:active) {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.mobile-float-actions :is(#mobileMenuButton, #mobileLayerButton, #mobileRadioTableButton, #mobileCarButton, #mobileRestoreButton, #mobileBaseButton, #mobileLocButton, #mobileNetworkButton, #mobilePrincipleButton, #mobileSearchButton, #mobilePrincipleFilterButton):is(.is-active, :active) {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.mobile-float-actions .mobile-float-button:is(.is-active, :active) .menu-icon {
  filter: brightness(0) invert(1);
}
.mobile-float-actions.is-open #mobileBaseButton { transform: translateY(-282px) scale(1); }
.mobile-float-actions.is-open #mobileLocButton { transform: translateY(-226px) scale(1); }
.mobile-float-actions.is-open #mobileNetworkButton { transform: translateY(-114px) scale(1); }
.mobile-float-actions.is-open #mobilePrincipleButton { transform: translateY(-170px) scale(1); }
.mobile-float-actions.is-open .mobile-float-button.mobile-search-button { transform: translateY(-58px) scale(1); }

.map-legend {
  top: calc(max(10px, env(safe-area-inset-top)) + 66px);
  right: auto;
  bottom: auto;
  left: 50%;
  flex-direction: row;
  gap: 10px;
  min-width: 0;
  width: max-content;
  max-width: calc(100vw - 24px);
  height: auto;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 8px 26px rgba(20, 46, 58, .10);
  color: #516a74;
  font-size: 11px;
  font-weight: 700;
  transform: translateX(-50%);
}
.map-legend__item { gap: 5px; }
.map-legend__label {
  min-width: 35px;
  padding: 3px 5px;
  border: 0;
  border-radius: 5px;
  box-shadow: none;
  font-size: 10px;
  text-shadow: none;
}
.map-legend__label--base { background: #ad711e; color: #fff; }

.map-toolbar, .layer-menu, .network-menu, .principle-distance-control {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, .98);
  color: var(--ink);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.map-toolbar {
  right: calc(50% - 136px);
  bottom: calc(max(17px, env(safe-area-inset-bottom)) + 64px);
  width: min(270px, calc(100vw - 32px));
  max-width: min(270px, calc(100vw - 32px));
  padding: 14px;
}
.layer-menu, .network-menu, .principle-distance-control {
  right: calc(50% - 136px);
  bottom: calc(max(17px, env(safe-area-inset-bottom)) + 64px);
}
.map-search, .distance-tool {
  border: 0;
  border-radius: 11px;
  background: var(--surface-soft);
  box-shadow: none;
  color: var(--muted);
}
.map-search select, .distance-tool select, .network-menu__select {
  border-color: var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
}
.layer-menu__button, .network-menu__button {
  border-color: var(--line);
  border-radius: 9px;
}
.layer-menu__button.is-active, .network-menu__button.is-active,
.principle-distance-control__auto { border-color: var(--accent); background: var(--accent); }

.leaflet-popup-content-wrapper {
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(20, 46, 58, .18);
}
.station-popup { color: var(--ink); }
.station-popup__section { border-color: var(--line); }
.station-popup__pss-toggle {
  border-color: var(--line);
  background: #f8faf9;
  color: #45636d;
}
.station-popup__pss-toggle:hover:not(.is-active) {
  border-color: #afd2d1;
  background: var(--accent-soft);
  color: var(--accent);
}
.station-popup__pss-toggle.is-active,
.station-popup__pss-toggle.is-active:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* Car inventory uses the same restrained surfaces. */
.car-page { background: #f6f9f9; color: var(--ink); }
.car-page__header {
  min-height: 66px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 3px 18px rgba(20, 46, 58, .04);
}
.car-page__title { font-size: 17px; font-weight: 750; }
.car-page__search, .car-card, .car-stage, .car-detail__panel {
  border-color: var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 7px 25px rgba(20, 46, 58, .055);
}

/* Read-only inventory for the radios shown at map stations. */
.radio-page {
  position: fixed;
  inset: 0;
  z-index: 1210;
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: var(--ink);
  background: #f5f8f8;
}
.radio-page[hidden], .radio-page__empty[hidden] { display: none; }
.radio-page__header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  padding: max(12px, env(safe-area-inset-top)) 24px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.radio-page__heading { min-width: 0; flex: 1; }
.radio-page__eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.radio-page__heading h1 { margin: 3px 0 0; font-size: 20px; line-height: 1.2; }
.radio-page__count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.radio-page__refresh, .radio-page__close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 23px;
  cursor: pointer;
}
.radio-page__refresh:disabled { opacity: .45; cursor: wait; }
.radio-page__refresh:hover, .radio-page__close:hover { border-color: var(--accent); color: var(--accent); }
.radio-page__filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
}
.radio-page__tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px; }
.radio-page__tabs button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: #59727a;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.radio-page__tabs button.is-active { border-color: var(--accent); background: var(--accent); color: #fff; }
.radio-page__search {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(370px, 100%);
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  box-sizing: border-box;
}
.radio-page__search svg { width: 17px; height: 17px; flex: 0 0 auto; }
.radio-page__search input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.radio-page__table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 24px 24px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.radio-page__table { width: 100%; min-width: 920px; border-collapse: collapse; text-align: center; }
.radio-page__table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
  background: #f7faf9;
  color: #627982;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}
.radio-page__table td {
  padding: 14px 15px;
  border-bottom: 1px solid #edf1f2;
  color: #405863;
  font-size: 13px;
  text-align: center;
  vertical-align: middle;
}
.radio-page__table tr:last-child td { border-bottom: 0; }
.radio-page__table tbody tr:hover { background: #f9fcfb; }
.radio-page__table td strong { display: block; color: var(--ink); font-size: 14px; }
.radio-page__station-name { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.radio-page__type { display: inline-block; padding: 5px 9px; border-radius: 7px; background: #e7f5f3; color: #087e85; font-weight: 700; }
.radio-page__type--cross { background: #edf0fa; color: #5962a2; }
.radio-page__type--handheld { background: #fff1df; color: #9c691e; }
.radio-page__map-link { padding: 7px 10px; border: 1px solid #b9dad7; border-radius: 8px; background: #f1faf8; color: #087e85; font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.radio-page__map-link:hover { background: var(--accent); color: white; }
.radio-page__empty { padding: 50px 18px; color: var(--muted); text-align: center; }

.welcome-screen {
  background: #f8faf9;
  color: var(--ink);
}
.welcome-screen::before, .welcome-screen::after { display: none; }
.welcome-card {
  gap: 12px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.welcome-card::before, .welcome-card__icon::after { display: none; }
.welcome-card__icon {
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 16px;
  background: var(--accent-soft);
  box-shadow: none;
}
.welcome-card__icon img { width: 54px; height: 54px; }
.welcome-card__chips { display: none; }
.welcome-card__title { color: var(--ink); font-size: 25px; }
.welcome-card__subtitle, .welcome-card__status { color: var(--muted); font-weight: 500; }
.welcome-card__bar { height: 5px; background: var(--line); box-shadow: none; }
.welcome-card__bar::after { background: var(--accent); box-shadow: none; }

@media (max-width: 720px) {
  .map-header {
    min-height: 58px;
    padding: max(7px, env(safe-area-inset-top)) 180px 7px max(12px, env(safe-area-inset-left));
  }
  .map-title__icon { width: 34px; height: 34px; }
  .map-title__icon img { width: 29px; height: 29px; }
  .map-title__name { font-size: 16px; }
  .map-title__eyebrow { font-size: 8px; }
  .edit-lock-button, .clear-cache-button, .add-location-button, .map-close-button {
    top: calc(max(7px, env(safe-area-inset-top)) + 2px);
    left: auto;
    width: 38px;
    height: 38px;
  }
  .map-close-button { right: 10px; }
  .edit-lock-button { right: 53px; }
  .clear-cache-button { right: 96px; }
  .add-location-button { right: 139px; }
  .edit-lock-button svg, .edit-lock-button img,
  .clear-cache-button svg, .clear-cache-button img,
  .add-location-button svg, .add-location-button img { width: 19px; height: 19px; }
  .map-legend {
    top: calc(max(7px, env(safe-area-inset-top)) + 62px);
    right: auto;
    bottom: auto;
    left: 50%;
    width: max-content;
    max-width: calc(100vw - 24px);
    height: auto;
    flex-wrap: nowrap;
    padding: 7px 9px;
    transform: translateX(-50%);
  }
  .mobile-float-actions { right: 50%; bottom: max(12px, env(safe-area-inset-bottom)); }
  .map-toolbar, .layer-menu, .network-menu, .principle-distance-control {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 62px);
    max-height: min(63vh, 460px);
    overflow-y: auto;
  }
  .map-toolbar { width: min(270px, calc(100vw - 24px)); max-width: min(270px, calc(100vw - 24px)); }
  .map-search select, .distance-tool select, .network-menu__select,
  .car-page input, .edit-form__input, .edit-form__textarea { font-size: 16px; }
  .radio-page__header { min-height: 58px; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 14px 8px; }
  .radio-page__heading h1 { font-size: 17px; }
  .radio-page__eyebrow { font-size: 9px; }
  .radio-page__count { font-size: 11px; }
  .radio-page__refresh, .radio-page__close { width: 36px; height: 36px; }
  .radio-page__filters { display: grid; gap: 10px; padding: 12px; }
  .radio-page__tabs { width: 100%; }
  .radio-page__tabs button { min-height: 36px; padding: 0 12px; }
  .radio-page__search { width: 100%; }
  .radio-page__search input { font-size: 16px; }
  .radio-page__table-wrap { margin: 0 12px 12px; padding: 0; border: 0; background: transparent; }
  .radio-page__table { min-width: 0; display: block; }
  .radio-page__table thead { display: none; }
  .radio-page__table tbody { display: grid; gap: 10px; }
  .radio-page__table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
  .radio-page__table td { display: grid; justify-items: center; gap: 4px; min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
  .radio-page__table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; }
  .radio-page__table td:first-child { grid-column: 1 / -1; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .radio-page__table td:first-child::before { display: none; }
  .radio-page__table td:last-child { grid-column: 1 / -1; }
  .radio-page__map-link { width: max-content; min-height: 34px; justify-self: center; }
}

@media (max-width: 390px) {
  .map-title__eyebrow { display: none; }
  .map-title__icon { width: 31px; height: 31px; }
  .map-header { padding-right: 160px; }
  .map-title__name { font-size: 15px; }
  .edit-lock-button, .clear-cache-button, .add-location-button, .map-close-button { width: 34px; height: 34px; }
  .map-close-button { right: 7px; }
  .edit-lock-button { right: 45px; }
  .clear-cache-button { right: 83px; }
  .add-location-button { right: 121px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .map-header { min-height: 46px; }
  .map-toolbar, .layer-menu, .network-menu, .principle-distance-control { max-height: 64vh; }
}
