/* ---------------------------------------------------------------------------
   AirportMap (live ADS-B) + AirportMapHistory (track replay)
   Floating panels over a full-screen OpenLayers map. Map drawing: js/initMap.js
   --------------------------------------------------------------------------- */

.am-page {
    --am-primary: var(--acv-cobalt, #1E429A);
    --am-primary-soft: #eef2fb;
    --am-surface: #ffffff;
    --am-border: #e2e8f0;
    --am-border-strong: #cbd5e1;
    --am-text: #0f172a;
    --am-muted: #64748b;
    --am-faint: #94a3b8;
    --am-arr: #1E429A;
    --am-dep: #d9480f;
    --am-gnd: #475569;
    --am-unk: #0f766e;
    --am-emg: #dc2626;
    --am-ok: #059669;
    --am-warn: #d97706;
    --am-accent: #00b38a;
    --am-radius: 12px;
    --am-shadow: 0 12px 32px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
    --am-panel-width: 340px;
    position: fixed;
    inset: 0;
    overflow: hidden;
    overflow: clip;
    background: #e2e8f0;
    color: var(--am-text);
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

.am-page *,
.am-page *::before,
.am-page *::after {
    box-sizing: border-box;
}

.am-map {
    position: absolute;
    inset: 0;
    /* the sea of the offline base map; OSM tiles cover it when they load */
    background: #cfe2f0;
}

/* ---------------------------------------------------------------- panel */

.am-panel {
    position: absolute;
    top: 16px;
    left: 16px;
    bottom: 16px;
    z-index: 20;
    width: var(--am-panel-width);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    /* the list shrinks first; a tall replay form on a short screen scrolls instead of spilling over the map */
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius);
    box-shadow: var(--am-shadow);
}

.am-panel.is-collapsed {
    bottom: auto;
}

.am-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.am-kicker {
    color: var(--am-primary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.am-title {
    margin: 2px 0 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--am-text);
}

.am-head-actions {
    display: flex;
    gap: 4px;
}

.am-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--am-muted);
    cursor: pointer;
}

.am-icon-btn:hover {
    background: var(--am-primary-soft);
    color: var(--am-primary);
}

.am-icon-btn:focus-visible,
.am-btn:focus-visible,
.am-chip:focus-visible,
.am-row:focus-visible,
.am-seg button:focus-visible {
    outline: 2px solid var(--am-primary);
    outline-offset: 2px;
}

/* connection strip */
.am-conn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #f1f5f9;
    color: var(--am-muted);
    font-size: 12px;
}

.am-conn-text {
    flex: 1;
    min-width: 0;
}

.am-conn strong {
    color: var(--am-text);
    font-weight: 600;
}

.am-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--am-faint);
}

.am-conn--ok {
    background: #ecfdf5;
}

.am-conn--ok .am-dot {
    background: var(--am-ok);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.18);
    animation: am-pulse 2s ease-in-out infinite;
}

.am-conn--warn {
    background: #fffbeb;
}

.am-conn--warn .am-dot {
    background: var(--am-warn);
}

.am-conn--bad {
    background: #fef2f2;
}

.am-conn--bad .am-dot {
    background: var(--am-emg);
}

@keyframes am-pulse {
    50% {
        box-shadow: 0 0 0 6px rgba(5, 150, 105, 0);
    }
}

.am-link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--am-primary);
    font-weight: 600;
    cursor: pointer;
}

.am-link-btn:hover {
    text-decoration: underline;
}

/* filter chips */
.am-chips {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.am-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 7px 8px;
    border: 1px solid var(--am-border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--am-muted);
    font-size: 11px;
    text-align: left;
    cursor: pointer;
}

.am-chip strong {
    color: var(--am-text);
    font-size: 16px;
    line-height: 1.1;
}

.am-chip:hover {
    border-color: var(--am-border-strong);
}

.am-chip.is-on {
    border-color: var(--am-primary);
    background: var(--am-primary-soft);
    color: var(--am-primary);
}

