/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2d3148;
  --accent: #4f7ef8;
  --accent-hover: #6b95ff;
  --text: #e2e6f0;
  --muted: #7b82a6;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

html.light {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface2: #eef0f7;
  --border: #d5d9ec;
  --accent: #3b6ef5;
  --accent-hover: #2558e8;
  --text: #1a1d2e;
  --muted: #6470a0;
  --green: #059669;
  --red: #dc2626;
  --yellow: #d97706;
  --shadow: 0 4px 24px rgba(0,0,0,.1);
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 5px 8px;
  transition: background .15s, color .15s;
  margin-left: auto;
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Navbar ── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text);
  text-decoration: none;
}
.nav-logo { font-size: 20px; }
.nav-logo-img { height: 28px; width: auto; display: block; }
.nav-brand-divider {
  width: 1px; height: 18px;
  background: var(--border);
  display: inline-block;
}
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 6px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: var(--surface2);
  color: var(--text);
}

/* ── Main ── */
main.container { flex: 1; padding-top: 32px; padding-bottom: 48px; }

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 56px 0 40px;
}
.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(135deg, #e2e6f0 30%, #4f7ef8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub { color: var(--muted); margin: 8px 0 28px; font-size: 1.05rem; }

.hero-search {
  display: flex;
  max-width: 640px;
  margin: 0 auto;
  gap: 0;
}
.hero-search input {
  flex: 1;
  padding: 12px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.hero-search input:focus { border-color: var(--accent); }
.hero-search button {
  padding: 12px 24px;
  background: var(--accent);
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.hero-search button:hover { background: var(--accent-hover); }

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 0 0 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -.5px;
}
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.related-app-card {
  border-left: 3px solid var(--accent);
}
.app-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.app-filters select {
  padding: 5px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.app-filters select:focus { border-color: var(--accent); }
.app-item--sep {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}
.app-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.app-file-num {
  font-family: monospace;
  font-weight: 700;
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Two/Three col layouts ── */
.two-col { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; }
.three-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }

/* ── Bar chart ── */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { width: 28px; font-weight: 700; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.bar-count { font-size: 12px; color: var(--muted); width: 54px; text-align: right; flex-shrink: 0; }

/* ── Data table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.data-table--full { table-layout: auto; }

.table-card { padding: 0; overflow: hidden; }
.table-card .data-table th:first-child,
.table-card .data-table td:first-child { padding-left: 20px; }
.table-card .data-table th:last-child,
.table-card .data-table td:last-child { padding-right: 20px; }

.call-sign { font-weight: 700; font-family: monospace; font-size: 13px; }
.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.coords { font-family: monospace; font-size: 11px; color: var(--muted); white-space: nowrap; }
.date { white-space: nowrap; color: var(--muted); font-size: 12px; }

/* ── Quick filters ── */
.quick-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip {
  padding: 6px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  transition: background .15s, border-color .15s;
  text-decoration: none;
}
.filter-chip:hover { background: var(--border); color: var(--text); text-decoration: none; }
.filter-chip--highlight { border-color: var(--accent); color: var(--accent); }
.filter-chip--highlight:hover { background: rgba(79,126,248,.15); }

/* ── Search filters ── */
.page-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 20px; }

.search-filters { padding: 20px 24px; }
.filter-form {}
.filter-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.filter-group--wide { flex: 2; min-width: 240px; }
.filter-group--action { flex-direction: row; gap: 8px; }
.filter-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.filter-group input,
.filter-group select {
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.filter-group input:focus,
.filter-group select:focus { border-color: var(--accent); }
.filter-group select option { background: var(--surface2); }

.btn-primary {
  padding: 9px 20px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  display: inline-block;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.btn-secondary {
  padding: 9px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-secondary:hover { background: var(--border); color: var(--text); text-decoration: none; }

/* ── Results header ── */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 12px;
}
.results-count { font-weight: 700; font-size: 14px; }
.results-page { color: var(--muted); font-size: 13px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge--green { background: rgba(52,211,153,.15); color: var(--green); }
.badge--gray  { background: rgba(123,130,166,.15); color: var(--muted); }
.badge--lg    { font-size: 13px; padding: 4px 14px; }
.badge--sm    { font-size: 11px; padding: 2px 8px; }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 24px; }
.page-btn {
  padding: 7px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  transition: background .15s;
}
.page-btn:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.page-btn--active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--muted);
}
.empty-state h1 { font-size: 1.4rem; color: var(--text); margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }
.empty-text { color: var(--muted); font-style: italic; }

/* ── Structure detail ── */
.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }

.struct-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}
.struct-title { font-size: 2rem; font-weight: 800; font-family: monospace; margin-bottom: 8px; }
.struct-meta { display: flex; align-items: center; gap: 10px; }
.struct-type-tag {
  padding: 3px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
}
.struct-fcc-link {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.struct-fcc-link:hover { background: var(--surface2); color: var(--text); }

.struct-height-box {
  text-align: right;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
}
.height-num { font-size: 2.4rem; font-weight: 800; color: var(--accent); line-height: 1; }
.height-label { color: var(--muted); font-size: 12px; margin-top: 2px; }
.height-amsl { color: var(--muted); font-size: 12px; margin-top: 6px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; }
.detail-list--cols { grid-template-columns: auto 1fr; }
.detail-list dt { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; padding-top: 2px; }
.detail-list dd { font-size: 13px; }

#map { height: 240px; border-radius: 8px; margin-top: 16px; overflow: hidden; }

.entity-block + .entity-block--sep { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

.count-badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  background: var(--surface2);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.remark-block { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.remark-block:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.remark-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.remark-block p { font-size: 13px; color: var(--text); }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { display: flex; gap: 12px; align-items: baseline; }
.history-date {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 80px;
  flex-shrink: 0;
}
.history-desc { font-size: 13px; }

/* ── Footer ── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 1.6rem; }
  .struct-header { flex-direction: column; gap: 16px; }
  .struct-height-box { text-align: left; }
}
