* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: absolute; inset: 0; }

/* Sol sütun: üstte panel, altında uçak kartı (ayrı kutular). */
#left {
  position: absolute; top: 12px; left: 12px; z-index: 12;
  width: 320px; display: flex; flex-direction: column; gap: 8px;
  max-height: calc(100vh - 24px); pointer-events: none;
}
#left > * { pointer-events: auto; }

#panel {
  background: rgba(15, 23, 42, 0.92); color: #e5e7eb;
  padding: 12px 14px; border-radius: 14px;
  border: 1px solid rgba(148,163,184,0.14);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45); backdrop-filter: blur(8px);
  font-size: 13px; line-height: 1.5; overflow-y: auto; flex: 0 1 auto;
}
.panel-header { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 6px; }
.panel-header .tld { color: #38bdf8; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #ef4444; transition: background .3s; }
.dot.on { background: #22c55e; }
.stat { font-size: 13px; }
.stat #count { font-size: 18px; font-weight: 700; color: #fff; }
.hint { color: #9ca3af; font-size: 12px; margin-top: 6px; }

.mini-btn {
  background: #374151; color: #e5e7eb; border: none; border-radius: 6px;
  padding: 4px 8px; font-size: 12px; cursor: pointer; margin-top: 6px;
}
.mini-btn:hover { background: #4b5563; }

.filters { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.filters.hidden { display: none; }
.filters label { font-size: 12px; color: #cbd5e1; display: flex; flex-direction: column; gap: 3px; }
.filters .range { display: flex; gap: 6px; }
.filters input[type="number"], .filters input[type="text"] { width: 100%; background: #111827; border: 1px solid #374151; color: #e5e7eb; border-radius: 5px; padding: 3px 6px; font-size: 12px; }
.filters .chk { flex-direction: row; align-items: center; gap: 6px; }

/* ---- Uçak kartı (Flightradar tarzı) ---- */
.detail {
  background: rgba(15, 23, 42, 0.94); color: #e5e7eb;
  border: 1px solid rgba(148,163,184,0.14); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45); backdrop-filter: blur(8px);
  padding: 10px 12px 12px; overflow-y: auto; flex: 1 1 auto; min-height: 0;
}
.detail.hidden { display: none; }
.card-close {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(2, 6, 23, 0.6); color: #e5e7eb; font-size: 15px; line-height: 1;
  backdrop-filter: blur(4px);
}
.card-close:hover { background: rgba(2, 6, 23, 0.85); }
.sheet-grip { display: none; }

.fr-photo { position: relative; margin: -10px -12px 9px; border-radius: 10px; overflow: hidden; background: #0b1220; }
.fr-photo img { width: 100%; display: block; aspect-ratio: 3 / 2; object-fit: cover; }
.fr-photo { border-radius: 13px 13px 0 0; }
.fr-photo .credit { position: absolute; right: 5px; bottom: 5px; font-size: 9px; color: #e5e7eb; background: rgba(0,0,0,0.55); padding: 1px 5px; border-radius: 3px; }
.fr-photo .ph-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  aspect-ratio: 3 / 1.4; color: #475569; font-size: 26px;
  background: repeating-linear-gradient(135deg, #0f172a, #0f172a 8px, #111c33 8px, #111c33 16px);
}
.fr-photo .ph-empty span { font-size: 11px; letter-spacing: 1px; color: #64748b; }

.fr-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fr-cs { font-size: 19px; font-weight: 800; color: #fff; letter-spacing: 0.4px; }
.fr-sub { font-size: 11px; color: #93c5fd; }
.fr-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 3px; font-size: 11px; color: #cbd5e1; }
.fr-chips b { color: #fff; font-weight: 600; }
.fr-chips i { color: #475569; font-style: normal; }
.fr-chips .mil { color: #fbbf24; }
.fr-chips .gnd { color: #fca5a5; }

.route-hdr { margin: 9px 0; padding: 8px 0 6px; border-top: 1px solid rgba(255,255,255,0.1); border-bottom: 1px solid rgba(255,255,255,0.1); }
.route-hdr.hidden { display: none; }
.rh-codes { display: flex; align-items: center; justify-content: space-between; font-size: 21px; font-weight: 800; color: #fff; letter-spacing: 0.5px; }
.rh-codes .arrow { color: #38bdf8; font-size: 14px; }
.rh-cities { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: #94a3b8; margin-top: 1px; }
.rh-cities span { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-cities span:last-child { text-align: right; }
.rh-bar { position: relative; height: 3px; border-radius: 2px; background: rgba(148,163,184,0.28); margin: 12px 0 4px; }
.rh-bar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: #38bdf8; }
.rh-bar i { position: absolute; top: -9px; transform: translateX(-50%) rotate(90deg); font-style: normal; font-size: 12px; color: #fff; }
.rh-meta { display: flex; justify-content: space-between; font-size: 10px; color: #94a3b8; }

.fr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 8px; }
.fr-grid .cell { background: rgba(255,255,255,0.05); border-radius: 7px; padding: 5px 7px; }
.fr-grid .lbl { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.6px; color: #94a3b8; }
.fr-grid .val { display: block; font-size: 14px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.fr-grid .val small { font-size: 10px; font-weight: 500; color: #94a3b8; margin-left: 3px; }
.fr-grid .up { color: #4ade80; } .fr-grid .down { color: #f87171; } .fr-grid .level { color: #94a3b8; }
.fr-info { display: none; margin-top: 9px; padding-top: 7px; border-top: 1px solid rgba(255,255,255,0.1); }
.fr-info.on { display: block; }
.fr-info-title { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.6px; color: #94a3b8; margin-bottom: 3px; }
.fr-info .row { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; padding: 1.5px 0; }
.fr-info .row span { color: #94a3b8; white-space: nowrap; }
.fr-info .row b { color: #e5e7eb; font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-foot { margin-top: 7px; font-size: 10px; color: #64748b; }

#controls {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: rgba(17,24,39,0.92); color: #e5e7eb; padding: 8px 10px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35); backdrop-filter: blur(4px);
}
.mode-row { display: flex; gap: 6px; justify-content: center; }
.mode-btn {
  background: #374151; color: #e5e7eb; border: none; border-radius: 6px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.mode-btn.active { background: #2563eb; color: #fff; }
/* Isı haritası çubuğu (zaman penceresi + filtre bilgisi) */
.heat-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; justify-content: center; }
.heat-bar.hidden { display: none; }
.heat-bar select { background: #111827; color: #e5e7eb; border: 1px solid #374151; border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.heat-note { font-size: 11px; color: #93c5fd; }

/* Harita katmanı seçici */
.maps {
  position: absolute; bottom: 78px; left: 50%; transform: translateX(-50%); z-index: 14;
  background: rgba(15,23,42,0.95); border: 1px solid rgba(148,163,184,0.16);
  border-radius: 14px; padding: 10px 12px; color: #e5e7eb;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(8px); min-width: 210px;
}
.maps.hidden { display: none; }
.maps-title { font-size: 10px; text-transform: uppercase; letter-spacing: .7px; color: #94a3b8; margin-bottom: 6px; }
#maps-list { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.map-opt {
  background: rgba(255,255,255,0.06); border: 1px solid transparent; color: #e5e7eb;
  border-radius: 8px; padding: 7px 9px; font-size: 12px; cursor: pointer; text-align: left;
}
.map-opt:hover { background: rgba(255,255,255,0.12); }
.map-opt.on { background: #2563eb; border-color: #60a5fa; color: #fff; font-weight: 600; }
.maps-chk { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: #cbd5e1; }
.maps-chk input:disabled + span { opacity: .5; }

#legend {
  position: absolute; bottom: 20px; left: 12px; z-index: 10;
  background: rgba(17,24,39,0.9); color: #e5e7eb; padding: 8px 10px;
  border-radius: 8px; font-size: 11px;
}
.legend-title { margin-bottom: 4px; }
.legend-bar { height: 8px; width: 160px; border-radius: 4px; background: linear-gradient(90deg, #00c853, #ffd600, #ff6d00, #d500f9); }
.legend-labels { display: flex; justify-content: space-between; margin-top: 2px; color: #9ca3af; }

#toasts { position: absolute; top: 12px; right: 12px; z-index: 20; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: rgba(17, 24, 39, 0.95); color: #e5e7eb; padding: 8px 12px; border-radius: 8px;
  font-size: 12px; box-shadow: 0 6px 24px rgba(0,0,0,0.4); border-left: 3px solid #38bdf8;
  animation: slidein .2s ease-out; transition: opacity .3s;
}
.toast b { color: #fff; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.maplibregl-popup-content { font-size: 12px; }

/* Hesap */
.account { margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 8px; }
.account.hidden, #acct-in.hidden { display: none; }
#acct-out input { width: 100%; margin-bottom: 5px; background: #111827; border: 1px solid #374151; color: #e5e7eb; border-radius: 5px; padding: 4px 6px; font-size: 12px; }
.acct-btns { display: flex; gap: 6px; }
.acct-btns .mini-btn { flex: 1; margin-top: 2px; }
.acct-msg { font-size: 11px; color: #fca5a5; margin-top: 4px; min-height: 14px; }
.acct-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acct-user span { font-weight: 600; color: #fff; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Arama */
.search { width: 100%; margin-top: 8px; background: #111827; border: 1px solid #374151; color: #e5e7eb; border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.search::placeholder { color: #6b7280; }
.pbtns { display: flex; gap: 6px; margin-top: 6px; }
.pbtns .mini-btn { flex: 1; margin-top: 0; }

/* Telefon / dar ekran */
@media (max-width: 640px) {
  #left { left: 8px; right: 8px; top: 8px; width: auto; max-height: none; }
  #panel { padding: 9px 11px; font-size: 12px; max-height: 42vh; }

  /* Uçak kartı ekranın altına yapışan çekmece: yarı açık (peek) ↔ tam açık.
     Yarı açıkken harita ve uçuş rotası görünür kalır. */
  .detail {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    border-radius: 18px 18px 0 0;
    padding: 6px 14px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 34px rgba(0,0,0,0.55);
    max-height: 27vh; transition: max-height .22s ease;
    touch-action: pan-y;
  }
  .detail.full { max-height: 76vh; }
  /* Yarı açıkta yalnız künye satırları görünür; foto/künye/düğmeler gizli. */
  .detail:not(.full) .fr-photo,
  .detail:not(.full) .fr-info,
  .detail:not(.full) .fr-acts,
  .detail:not(.full) .fr-foot { display: none; }
  .detail:not(.full) .fr-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .detail:not(.full) .fr-grid .cell:nth-child(n+5) { display: none; }
  .detail:not(.full) .fr-grid .val { font-size: 12.5px; }
  .detail:not(.full) .route-hdr { margin: 6px 0 4px; padding: 6px 0 2px; }
  .detail:not(.full) .rh-codes { font-size: 17px; }
  .sheet-grip { cursor: grab; }
  .sheet-grip::after {
    content: ''; position: absolute; left: 0; right: 0; top: 0; height: 34px;
  }
  .sheet-grip {
    display: block; width: 38px; height: 4px; margin: 2px auto 8px;
    border-radius: 2px; background: rgba(148,163,184,0.45);
  }
  .fr-photo { margin: 0 -14px 9px; border-radius: 0; }
  .fr-photo img { aspect-ratio: 16 / 9; }
  .fr-photo .ph-empty { aspect-ratio: 16 / 6; }
  .card-close { top: 6px; right: 10px; }
  /* Kart açıkken alttaki kontroller altında kalmasın */
  body.card-open #controls { display: none; }
  .panel-header { font-size: 14px; margin-bottom: 4px; }
  .stat #count { font-size: 15px; }
  .hint { font-size: 11px; }
  #legend { display: none; }                 /* kontrollerle çakışmasın */
  #controls { bottom: 12px; padding: 6px 8px; max-width: calc(100vw - 16px); }
  .mode-btn { padding: 5px 9px; font-size: 12px; }
  .maps { bottom: 74px; width: calc(100vw - 24px); }
  #maps-list { grid-template-columns: 1fr 1fr; }
  #toasts { max-width: 70vw; }
}

.fr-photo .ph-empty .note { display: block; font-size: 10px; font-style: normal; color: #7c8ba1; margin-top: 2px; }

/* Favoriler + takip */
.fav-title { display: flex; align-items: center; gap: 6px; margin-top: 9px; color: #fbbf24; font-size: 11.5px; }
.fav-title span { color: #64748b; }
#favlist { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; max-height: 132px; overflow-y: auto; }
#favlist .f { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; }
#favlist .f b { color: #e5e7eb; font-weight: 600; cursor: pointer; }
#favlist .f b:hover { color: #38bdf8; }
#favlist .f .st { color: #64748b; font-size: 10.5px; margin-left: auto; margin-right: 6px; }
#favlist .f .st.on { color: #4ade80; }
#favlist .f button { background: none; border: none; color: #f87171; cursor: pointer; font-size: 12px; padding: 0 2px; }
.fr-acts { display: flex; gap: 6px; margin-top: 7px; }
.fr-acts button {
  flex: 1; background: #1f2937; color: #e5e7eb; border: 1px solid #374151; border-radius: 7px;
  padding: 5px 8px; font-size: 11.5px; cursor: pointer;
}
.fr-acts button:hover { background: #374151; }
.fr-acts button.on { background: #b45309; border-color: #f59e0b; color: #fff; }
.fr-acts button.follow.on { background: #1d4ed8; border-color: #3b82f6; }

/* ---- Kiosk (Raspberry Pi cihazı) ---- */
#kiosk-bar {
  position: absolute; top: 10px; right: 56px; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  background: rgba(15,23,42,0.92); border: 1px solid rgba(148,163,184,0.14);
  border-radius: 12px; padding: 7px 12px; color: #e5e7eb; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45); backdrop-filter: blur(8px);
  font-variant-numeric: tabular-nums;
}
#kiosk-bar.hidden { display: none; }
#kiosk-bar .low { color: #fca5a5; }
#kiosk-bar button {
  background: none; border: none; color: #cbd5e1; font-size: 17px; cursor: pointer; padding: 0 2px;
}
/* Dokunmatik ekranda hedefler büyür, hesap paneli gizlenir (giriş cihazda) */
body.kiosk .mini-btn { padding: 9px 14px; font-size: 14px; }
body.kiosk .search { padding: 11px 12px; font-size: 15px; }
body.kiosk .mode-btn { padding: 10px 18px; font-size: 15px; }
body.kiosk #account-toggle { display: none; }
body.kiosk .filters label { font-size: 13px; }
body.kiosk .filters input { padding: 9px 10px; font-size: 15px; }
body.kiosk .fr-acts button { padding: 10px 12px; font-size: 13px; }

/* ---- Yuvarlak ekran (dairesel panel: köşeler kesik) ----
   Güvenli alan = daire içine sığan kare (kenar ≈ çap × 0.707).
   Tüm arayüz bu bandın içinde kalır, köşelere hiçbir şey konmaz. */
body.round #left {
  left: 50%; right: auto; transform: translateX(-50%);
  top: 7%; width: 66%; max-height: 42%;
}
body.round #panel { padding: 8px 10px; text-align: center; border-radius: 16px; }
body.round .panel-header { justify-content: center; font-size: 14px; margin-bottom: 2px; }
body.round .stat { font-size: 12px; }
body.round .stat #count { font-size: 16px; }
body.round .hint, body.round #legend, body.round .maplibregl-ctrl-bottom-left,
body.round .maplibregl-ctrl-top-right { display: none; }
body.round .pbtns { justify-content: center; }
body.round #controls { bottom: 8%; padding: 6px 8px; border-radius: 14px; }
body.round .maps { bottom: 20%; min-width: 0; width: 74%; }
body.round .mode-btn { padding: 7px 11px; font-size: 12px; }
body.round #kiosk-bar { top: 4%; right: 50%; transform: translateX(50%); padding: 5px 10px; font-size: 12px; }
body.round .detail {
  position: fixed; left: 12%; right: 12%; bottom: 5%; top: auto;
  max-height: 44%; border-radius: 18px; padding: 8px 12px;
}
body.round .detail .fr-photo, body.round .detail .fr-info { display: none; }
body.round .fr-grid { grid-template-columns: 1fr 1fr; }
body.round .fr-cs { font-size: 16px; }
body.round #toasts { top: auto; bottom: 22%; right: 50%; transform: translateX(50%); align-items: center; }

/* Çok küçük yuvarlak paneller (240–320 px): sadece en gerekli bilgi */
@media (max-width: 360px) {
  body.round #left { top: 5%; width: 74%; }
  body.round .panel-header strong { display: none; }
  body.round .search, body.round .pbtns { display: none; }
  body.round #controls { display: none; }
  body.round .detail { left: 8%; right: 8%; bottom: 6%; max-height: 46%; }
  body.round .fr-grid .cell:nth-child(n+5) { display: none; }
  body.round .fr-chips, body.round .fr-acts { display: none; }
}
.fr-chips .est { color: #a5b4fc; }

/* Dil seçici */
.lang {
  width: 100%; margin-top: 6px; background: #111827; color: #e5e7eb;
  border: 1px solid #374151; border-radius: 6px; padding: 4px 6px; font-size: 12px;
}
body.round .lang, body.kiosk .lang { font-size: 13px; padding: 6px 8px; }
