/* Approach Control - UI shell.
   The aesthetic is an airport operations room: dark, dense, high-contrast, with a
   single amber accent for anything that needs a human decision. */

:root {
  --bg: #0a0e14;
  --bg-2: #111823;
  --bg-3: #18212f;
  --panel: rgba(13, 19, 28, 0.94);
  --panel-solid: #0d131c;
  --line: #24303f;
  --line-soft: #1b242f;
  --ink: #e8eef6;
  --ink-2: #9fb0c4;
  --ink-3: #6b7d92;
  --accent: #ffb02e;
  --accent-dim: #8a5f14;
  --good: #3ddc84;
  --warn: #ffb02e;
  --bad: #ff5f56;
  --info: #4aa8ff;
  --runway: #2b3442;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* `display: grid` on .overlay would otherwise beat the hidden attribute's default
   display:none, leaving an invisible full-screen layer eating every click. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#view.dragging { cursor: grabbing; }
#view.building { cursor: crosshair; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- overlays --- */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 35%, #12202f 0%, #070a0e 70%);
  z-index: 100;
  padding: 24px 16px;
  overflow: auto;
}

.boot-card {
  width: min(680px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.boot-title { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.boot-mark { color: var(--accent); display: grid; place-items: center; flex: 0 0 auto; }
.boot-title h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
.boot-sub { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }

.boot-status { color: var(--ink-2); font-size: 13px; padding: 10px 0; }
.boot-error {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: rgba(255, 95, 86, 0.12); border: 1px solid rgba(255, 95, 86, 0.4);
  color: #ffc9c5; font-size: 13px; white-space: pre-wrap;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin-bottom: 5px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; font-size: 14px;
}
input.short { width: 96px; }
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.scenarios { display: grid; gap: 10px; margin: 18px 0; }
.scenario {
  text-align: left; display: block; width: 100%; cursor: pointer;
  padding: 13px 15px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; transition: border-color .12s, background .12s;
}
.scenario:hover { border-color: var(--ink-3); }
.scenario[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 176, 46, 0.08); }
.scenario-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.scenario-name { font-weight: 650; font-size: 15px; }
.scenario-diff { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); }
.scenario-desc { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.scenario-money { margin-top: 7px; font-size: 12px; color: var(--ink-3); font-family: var(--mono); }

.boot-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.boot-hint { margin: 16px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--ink-2);
}

button {
  cursor: pointer; font-family: inherit; font-size: 13.5px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink);
  transition: background .12s, border-color .12s, opacity .12s;
}
button:hover:not(:disabled) { background: #202c3c; border-color: var(--ink-3); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a1206; font-weight: 650; }
button.primary:hover:not(:disabled) { background: #ffc04f; border-color: #ffc04f; }
button.ghost { background: transparent; }
button.danger { border-color: rgba(255, 95, 86, .5); color: #ffb3ae; }
button.danger:hover:not(:disabled) { background: rgba(255, 95, 86, .14); }
button.small { padding: 5px 10px; font-size: 12px; }

.save-list { display: grid; gap: 7px; margin-top: 12px; }
.save-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 12.5px;
}
.save-row .meta { color: var(--ink-3); font-family: var(--mono); font-size: 11.5px; }

/* -------------------------------------------------------------------- hud --- */

.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: stretch; gap: 1px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.hud-group { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
.hud-group + .hud-group { border-left: 1px solid var(--line-soft); }
.hud-identity { gap: 9px; }
.hud-icao {
  font-weight: 700; font-size: 15px; letter-spacing: 0.06em; color: var(--accent);
  background: rgba(255, 176, 46, .1); padding: 3px 8px; border-radius: 5px;
}
.hud-name { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.hud-clock { gap: 10px; }
#hudDate { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
#hudTime { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }

.hud-fast {
  font-weight: 700; font-size: 10.5px; letter-spacing: 0.08em; color: #1a1206;
  background: var(--warn); padding: 3px 7px; border-radius: 5px;
}

.speeds { display: flex; gap: 2px; background: var(--bg-2); padding: 2px; border-radius: var(--radius-sm); }
.speeds button {
  padding: 4px 8px; font-size: 11.5px; border: none; background: transparent;
  color: var(--ink-3); border-radius: 4px; font-family: var(--mono);
}
.speeds button:hover { background: var(--bg-3); color: var(--ink); }
.speeds button[aria-pressed="true"] { background: var(--accent); color: #1a1206; font-weight: 700; }

.hud-stats { gap: 16px; flex: 1 1 auto; }
.stat { display: flex; flex-direction: column; gap: 1px; min-width: 58px; }
.stat-k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); }
.stat-v { font-size: 14px; font-weight: 600; font-family: var(--mono); }
.stat-v.good { color: var(--good); }
.stat-v.warn { color: var(--warn); }
.stat-v.bad { color: var(--bad); }

.hud-weather { flex-direction: column; align-items: flex-start; gap: 2px; }
.wx { font-size: 12.5px; color: var(--ink-2); }
.metar { font-size: 10.5px; color: var(--ink-3); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.alert-strip {
  position: absolute; top: 54px; left: 50%; transform: translateX(-50%); z-index: 19;
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: min(900px, 94vw);
}
.alert {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 550;
  background: rgba(255, 176, 46, .16); border: 1px solid rgba(255, 176, 46, .45); color: #ffd792;
}
.alert.bad { background: rgba(255, 95, 86, .16); border-color: rgba(255, 95, 86, .5); color: #ffb3ae; }
.alert.info { background: rgba(74, 168, 255, .14); border-color: rgba(74, 168, 255, .4); color: #aed6ff; }

/* ---------------------------------------------------------------- toolbar --- */

.toolbar {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%); z-index: 18;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.tool {
  display: grid; place-items: center; width: 44px; height: 42px;
  border: none; background: transparent; border-radius: 8px; color: var(--ink-2);
  position: relative; padding: 0;
}
.tool:hover { background: var(--bg-3); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--accent); color: #1a1206; }
.tool svg { width: 20px; height: 20px; }
.tool .tool-label {
  position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
  background: var(--panel-solid); border: 1px solid var(--line); color: var(--ink);
  padding: 4px 9px; border-radius: 6px; font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .1s;
}
.tool:hover .tool-label { opacity: 1; }
.tool .badge {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px;
  border-radius: 999px; background: var(--bad); color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px;
}

/* ------------------------------------------------------------------ panel --- */

.panel {
  position: absolute; right: 10px; top: 62px; bottom: 10px; width: min(430px, calc(100vw - 80px));
  z-index: 18; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(14px); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.panel-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }
.icon-btn {
  width: 28px; height: 28px; padding: 0; display: grid; place-items: center;
  border: none; background: transparent; color: var(--ink-3); font-size: 20px; border-radius: 6px;
}
.icon-btn:hover { background: var(--bg-3); color: var(--ink); }
.panel-body { overflow-y: auto; padding: 14px; flex: 1 1 auto; scrollbar-width: thin; }
.panel-body::-webkit-scrollbar { width: 9px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; }

h3.sec { margin: 18px 0 9px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-3); }
h3.sec:first-child { margin-top: 0; }

.row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.row:last-child { border-bottom: none; }
.row .k { color: var(--ink-2); }
.row .v { font-family: var(--mono); font-weight: 600; }

.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 9px;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--ink-3); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.card-title { font-weight: 650; font-size: 13.5px; }
.card-sub { font-size: 11.5px; color: var(--ink-3); }
.card-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; margin: 6px 0 0; }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10.5px;
  font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--bg-3); color: var(--ink-2);
}
.tag.good { background: rgba(61, 220, 132, .16); color: var(--good); }
.tag.warn { background: rgba(255, 176, 46, .16); color: var(--warn); }
.tag.bad { background: rgba(255, 95, 86, .16); color: var(--bad); }
.tag.info { background: rgba(74, 168, 255, .16); color: var(--info); }

.bar { height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar > i.good { background: var(--good); }
.bar > i.bad { background: var(--bad); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stack { display: grid; gap: 9px; }

table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); font-weight: 600; padding: 5px 6px 7px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel-solid);
}
table.data td { padding: 6px; border-bottom: 1px solid var(--line-soft); }
table.data td.num, table.data th.num { font-family: var(--mono); text-align: right; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--bg-3); }

