/* Airparks Research Database - local viewer.
   Visual language follows the sibling BitPetro Lead Engine: near-black
   ground, single accent color, monospace numerics. Airparks uses a runway
   blue/green accent instead of BitPetro's orange so the two tools are
   visually distinguishable while still reading as one family. */

:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1b1b1b;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f5;
  --muted: rgba(255, 255, 255, 0.55);
  --faint: rgba(255, 255, 255, 0.34);
  --accent: #38bdf8;
  --violet: #a78bfa;
  --slate: #7f9ab5;
  --green: #4ade80;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --red: #f87171;
  --header-h: 108px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

/* overflow-x lives on <html>, NEVER on <body> - on body it makes the body its
   own scroll container and silently kills position:sticky.
   AG-WEB-STANDARDS.md Part 1.2. */
html {
  overflow-x: hidden;
  background: var(--bg);
}

* { box-sizing: border-box; }

body {
  overflow-x: visible;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* every anchor target and every id-bearing element clears the pinned
   header, so a jump-link or in-page focus target never lands underneath
   it. AG-WEB-STANDARDS.md Part 1.2. */
:target,
[id] {
  scroll-margin-top: var(--header-h);
}

/* ---------- sticky header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
  text-decoration: none;
  flex: 0 0 auto;
}
.brand:hover { text-decoration: none; }
.brand:hover .brand-name { color: var(--accent); }

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: color 0.2s;
}
.brand-name span { color: var(--accent); }

.brand-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
}

.search-wrap { flex: 1 1 260px; min-width: 200px; }

#search {
  width: 100%;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
#search:focus { outline: none; border-color: var(--accent); }
#search::placeholder { color: var(--faint); }

.presets { display: flex; gap: 6px; flex: 0 0 auto; }

.preset {
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.preset:hover { border-color: var(--line-strong); color: var(--text); }
.preset[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.count {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.count strong { color: var(--accent); }

.logout, .lang-selector-btn {
  padding: 8px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: 600 12px var(--sans);
  cursor: pointer;
}
.logout:hover, .lang-selector-btn:hover { border-color: var(--accent); }
.lang-selector-wrapper { position: relative; margin-left: auto; }
.lang-selector-btn { display: flex; gap: 6px; align-items: center; }
.lang-dropdown {
  display: none; position: absolute; top: calc(100% + 7px); right: 0; z-index: 100;
  width: 220px; padding: 8px; background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.lang-dropdown.open { display: block; }
.lang-search input { width: 100%; padding: 8px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; }
.lang-list { list-style: none; padding: 5px 0 0; margin: 0; }
.lang-list button { width: 100%; padding: 8px; text-align: left; color: var(--text); background: transparent; border: 0; border-radius: 5px; cursor: pointer; }
.lang-list button:hover, .lang-list button[aria-selected="true"] { background: rgba(56,189,248,.14); color: var(--accent); }

/* ---------- login ---------- */
.login-page { min-height: 100vh; background: radial-gradient(circle at 50% 15%, #0a2233 0, var(--bg) 42%); }
.login-header .header-row { justify-content: space-between; }
.login-main { min-height: calc(100vh - 74px); display: grid; place-items: center; padding: 32px 18px; }
.login-card { width: min(430px, 100%); padding: 34px; background: rgba(20,20,20,.96); border: 1px solid var(--line-strong); border-top: 3px solid var(--accent); border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.55); }
.login-card h1 { margin: 5px 0 8px; font-size: 28px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.login-copy { margin: 0 0 24px; color: var(--muted); }
.login-card label { display: grid; gap: 6px; margin: 0 0 16px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-card input { padding: 11px 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px; font: 15px var(--sans); }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,.12); }
.login-submit { width: 100%; padding: 11px; border: 0; border-radius: 6px; background: var(--accent); color: #000; font: 800 14px var(--sans); cursor: pointer; }
.login-submit:disabled { opacity: .55; cursor: wait; }
.login-error { padding: 9px 11px; border: 1px solid rgba(248,113,113,.45); border-radius: 6px; color: var(--red); background: rgba(248,113,113,.08); }

/* ---------- layout: filters | results | saved lists ---------- */

.shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr) 260px;
  gap: 0;
  align-items: start;
}

@media (max-width: 1200px) {
  .shell { grid-template-columns: 244px minmax(0, 1fr); }
  .lists-panel { grid-column: 1 / -1; position: static !important; max-height: none !important; border-left: none; border-top: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static !important; max-height: none !important; border-right: none; border-bottom: 1px solid var(--line); }
}

/* ---------- facets and ranges ---------- */

.sidebar {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 16px 14px 40px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

#facets fieldset,
#ranges fieldset {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0 0 14px;
  padding: 12px 0 0;
}
#facets fieldset:first-of-type { border-top: none; padding-top: 0; }

#facets legend,
#ranges legend {
  padding: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin-bottom: 8px;
}

