:root {
  --bg: #0a0e14;
  --surface: #111722;
  --surface-2: #17202e;
  --border: #233044;
  --text: #e6edf6;
  --muted: #8b9bb4;
  --amber: #f59e0b;
  --cyan: #38bdf8;
  --emerald: #10b981;
  --rose: #f43f5e;
  --radius: 10px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 15% -10%, rgba(56, 189, 248, 0.08), transparent),
              radial-gradient(900px 500px at 85% 0%, rgba(245, 158, 11, 0.06), transparent),
              var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  min-height: 100vh;
}

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

code, pre, .mono { font-family: var(--font-mono); }
code {
  background: rgba(56, 189, 248, 0.1);
  color: #bae6fd;
  padding: 0.1em 0.38em;
  border-radius: 4px;
  font-size: 0.88em;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.main { padding: 28px 20px 64px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mt-sm { margin-top: 10px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 26px; }
.accent-amber { color: var(--amber); }
.accent-cyan { color: var(--cyan); }
.accent-emerald { color: var(--emerald); }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(10, 14, 20, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-name strong { color: var(--amber); }
.brand-tld { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link {
  position: relative;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
}
.nav-link:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-link.active { color: var(--text); }
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  border-bottom: 2px solid var(--amber);
}

.quick-lookup { display: flex; gap: 6px; }
.quick-lookup input {
  width: 175px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 0.86rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
}
.quick-lookup input::placeholder { text-transform: none; font-family: var(--font-sans); color: var(--muted); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: #3a5070; text-decoration: none; }
.btn-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #0b0f14;
}
.btn-primary:hover { background: #fbbf24; border-color: #fbbf24; }
.btn-cyan {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #0b0f14;
}
.btn-cyan:hover { background: #7dd3fc; border-color: #7dd3fc; }
.btn-secondary { background: var(--surface); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

.select, .input, input[type="text"], textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: inherit;
}
textarea { width: 100%; resize: vertical; font-size: 0.82rem; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card h3 { margin: 0; font-size: 1.04rem; }
.card-kicker {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 6px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 34px;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  color: var(--amber);
  margin-bottom: 10px;
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(1.85rem, 3.2vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.lead { color: #c4d1e2; font-size: 1.02rem; margin: 0 0 20px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.spec-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0 0 18px;
}
.spec-grid dt { font-size: 0.76rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.spec-grid dd { margin: 2px 0 0; font-size: 0.9rem; font-weight: 600; }

.spectrum-bar { border-top: 1px solid var(--border); padding-top: 12px; }
.spectrum-label { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); margin-bottom: 6px; }
.subchannel-track { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.subch {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  text-align: center;
  padding: 6px 2px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}
.subch.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 700;
}
.subch.active-rx {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--cyan);
  color: var(--cyan);
  font-weight: 700;
}

/* Badges */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.badge-emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-cyan { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.35); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* Protocol diagrams */
.section-head { margin-bottom: 14px; }
.section-head h2 { margin: 0 0 4px; font-size: 1.35rem; }
.section-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.section-bar h1 { margin: 0 0 4px; font-size: 1.65rem; }
.filter-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.88rem;
  cursor: pointer;
}

.exchange-steps { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 12px; }
.exchange-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.slot-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.slot-tx { background: rgba(245, 158, 11, 0.18); color: var(--amber); }
.slot-rx { background: rgba(56, 189, 248, 0.18); color: var(--cyan); }
.slot-ok { background: rgba(16, 185, 129, 0.18); color: var(--emerald); }

.bit-frame { margin-top: 14px; }
.bit-frame-title { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.bit-row { display: flex; gap: 3px; }
.bit-seg {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 4px;
  text-align: center;
  overflow: hidden;
  min-width: 0;
}
.bit-seg span { display: block; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bit-seg small { display: block; font-size: 0.68rem; color: var(--muted); }
.seg-amber { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.1); }
.seg-cyan { border-color: rgba(56, 189, 248, 0.45); background: rgba(56, 189, 248, 0.1); }
.seg-emerald { border-color: rgba(16, 185, 129, 0.45); background: rgba(16, 185, 129, 0.1); }

.milestones { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.milestone { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.dot-ok { background: var(--emerald); box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px; }
.kpi-label { font-size: 0.76rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-val { font-family: var(--font-mono); font-size: 1.55rem; line-height: 1.15; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }

/* World Maidenhead Map */
.map-wrap { width: 100%; overflow-x: auto; }
.grid-map-svg { width: 100%; height: auto; display: block; border-radius: 6px; background: #080c12; }
.map-cell { stroke: rgba(35, 48, 68, 0.65); stroke-width: 0.5; transition: opacity 0.12s; cursor: pointer; }
.map-cell:hover { stroke: #ffffff; stroke-width: 1.2; }
.map-legend { display: flex; gap: 14px; align-items: center; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.swatch-confirmed { background: var(--emerald); }
.swatch-worked { background: var(--amber); }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: rgba(56, 189, 248, 0.04); }
.call-link { font-family: var(--font-mono); font-weight: 700; color: var(--cyan); cursor: pointer; }

/* Upload */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 0.88rem; font-weight: 600; }
.form-actions { display: flex; gap: 10px; margin-top: 14px; }
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px 18px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.06);
}
.dropzone-icon { font-size: 1.8rem; color: var(--amber); margin-bottom: 6px; }
.dropzone-title { font-weight: 600; margin-bottom: 4px; }
.bullet-list { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; color: #c4d1e2; }
.code-block {
  background: #070a0f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  font-size: 0.8rem;
  margin: 10px 0 0;
}
.code-block code { background: transparent; padding: 0; color: #e2e8f0; }

/* Callsign Profile */
.call-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.call-title { margin: 0; font-size: 2rem; color: var(--amber); }
.kpi-inline { display: flex; gap: 22px; flex-wrap: wrap; }
.kpi-inline > div { display: flex; flex-direction: column; }
.kpi-inline span { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; }
.kpi-inline strong { font-family: var(--font-mono); font-size: 1.25rem; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.chip.confirmed { border-color: rgba(16, 185, 129, 0.45); color: #34d399; background: rgba(16, 185, 129, 0.1); }

/* Auth & Dialog */
.auth-controls { display: flex; align-items: center; gap: 8px; }
.auth-gate, .authed-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-color: rgba(245, 158, 11, 0.35);
}
.authed-bar {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.06);
}
.authed-bar-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-gate h3 { margin: 0 0 4px; }

.modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}
.modal::backdrop {
  background: rgba(4, 8, 14, 0.72);
  backdrop-filter: blur(4px);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; font-size: 1.3rem; }
.code-input {
  font-size: 1.4rem;
  letter-spacing: 0.25em;
  text-align: center;
  padding: 10px;
}

/* Bluetooth Sync Card */
.ble-card {
  border-color: rgba(56, 189, 248, 0.35);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.06), var(--surface));
}
.ble-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.ble-head h3 { margin: 0 0 4px; }
.ble-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ble-pin { width: 130px; font-family: var(--font-mono); }
.ble-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  background: #070a0f;
  border: 1px solid var(--border);
  color: #bae6fd;
}

/* Footer */
.footer { border-top: 1px solid var(--border); padding: 20px 0; margin-top: 40px; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 960px) {
  .hero, .grid-2, .grid-3, .grid-4, .milestones { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