.ontime { color: var(--good); }
.minor { color: var(--warn); }
.major { color: #ff9257; }
.severe, .cancelled { color: var(--bad); }

.empty { color: var(--ink-3); font-size: 12.5px; text-align: center; padding: 22px 10px; line-height: 1.6; }

/* Range slider rows for fees and wages */
.slider-row { display: grid; gap: 5px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; }
.slider-head .v { font-family: var(--mono); font-weight: 650; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-note { font-size: 11px; color: var(--ink-3); }

/* --------------------------------------------------------------- build bar --- */

.build-bar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 19;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  max-width: min(960px, 94vw);
}
.build-cats { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; backdrop-filter: blur(14px); }
.build-cats button { padding: 6px 12px; font-size: 12.5px; border: none; background: transparent; color: var(--ink-2); border-radius: 7px; }
.build-cats button[aria-pressed="true"] { background: var(--accent); color: #1a1206; font-weight: 650; }
.build-items {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px; max-width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(14px);
}
.build-item {
  flex: 0 0 auto; width: 124px; text-align: left; padding: 9px 10px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
}
.build-item[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 176, 46, .1); }
.build-item.unaffordable { opacity: .5; }
.build-item .bi-name { font-size: 12px; font-weight: 600; line-height: 1.3; }
.build-item .bi-cost { font-size: 11px; color: var(--ink-3); font-family: var(--mono); margin-top: 3px; }
.build-hint {
  font-size: 12px; color: var(--ink-2); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; backdrop-filter: blur(14px); text-align: center;
}
.build-hint .bad { color: var(--bad); }
.build-hint .warn { color: var(--warn); }

/* -------------------------------------------------------------- inspector --- */

.inspector {
  position: absolute; left: 64px; bottom: 12px; z-index: 18; width: min(330px, calc(100vw - 80px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
  font-size: 12.5px;
}
.insp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.insp-title { font-weight: 700; font-size: 14px; font-family: var(--mono); }
.insp-sub { color: var(--ink-3); font-size: 11.5px; }
.insp-rows { display: grid; gap: 4px; }
.insp-row { display: flex; justify-content: space-between; gap: 10px; }
.insp-row .k { color: var(--ink-3); }
.insp-row .v { font-family: var(--mono); }
.insp-tasks { margin-top: 9px; display: grid; gap: 3px; max-height: 170px; overflow-y: auto; }
.insp-task { display: flex; align-items: center; gap: 7px; font-size: 11.5px; }
.insp-task .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--ink-3); flex: 0 0 auto; }
.insp-task .dot.done { background: var(--good); }
.insp-task .dot.active { background: var(--accent); }
.insp-task .dot.blocked { background: var(--bad); }
.insp-task .t { flex: 1 1 auto; color: var(--ink-2); }

/* ----------------------------------------------------------------- toasts --- */

.toasts {
  position: absolute; right: 10px; bottom: 10px; z-index: 30;
  display: flex; flex-direction: column; gap: 7px; align-items: flex-end;
  max-width: min(380px, 90vw); pointer-events: none;
}
.toast {
  background: var(--panel-solid); border: 1px solid var(--line); border-left: 3px solid var(--info);
  border-radius: 8px; padding: 9px 13px; font-size: 12.5px; color: var(--ink);
  box-shadow: var(--shadow); animation: toastIn .18s ease-out;
}
.toast.success { border-left-color: var(--good); }
.toast.warning { border-left-color: var(--warn); }
.toast.danger { border-left-color: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ modal --- */

.modal-overlay { background: rgba(4, 7, 11, .72); backdrop-filter: blur(3px); z-index: 120; }
.modal-card {
  width: min(460px, 100%); background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 9px; font-size: 17px; }
.modal-card p { margin: 0 0 16px; color: var(--ink-2); line-height: 1.55; font-size: 13px; }
.modal-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

/* -------------------------------------------------------------- charts/svg --- */

.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .lbl { fill: var(--ink-3); font-size: 9px; font-family: var(--mono); }
.chart .ser1 { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .ser2 { fill: none; stroke: var(--info); stroke-width: 2; }
.chart .ser3 { fill: none; stroke: var(--good); stroke-width: 2; }
.chart .barp { fill: var(--accent); }
.chart .barn { fill: var(--bad); }

/* ----------------------------------------------------------------- mobile --- */

@media (max-width: 900px) {
  .hud-weather { display: none; }
  .hud-stats { gap: 12px; }
  .panel { top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-height: 62vh; border-radius: 12px 12px 0 0; }
  .toolbar {
    flex-direction: row; left: 8px; right: 8px; top: auto; bottom: 8px; transform: none;
    justify-content: space-between; overflow-x: auto;
  }
  .tool { width: 40px; height: 38px; }
  .tool .tool-label { display: none; }
  .inspector { left: 8px; right: 8px; bottom: 58px; width: auto; }
  .build-bar { bottom: 56px; }
  .toasts { bottom: 56px; }
}
@media (max-width: 560px) {
  body { font-size: 13px; }
  .hud-identity .hud-name { display: none; }
  .stat { min-width: 48px; }
  .stat-v { font-size: 12.5px; }
  #hudTime { font-size: 16px; }
}