.facet-opt {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.facet-opt:hover { color: var(--text); }
.facet-opt input { accent-color: var(--accent); margin: 0; flex: 0 0 auto; }
.facet-opt .tally {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
}

.facet-scroll { max-height: 168px; overflow-y: auto; }

.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.range-row .range-sep { color: var(--faint); font-size: 12px; }
#ranges input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}
#ranges input[type="number"]:focus { outline: none; border-color: var(--accent); }

.reset {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.reset:hover { border-color: var(--red); color: var(--red); }

/* ---------- table ---------- */

.table-wrap { overflow-x: auto; padding-bottom: 72px; }

table { border-collapse: collapse; width: 100%; min-width: 1080px; }

thead th {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line-strong);
  padding: 9px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  white-space: nowrap;
}
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { color: var(--text); }
thead th .arrow { color: var(--accent); margin-left: 3px; }

tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr.airport-row { cursor: pointer; }
tbody tr.airport-row:hover { background: rgba(56, 189, 248, 0.05); }
tbody tr.airport-row.open { background: rgba(56, 189, 248, 0.08); }

.num { font-family: var(--mono); font-size: 12px; text-align: right; white-space: nowrap; }
.name { font-weight: 600; }
.sub { color: var(--faint); font-size: 12px; }
.nowrap { white-space: nowrap; }

.sel-cell { width: 30px; }
.sel-cell input { accent-color: var(--accent); cursor: pointer; }

/* ---------- pills ---------- */

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border: 1px solid currentColor;
}

.status-active   { color: var(--green); }
.status-inactive { color: var(--faint); }
.status-closed   { color: var(--red); }
.status-abandoned { color: var(--red); }
.status-under_construction { color: var(--amber); }
.status-unknown  { color: var(--muted); }

.conf-high   { color: var(--green); background: rgba(74, 222, 128, 0.16); }
.conf-medium { color: var(--amber); background: rgba(251, 191, 36, 0.10); }
.conf-low    { color: var(--faint); background: transparent; }

.tag {
  display: inline-block;
  margin: 0 3px 2px 0;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

/* ---------- detail row ---------- */

.detail-cell { padding: 0 !important; border-bottom: 1px solid var(--line-strong) !important; }

.detail {
  border-left: 3px solid var(--accent);
  background: var(--panel);
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 26px;
}
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }

.detail h4 {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
}
.detail section { margin-bottom: 16px; }
.detail p { margin: 0 0 8px; color: rgba(255, 255, 255, 0.82); }

.detail ul { margin: 0; padding-left: 16px; }
.detail li { margin-bottom: 3px; color: var(--muted); font-size: 13px; }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--faint); white-space: nowrap; }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.status-select {
  padding: 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
}

/* ---------- saved lists panel ---------- */

.lists-panel {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 16px 14px 40px;
  border-left: 1px solid var(--line);
  background: var(--bg);
}

.lists-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.lists-panel-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}
.new-list {
  padding: 5px 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent);
  font: 700 11px var(--sans);
  cursor: pointer;
}
.new-list:hover { border-color: var(--accent); }

.lists-body { display: flex; flex-direction: column; gap: 8px; }