.am-chip-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.am-swatch {
    display: inline-block;
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--am-faint);
}

.am-swatch--arr { background: var(--am-arr); }
.am-swatch--dep { background: var(--am-dep); }
.am-swatch--gnd { background: var(--am-gnd); }
.am-swatch--unk { background: var(--am-unk); }
.am-swatch--emg { background: var(--am-emg); }
.am-swatch--sel { background: transparent; border: 2px solid var(--am-accent); }

/* search + fields */
.am-search {
    position: relative;
    display: flex;
    align-items: center;
}

.am-search > i {
    position: absolute;
    left: 11px;
    color: var(--am-faint);
    pointer-events: none;
}

.am-search input,
.am-select {
    width: 100%;
    height: 36px;
    padding: 0 32px 0 32px;
    border: 1px solid var(--am-border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--am-text);
    font: inherit;
}

.am-select {
    padding: 0 10px;
}

.am-search input:focus,
.am-select:focus {
    border-color: var(--am-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 66, 154, 0.14);
}

.am-search .am-icon-btn {
    position: absolute;
    right: 3px;
    width: 28px;
    height: 28px;
}

.am-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.am-field label {
    color: var(--am-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* display toggles */
.am-toggles {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}

.am-seg {
    display: inline-flex;
    padding: 2px;
    border-radius: 8px;
    background: #f1f5f9;
}

.am-seg button {
    padding: 4px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--am-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.am-seg button.is-on {
    background: #ffffff;
    color: var(--am-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.am-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--am-text);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.am-switch input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--am-primary);
    cursor: pointer;
}

/* list */
.am-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--am-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.am-list {
    flex: 1;
    min-height: 0;
    margin: 0 -6px;
    padding: 0 6px 2px;
    overflow-y: auto;
}

.am-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 4px;
    padding: 8px 10px 8px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.am-row:hover {
    background: #f8fafc;
    border-color: var(--am-border);
}

.am-row.is-selected {
    background: #ecfdf7;
    border-color: var(--am-accent);
}

/* gone quiet: faded like on the map */
.am-row.is-stale .am-row-main,
.am-row.is-stale .am-row-meta {
    opacity: 0.55;
}

.am-list-count {
    margin-left: 4px;
    color: var(--am-text);
}

.am-sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
}

.am-sort .am-select {
    width: auto;
    height: 26px;
    padding: 0 6px;
    font-size: 12px;
}

.am-airlines {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: -4px;
}

.am-airline {
    padding: 2px 7px;
    border: 1px solid var(--am-border);
    border-radius: 999px;
    color: var(--am-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.am-airline b {
    color: var(--am-text);
    font-weight: 700;
}

.am-row-bar {
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 5px;
    width: 3px;
    border-radius: 2px;
    background: var(--am-faint);
}

.am-cat-arr .am-row-bar { background: var(--am-arr); }
.am-cat-dep .am-row-bar { background: var(--am-dep); }
.am-cat-gnd .am-row-bar { background: var(--am-gnd); }
.am-cat-unk .am-row-bar { background: var(--am-unk); }
.am-row.is-emg .am-row-bar { background: var(--am-emg); }

.am-row-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.am-row-ident {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 14px;
}

.am-row-ident small {
    color: var(--am-muted);
    font-size: 11px;
    font-weight: 500;
}

.am-row-sub {
    overflow: hidden;
    color: var(--am-muted);
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.am-row-meta {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.am-row-meta span:first-child {
    color: var(--am-text);
    font-weight: 600;
}

.am-row-meta span + span {
    color: var(--am-muted);
}

.am-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 12px;
    color: var(--am-muted);
    text-align: center;
}

.am-empty i {
    color: var(--am-faint);
    font-size: 22px;
}

.am-empty strong {
    color: var(--am-text);
}

.am-error {
    padding: 8px 10px;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 12px;
}

/* ---------------------------------------------------------------- detail card */

.am-detail {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
    width: 330px;
    max-height: calc(100% - 32px);
    overflow-y: auto;
    padding: 14px;
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius);
    box-shadow: var(--am-shadow);
}

.am-page--playback .am-detail {
    max-height: calc(100% - 112px);
}

.am-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.am-detail-ident {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.15;
}

.am-detail-sub {
    margin-top: 2px;
    color: var(--am-muted);
    font-size: 12px;
}

.am-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
}

.am-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--am-muted);
    font-size: 11px;
    font-weight: 700;
}

