:root {
  --bg: #10121a;
  --panel: rgba(16, 18, 26, 0.92);
  --bar: rgba(6, 7, 12, 0.82);
  --edge: #2a2f42;
  --text: #c9cede;
  --dim: #6b7186;
  --accent: #57c7ff;
  --sel: #26405e;
}

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 12px/1.4 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

#map { position: absolute; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font: inherit; }

/* ---- top bar ---- */
#infobar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  padding: 4px 10px; background: var(--bar);
  border-bottom: 1px solid var(--edge);
}
#brand { color: var(--accent); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
#conn { display: flex; align-items: center; gap: 5px; color: var(--dim); }
#stats { color: var(--dim); }
#stats b { color: var(--text); font-weight: 600; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
  background: #555; box-shadow: 0 0 4px rgba(0,0,0,.6);
}
.dot.ok    { background: #2fd06a; box-shadow: 0 0 6px #2fd06a; }
.dot.warn  { background: #ffb020; box-shadow: 0 0 6px #ffb020; }
.dot.bad   { background: #ff4d4d; box-shadow: 0 0 6px #ff4d4d; }
.spacer { flex: 1; }

.tbtn {
  background: #1b2030; color: var(--text); border: 1px solid var(--edge);
  border-radius: 3px; padding: 3px 10px; cursor: pointer; font: inherit;
}
.tbtn:hover { background: #232a3e; }
.tbtn.active { border-color: var(--accent); color: var(--accent); }

/* ---- panels ---- */
.panel {
  position: absolute; z-index: 900;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 4px;
  box-shadow: 0 2px 14px rgba(0,0,0,.55);
}
.hidden { display: none !important; }

/* ---- aircraft table ---- */
#table_panel {
  top: 34px; right: 8px; bottom: 8px; width: 520px; max-width: 72vw;
  overflow: auto; padding: 2px;
}
#atable { border-collapse: collapse; width: 100%; }
#atable th, #atable td {
  padding: 3px 7px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid #1b1e2c;
}
#atable th {
  position: sticky; top: 0; background: #141725; color: var(--dim);
  cursor: pointer; user-select: none; font-weight: 600; z-index: 5;
}
#atable th:hover { color: var(--text); }
#atable th.sorted { color: var(--accent); }
#atable td { color: var(--text); font-variant-numeric: tabular-nums; }
#atable td.call { text-align: left; font-weight: 600; }
#atable td.id { text-align: left; color: var(--dim); }
#atable td.type { text-align: center; color: var(--dim); font-weight: 700; }
#atable tbody tr { cursor: pointer; }
#atable tbody tr:hover { background: #1d2334; }
#atable tbody tr.selected { background: var(--sel); }
#atable tbody tr.endoftrack td.call { text-decoration: line-through; color: var(--dim); }

/* ---- detail panel ---- */
#detail_panel {
  top: 34px; left: 8px; width: 340px; max-width: 60vw;
  max-height: calc(100% - 120px); display: flex; flex-direction: column;
  padding: 8px 10px;
}
#detail_head {
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--edge); padding-bottom: 6px; margin-bottom: 6px;
}
#detail_title { color: var(--accent); font-size: 14px; font-weight: 700; }
#follow_label { color: var(--dim); cursor: pointer; display: flex; align-items: center; gap: 3px; }
#detail_fields { overflow-y: auto; }
.frow { display: flex; border-bottom: 1px solid #171a27; padding: 2px 0; }
.frow .fk { width: 46%; color: var(--dim); flex-shrink: 0; padding-right: 8px; word-break: break-all; }
.frow .fv { flex: 1; text-align: right; word-break: break-all; font-variant-numeric: tabular-nums; }
.frow.fgroup .fk { color: var(--accent); font-weight: 700; padding-top: 6px; }
.frow.fgroup { border-bottom: none; }
.fswatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 5px; vertical-align: -1px; }
#detail_raw { margin-top: 6px; color: var(--dim); }
#detail_raw summary { cursor: pointer; outline: none; }
#detail_raw pre {
  max-height: 220px; overflow: auto; font-size: 11px; color: var(--text);
  background: #0b0d15; border: 1px solid var(--edge); border-radius: 3px; padding: 6px;
}

/* ---- legend ---- */
#legend {
  position: absolute; left: 10px; bottom: 12px; z-index: 800;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 4px;
  padding: 5px 8px; color: var(--dim); font-size: 11px;
}
#legend .grad { height: 8px; width: 180px; border-radius: 2px; margin: 3px 0 2px; }
#legend .ends { display: flex; justify-content: space-between; width: 180px; }

/* ---- markers ---- */
.ac-icon { background: none; border: none; }
.ac-icon svg { display: block; width: 34px; height: 34px; overflow: visible; }
.ac-icon .sel-ring {
  position: absolute; inset: 3px; border: 2px solid #fff; border-radius: 50%;
  opacity: .9; box-shadow: 0 0 8px #fff;
}

/* ---- tooltip ---- */
.ac-tip {
  background: var(--panel); border: 1px solid var(--edge); color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,.5); font-size: 11px; padding: 4px 7px;
}
.ac-tip::before { border-top-color: var(--edge) !important; }

/* ---- scrollbars ---- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #232a3e; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
