html, body.map-page { height: 100%; overflow: hidden; }
.map-page { display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 8px 14px;
  background: var(--navy-900); color: #fff; z-index: 1100; position: relative;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-family: var(--font-cond); font-size: 20px; font-weight: 600; letter-spacing: .5px; white-space: nowrap; }
.brand img { border-radius: 8px; }
.brand b { color: var(--amber); font-weight: 700; }
.modes { display: flex; background: rgba(255,255,255,.08); border-radius: 10px; padding: 3px; }
.modes button {
  border: 0; background: none; color: #c8d4ee; padding: 7px 14px; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.modes button[aria-selected="true"] { background: #fff; color: var(--navy-900); }
.search { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search input {
  width: 100%; padding: 8px 12px 8px 34px; border-radius: 9px; border: 0;
  background: rgba(255,255,255,.12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23c8d4ee' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") 11px 50% no-repeat;
  color: #fff;
}
.search input::placeholder { color: #9fb0d3; }
.search input:focus { outline: 2px solid var(--sky); background-color: rgba(255,255,255,.18); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: #fff; color: var(--ink); border-radius: 10px; box-shadow: var(--shadow); max-height: 360px; overflow: auto;
}
.search-results li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--sky-soft); }
.search-results .code { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--navy-700); min-width: 44px; }
.search-results .kind { margin-left: auto; font-size: 12px; color: var(--ink-2); }
.btn-app { background: var(--amber); border-color: var(--amber); color: var(--navy-950); }
.btn-app:hover { background: #ffc233; border-color: #ffc233; }

/* ---------- layout ---------- */
.workspace { flex: 1; display: flex; min-height: 0; position: relative; }
.panel {
  width: 380px; flex: none; background: var(--card); border-right: 1px solid var(--line);
  overflow-y: auto; z-index: 1000; position: relative;
}
.panel-handle { display: none; }
.pane { padding: 16px; }
.pane-head { display: flex; align-items: center; justify-content: space-between; }
.pane h2 { font-family: var(--font-cond); font-size: 22px; margin: 0; letter-spacing: .3px; }
.pane h3 { font-family: var(--font-cond); font-size: 16px; margin: 18px 0 6px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--ink-2); line-height: 1.45; margin: 8px 0 12px; }
.tools { display: flex; gap: 4px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--bg); }

.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #dfe6ef; }

/* ---------- waypoint list ---------- */
.wp-list { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: wp; }
.wp-list li {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 4px; border-radius: 8px;
  counter-increment: wp; border: 1px solid transparent;
}
.wp-list li:hover { background: var(--bg); }
.wp-list li::before {
  content: counter(wp); width: 22px; height: 22px; flex: none; border-radius: 50%;
  background: var(--route); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.wp-list li:first-child::before { content: 'A'; background: var(--green); }
.wp-list li:last-child:not(:first-child)::before { content: 'B'; background: var(--red); }
.wp-name { flex: 1; min-width: 0; }
.wp-name input { width: 100%; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; font-weight: 600; background: transparent; }
.wp-name input:focus { border-color: var(--sky); background: #fff; outline: none; }
.wp-name small { display: block; padding: 0 7px; color: var(--ink-2); font-family: var(--mono); font-size: 11px; }
.wp-list .row-btns { display: flex; gap: 2px; opacity: .55; }
.wp-list li:hover .row-btns { opacity: 1; }
.wp-list .row-btns button { border: 0; background: none; cursor: pointer; padding: 3px 5px; border-radius: 5px; font-size: 13px; }
.wp-list .row-btns button:hover { background: #e3e8f2; }
.wp-list .row-btns button:disabled { visibility: hidden; }
.wp-list .drag-over { border-color: var(--sky); background: var(--sky-soft); }

/* ---------- params / navlog ---------- */
.params { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.params summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; }
.grid2 label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: flex; flex-direction: column; gap: 3px; }
.grid2 label span { font-weight: 400; }
.grid2 input { padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line); font-family: var(--mono); font-size: 14px; color: var(--ink); width: 100%; }
.grid2 input:focus { outline: 2px solid var(--sky); border-color: transparent; }

.navlog-wrap { overflow-x: auto; margin-bottom: 14px; }
.navlog { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.navlog th { text-align: right; font-family: var(--font-cond); font-size: 13px; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-2); padding: 4px 5px; border-bottom: 2px solid var(--line); }
.navlog th:first-child, .navlog td:first-child { text-align: left; }
.navlog td { text-align: right; padding: 5px; border-bottom: 1px solid var(--line); font-family: var(--mono); white-space: nowrap; }
.navlog td:first-child { font-family: var(--font); font-weight: 600; white-space: normal; max-width: 120px; }
.navlog tfoot td { font-weight: 700; border-bottom: 0; padding-top: 8px; }
.navlog .empty td { text-align: center; color: var(--ink-2); font-family: var(--font); font-weight: 400; padding: 14px; }
.navlog .warn { color: var(--red); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn-primary { grid-column: span 2; padding: 11px; font-size: 15px; }

/* ---------- player ---------- */
.player { display: flex; gap: 8px; align-items: center; margin: 6px 0 12px; }
.speed { margin-left: auto; font-size: 13px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.speed select { padding: 6px; border-radius: 7px; border: 1px solid var(--line); }
input[type=range] { width: 100%; accent-color: var(--route); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 10px 0; }
.airspace-log { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.airspace-log li { padding: 7px 9px; border-left: 4px solid var(--c, #757575); background: var(--bg); border-radius: 0 8px 8px 0; margin-bottom: 5px; }
.airspace-log li.now { background: #fff4d6; }
.airspace-log li b { display: block; }
.airspace-log li span { color: var(--ink-2); font-size: 12px; font-family: var(--mono); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 26px 14px; border: 2px dashed #b9c4d8; border-radius: var(--radius); cursor: pointer; margin-top: 12px;
  transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--sky); background: var(--sky-soft); }
.dropzone span { font-size: 12px; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.stats div { background: var(--bg); border-radius: 9px; padding: 8px 10px; }
.stats dt { font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .6px; }
.stats dd { margin: 2px 0 0; font-family: var(--mono); font-weight: 600; font-size: 15px; }
.stats .full { grid-column: span 2; }
.profile { width: 100%; height: 110px; display: block; margin-top: 10px; border-radius: 8px; background: var(--bg); cursor: pointer; }

/* ---------- map overlays ---------- */
.map-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: #fff; box-shadow: var(--shadow);
  font-size: 20px; cursor: pointer; display: grid; place-items: center; color: var(--navy-900);
}
.map-btn:hover { background: #f3f6fb; }
.layers-ctl { position: absolute; top: 12px; right: 12px; z-index: 900; }
.layers-menu {
  position: absolute; right: 0; top: 48px; width: 270px; max-height: calc(100vh - 160px); overflow: auto;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 14px 12px; font-size: 14px;
}
.layers-menu h4 { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .8px; font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; }
.layers-menu label { display: flex; gap: 8px; align-items: center; padding: 3px 0; cursor: pointer; }
.swatch { width: 14px; height: 10px; border-radius: 3px; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 25%, transparent); flex: none; }
.locate-btn { position: absolute; top: 60px; right: 12px; z-index: 900; }
.leaflet-top.leaflet-left { top: 0; }

.map-footer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 800; display: flex; gap: 14px; justify-content: space-between;
  padding: 4px 10px; font-size: 11.5px; color: #33415a; background: rgba(255,255,255,.85); pointer-events: none;
}
.leaflet-bottom { bottom: 22px; }

.hud {
  position: absolute; left: 50%; transform: translateX(-50%); top: 12px; z-index: 900; display: flex;
  background: var(--navy-950); color: #fff; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.hud > div { padding: 7px 14px; border-right: 1px solid rgba(255,255,255,.12); display: flex; flex-direction: column; min-width: 76px; }
.hud > div:last-child { border-right: 0; }
.hud span { font-family: var(--font-cond); font-size: 11px; letter-spacing: 1px; color: #8fa3cc; }
.hud b { font-family: var(--mono); font-size: 20px; color: #7CFFB2; font-weight: 600; line-height: 1.15; }
.hud i { font-style: normal; font-size: 11px; color: #8fa3cc; font-family: var(--mono); }
.hud .wide { min-width: 130px; }
.hud .wide b { color: #ff7ad9; font-family: var(--font-cond); font-size: 20px; }
.alert-banner {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%); z-index: 900; padding: 8px 16px; border-radius: 10px;
  background: var(--amber); color: var(--navy-950); font-weight: 700; box-shadow: var(--shadow); font-size: 14px; max-width: 90%;
}
.alert-banner.danger { background: var(--red); color: #fff; }

/* ---------- markers ---------- */
.ap-icon { display: flex; align-items: center; justify-content: center; }
.ap-icon svg { display: block; overflow: visible; }
.map-label {
  background: rgba(255,255,255,.82); border: 0; box-shadow: none; padding: 0 3px; border-radius: 3px;
  font-family: var(--font-cond); font-weight: 600; font-size: 12px; color: var(--navy-900);
}
.map-label::before { display: none; }
.map-label.pt { color: #0d47a1; font-size: 11px; }
.wp-marker {
  width: 22px; height: 22px; border-radius: 50%; background: var(--route); color: #fff; border: 2px solid #fff;
  display: grid; place-items: center; font: 700 11px var(--font); box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.wp-marker.start { background: var(--green); }
.wp-marker.end { background: var(--red); }
.leg-label {
  background: var(--route); color: #fff; border: 0; border-radius: 6px; padding: 1px 6px;
  font: 600 11px var(--mono); box-shadow: 0 1px 3px rgba(0,0,0,.3); white-space: nowrap;
}
.leg-label::before { display: none; }
.plane-icon { transition: none; }
.plane-icon svg { filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.leaflet-popup-content { font-family: var(--font); font-size: 13px; margin: 12px 14px; min-width: 200px; }
.pop h3 { margin: 0 0 2px; font-family: var(--font-cond); font-size: 18px; }
.pop .sub { color: var(--ink-2); font-size: 12px; margin-bottom: 6px; }
.pop table { border-collapse: collapse; width: 100%; margin: 4px 0 8px; }
.pop td { padding: 2px 4px 2px 0; font-family: var(--mono); font-size: 12px; vertical-align: top; }
.pop td:first-child { font-family: var(--font); color: var(--ink-2); }
.pop .btn { width: 100%; padding: 6px 10px; }
.pop ul { margin: 4px 0 8px; padding-left: 0; list-style: none; }
.pop li { padding: 3px 0 3px 8px; border-left: 3px solid var(--c, #757575); margin-bottom: 3px; }
.pop li span { color: var(--ink-2); font-family: var(--mono); font-size: 11px; display: block; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(6,20,48,.55); display: grid; place-items: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 16px; padding: 24px; max-width: 640px; width: 100%; position: relative; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 16px; font-family: var(--font-cond); font-size: 26px; }
.modal-close { position: absolute; top: 12px; right: 12px; border: 0; background: var(--bg); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.send-grid { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
.qr { width: 200px; height: 200px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qr img, .qr canvas { width: 100% !important; height: auto !important; }
.steps { margin: 0 0 14px; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; min-width: 0; padding: 8px; border-radius: 8px; border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; }
.toast {
  position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%); z-index: 2100; background: var(--navy-950); color: #fff;
  padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px;
}

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .brand span { display: none; }
  .modes { order: 3; width: 100%; }
  .modes button { flex: 1; padding: 7px 4px; }
  .search { max-width: none; }
  .btn-app { padding: 7px 10px; }
  .workspace { flex-direction: column; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; max-height: 55%; border-right: 0; z-index: 1001;
    border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(6,20,48,.18); transition: transform .25s;
  }
  .panel.collapsed { transform: translateY(calc(100% - 44px)); overflow: hidden; }
  .panel-handle { display: block; width: 100%; height: 26px; border: 0; background: none; cursor: pointer; position: sticky; top: 0; z-index: 2; background: #fff; }
  .panel-handle span { display: block; width: 44px; height: 5px; border-radius: 3px; background: #c5cdda; margin: 0 auto; }
  .pane { padding-top: 0; }
  .hud { top: 8px; width: calc(100% - 70px); left: 8px; transform: none; flex-wrap: wrap; }
  .hud > div { min-width: 0; flex: 1; padding: 5px 8px; }
  .hud b { font-size: 16px; }
  .hud .wide { min-width: 0; }
  .map-footer span:first-child { display: none; }
  .map-footer { bottom: 44px; }
  .leaflet-bottom { bottom: 64px; }
  .send-grid { grid-template-columns: 1fr; justify-items: center; }
}
.pop li .freq, .airspace-log li .freq { display: block; font-family: var(--mono); font-size: 11.5px; color: #1b5e20; font-weight: 600; margin-top: 2px; }

/* ---------- embedded on the home page (iframe): its header already has the logo and the app link ---------- */
.embedded .topbar .brand, .embedded .topbar .btn-app { display: none; }

/* ---------- typing route points in (Trasa) ---------- */
.wp-add { position: relative; margin: 0 0 12px; }
.wp-add input {
  width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px dashed #b9c4d8; background: var(--bg);
  font-size: 14px; color: var(--ink);
}
.wp-add input:focus { outline: 2px solid var(--sky); border-color: transparent; background: #fff; }
.wp-add .search-results { top: 40px; z-index: 5; max-height: 280px; }
.wp-add .hint { margin: 6px 0 0; }
.wp-add code { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 0 4px; border-radius: 4px; }
.sim-params { margin: 4px 0 10px; }