.am-badge--arr { background: #e8edf8; color: var(--am-arr); }
.am-badge--dep { background: #fff1e8; color: var(--am-dep); }
.am-badge--gnd { background: #eef2f6; color: var(--am-gnd); }
.am-badge--unk { background: #e6f4f2; color: var(--am-unk); }
.am-badge--emg { background: #fee2e2; color: var(--am-emg); }
.am-badge--stale { background: #fef3c7; color: var(--am-warn); }
.am-badge--lost { background: #f1f5f9; color: var(--am-muted); }
.am-badge--replay { background: #ede9fe; color: #5b21b6; }

.am-detail-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.am-btn {
    display: inline-flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--am-border-strong);
    border-radius: 8px;
    background: #ffffff;
    color: var(--am-text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.am-btn:hover:not(:disabled) {
    border-color: var(--am-primary);
    color: var(--am-primary);
}

.am-btn.is-on {
    border-color: var(--am-accent);
    background: #ecfdf7;
    color: #047857;
}

.am-btn--primary {
    border-color: var(--am-primary);
    background: var(--am-primary);
    color: #ffffff;
}

.am-btn--primary:hover:not(:disabled) {
    background: var(--acv-cobalt-dark, #152e6b);
    color: #ffffff;
}

.am-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.am-section-title {
    margin: 12px 0 6px;
    color: var(--am-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.am-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin: 0;
}

.am-grid > div {
    min-width: 0;
}

.am-grid dt {
    color: var(--am-muted);
    font-size: 11px;
    font-weight: 500;
}

.am-grid dd {
    margin: 0;
    overflow: hidden;
    color: var(--am-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.am-grid--wide {
    grid-column: 1 / -1;
}

.am-grid--compact {
    grid-template-columns: repeat(3, 1fr);
}

.am-detail-foot {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--am-border);
    color: var(--am-muted);
    font-size: 11px;
}

.am-events {
    margin: 0;
    padding: 0;
    list-style: none;
}

.am-events button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 4px;
    padding: 6px 8px;
    border: 1px solid var(--am-border);
    border-radius: 8px;
    background: #ffffff;
    color: inherit;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

.am-events button:hover {
    border-color: #f59e0b;
    background: #fffbeb;
}

.am-events time {
    color: var(--am-muted);
    font-variant-numeric: tabular-nums;
}

.am-events i {
    color: #f59e0b;
    font-size: 10px;
}

/* ---------------------------------------------------------------- flight card (live) */

.am-fr {
    padding: 0 0 14px;
    overflow-x: hidden;
}

.am-fr > *:not(.am-fr-head) {
    margin-right: 14px;
    margin-left: 14px;
}

.am-fr-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 10px 12px 14px;
    border-radius: var(--am-radius) var(--am-radius) 0 0;
    background: linear-gradient(135deg, var(--acv-cobalt, #1E429A), var(--acv-cobalt-dark, #152e6b));
    color: #ffffff;
}

.am-fr-head .am-icon-btn {
    color: rgba(255, 255, 255, 0.8);
}

.am-fr-head .am-icon-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.am-fr-head-actions {
    display: flex;
    flex: none;
    flex-direction: row-reverse;
    gap: 2px;
}

/* minimising the card is for phones, where it covers the bottom of the map */
.am-fr-head .am-fr-min {
    display: none;
}

.am-fr-ident {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.am-fr-flight {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0.01em;
}

.am-fr-callsign {
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 12px;
    font-weight: 600;
}

.am-fr-airline {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 12px;
}

.am-fr .am-badges {
    margin-top: 10px;
}

.am-fr-route {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.am-fr-end {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.am-fr-end--to {
    align-items: flex-end;
    text-align: right;
}

.am-fr-end strong {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: 0.02em;
}

.am-fr-end span {
    overflow: hidden;
    max-width: 100%;
    color: var(--am-muted);
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.am-fr-route-icon {
    flex: none;
    color: var(--am-faint);
    font-size: 16px;
}

.am-fr-progress {
    height: 6px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.am-fr-progress-bar {
    height: 100%;
    border-radius: 999px;
    background: var(--am-primary);
    transition: width 0.6s ease;
}

.am-fr-progress-bar.am-cat-dep { background: var(--am-dep); }
.am-fr-progress-bar.am-cat-gnd { background: var(--am-gnd); }

.am-fr-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 5px;
    color: var(--am-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.am-fr-times {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 12px;
    overflow: hidden;
    border: 1px solid var(--am-border);
    border-radius: 8px;
}

.am-fr-times > div {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 10px;
    font-variant-numeric: tabular-nums;
}

.am-fr-times > div + div {
    border-left: 1px solid var(--am-border);
}

.am-fr-time-label {
    color: var(--am-muted);
    font-size: 11px;
}

.am-fr-times strong {
    font-size: 16px;
    font-weight: 700;
}

.am-fr-times small {
    min-height: 14px;
    color: var(--am-faint);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.am-fr-note {
    margin-top: 6px;
    color: var(--am-muted);
    font-size: 12px;
}

.am-fr .am-detail-actions {
    margin-top: 12px;
}

.am-fr-chart {
    margin-top: 10px;
}

.am-fr-chart svg {
    display: block;
    width: 100%;
    height: 72px;
    border-radius: 6px;
    background: #f8fafc;
}

.am-chart-alt-fill {
    fill: rgba(30, 66, 154, 0.14);
}

.am-chart-alt {
    fill: none;
    stroke: var(--am-primary);
    stroke-width: 1.6;
    vector-effect: non-scaling-stroke;
}

.am-chart-gs {
    fill: none;
    stroke: var(--am-dep);
    stroke-width: 1.4;
    vector-effect: non-scaling-stroke;
}

.am-chart-legend {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    color: var(--am-muted);
    font-size: 11px;
}

.am-chart-key::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 3px;
    margin-right: 5px;
    vertical-align: middle;
    border-radius: 2px;
}

.am-chart-key--alt::before { background: var(--am-primary); }
.am-chart-key--gs::before { background: var(--am-dep); }

.am-chart-empty {
    padding: 14px;
    border-radius: 6px;
    background: #f8fafc;
    color: var(--am-muted);
    font-size: 12px;
    text-align: center;
}

.am-alt-legend {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
}

.am-alt-legend-bar {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, #16a34a 0%, #84cc16 12.5%, #eab308 25%, #f97316 50%, #ef4444 75%, #a855f7 100%);
}

.am-alt-legend-ticks {
    display: flex;
    justify-content: space-between;
    color: var(--am-faint);
    font-size: 10px;
}

/* hover tooltip on the map (OpenLayers overlay) */
.am-tip {
    padding: 6px 9px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.92);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
    color: #f8fafc;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    font-size: 11px;
    line-height: 1.35;
    white-space: nowrap;
    pointer-events: none;
}

.am-tip strong {
    margin-right: 6px;
    font-size: 12px;
}

.am-tip span {
    color: #cbd5e1;
}

.am-tip div {
    color: #e2e8f0;
}

/* ---------------------------------------------------------------- legend */

.am-legend {
    position: absolute;
    bottom: 16px;
    left: calc(var(--am-panel-width) + 32px);
    z-index: 15;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 7px 12px;
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
    color: var(--am-muted);
    font-size: 11px;
    font-weight: 600;
}

.am-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.am-panel.is-collapsed ~ .am-legend {
    left: 16px;
}

/* shown by initMap.js until the first base map content is drawn */
.am-maploading {
    position: absolute;
    top: 16px;
    left: 50%;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    color: var(--am-muted);
    font-size: 12px;
    font-weight: 600;
    transform: translateX(-50%);
    pointer-events: none;
}

.am-maploading::before {
    content: "";
    width: 12px;
    height: 12px;
    border: 2px solid var(--am-border-strong);
    border-top-color: var(--am-primary);
    border-radius: 50%;
    animation: am-spin 0.9s linear infinite;
}

@keyframes am-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .am-maploading::before {
        animation: none;
    }
}

/* the portal's floating notification bell (TelerikLayout) is a sibling of the page: keep it off the flight card */
.am-page.am-page--live.am-page--card ~ .nb-floating.nb-floating {
    right: calc(330px + 32px);
}

/* the same where the layout nests the bell elsewhere (kept apart: a browser without :has drops only this rule) */
body:has(.am-page--live.am-page--card) .nb-floating.nb-floating {
    right: calc(330px + 32px);
}

/* ---------------------------------------------------------------- playback bar (built by initMap.js) */

/* ---------------------------------------------------------------- point popup (OpenLayers overlay) */

.am-popup {
    width: 230px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid var(--am-border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    color: #0f172a;
    font-size: 12px;
}

.am-popup::after {
    content: "";
    position: absolute;
    bottom: -7px;
    left: 50%;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    transform: rotate(45deg);
}

.am-popup-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.am-popup-head strong {
    font-size: 14px;
}

.am-popup-head span {
    flex: 1;
    color: #64748b;
}

.am-popup-close {
    padding: 0 4px;
    border: 0;
    background: none;
    color: #64748b;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.am-popup dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 10px;
    margin: 0 0 8px;
}

.am-popup dt {
    color: #64748b;
    font-weight: 500;
}

.am-popup dd {
    margin: 0;
    font-weight: 600;
}

.am-popup-action {
    width: 100%;
    height: 28px;
    border: 1px solid #1E429A;
    border-radius: 6px;
    background: #eef2fb;
    color: #1E429A;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* ---------------------------------------------------------------- OpenLayers controls */

/* top-left of the map area, beside the panel: clear of the card (right) and the replay bar (bottom) */
.am-map .ol-zoom {
    top: 16px;
    right: auto;
    bottom: auto;
    left: calc(var(--am-panel-width) + 32px);
}

.am-map .ol-zoom button {
    width: 32px;
    height: 32px;
    margin: 0 0 2px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.97);
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
    font-size: 18px;
}

.am-map .ol-zoom button:hover {
    color: #1E429A;
}

.am-map .ol-scale-line {
    right: 60px;
    bottom: 22px;
    left: auto;
}

.am-page--playback .am-map .ol-scale-line {
    bottom: 86px;
}

.am-page--playback .am-map .ol-attribution {
    bottom: 76px;
}

/* ---------------------------------------------------------------- 2D / 3D switch and the 3D view (initMap3D.js) */

/* right of the zoom buttons */
.am-viewmode {
    position: absolute;
    top: 16px;
    left: calc(var(--am-panel-width) + 76px);
    z-index: 15;
    display: inline-flex;
    padding: 2px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

.am-viewmode button {
    min-width: 40px;
    height: 28px;
    padding: 4px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--am-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.am-viewmode button:focus-visible {
    outline: 2px solid var(--am-primary);
    outline-offset: 2px;
}

.am-viewmode button.is-on {
    background: var(--am-primary);
    color: #ffffff;
}

.am-viewmode button:disabled {
    cursor: progress;
}

.am-viewnote {
    position: absolute;
    top: 54px;
    left: calc(var(--am-panel-width) + 32px);
    z-index: 15;
    max-width: 360px;
    padding: 7px 12px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    font-size: 12px;
}

.am-viewnote.is-3d {
    top: 132px;
}

/* hidden but still sized, so the other view can be built and switched to without a resize */
.am-map.is-off {
    visibility: hidden;
    pointer-events: none;
}

.am-map3d {
    overflow: hidden;
    overflow: clip;
    contain: layout paint;
    background: #0b1220;
}

.am-map3d > .am3d-root {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.am-map3d > .am3d-loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b1220;
    color: #cbd5e1;
    font-size: 14px;
    letter-spacing: 0.02em;
}

.am-tip3d {
    position: absolute;
    z-index: 5;
    transform: translate(-50%, -100%);
}

.am3d-zoom {
    position: absolute;
    top: 16px;
    left: calc(var(--am-panel-width) + 32px);
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.am3d-zoom button {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.97);
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.am3d-zoom button .fas {
    font-size: 13px;
}

.am3d-zoom button:hover {
    color: #1E429A;
}

.am3d-zoom button:focus-visible {
    outline: 2px solid var(--am-primary);
    outline-offset: 2px;
}

.am3d-compass svg {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    transition: transform 0.12s linear;
}

.am-map3d > .am3d-root:focus {
    outline: none;
}

.am3d-credit {
    position: absolute;
    right: 8px;
    bottom: 4px;
    z-index: 5;
    max-width: 50%;
    overflow: hidden;
    font-size: 10px;
    color: #f8fafc;
    text-shadow: 0 0 3px #000;
}

.am3d-credit .cesium-widget-credits {
    position: static;
}

.am3d-credit img {
    height: 16px;
    vertical-align: middle;
}

.am3d-model-credits-open {
    margin: 0 0 0 6px;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.am3d-model-credits {
    position: absolute;
    /* clear of the portal's floating bell in the bottom-right corner */
    right: 72px;
    bottom: 26px;
    z-index: 7;
    width: min(420px, calc(100% - 80px));
    max-height: 60%;
    overflow: auto;
    padding: 10px 28px 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
    font-size: 11px;
    line-height: 1.45;
    color: #0f172a;
}

.am3d-model-credits[hidden] {
    display: none;
}

.am3d-model-credits-title {
    margin-bottom: 4px;
    font-weight: 600;
}

.am3d-model-credits ul {
    margin: 0;
    padding-left: 16px;
}

.am3d-model-credits a {
    color: #0369a1;
}

.am3d-model-credits-close {
    position: absolute;
    top: 4px;
    right: 6px;
    border: 0;
    background: none;
    font-size: 16px;
    line-height: 1;
    color: #475569;
    cursor: pointer;
}

.am3d-alert {
    position: absolute;
    top: 16px;
    left: 50%;
    z-index: 6;
    max-width: calc(100% - 32px);
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.88);
    color: #f8fafc;
    font-size: 12px;
    transform: translateX(-50%);
    pointer-events: none;
}

/* under the flight card it would be cut in half; in a replay the time bar holds that corner */
.am-page--card .am3d-hint,
.am-page--playback .am3d-hint {
    display: none;
}

.am3d-hint {
    position: absolute;
    right: 8px;
    bottom: 26px;
    z-index: 5;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.6);
    color: #e2e8f0;
    font-size: 11px;
    pointer-events: none;
}

/* ---------------------------------------------------------------- small screens */

@media (max-width: 768px) {
    .am-page {
        --am-panel-width: calc(100vw - 24px);
    }

    /* panel on top, card at the bottom, a strip of map left between them */
    .am-panel {
        top: 12px;
        left: 12px;
        bottom: auto;
        max-height: 44vh;
        padding: 12px;
        gap: 10px;
    }

    .am-detail {
        top: auto;
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
        max-height: 40vh;
    }

    .am-fr-head .am-fr-min {
        display: inline-flex;
    }

    .am-detail.is-min > :not(.am-fr-head):not(.am-badges):not(.am-detail-actions) {
        display: none;
    }

    .am-detail.is-min .am-fr-head {
        padding-bottom: 8px;
    }

    .am-maploading {
        top: auto;
        bottom: 24px;
    }

    /* above the card, on the side away from the 2D/3D switch */
    .am-page.am-page--live.am-page--card ~ .nb-floating.nb-floating {
        right: auto;
        bottom: calc(40vh + 24px);
        left: 12px;
    }

    .am-page.am-page--live.am-page--card ~ .nb-floating .nb-panel.nb-panel {
        right: auto;
        left: 0;
        max-height: calc(60vh - 110px);
    }

    body:has(.am-page--live.am-page--card) .nb-floating.nb-floating {
        right: auto;
        bottom: calc(40vh + 24px);
        left: 12px;
    }

    body:has(.am-page--live.am-page--card) .nb-floating .nb-panel.nb-panel {
        right: auto;
        left: 0;
        max-height: calc(60vh - 110px);
    }

    /* the replay bar wraps to two rows on a phone */
    .am-page--playback .am-detail {
        bottom: 152px;
        max-height: 30vh;
    }

    .am-chips {
        gap: 4px;
    }

    .am-chip {
        padding: 6px;
    }

    /* every row of the panel counts on a phone */
    .am-airlines {
        display: none;
    }

    .am-legend {
        display: none;
    }

    /* pinch to zoom on a phone; the buttons would sit under the panel */
    .am-map .ol-zoom,
    .am3d-zoom,
    .am3d-hint {
        display: none;
    }

    /* the panel covers the top of the screen: the switch sits at the bottom right */
    .am-viewmode {
        top: auto;
        right: 12px;
        bottom: calc(40vh + 24px);
        left: auto;
    }

    .am-viewnote,
    .am-viewnote.is-3d {
        top: auto;
        right: 12px;
        bottom: calc(40vh + 64px);
        left: 12px;
    }

}

/* ---------------------------------------------------------------------------
   Platform: share link, kiosk, unmatched aircraft, colour-blind-safe palette
   --------------------------------------------------------------------------- */

.am-page {
    --am-unm: #94a3b8;
}

.am-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.am-detail:focus {
    outline: none;
}

.am-detail:focus-visible {
    outline: 2px solid var(--am-accent);
    outline-offset: 2px;
}

.am-toggles--platform {
    margin-top: -4px;
}

.am-swatch--unm { background: var(--am-unm); }
.am-row.is-unmatched .am-row-bar { background: var(--am-unm); }
.am-row.is-unmatched .am-row-ident { color: var(--am-muted); }

.am-copynote {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100vw - 32px);
    padding: 6px 8px 6px 14px;
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: 999px;
    box-shadow: var(--am-shadow);
    font-weight: 600;
}

.am-copynote input {
    width: min(52vw, 420px);
    min-width: 0;
    padding: 4px 8px;
    border: 1px solid var(--am-border-strong);
    border-radius: 6px;
    font: inherit;
    font-weight: 400;
}

/* colour-blind safe (Okabe-Ito) with a shape per category */
.am-page--cb {
    --am-arr: #0072B2;
    --am-dep: #E69F00;
    --am-gnd: #5c5c5c;
    --am-unk: #CC79A7;
    --am-unm: #a3a3a3;
    --am-emg: #D55E00;
}

.am-page--cb .am-swatch--arr { border-radius: 0; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.am-page--cb .am-swatch--dep { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.am-page--cb .am-swatch--gnd { border-radius: 0; }
.am-page--cb .am-swatch--unk,
.am-page--cb .am-swatch--unm { border-radius: 50%; }
.am-page--cb .am-swatch--emg { border-radius: 0; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.am-page--cb .am-cat-dep .am-row-bar { background: repeating-linear-gradient(to bottom, var(--am-dep) 0 6px, transparent 6px 9px); }
.am-page--cb .am-cat-gnd .am-row-bar { background: repeating-linear-gradient(to bottom, var(--am-gnd) 0 3px, transparent 3px 6px); }
.am-page--cb .am-row.is-emg .am-row-bar { background: var(--am-emg); }

/* kiosk / wallboard: ?kiosk=1 */
.am-page--kiosk .am-head-actions,
.am-page--kiosk .am-viewmode,
.am-page--kiosk .am-copynote {
    display: none;
}

.am-page--kiosk .am-title {
    font-size: 22px;
}

.am-page--kiosk .am-conn,
.am-page--kiosk .am-legend {
    font-size: 15px;
}

body:has(.am-page--kiosk) .nb-floating {
    display: none !important;
}

/* data source: Live / Playback / History */
.am-modes {
    display: flex;
    gap: 2px;
    padding: 2px;
    border-radius: 8px;
    background: #f1f5f9;
}

.am-modes > button,
.am-modes > a {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--am-muted);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.am-modes > .is-on {
    background: var(--am-surface);
    color: var(--am-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.am-modes > button:focus-visible,
.am-modes > a:focus-visible {
    outline: 2px solid var(--am-primary);
    outline-offset: 2px;
}

/* what a log replay cannot show, said once under the playback form */
.am-replay-note {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    background: #ede9fe;
    color: #5b21b6;
    font-size: 11px;
    line-height: 1.4;
}

.am-replay-note .fas {
    margin-top: 2px;
}

/* replay on the map page: the time bar takes the bottom edge, the legend sits above it */
.am-page--playback .am-legend {
    bottom: 76px;
}

.am-page--playback.am-page--card .am-gp-bar {
    right: calc(330px + 32px);
}

/* playback form and time bar */
.am-gp-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.am-gp-form .am-field:first-child {
    grid-column: 1 / -1;
}

.am-gp-load {
    grid-column: 1 / -1;
    justify-content: center;
}

.am-gp-summary {
    color: var(--am-muted);
    font-size: 12px;
}

.am-gp-bar {
    position: absolute;
    right: 16px;
    bottom: 16px;
    left: calc(var(--am-panel-width) + 32px);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius);
    box-shadow: var(--am-shadow);
    font-variant-numeric: tabular-nums;
}

.am-gp-bar:not(.is-active) {
    opacity: 0.7;
}

.am-gp-time {
    flex: none;
    min-width: 64px;
    font-weight: 700;
}

.am-gp-slider {
    flex: 1;
    min-width: 80px;
    accent-color: var(--am-primary);
}

.am-gp-speed {
    flex: none;
}

@media (max-width: 768px) {
    .am-gp-bar {
        left: 16px;
        flex-wrap: wrap;
    }

    .am-gp-slider {
        order: 3;
        flex-basis: 100%;
    }
}

/* multi-airport overview: /AirportMapOverview */
.amo-page {
    --am-primary: var(--acv-cobalt, #1E429A);
    --am-surface: #ffffff;
    --am-border: #e2e8f0;
    --am-text: #0f172a;
    --am-muted: #64748b;
    --am-faint: #94a3b8;
    --am-arr: #1E429A;
    --am-dep: #d9480f;
    --am-gnd: #475569;
    --am-unm: #94a3b8;
    --am-emg: #dc2626;
    --am-ok: #059669;
    --am-warn: #d97706;
    padding: 16px;
    color: var(--am-text);
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    font-size: 13px;
}

.amo-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}

.amo-title {
    margin: 2px 0 0;
    font-size: 20px;
    font-weight: 700;
}

.amo-cap,
.amo-empty {
    color: var(--am-muted);
}

.amo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 16px;
}

.amo-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.amo-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.amo-card-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.amo-card-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.amo-card-head .am-btn {
    text-decoration: none;
}

.amo-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 0;
}

.amo-stats dt {
    color: var(--am-muted);
    font-size: 11px;
    font-weight: 600;
}

.amo-stats dd {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.amo-emg.is-on {
    color: var(--am-emg);
}

.amo-split {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    color: var(--am-muted);
    font-size: 12px;
}

.amo-split > span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