.list-card {
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.list-card:hover { border-color: var(--line-strong); }
.list-card.active { border-color: var(--accent); }
.list-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-card .list-name { font-weight: 600; font-size: 13px; cursor: pointer; }
.list-card .list-name:hover { color: var(--accent); }
.list-card .list-desc { font-size: 12px; margin-top: 3px; }
.list-card .list-meta { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 2px; }
.list-card .note-actions { flex-wrap: wrap; margin-top: 8px; }
.list-card .note-error { margin-top: 6px; }

.list-inline-editor { display: flex; flex-direction: column; gap: 6px; }

.list-input {
  width: 100%;
  padding: 6px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
}
.list-input:focus { outline: none; border-color: var(--accent); }

.list-seed-opt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 6px; cursor: pointer; }

.lists-empty { font-size: 13px; line-height: 1.5; }

.list-expanded {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-expanded h4 {
  margin: 4px 0 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}

.list-add-selection { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-add-selection button {
  padding: 3px 9px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--text);
  font: 600 11px var(--sans);
  cursor: pointer;
}
.list-add-selection button:hover { border-color: var(--accent); color: var(--accent); }

.list-items { display: flex; flex-direction: column; gap: 6px; }
.list-item { display: flex; align-items: center; gap: 6px; }
.list-item-name {
  flex: 0 0 auto;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}
.list-item-note { flex: 1 1 auto; min-width: 0; }
.list-item-remove {
  flex: 0 0 auto;
  padding: 2px 7px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--muted);
  font: 600 10px var(--sans);
  cursor: pointer;
}
.list-item-remove:hover { border-color: var(--red); color: var(--red); }

.active-list-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  margin: 12px 12px 0;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
}
.active-list-banner-text { font-weight: 600; }
.active-list-banner-back {
  flex: 0 0 auto;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--accent);
  font: 700 11px var(--sans);
  cursor: pointer;
}
.active-list-banner-back:hover { border-color: var(--accent); }

/* ---------- footer bar ---------- */

.footbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--panel-2);
  border-top: 1px solid var(--line-strong);
  flex-wrap: wrap;
}

.footbar button {
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.footbar button:hover { border-color: var(--accent); color: var(--accent); }
.footbar button.primary { background: var(--accent); border-color: var(--accent); color: #000; }
.footbar button.primary:hover { opacity: 0.88; color: #000; }

.footbar .spacer { flex: 1 1 auto; }
.footbar .meta { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.footbar .sel-count { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 700; }

.empty { padding: 60px 20px; text-align: center; color: var(--faint); }

/* ---------- detail panel: loading/error, runway & ownership tables, tags ---------- */

.detail-loading, .detail-error { padding: 18px 22px; font-size: 13px; }
.detail-error { color: var(--red); }

.detail table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.detail .runway-table, .detail .ownership-table { font-size: 12px; }
.detail table th {
  position: static;
  text-align: left;
  padding: 4px 8px 4px 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.detail table td {
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.tag-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-grid .tag { margin: 0; }

/* ---------- notes thread ---------- */

.notes-thread { display: flex; flex-direction: column; gap: 10px; }

.note-add { display: flex; flex-direction: column; gap: 6px; }
.note-add-actions { display: flex; justify-content: flex-end; }

.note-textarea, .note-edit-textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}
.note-textarea:focus, .note-edit-textarea:focus { outline: none; border-color: var(--accent); }

.note-counter { font-family: var(--mono); font-size: 11px; color: var(--faint); text-align: right; }
.note-counter.over { color: var(--red); }

.note-error { font-size: 12px; color: var(--red); }

.notes-list { display: flex; flex-direction: column; gap: 10px; }
.notes-empty, .notes-loading { font-size: 13px; padding: 4px 0; }

.note-item {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; color: rgba(255, 255, 255, 0.9); }
.note-meta { display: flex; gap: 10px; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.note-edited { color: var(--accent); }

.note-actions { display: flex; align-items: center; gap: 8px; }
.note-actions button {
  padding: 3px 9px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--text);
  font: 600 11px var(--sans);
  cursor: pointer;
}
.note-actions button:hover { border-color: var(--accent); color: var(--accent); }
.note-actions button.note-delete:hover,
.note-actions button.note-delete-confirm { border-color: var(--red); color: var(--red); }
.note-confirm-text { font-size: 12px; }

.note-save[disabled] { opacity: 0.4; cursor: not-allowed; }
.note-save[disabled]:hover { border-color: var(--line-strong); color: var(--text); }
