:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel-2: #16223b;
  --line: #22314f;
  --text: #e6ecf7;
  --muted: #8796b3;
  --accent: #ffb020;
  --air: #4fc3ff;
  --down: #ff8a4c;
  --up: #7be38b;
  --ground: #9aa6bd;
  --danger: #ff5370;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-icon { width: 22px; height: 22px; fill: var(--accent); transform: rotate(45deg); }
.tabs { display: flex; gap: 4px; }
.tab {
  background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600;
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--bg); background: var(--accent); }
.badge { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.status-line { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ground); }
.dot.live { background: var(--up); box-shadow: 0 0 0 0 rgba(123,227,139,.6); animation: pulse 2s infinite; }
.dot.err { background: var(--danger); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(123,227,139,0); } 100% { box-shadow: 0 0 0 0 rgba(123,227,139,0); } }

main { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; }
.view.active { display: flex; }
#view-board.active, #view-watch.active { display: block; overflow-y: auto; }

#map { flex: 1; height: 100%; background: #0a1020; }
.leaflet-container { font: inherit; }
.side {
  width: 360px; max-width: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}
#search {
  margin: 12px; padding: 9px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font: inherit;
}
.list-head { display: flex; justify-content: space-between; padding: 4px 14px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.flight-list { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; flex: 1; }
.flight-list li {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.flight-list li:hover, .flight-list li.sel { background: var(--panel-2); }
.cs { font-family: var(--mono); font-weight: 600; }
.route-sm { color: var(--muted); font-size: 12px; grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.st { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; white-space: nowrap; align-self: start; }
.st-air { background: rgba(79,195,255,.15); color: var(--air); }
.st-down { background: rgba(255,138,76,.15); color: var(--down); }
.st-up { background: rgba(123,227,139,.15); color: var(--up); }
.st-ground, .st-arrived { background: rgba(154,166,189,.15); color: var(--ground); }
.st-arrived { color: var(--up); }
.st-emerg { background: rgba(255,83,112,.2); color: var(--danger); }

.detail { margin: 0 12px 10px; padding: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.detail .d-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.detail .d-cs { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.detail .d-airline { color: var(--muted); font-size: 13px; }
.d-route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 12px 0 6px; gap: 6px; }
.d-route .ap { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.d-route .city { color: var(--muted); font-size: 12px; }
.d-route .to { text-align: right; }
.progress { height: 6px; background: var(--line); border-radius: 3px; position: relative; margin: 6px 0 12px; }
.progress > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; }
.d-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 13px; }
.d-stats b { display: block; font-family: var(--mono); font-size: 15px; color: var(--text); }
.d-stats span { color: var(--muted); }
.d-actions { display: flex; gap: 8px; margin-top: 12px; }

.btn {
  background: var(--accent); color: var(--bg); border: 0; border-radius: 8px;
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.x { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; }

.plane-icon svg { width: 22px; height: 22px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }
.plane-icon.sel svg path { fill: var(--accent); }
.plane-icon.watched svg path { fill: #ff5fd2; }

.board-wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }
.board-controls { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.board-controls label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
select, .watch-add input, #airport-input {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}
#airport-input { min-width: 320px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.small-note { font-size: 12px; margin: 0 0 14px; }
.board-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.board-col { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; overflow-x: auto; }
.board-col h2 { margin: 0 0 10px; font-size: 16px; }
.board-col h2 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.schedule { margin-top: 16px; }
table.board { width: 100%; border-collapse: collapse; }
.board th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.board td { padding: 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.board tr:last-child td { border-bottom: 0; }
.board td.mono, .mono { font-family: var(--mono); }
.board tr.click { cursor: pointer; }
.board tr.click:hover { background: var(--panel-2); }
.empty { color: var(--muted); padding: 14px 8px; text-align: center; }
.muted { color: var(--muted); }

.watch-add { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.watch-list, .event-log { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.watch-list li {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center;
}
.event-log li { background: var(--panel); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.event-log time { color: var(--muted); font-family: var(--mono); margin-right: 8px; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 2000; }
.toast {
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 10px; padding: 12px 16px;
  max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: slide .25s ease-out;
}
.toast b { display: block; margin-bottom: 2px; }
@keyframes slide { from { transform: translateY(12px); opacity: 0; } }

@media (max-width: 860px) {
  .view.active#view-map { flex-direction: column; }
  #map { height: 55%; flex: none; }
  .side { width: 100%; border-left: 0; border-top: 1px solid var(--line); flex: 1; }
  .board-grid { grid-template-columns: 1fr; }
  .status-line { margin-left: 0; }
  .watch-list li { grid-template-columns: 1fr auto; }
  #airport-input { min-width: 0; width: 100%; }
  .board-controls label { flex-wrap: wrap; width: 100%; }
}
