:root {
  --bg: #ffffff;
  --bg-soft: #f4f6fa;
  --fg: #111827;
  --muted: #5b6474;
  --line: #e3e7ee;
  --brand: #0a58ca;
  --brand-soft: #e7f0ff;
  --accent: #ffc107;
  --danger: #d92d20;
  --ok: #067647;
  --shadow: 0 8px 30px rgba(15, 23, 42, .14);
  --radius: 12px;
  --panel-w: 360px;
  --header-h: 56px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-size: 14px; }
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }

/* ---------- Nagłówek ---------- */
.rl-header {
  position: fixed; inset: 0 0 auto 0; height: var(--header-h); z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.rl-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--fg); text-decoration: none; white-space: nowrap; letter-spacing: -.02em; }
.rl-logo svg { width: 28px; height: 28px; }
.rl-logo span b { color: var(--brand); }
.rl-header nav { margin-left: auto; display: flex; gap: 4px; }
.rl-header nav button, .rl-header nav a {
  border: 0; background: transparent; color: var(--muted); padding: 8px 10px; border-radius: 8px; text-decoration: none; font-weight: 600;
}
.rl-header nav button:hover, .rl-header nav a:hover { background: var(--bg-soft); color: var(--fg); }

/* ---------- Wyszukiwarka ---------- */
.rl-search { position: relative; flex: 1; max-width: 480px; }
.rl-search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft); font: inherit; font-size: 15px; color: var(--fg); outline: none;
}
.rl-search input:focus { border-color: var(--brand); background: var(--bg); box-shadow: 0 0 0 3px var(--brand-soft); }
.rl-search > svg { position: absolute; left: 12px; top: 12px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.rl-results {
  position: absolute; top: 46px; left: 0; right: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; display: none; z-index: 30;
}
.rl-results.open { display: block; }
.rl-results .grp { padding: 8px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.rl-results .item { display: flex; gap: 10px; align-items: center; padding: 8px 12px; cursor: pointer; }
.rl-results .item:hover, .rl-results .item.active { background: var(--brand-soft); }
.rl-results .item .ic { width: 28px; height: 28px; border-radius: 8px; background: var(--bg-soft); display: grid; place-items: center; flex: none; font-size: 15px; }
.rl-results .item .t { font-weight: 600; }
.rl-results .item .s { color: var(--muted); font-size: 12px; }
.rl-results .empty { padding: 12px; color: var(--muted); }

/* ---------- Mapa ---------- */
#map { position: fixed; top: var(--header-h); left: 0; right: var(--panel-w); bottom: 0; }
body.embed #map { top: 0; right: 0; }
.maplibregl-ctrl-attrib { font-size: 11px; }
.rl-counter {
  position: absolute; left: 10px; bottom: 10px; z-index: 5; background: rgba(255,255,255,.92); border-radius: 8px;
  padding: 5px 10px; font-size: 12px; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.15); pointer-events: none;
}
.rl-notice {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 5; background: #111827; color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; display: none; white-space: nowrap;
}
.rl-notice.show { display: block; }

/* ---------- Panel boczny ---------- */
.rl-panel {
  position: fixed; top: var(--header-h); right: 0; bottom: 0; width: var(--panel-w); z-index: 10;
  background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain;
}
.rl-panel .sec { padding: 16px; border-bottom: 1px solid var(--line); }
.rl-panel h1 { font-size: 18px; margin: 0 0 6px; letter-spacing: -.01em; }
.rl-panel h2 { font-size: 13px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.rl-panel p { margin: 0 0 8px; color: var(--muted); line-height: 1.5; }
.rl-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 18px; line-height: 1; z-index: 2; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 10px; font-weight: 600; font-size: 13px; color: var(--fg); }
.chip:hover { border-color: var(--brand); color: var(--brand); }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 700; background: var(--brand); color: #fff; }
.btn.secondary { background: var(--bg-soft); color: var(--fg); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.on { background: var(--ok); color: #fff; }

/* samolot */
.ac-photo { position: relative; aspect-ratio: 16/9; background: var(--bg-soft) center/cover no-repeat; }
.ac-photo .credit { position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.8); text-decoration: none; }
.ac-photo.none { display: grid; place-items: center; color: var(--muted); font-size: 12px; aspect-ratio: 16/6; }
.ac-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ac-head .cs { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.ac-head .fn { color: var(--muted); font-weight: 600; }
.ac-airline { color: var(--muted); margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--bg-soft); color: var(--muted); vertical-align: middle; }
.badge.mil { background: #e8f5e0; color: #2e6b12; }
.badge.est { background: #fff4d6; color: #8a5a00; }
.badge.emg { background: #fde8e7; color: var(--danger); }

.route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.route .ap { min-width: 0; }
.route .ap.r { text-align: right; }
.route .code { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.route .city { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route .mid { color: var(--muted); font-size: 18px; }
.progress { margin-top: 12px; height: 6px; background: var(--bg-soft); border-radius: 99px; position: relative; }
.progress i { position: absolute; inset: 0 auto 0 0; background: var(--brand); border-radius: 99px; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }
.route-note { font-size: 11px; color: var(--muted); margin-top: 8px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.kv .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kv .v { font-size: 15px; font-weight: 700; margin-top: 2px; }
.kv .v small { font-weight: 500; color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs button { flex: 1; border: 0; border-radius: 8px; padding: 7px; background: var(--bg-soft); color: var(--muted); font-weight: 700; font-size: 12px; }
.tabs button.on { background: var(--brand-soft); color: var(--brand); }
.chart svg { width: 100%; height: 110px; display: block; }
.chart .empty { color: var(--muted); font-size: 12px; padding: 20px 0; text-align: center; }

.near { list-style: none; margin: 0; padding: 0; }
.near li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.near li:hover .t { color: var(--brand); }
.near .t { font-weight: 700; }
.near .s { color: var(--muted); font-size: 12px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* reklama */
.ad-slot {
  margin: 16px auto; width: 300px; min-height: 250px; display: grid; place-items: center; border: 1px dashed #c9d0db;
  border-radius: 8px; color: #9aa3b2; font-size: 12px; background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 10px, #f3f5f8 10px, #f3f5f8 20px);
}

/* modal osadzania */
.rl-modal { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; padding: 16px; }
.rl-modal.open { display: flex; }
.rl-modal .box { background: var(--bg); border-radius: 14px; width: min(920px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow); display: grid; grid-template-columns: 320px 1fr; }
.rl-modal .form { padding: 20px; border-right: 1px solid var(--line); }
.rl-modal .form h2 { margin: 0 0 4px; font-size: 18px; }
.rl-modal .form p { color: var(--muted); margin: 0 0 16px; line-height: 1.5; }
.rl-modal label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 4px; }
.rl-modal input[type=text], .rl-modal select { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; }
.rl-modal .check { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--fg); font-size: 13px; }
.rl-modal textarea { width: 100%; height: 130px; font: 12px/1.4 ui-monospace, Menlo, monospace; border: 1px solid var(--line); border-radius: 8px; padding: 8px; resize: vertical; margin-top: 12px; }
.rl-modal .preview { padding: 20px; display: flex; flex-direction: column; gap: 8px; min-height: 420px; }
.rl-modal .preview iframe { flex: 1; width: 100%; border: 1px solid var(--line); border-radius: 10px; min-height: 380px; }

/* ---------- Embed ---------- */
body.embed .rl-header, body.embed .rl-panel { display: none; }
.em-bar { position: absolute; top: 10px; left: 10px; right: 56px; z-index: 12; display: flex; gap: 8px; align-items: flex-start; }
.em-brand { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 10px; padding: 0 10px; height: 40px; font-weight: 800; text-decoration: none; color: var(--fg); box-shadow: 0 1px 6px rgba(0,0,0,.18); white-space: nowrap; }
.em-brand svg { width: 22px; height: 22px; }
.em-brand b { color: var(--brand); }
body.embed .rl-search input { background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.18); border-color: transparent; }
.em-card { position: absolute; left: 10px; right: 10px; bottom: 30px; z-index: 12; max-width: 380px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; display: none; }
.em-card.open { display: block; }
.em-card .rl-close { background: var(--bg-soft); color: var(--fg); top: 8px; right: 8px; width: 28px; height: 28px; font-size: 16px; }
.em-card .more { display: inline-block; margin-top: 10px; font-weight: 700; text-decoration: none; }
body.embed .rl-counter { bottom: 30px; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  :root { --panel-w: 0px; }
  .rl-header { padding: 0 10px; gap: 8px; }
  .rl-logo span { display: none; }
  .rl-header nav .hide-m { display: none; }
  #map { right: 0; }
  .rl-panel {
    top: auto; left: 0; width: auto; max-height: 62vh; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; box-shadow: var(--shadow); transform: translateY(100%); transition: transform .25s ease;
  }
  .rl-panel.open { transform: none; }
  .rl-modal .box { grid-template-columns: 1fr; }
  .rl-modal .form { border-right: 0; border-bottom: 1px solid var(--line); }
  .em-bar { right: 50px; }
  .em-brand span { display: none; }
}
