:root {
  --header-height: 52px;
  --header-bg: #0e1724;
  --header-border: rgba(140, 190, 255, 0.22);
  --header-text: #e8f1ff;
  --header-muted: #9db0c7;
  --accent: #7ec8ff;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: #0b1220;
  color: var(--header-text);
}

.top_header_bar {
  box-sizing: border-box;
  height: var(--header-height);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
}

.header_title_block {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.header_title_block h1 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.header_subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--header-muted);
  white-space: nowrap;
}

.header_metrics_block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
  font-size: 0.82rem;
  color: var(--header-muted);
}

.header_metrics_block strong {
  color: var(--header-text);
}

.header_actions_block {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header_toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  white-space: nowrap;
}

#manual_refresh_button,
#access_logs_button,
#access_logs_close_button,
.language_switcher button {
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #082033;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

#access_logs_button,
.language_switcher button {
  background: #1d334d;
  color: var(--header-text);
}

.language_switcher {
  display: flex;
  gap: 4px;
}

.language_switcher button.is_language_active {
  background: var(--accent);
  color: #082033;
}

.session_email_label {
  font-size: 0.75rem;
  color: var(--header-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign_out_link {
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: none;
  white-space: nowrap;
}

.sign_out_link:hover {
  text-decoration: underline;
}

.access_logs_modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 10, 18, 0.72);
  padding: 16px;
}

.access_logs_modal[hidden] {
  display: none;
}

.access_logs_dialog {
  width: min(960px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #101a28;
  border: 1px solid var(--header-border);
  border-radius: 10px;
  padding: 14px 16px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.access_logs_dialog_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.access_logs_dialog_header h2 {
  margin: 0;
  font-size: 1rem;
}

.access_logs_date_label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: var(--header-muted);
}

#access_logs_date_select {
  background: #0b1220;
  color: var(--header-text);
  border: 1px solid var(--header-border);
  border-radius: 6px;
  padding: 4px 8px;
}

#access_logs_text_block {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  padding: 10px;
  background: #071018;
  border-radius: 6px;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  color: #d5e6f8;
}

.login_page_body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login_card {
  width: min(420px, 100%);
  background: #101a28;
  border: 1px solid var(--header-border);
  border-radius: 12px;
  padding: 28px 24px;
}

.login_card h1 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.login_card_subtitle {
  margin: 0 0 8px;
  color: var(--header-muted);
  font-size: 0.92rem;
}

.login_error_label {
  margin: 12px 0;
  color: #ff8a8a;
  font-size: 0.86rem;
}

.login_google_button {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #082033;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

#leaflet_map_canvas {
  width: 100%;
  height: calc(100vh - var(--header-height));
}

.marker_popup {
  min-width: 220px;
}

.marker_popup h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.marker_popup dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  font-size: 0.82rem;
}

.marker_popup dt {
  color: #667;
}

.aircraft_icon,
.vessel_icon,
.airport_icon,
.seaport_icon,
.webcam_icon {
  font-size: 16px;
  line-height: 22px;
  text-align: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.airport_icon,
.seaport_icon,
.webcam_icon {
  font-size: 14px;
  line-height: 20px;
}

.webcam_popup {
  min-width: 300px;
}

.webcam_player_frame {
  display: block;
  width: 100%;
  height: 240px;
  margin-top: 8px;
  border: 0;
  background: #111;
  border-radius: 4px;
  object-fit: cover;
}

.webcam_player_fallback {
  margin: 8px 0 0;
  font-size: 0.78rem;
}

.leaflet-overlay-pane .leaflet-interactive {
  cursor: pointer;
}

.leaflet-control-layers {
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.layer_drawer_toggle,
.layer_drawer_backdrop,
.layer_drawer_panel {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --header-height: 96px;
  }

  .top_header_bar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-height);
    padding: 8px 10px;
    gap: 8px;
  }

  .header_title_block h1 {
    font-size: 0.88rem;
  }

  .header_subtitle {
    display: none;
  }

  .header_metrics_block,
  .header_actions_block {
    gap: 8px;
    font-size: 0.75rem;
  }

  .session_email_label {
    display: none;
  }

  #manual_refresh_button,
  #access_logs_button,
  .language_switcher button {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  #leaflet_map_canvas {
    height: calc(100vh - 96px);
  }

  .leaflet-control-layers {
    display: none !important;
  }

  .leaflet-control-zoom a {
    width: 36px;
    height: 36px;
    line-height: 36px;
    font-size: 18px;
  }

  .leaflet-popup-close-button {
    width: 32px;
    height: 32px;
    font-size: 22px;
    line-height: 32px;
  }

  .leaflet-popup-content-wrapper {
    border-radius: 10px;
  }

  .leaflet-popup-content {
    margin: 10px 12px;
    min-width: 0;
  }

  .marker_popup {
    min-width: 0;
    max-width: 72vw;
  }

  .marker_popup h2 {
    font-size: 0.88rem;
  }

  .marker_popup dl {
    font-size: 0.74rem;
  }

  .webcam_popup {
    min-width: 0;
  }

  .webcam_player_frame {
    height: 160px;
  }

  .layer_drawer_toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: fixed;
    right: 14px;
    bottom: 18px;
    z-index: 1200;
    min-width: 48px;
    min-height: 48px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: #101a28;
    color: var(--header-text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-weight: 650;
    font-size: 0.82rem;
    cursor: pointer;
  }

  .layer_drawer_backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(4, 10, 18, 0.55);
  }

  .layer_drawer_backdrop[hidden] {
    display: none;
  }

  .layer_drawer_panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1400;
    max-height: 72vh;
    background: #101a28;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.4);
    transform: translateY(0);
    transition: transform 0.22s ease;
  }

  .layer_drawer_panel[hidden] {
    display: none;
  }

  .layer_drawer_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
  }

  .layer_drawer_header h2 {
    margin: 0;
    font-size: 1rem;
  }

  #layer_drawer_close_button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: #1d334d;
    color: var(--header-text);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
  }

  .layer_drawer_list {
    overflow-y: auto;
    padding: 4px 12px 20px;
  }

  .layer_drawer_option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 8px 8px;
    font-size: 0.92rem;
  }

  .layer_drawer_option input {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 960px) and (min-width: 769px) {
  :root {
    --header-height: 86px;
  }

  .top_header_bar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-height);
    padding: 8px 12px;
  }

  .header_subtitle {
    display: none;
  }

  #leaflet_map_canvas {
    height: calc(100vh - 86px);
  }
}
