:root {
  color-scheme: dark;
  --bg: #06111c;
  --panel: #0b1b29;
  --panel-2: #102535;
  --line: #21394a;
  --text: #edf7ff;
  --muted: #8fa8b8;
  --cyan: #35c9f2;
  --cyan-soft: rgba(53, 201, 242, .16);
  --amber: #ffb23f;
  --magenta: #d267ff;
  --danger: #ff6b73;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
.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; }
.hidden { display: none !important; }

.app-shell { height: 100dvh; display: grid; grid-template-rows: 72px minmax(0, 1fr) 36px; background: radial-gradient(circle at 70% 0%, rgba(39, 122, 162, .14), transparent 35%), var(--bg); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(6, 17, 28, .92); backdrop-filter: blur(16px); z-index: 1000; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand strong { display: block; font-size: 21px; line-height: 1; letter-spacing: -.03em; }
.brand small { color: var(--cyan); font-size: 9px; letter-spacing: .22em; font-weight: 800; }
.brand-mark { width: 42px; aspect-ratio: 1; border: 1px solid rgba(53, 201, 242, .42); border-radius: 50%; display: grid; place-items: center; position: relative; background: radial-gradient(circle, rgba(53, 201, 242, .22), transparent 64%); box-shadow: inset 0 0 20px rgba(53, 201, 242, .08); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; border: 1px solid rgba(53, 201, 242, .25); border-radius: 50%; inset: 7px; }
.brand-mark::after { inset: 14px; }
.brand-mark span { width: 21px; height: 7px; background: var(--cyan); clip-path: polygon(0 42%, 40% 42%, 48% 0, 58% 0, 57% 42%, 100% 42%, 100% 60%, 57% 60%, 54% 100%, 46% 100%, 40% 60%, 0 60%); transform: rotate(-18deg); filter: drop-shadow(0 0 6px var(--cyan)); z-index: 2; }
.brand-mark.large { width: 76px; margin-bottom: 20px; }
.brand-mark.large span { width: 38px; height: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-chip, .account-button { min-height: 42px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.status-chip { display: flex; align-items: center; gap: 8px; padding: 0 13px; color: var(--muted); font-size: 12px; font-weight: 700; }
.status-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.status-chip.online i { background: #53df8a; box-shadow: 0 0 10px #53df8a; }
.status-chip.error i { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.icon-button { border: 0; cursor: pointer; }
.account-button { display: flex; align-items: center; gap: 9px; padding: 5px 12px 5px 6px; }
.account-avatar { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: var(--cyan-soft); color: var(--cyan); font-weight: 900; }
.account-label { font-size: 13px; font-weight: 800; }

.radar-layout { min-height: 0; display: grid; grid-template-columns: 330px minmax(380px, 1fr) 300px; gap: 10px; padding: 10px; }
.side-panel, .detail-panel, .map-panel { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(11, 27, 41, .94); min-height: 0; overflow: hidden; }
.side-panel { display: flex; flex-direction: column; }
.panel-heading { padding: 20px 20px 12px; }
.eyebrow { color: var(--cyan); font-size: 10px; letter-spacing: .17em; font-weight: 900; margin: 0 0 7px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 25px; margin-bottom: 8px; letter-spacing: -.035em; }
h2 { letter-spacing: -.025em; }
.summary { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 0; }
.toolbar { display: grid; gap: 9px; padding: 0 14px 14px; }
.primary-button, .secondary-button, .guest-button { border-radius: 11px; min-height: 43px; padding: 0 15px; font-weight: 850; cursor: pointer; }
.primary-button { border: 1px solid var(--cyan); color: #03121b; background: linear-gradient(135deg, #58d9f7, #22b9e6); }
.secondary-button, .guest-button { border: 1px solid var(--line); background: var(--panel-2); }
.search-field { min-height: 42px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 11px; background: #071621; padding: 0 12px; color: var(--muted); }
.search-field:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.filter-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 0 14px 12px; }
.filter-strip button { position: relative; min-width: 0; min-height: 35px; padding: 0 7px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: linear-gradient(180deg, rgba(16, 37, 53, .92), rgba(7, 22, 33, .92)); color: var(--muted); font-size: 9px; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.filter-strip button::after { content: ""; position: absolute; right: 7px; bottom: 4px; left: 7px; height: 2px; border-radius: 2px; background: transparent; }
.filter-strip button:hover { border-color: #345c72; color: var(--text); }
.filter-strip button.active { border-color: rgba(53, 201, 242, .65); background: linear-gradient(180deg, rgba(31, 78, 99, .95), rgba(12, 43, 59, .95)); color: #e8faff; box-shadow: inset 0 0 18px rgba(53, 201, 242, .08); }
.filter-strip button.active::after { background: var(--cyan); box-shadow: 0 0 7px rgba(53, 201, 242, .65); }
.list-heading { display: flex; justify-content: space-between; padding: 11px 16px; border-block: 1px solid var(--line); font-size: 12px; }
.list-heading span { color: var(--muted); }
.aircraft-list { flex: 1; overflow-y: auto; scrollbar-color: #345468 transparent; }
.aircraft-card { width: 100%; display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; padding: 12px 14px; border: 0; border-bottom: 1px solid rgba(33, 57, 74, .75); text-align: left; background: transparent; cursor: pointer; }
.aircraft-card:hover, .aircraft-card.active { background: var(--cyan-soft); }
.aircraft-card.active { box-shadow: inset 3px 0 var(--cyan); }
.aircraft-symbol { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: #112b3c; color: var(--cyan); font-size: 20px; transform: none; }
.aircraft-main { min-width: 0; }
.aircraft-main strong, .aircraft-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aircraft-main strong { font-size: 13px; }
.aircraft-main span { color: var(--muted); font-size: 11px; margin-top: 4px; }
.aircraft-main em { display: block; overflow: hidden; margin-top: 3px; color: var(--cyan); font-size: 9px; font-style: normal; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.aircraft-metrics { text-align: right; font-size: 11px; }
.aircraft-metrics strong, .aircraft-metrics span { display: block; }
.aircraft-metrics span { color: var(--muted); margin-top: 4px; }
.empty-state { min-height: 220px; display: grid; place-items: center; align-content: center; text-align: center; padding: 30px; color: var(--muted); }
.empty-state strong { color: var(--text); }
.empty-state p { font-size: 12px; margin: 5px 0; }
.radar-glyph { color: var(--cyan); font-size: 40px; margin-bottom: 12px; }
.source-note { margin: 0; padding: 8px 12px; border-top: 1px solid var(--line); color: #6f899a; font-size: 9px; }

.map-panel { position: relative; background: #07131e; }
#map { height: 100%; width: 100%; background: #07131e; }
.leaflet-container { font-family: inherit; }
.leaflet-control-zoom a { background: #0d2130 !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(4, 13, 21, .8) !important; color: #8da5b4 !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: var(--cyan) !important; }
.map-overlay { position: absolute; z-index: 500; border: 1px solid var(--line); background: rgba(7, 19, 30, .88); backdrop-filter: blur(12px); border-radius: 12px; }
.map-title { top: 13px; left: 54px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; pointer-events: none; }
.map-title small, .map-title strong { display: block; }
.map-title small { color: var(--cyan); font-size: 8px; font-weight: 900; letter-spacing: .14em; }
.map-title strong { font-size: 12px; }
.pulse { width: 10px; height: 10px; background: #53df8a; border-radius: 50%; box-shadow: 0 0 0 0 rgba(83, 223, 138, .65); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(83, 223, 138, 0); } }
.map-legend { left: 12px; bottom: 24px; display: flex; gap: 12px; padding: 8px 10px; font-size: 10px; }
.map-legend span { display: flex; align-items: center; gap: 5px; }
.legend-plane { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: var(--cyan); }
.legend-plane.mlat { background: var(--cyan); }
.map-control { position: absolute; z-index: 500; top: 12px; right: 12px; width: 39px; height: 39px; border: 1px solid var(--line); border-radius: 11px; background: rgba(7, 19, 30, .9); font-size: 22px; cursor: pointer; }
.map-control.loading { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.plane-marker { width: 31px; height: 31px; border-radius: 50%; display: grid; place-items: center; color: #04131c; background: var(--cyan); border: 2px solid #dff9ff; box-shadow: 0 0 0 4px rgba(53, 201, 242, .2), 0 4px 16px #000; font-size: 17px; transition: transform .2s; }
.plane-marker.mlat { background: var(--cyan); box-shadow: 0 0 0 4px rgba(53, 201, 242, .2), 0 4px 16px #000; }
.plane-marker.stale { opacity: .55; }
.plane-marker.selected { z-index: 2; border-color: #fff1cf; background: var(--amber); box-shadow: 0 0 0 5px rgba(255, 178, 63, .3), 0 0 24px rgba(255, 178, 63, .95), 0 6px 18px #000; transform: scale(1.28); }
.plane-marker .plane-glyph { display: block; width: 19px; height: 19px; fill: currentColor; transform-origin: center; }
.selected-aircraft-label { border: 1px solid rgba(255, 178, 63, .65) !important; background: #0b1b29 !important; color: #fff3d9 !important; box-shadow: 0 5px 16px rgba(0, 0, 0, .45) !important; font-weight: 850; }
.selected-aircraft-label::before { border-top-color: rgba(255, 178, 63, .65) !important; }

.detail-panel { position: relative; overflow-y: auto; }
.detail-close, .dialog-close { position: absolute; right: 12px; top: 12px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; z-index: 2; }
.detail-empty { min-height: 100%; display: grid; place-items: center; align-content: center; text-align: center; padding: 28px; }
.detail-empty p:last-child { color: var(--muted); font-size: 13px; line-height: 1.5; }
.large-plane { width: 55px; height: 55px; color: var(--cyan); fill: currentColor; filter: drop-shadow(0 0 20px rgba(53, 201, 242, .4)); margin-bottom: 22px; transform-origin: center; }
.detail-empty .large-plane { width: auto; height: auto; font-size: 55px; }
.detail-content { padding: 24px 16px; }
.detail-hero { padding: 20px 14px; margin: -24px -16px 18px; background: radial-gradient(circle at 50% 0, rgba(53, 201, 242, .21), transparent 70%); border-bottom: 1px solid var(--line); text-align: center; }
.detail-hero .large-plane { display: block; margin: 12px auto; }
.detail-hero h2 { margin-bottom: 3px; font-size: 23px; }
.detail-hero p { color: var(--muted); margin-bottom: 0; }
.badges { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.badge { border-radius: 999px; padding: 4px 8px; background: var(--cyan-soft); color: var(--cyan); font-size: 9px; font-weight: 900; }
.badge.mlat { background: var(--cyan-soft); color: var(--cyan); }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { border: 1px solid var(--line); border-radius: 11px; padding: 10px; background: rgba(16, 37, 53, .65); }
.metric small, .metric strong { display: block; }
.metric small { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { margin-top: 4px; font-size: 13px; }
.metric.alert { grid-column: 1 / -1; border-color: rgba(255, 91, 91, .72); background: rgba(147, 31, 43, .2); }
.metric.alert small { color: #ffaaa8; }
.metric.alert strong { color: #ffd0ce; }
.route-card { margin-top: 12px; padding: 12px; border: 1px solid rgba(255, 178, 63, .38); border-radius: 12px; background: rgba(255, 178, 63, .07); }
.route-card > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.route-card.unavailable { border-color: var(--line); background: rgba(16, 37, 53, .45); }
.route-card.loading { border-color: rgba(53, 201, 242, .4); background: rgba(53, 201, 242, .07); }
.route-card.loading > strong::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border: 2px solid rgba(53, 201, 242, .35); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
.route-card.unavailable > strong { display: block; font-size: 12px; }
.route-card.loading > strong { display: block; font-size: 12px; }
.route-airports { display: flex; align-items: center; gap: 7px; overflow-x: auto; }
.route-airports div { min-width: 0; flex: 1; }
.route-airports small, .route-airports strong, .route-airports span { display: block; }
.route-airports small { color: var(--muted); font-size: 8px; text-transform: uppercase; }
.route-airports strong { margin-top: 2px; color: var(--amber); font-size: 20px; }
.route-airports span { overflow: hidden; margin-top: 2px; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.route-airports i { color: var(--amber); font-style: normal; }
.data-warning { margin-top: 14px; border-left: 3px solid var(--amber); padding: 9px 10px; background: rgba(255, 178, 63, .08); color: #ddc89e; font-size: 11px; line-height: 1.45; }

footer { display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-top: 1px solid var(--line); color: #6f899a; font-size: 9px; }
footer nav { display: flex; gap: 15px; }
footer a { text-decoration: none; }
footer a:hover { color: var(--cyan); }
.powered { font-weight: 800; color: #90aaba; }

dialog { color: var(--text); border: 1px solid #294759; border-radius: 22px; background: #0a1b28; box-shadow: 0 30px 90px rgba(0, 0, 0, .65); }
dialog::backdrop { background: rgba(1, 7, 12, .82); backdrop-filter: blur(8px); }
.auth-dialog { width: min(850px, calc(100vw - 28px)); max-width: calc(100vw - 28px); min-width: 0; padding: 0; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); overflow: hidden; }
.auth-dialog[open] { display: grid; }
.auth-intro { min-width: 0; padding: 44px; display: flex; flex-direction: column; justify-content: center; background: radial-gradient(circle at 20% 15%, rgba(53, 201, 242, .2), transparent 45%), #071722; }
.auth-intro h2 { font-size: 38px; margin-bottom: 10px; }
.auth-intro > p:last-child { color: var(--muted); line-height: 1.6; }
.auth-box { min-width: 0; padding: 34px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 20px; background: #06131d; border: 1px solid var(--line); border-radius: 12px; }
.auth-tabs button { min-width: 0; min-height: 38px; padding-inline: 7px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 850; color: var(--muted); }
.auth-tabs button.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px var(--cyan); }
.auth-form { display: grid; gap: 13px; }
.auth-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.auth-form input { width: 100%; min-height: 43px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #06131d; color: var(--text); }
.auth-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.password-wrap { position: relative; display: block; }
.show-password { position: absolute; right: 5px; top: 5px; width: 34px; height: 33px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.text-button { border: 0; background: transparent; color: var(--cyan); cursor: pointer; }
.guest-button { width: 100%; margin-top: 15px; }
.auth-message { min-height: 18px; margin: 12px 0 0; color: var(--danger); font-size: 11px; line-height: 1.4; }
.small-dialog { width: min(420px, calc(100% - 28px)); padding: 28px; }
.small-dialog h2 { margin-bottom: 5px; }
.small-dialog > p:not(.eyebrow) { color: var(--muted); }
.dialog-actions { display: grid; gap: 9px; margin-top: 22px; }

@media (max-width: 1100px) {
  .radar-layout { grid-template-columns: 290px minmax(350px, 1fr); }
  .detail-panel { position: absolute; z-index: 900; right: 18px; top: 92px; bottom: 50px; width: 310px; box-shadow: 0 20px 60px #000; transform: translateX(calc(100% + 30px)); transition: transform .25s; }
  .detail-panel.open { transform: translateX(0); }
}

@media (max-width: 720px) {
  body { overflow: hidden; }
  .app-shell { grid-template-rows: calc(60px + env(safe-area-inset-top)) minmax(0, 1fr); }
  .topbar { padding-top: calc(8px + env(safe-area-inset-top)); }
  .brand-mark { width: 36px; }
  .brand strong { font-size: 18px; }
  .status-chip span { display: none; }
  .status-chip { min-width: 38px; justify-content: center; padding: 0; }
  .account-label { display: none; }
  .account-button { padding-right: 6px; }
  .radar-layout { position: relative; display: block; padding: 0; }
  .map-panel { position: absolute; inset: 0 0 240px; border: 0; border-radius: 0; }
  .side-panel { position: absolute; inset: auto 0 0; height: 250px; border-radius: 18px 18px 0 0; z-index: 600; box-shadow: 0 -12px 40px rgba(0,0,0,.45); }
  .panel-heading { display: none; }
  .toolbar { grid-template-columns: auto 1fr; padding: 10px; }
  .filter-strip { display: flex; gap: 6px; padding: 0 10px 8px; overflow-x: auto; scrollbar-width: none; }
  .filter-strip::-webkit-scrollbar { display: none; }
  .filter-strip button { flex: 0 0 auto; min-width: 76px; }
  .primary-button { white-space: nowrap; }
  .toolbar .primary-button { font-size: 0; width: 43px; padding: 0; }
  .toolbar .primary-button span { font-size: 20px; }
  .list-heading { padding-block: 8px; }
  .aircraft-list { display: flex; overflow-x: auto; overflow-y: hidden; }
  .aircraft-card { flex: 0 0 250px; border-bottom: 0; border-right: 1px solid var(--line); }
  .empty-state { min-width: 100%; min-height: 100px; padding: 10px; }
  .radar-glyph { display: none; }
  .source-note { display: none; }
  .map-title { left: 52px; }
  .map-legend { bottom: 12px; }
  .detail-panel { position: absolute; inset: 0; width: auto; border-radius: 0; transform: translateY(100%); transition: transform .25s; }
  .detail-panel.open { transform: translateY(0); }
  footer { display: none; }
  .auth-dialog { width: calc(100vw - 24px); max-width: calc(100vw - 24px); }
  .auth-dialog[open] { display: block; max-height: calc(100dvh - 24px); overflow-x: hidden; overflow-y: auto; }
  .auth-intro { padding: 25px 25px 18px; }
  .auth-intro .brand-mark { display: none; }
  .auth-intro h2 { font-size: 29px; margin-bottom: 5px; }
  .auth-intro > p:last-child { font-size: 12px; margin-bottom: 0; }
  .auth-box { padding: 20px 24px 25px; }
}
