/* Colours and fonts match the C212 EFB (PackageSources/.../EFB/EFB.css) */
:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --panel: #12161d;         /* sidebar, top bar */
  --card: #171c25;          /* cards / panels */
  --panel-hover: #232b38;
  --border: #262d3a;
  --text: #e8edf4;
  --text-dim: #8b96a8;
  --text-faint: #5a6475;
  --accent: #35a4ff;
  --accent-soft: rgba(53, 164, 255, 0.1);
  --ok: #35c96e;
  --warn: #ffb43c;
  --danger: #ff5b5b;

  --font: "Segoe UI", system-ui, Roboto, sans-serif;
  --mono: Consolas, "Courier New", monospace;

  --sidebar-w: 232px;
  --sidebar-w-collapsed: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  transition: width 0.2s ease;
  z-index: 1001;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  position: relative;
  flex: 1;
  min-width: 0;
  margin-right: 8px;
}

/* Aircraft selector */
.dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: 600 14px var(--mono);
  letter-spacing: 0.5px;
  cursor: pointer;
}
.dropdown-toggle:hover { border-color: var(--accent); }
.dropdown-toggle svg { color: var(--text-dim); flex-shrink: 0; }
.dropdown.open .dropdown-toggle { border-color: var(--accent); }
.dropdown.open .dropdown-toggle svg { transform: rotate(180deg); }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 10;
}
.dropdown.open .dropdown-menu { display: block; }

.dropdown-menu li {
  padding: 8px 10px;
  border-radius: 0;
  font: 500 13px var(--mono);
  color: var(--text-dim);
  cursor: pointer;
}
.dropdown-menu li:hover { background: var(--panel-hover); color: var(--text); }
.dropdown-menu li[aria-selected="true"] { color: var(--accent); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.icon-btn:hover { background: var(--panel-hover); color: var(--text); }
.icon-btn svg { transition: transform 0.2s ease; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
}

.nav-bottom {
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 0;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--panel-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 2px 17px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}
.status-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}
.status.is-off .status-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

/* Collapsed state */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .status-text { display: none; }
.sidebar.collapsed .brand { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; }
.sidebar.collapsed #sidebarToggle svg { transform: rotate(180deg); }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }
.sidebar.collapsed .status { justify-content: center; padding-left: 0; padding-right: 0; }

/* ---------- Main ---------- */
.main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

body.is-loading .main { visibility: hidden; }

.muted { color: var(--text-dim); margin: 0; }

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 18px; }
h2 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  flex-shrink: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title .muted { font-size: 12px; margin-top: 2px; }
#topbarAircraft { font-family: var(--mono); color: var(--accent); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-weight: 600; }
.user-rank { font-size: 12px; color: var(--text-dim); }

/* Content */
.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--border);
}

/* Map panel */
.map-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 58vh;
  min-height: 320px;
  flex-shrink: 0;
  overflow: hidden;
}
.map-panel.maximized {
  position: absolute;
  inset: 0;
  height: auto;
  z-index: 900;
  border-radius: 0;
  border: none;
}

#map {
  flex: 1;
  background: var(--bg);
}

.icon-min { display: none; }
.map-panel.maximized .icon-max { display: none; }
.map-panel.maximized .icon-min { display: block; }

.leaflet-control-attribution {
  background: rgba(17, 22, 29, 0.8) !important;
  color: var(--text-dim) !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }

.leaflet-bar a {
  background: var(--panel);
  color: var(--text);
  border-bottom-color: var(--border);
}
.leaflet-bar a:hover { background: var(--panel-hover); color: var(--text); }
.leaflet-bar { border: 1px solid var(--border) !important; }

/* Dashboard cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  min-height: 120px;
}
.stat-big {
  font: 600 24px var(--mono);
}
.progress {
  height: 6px;
  border-radius: 0;
  background: var(--bg);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.4s ease;
}

.card-wide { grid-column: span 2; }
.small { font-size: 12px; }

/* ---------- Views ---------- */
.content[hidden] { display: none; }

/* ---------- Buttons ---------- */
.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 0;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 13px var(--font);
  text-decoration: none;
  cursor: pointer;
  align-self: flex-start;
}
.btn-small:hover { background: var(--accent); color: #04121f; }
.btn-small:disabled { opacity: 0.4; cursor: default; background: var(--accent-soft); color: var(--accent); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger); color: #1a0406; }

/* ---------- Jobs ---------- */
.jobs-view { gap: 12px; }

.jobs-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 12px 16px;
  flex-shrink: 0;
}
.jobs-toolbar .btn-primary { margin: 0; padding: 0 20px; }

.field-inline { flex: 0 1 320px; }

.type-filter {
  display: flex;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}
.filter-btn {
  padding: 0 14px;
  border: none;
  background: var(--bg);
  color: var(--text-dim);
  font: 500 14px var(--font);
  cursor: pointer;
}
.filter-btn + .filter-btn { border-left: 1px solid var(--border); }
.filter-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.filter-btn:hover { color: var(--text); }

.jobs-count { align-self: flex-end; padding-bottom: 12px; }
.field select {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px var(--font);
}
.field select:focus { outline: none; border-color: var(--accent); }

.notice {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(63, 169, 245, 0.35);
  border-radius: 0;
  background: var(--accent-soft);
  font-size: 13px;
}
.notice a { color: var(--accent); }
.notice[hidden] { display: none; }

.jobs-layout {
  flex: 1;
  min-height: 420px;
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 16px;
}

.job-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}
.job-list .empty { padding: 16px 4px; }

.jobs-map-panel { overflow: hidden; display: flex; }
.board-map { flex: 1; background: var(--bg); }

.job-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
  cursor: pointer;
}
.job-card:hover, .job-card.is-hovered { border-color: var(--accent); }

.job-card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}
.job-card-head .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flight-no {
  font: 600 14px var(--mono);
  color: var(--accent);
}

.xp-badge {
  font: 600 12px var(--mono);
  color: var(--ok);
}

.job-route {
  display: flex;
  align-items: center;
  gap: 12px;
}
.job-route > div { display: flex; flex-direction: column; min-width: 0; }
.job-route strong { font: 600 18px var(--mono); }
.job-route .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-arrow { color: var(--text-dim); font-size: 18px; }

.job-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 13px;
  color: var(--text-dim);
}
.job-meta .btn-small { margin-left: auto; }

.tag {
  padding: 2px 8px;
  border-radius: 0;
  font-size: 12px;
  background: var(--panel-hover);
  color: var(--text);
}
.tag-cargo { color: #f5b83f; }
.tag-passenger { color: #8fd0ff; }
.tag-ferry { color: var(--ok); background: rgba(61, 220, 132, 0.12); }

.active-job { display: flex; flex-direction: column; gap: 10px; }

/* Flight status (dashboard) */
.flight-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 12px;
  border-radius: 0;
  background: var(--bg);
}
.status-pill {
  padding: 2px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-hover);
  color: var(--text-dim);
}
.status-pill.is-live { background: rgba(61, 220, 132, 0.15); color: var(--ok); }
.status-pill.is-stale { background: rgba(242, 97, 107, 0.15); color: var(--danger); }
.mono { font-family: var(--mono); }

.aircraft-icon { background: none; border: none; }

/* Settings: EFB link */
.efb-card, .account-card { max-width: 560px; }
.efb-creds {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 40px;
  padding: 12px 0;
}
.efb-value { font: 600 20px var(--mono); margin-top: 4px; }
.efb-key { letter-spacing: 4px; color: var(--accent); }

.details-hint { margin-left: auto; color: var(--accent); font-weight: 500; }

/* Job details */
.job-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.back-link {
  align-self: flex-start;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: 500 13px var(--font);
  cursor: pointer;
}
.back-link:hover { text-decoration: underline; }

.detail-airports {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
}
.detail-airports .job-arrow { padding-top: 22px; }
.detail-airport { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.detail-airport strong { font: 600 22px var(--mono); }
.detail-airport .muted { font-size: 12px; }

.detail-label, .detail-grid dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.detail-grid dd { margin: 2px 0 0; font: 500 14px var(--mono); }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.detail-actions .btn-primary { margin: 0; padding: 0 18px; flex: 1 0 auto; }

.btn-secondary {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 14px var(--font);
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; border-color: var(--border); }

.leaflet-tooltip.route-label {
  padding: 2px 6px;
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--text);
  font: 600 12px var(--mono);
  box-shadow: none;
}
.leaflet-tooltip.route-label::before { border-top-color: var(--accent); }

.mobile-menu {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  color: var(--text);
}

.backdrop { display: none; }

/* ---------- Auth page ---------- */
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 18px;
  font-weight: 600;
}
.brand-mark {
  font: 600 13px var(--mono);
  letter-spacing: 1px;
  padding: 4px 7px;
  border-radius: 0;
  background: var(--accent);
  color: #04121f;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 0;
  background: var(--bg);
}
.tab {
  flex: 1;
  height: 34px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  font: 500 14px var(--font);
  cursor: pointer;
}
.tab.active { background: var(--panel-hover); color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form[hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-dim); }
.field input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px var(--font);
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input.invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; min-height: 0; }
.field-error:empty { display: none; }

.form-error { margin: 0; color: var(--danger); font-size: 13px; }
.form-error:empty { display: none; }

.btn-primary {
  height: 40px;
  margin-top: 4px;
  border: none;
  border-radius: 0;
  background: var(--accent);
  color: #04121f;
  font: 600 14px var(--font);
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  #sidebarToggle { display: none; }

  .mobile-menu { display: grid; }
  .topbar { padding: 0 16px; }
  .topbar-title .muted, .user-meta { display: none; }
  .content { padding: 16px; }
  .card-wide { grid-column: auto; }
  .jobs-layout { grid-template-columns: 1fr; grid-template-rows: 300px auto; }
  .jobs-map-panel { grid-row: 1; }
  .job-list { overflow: visible; }
  .jobs-toolbar { flex-wrap: wrap; }

  .backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
  }
}

/* ---------- Profile ---------- */
.profile-view > * { flex-shrink: 0; } /* sections keep their height; the page scrolls instead */
.profile-hero { padding: 28px 24px; display: flex; flex-direction: column; gap: 8px; }
.profile-name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.profile-name { font-size: 44px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1; word-break: break-word; }
.profile-rank { margin: 0; font-size: 16px; color: var(--accent); font-weight: 500; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 12px 36px; margin-top: 12px; }
.profile-stat { display: flex; flex-direction: column; gap: 2px; }
.profile-stat strong { font: 600 20px var(--mono); }

.badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 8px;
  border: 1px solid var(--badge-color, var(--accent));
  border-radius: 0;
  color: var(--badge-color, var(--accent));
  background: color-mix(in srgb, var(--badge-color, var(--accent)) 12%, transparent);
  font-size: 14px;
  font-weight: 600;
}
.badge-chip[hidden] { display: none; }
.badge-icon { margin-right: 4px; }
.badge-icon:empty { display: none; }

.card-title-row { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.progress-lg { height: 10px; border-radius: 0; }

.rank-ladder {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.rank-step {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
}
.rank-dot {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font: 600 12px var(--mono);
  background: var(--panel-hover);
  color: var(--text-dim);
}
.rank-name { font-weight: 600; font-size: 13px; }
.rank-xp { font: 12px var(--mono); color: var(--text-dim); }
.rank-step.is-done .rank-dot { background: rgba(61, 220, 132, 0.15); color: var(--ok); }
.rank-step.is-current { border-color: var(--accent); background: var(--accent-soft); }
.rank-step.is-current .rank-dot { background: var(--accent); color: #04121f; }
.rank-step.is-locked { opacity: 0.55; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  font: 13px var(--font);
  cursor: pointer;
}
.badge-option:hover { border-color: var(--badge-color, var(--accent)); }
.badge-option.is-selected {
  border-color: var(--badge-color, var(--accent));
  background: color-mix(in srgb, var(--badge-color, var(--accent)) 12%, var(--bg));
}
.badge-option:disabled { opacity: 0.35; cursor: not-allowed; }
.badge-option-icon { font-size: 22px; line-height: 1.2; }
.badge-option-name { font-weight: 600; color: var(--badge-color, var(--text)); }
.badge-option-desc { font-size: 12px; color: var(--text-dim); }
.badge-none .badge-option-icon { color: var(--text-dim); }

.table-wrap { overflow-x: auto; }
.flights-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.flights-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.flights-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.flights-table tbody tr:hover { background: var(--panel-hover); }
.flights-table .empty-row { padding: 20px 10px; white-space: normal; }

/* ---------- Modal (flight replay) ---------- */
.modal { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.modal-panel {
  position: relative;
  width: min(900px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15px; color: var(--text); text-transform: none; letter-spacing: 0; }
.modal-body { overflow-y: auto; padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; }

.replay-map { height: 320px; border-radius: 0; overflow: hidden; background: var(--bg); flex-shrink: 0; }
.replay-stats { grid-template-columns: repeat(4, 1fr); }
.replay-h { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.replay-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.alt-chart { margin: 0; }
.alt-chart svg { width: 100%; height: 140px; display: block; background: var(--bg); border-radius: 0; }
.alt-area { fill: rgba(63, 169, 245, 0.15); }
.alt-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.alt-chart figcaption { display: flex; justify-content: space-between; margin-top: 4px; }

.result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-table td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.result-table .num { text-align: right; font-family: var(--mono); }
.result-table .is-bad { color: var(--danger); }
.result-table .is-total td { font-weight: 600; color: var(--ok); border-bottom: none; }

.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.event-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.event-list strong { text-transform: capitalize; }

@media (max-width: 768px) {
  .profile-name { font-size: 32px; }
  .replay-stats { grid-template-columns: repeat(2, 1fr); }
  .replay-cols { grid-template-columns: 1fr; }
}

/* ---------- Confirm dialog ---------- */
.confirm-panel { width: min(420px, 100%); padding: 24px; gap: 10px; }
.confirm-title { font-size: 18px; color: var(--text); text-transform: none; letter-spacing: 0; }
.confirm-panel p { margin: 0; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.confirm-actions .btn-primary { margin: 0; padding: 0 18px; }
.btn-primary-danger { background: var(--danger); color: #1a0406; }

/* ---------- Switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text-dim); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 0;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .switch-track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; }

.profile-hero { position: relative; }
.profile-privacy { position: absolute; top: 20px; right: 24px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.profile-privacy[hidden] { display: none; }

/* ---------- Leaderboard ---------- */
.leaderboard-view > * { flex-shrink: 0; }
.leaderboard-table .num { text-align: right; font-family: var(--mono); }
.leaderboard-table th.num { text-align: right; }
.leaderboard-table .is-sorted { color: var(--accent); font-weight: 600; }
.lb-pos { width: 40px; font: 600 14px var(--mono); color: var(--text-dim); }
.lb-badge { margin-right: 6px; }
.leaderboard-table tr.is-top-1 .lb-pos { color: #f5d33f; }
.leaderboard-table tr.is-top-2 .lb-pos { color: #c9d1d9; }
.leaderboard-table tr.is-top-3 .lb-pos { color: #d08b52; }
.leaderboard-table tr.is-me { background: var(--accent-soft); }
.leaderboard-table tr.is-me:hover { background: var(--accent-soft); }

@media (max-width: 768px) {
  .profile-privacy { position: static; margin-bottom: 8px; }
}

/* ---------- Multi-leg ---------- */
.job-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-multileg {
  color: #c4a5ff;
  background: rgba(167, 139, 250, 0.14);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
}
.tag-multileg-kind { color: #c4a5ff; border: 1px solid rgba(167, 139, 250, 0.4); background: transparent; font-size: 11px; }

.job-route.is-chain { flex-wrap: wrap; gap: 6px 10px; }
.job-route.is-chain strong { font-size: 15px; }
.job-route.is-chain .job-arrow { font-size: 14px; }

.legs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.legs-table th {
  text-align: left;
  padding: 6px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.legs-table td { padding: 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.legs-table .num { text-align: right; font-family: var(--mono); color: var(--ok); }
.legs-table tr.is-bonus td { color: #c4a5ff; border-bottom: none; }
.legs-table tr.is-bonus .num { color: #c4a5ff; }
.legs-table tr.is-current td { background: var(--accent-soft); }
.legs-table tr.is-done td { color: var(--text-dim); }
.leg-chip { font: 600 11px var(--mono); color: #c4a5ff; margin-left: 6px; }

/* ---------- Missions ---------- */
.missions-view > * { flex-shrink: 0; }
.missions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.mission-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.mission-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mission-kind {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.mission-kind-daily { background: rgba(245, 184, 63, 0.15); color: #f5b83f; }
.mission-kind-weekly { background: rgba(167, 139, 250, 0.16); color: #c4a5ff; }
.mission-title { font-size: 22px; color: var(--text); text-transform: none; letter-spacing: 0; }
.mission-briefing { margin: 0; line-height: 1.6; font-size: 14px; }
.mission-map { height: 240px; border-radius: 0; overflow: hidden; background: var(--bg); }

.mission-legs { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.mission-legs > li::marker { color: var(--text-dim); font-family: var(--mono); }
.mission-leg-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.mission-legs p { margin: 4px 0; color: var(--text-dim); }

.objective-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.objective-list li { display: flex; gap: 8px; align-items: baseline; }
.obj-kind {
  flex-shrink: 0;
  width: 46px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  border-radius: 0;
  padding: 1px 0;
}
.objective-list .is-main .obj-kind { background: rgba(167, 139, 250, 0.18); color: #c4a5ff; }
.objective-list .is-side .obj-kind { background: var(--panel-hover); color: var(--text-dim); }

.mission-rewards { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; padding: 10px 12px; border-radius: 0; background: var(--bg); }
.mission-rewards > .muted { flex-basis: 100%; }
.star-reward { font: 600 13px var(--mono); color: var(--ok); }
.stars { color: #f5d33f; letter-spacing: 1px; white-space: nowrap; }
.stars-lg { font-size: 22px; }
.mission-done { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.btn-link-primary { display: inline-flex; align-items: center; text-decoration: none; margin: 0; padding: 0 18px; }
.mission-board td, .mission-board th { padding: 6px 8px; }
.mission-board .num { text-align: right; font-family: var(--mono); }

.mission-summary { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.mission-dash-title { font-size: 15px; }
.mission-banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.objective-label { border-color: #c4a5ff !important; color: #c4a5ff !important; }
.objective-label::before { border-right-color: #c4a5ff !important; }

@media (max-width: 768px) {
  .missions-grid { grid-template-columns: 1fr; }
}
.star-on { color: #f5d33f; }
.star-off { color: var(--border); }

/* ---------- EFB look ----------
   Same typography as the C212 EFB: uppercase, widely spaced labels (EFB .card-tag),
   uppercase buttons and tabs, bold accent buttons, numbers in the mono font. */
h2, .detail-label, .detail-grid dt, .flights-table th, .legs-table th, .replay-h, .field > span {
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
h2 { font-size: 12px; }

.nav-item span {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  font-weight: 600;
}
.nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }

.btn-primary, .btn-secondary, .btn-small, .filter-btn, .tab, .back-link, .details-hint, .dropdown-toggle {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.btn-primary { font-weight: 700; }
.btn-primary:hover { background: #5cb6ff; filter: none; }

.topbar h1, .profile-name, .mission-title { letter-spacing: 0.02em; }
.stat-big, .efb-value, .profile-stat strong, .flight-no, .xp-badge, .job-route strong,
.detail-airport strong, .detail-grid dd, .rank-xp, .mono { font-family: var(--mono); }

/* Tags and pills read like the EFB's square status badges */
.tag, .status-pill, .mission-kind, .badge-chip { letter-spacing: 0.06em; }
.status-pill, .mission-kind { text-transform: uppercase; }
.status-pill.is-live { border: 1px solid var(--ok); }
.status-pill.is-stale { border: 1px solid var(--danger); }

/* Leaflet controls and labels: square too */
.leaflet-bar, .leaflet-bar a, .leaflet-tooltip, .leaflet-control-attribution { border-radius: 0 !important; }
.leaflet-tooltip.route-label { font-family: var(--mono); letter-spacing: 0.05em; }

/* ---------- Force finish ---------- */
.btn-warn { border-color: var(--warn); color: var(--warn); background: transparent; }
.btn-warn:hover { background: var(--warn); color: #1a1204; }
.tag-flagged { color: var(--danger); background: rgba(255, 91, 91, 0.12); }
.tag-forced { color: var(--warn); background: rgba(255, 180, 60, 0.12); margin-left: 4px; }
.notice-bad { border-color: rgba(255, 91, 91, 0.4); background: rgba(255, 91, 91, 0.1); }

/* ---------- Public pilot profiles ---------- */
.profile-content { display: flex; flex-direction: column; gap: 16px; }
.profile-content[hidden] { display: none; }
.profile-content > * { flex-shrink: 0; }
.profile-private { align-items: center; text-align: center; color: var(--text-dim); padding: 40px 20px; }
.profile-private[hidden] { display: none; }
.profile-private p { margin: 0; font-size: 15px; }
.back-link[hidden] { display: none; }

.badge-option { position: relative; }
.badge-option.is-static { cursor: default; }
.badge-option.is-static:hover { border-color: var(--border); }
.badge-option.is-static.is-selected:hover { border-color: var(--badge-color, var(--accent)); }
.badge-option.is-locked > :not(.badge-lock) { filter: grayscale(1); opacity: 0.35; }
.badge-option.is-locked .badge-option-name { color: var(--text-dim); }
.badge-lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  pointer-events: none;
}

.pilot-link { color: inherit; text-decoration: none; }
.pilot-link:hover { color: var(--accent); text-decoration: underline; }
.leaderboard-table tbody tr[data-pilot] { cursor: pointer; }
.switch[hidden] { display: none; }

/* Anything marked hidden stays hidden, whatever display its class sets */
[hidden] { display: none !important; }

/* ---------- Notifications ---------- */
.notif { position: relative; }
.notif-bell { position: relative; width: 38px; height: 38px; }
.notif-count {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font: 700 10px/17px var(--font);
  text-align: center;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, calc(100vw - 32px));
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  z-index: 1500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.notif-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: default; }
.notif-item[data-link] { cursor: pointer; }
.notif-item:hover { background: var(--panel-hover); }
.notif-item.is-unread { box-shadow: inset 3px 0 0 var(--accent); }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-item.is-unread .notif-title { color: var(--text); }
.notif-item:not(.is-unread) .notif-title { color: var(--text-dim); }
.notif-text { margin-top: 2px; }
.notif-time { margin-top: 4px; font-size: 11px; }
.notif-actions { display: flex; gap: 6px; margin-top: 8px; }
.notif-empty { padding: 20px 14px; }
.btn-secondary-small { border-color: var(--border); background: transparent; color: var(--text-dim); }
.btn-secondary-small:hover { background: var(--panel-hover); color: var(--text); }

/* ---------- Friends ---------- */
.friend-action { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 0; }
.friend-action:empty { display: none; }
.tag-friend { color: var(--ok); background: rgba(53, 201, 110, 0.12); }
.friend-add { display: flex; gap: 6px; }
.friend-input {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: 13px var(--font);
  width: 180px;
}
.friend-input:focus { outline: none; border-color: var(--accent); }
.friend-list { list-style: none; margin: 0 0 8px; padding: 0; }
.friend-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.friend-row:last-child { border-bottom: none; }
.friend-row-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ---------- Share a job ---------- */
.share-list { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; }
.share-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ---------- Live traffic ---------- */
.leaflet-tooltip.traffic-tip {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font: 12px/1.5 var(--font);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.leaflet-tooltip.traffic-tip::before { border-top-color: var(--border); }

/* Square icon button (e.g. Share with friend) */
.btn-icon-square {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
}
.btn-icon-square:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon-square.btn-icon-small { width: 30px; height: 30px; }

/* ---------- Account emails, bans, admin ---------- */
.form-ok { margin: 0; color: var(--ok); font-size: 13px; }
.form-ok:empty, .form-error:empty { display: none; }
.auth-title { margin: 0; font-size: 16px; color: var(--text); text-transform: none; letter-spacing: 0; }
.auth-title-bad { color: var(--danger); }
.auth-link { align-self: center; }
.auth-details summary { cursor: pointer; color: var(--text-dim); font-size: 13px; }
.auth-inline-form { display: flex; gap: 8px; margin-top: 10px; }
.auth-inline-form input { flex: 1; min-width: 0; height: 30px; padding: 0 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--font); }
.ban-reason { padding: 10px 14px; border: 1px solid rgba(255, 91, 91, 0.4); background: rgba(255, 91, 91, 0.08); }
.ban-reason p { margin: 6px 0 0; white-space: pre-line; }

.notif-text { white-space: pre-line; }
.tag-hidden { color: var(--text-dim); background: rgba(139, 150, 168, 0.14); margin-left: 4px; }
.subhead { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--text); }
.inline-link { display: inline; font-size: 12px; }
.account-form { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }

.field textarea, .field input[type="color"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: 14px var(--font);
  resize: vertical;
}
.field input[type="color"] { width: 64px; height: 40px; padding: 4px; cursor: pointer; }
.field textarea:focus { outline: none; border-color: var(--accent); }
.form-modal { display: flex; flex-direction: column; gap: 14px; }
.form-modal-fields { display: flex; flex-direction: column; gap: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); cursor: pointer; }

.admin-body { display: flex; flex-direction: column; gap: 12px; }
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-toolbar select { height: 30px; padding: 0 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--font); }
.admin-table td { vertical-align: middle; }
.admin-table td.wrap { white-space: normal; min-width: 180px; }
.admin-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.admin-notes .tag { margin: 1px 2px 1px 0; }
.admin-badges span { margin-right: 3px; }
.admin-table tr.is-banned td { opacity: 0.6; }
.admin-badge-list { list-style: none; margin: 0; padding: 0; }
.admin-badge-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
#flightsMore { align-self: center; }

.notif-item { position: relative; padding-right: 36px; }
.notif-delete {
  position: absolute; top: 8px; right: 8px;
  display: grid; place-items: center; width: 22px; height: 22px;
  padding: 0; border: none; background: none; color: var(--text-faint); cursor: pointer;
  opacity: 0;
}
.notif-item:hover .notif-delete, .notif-delete:focus-visible { opacity: 1; }
.notif-delete:hover { color: var(--danger); }
@media (hover: none) { .notif-delete { opacity: 1; } }
.notif-head-actions { display: flex; gap: 14px; }
.notif-clear { color: var(--danger); }
.auth-brand { color: #fff; }
.traffic-tip-hint { color: var(--accent); font-size: 11px; }

/* ---------- Phones ---------- */
.app { height: 100dvh; }   /* dvh: the visible height, without the phone browser's address bar */
.tab { white-space: nowrap; }

@media (max-width: 768px) {
  /* Top bar: one line, name shortened if it has to be */
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar-title h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
  .user-chip { gap: 4px; }

  /* Notifications: full width under the top bar instead of hanging off the left edge */
  .notif { position: static; }
  .notif-panel { position: fixed; top: 64px; left: 8px; right: 8px; width: auto; max-height: calc(100dvh - 80px); }
  .notif-head { flex-wrap: wrap; gap: 8px; }

  /* Jobs: the list grows with the page instead of spilling out of a fixed box */
  .jobs-layout { flex: none; min-height: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: 260px auto; }
  /* Wide tables scroll sideways inside their card instead of stretching the page */
  .legs-table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Maps: the scale bar collides with the attribution on narrow screens */
  .leaflet-control-scale { display: none; }
  .leaflet-control-attribution { font-size: 9px; }

  .content { padding: 12px; gap: 12px; }
  .auth-card { padding: 24px 18px; }
  .tab { font-size: 12px; }
}

/* Leaderboard on phones: position, pilot (rank underneath) and the column it's sorted by */
.lb-rank-inline { display: none; }
@media (max-width: 768px) {
  .leaderboard-table th:nth-child(3), .leaderboard-table td:nth-child(3),
  .leaderboard-table th:nth-child(7), .leaderboard-table td:nth-child(7),
  .leaderboard-table[data-sort="xp"] :is(th, td):is(:nth-child(5), :nth-child(6)),
  .leaderboard-table[data-sort="hours"] :is(th, td):is(:nth-child(4), :nth-child(6)),
  .leaderboard-table[data-sort="distance"] :is(th, td):is(:nth-child(4), :nth-child(5)) { display: none; }
  .lb-rank-inline { display: block; margin-top: 2px; }
  .leaderboard-table { white-space: normal; }
  .leaderboard-view .card-title-row .type-filter { width: 100%; }
  .leaderboard-view .card-title-row .filter-btn { flex: 1; padding: 0 6px; font-size: 11px; white-space: nowrap; }
}

/* Past flights on phones: date, flight, route, XP and the view button (operator, load, distance, time in the replay) */
@media (max-width: 768px) {
  .profile-view .flights-table :is(th, td):is(:nth-child(4), :nth-child(5), :nth-child(6), :nth-child(7)) { display: none; }
  .profile-view .flights-table td, .profile-view .flights-table th { padding: 8px 6px; }
  .profile-view .flights-table .leg-chip { display: block; margin: 2px 0 0; }
  .friend-add { width: 100%; }
  .friend-add .friend-input { flex: 1; min-width: 0; }
}
.flight-row { cursor: pointer; }
@media (max-width: 768px) {
  .profile-view .flights-table :is(th, td):nth-child(9) { display: none; }
  .profile-view .flights-table td:nth-child(8) { white-space: normal; }
  .profile-view .flights-table { white-space: normal; }
  .profile-view .flights-table td:nth-child(-n+3) { white-space: nowrap; }
}
@media (max-width: 768px) {
  .profile-view .flights-table td:nth-child(8) .tag { display: inline-block; margin: 2px 0 0; }
  .profile-view .flights-table td:first-child { font-size: 12px; }

  /* Rank ladder: two compact columns instead of ten full-width rows */
  .rank-ladder { grid-template-columns: 1fr 1fr; gap: 6px; }
  .rank-step { padding: 7px 8px; column-gap: 8px; }
  .rank-dot { width: 22px; height: 22px; font-size: 11px; }
  .rank-name { font-size: 12px; }
  .rank-xp { font-size: 11px; }

  /* Admin: tabs in a 2×2 grid, toolbar fields share the width */
  .admin-view .card-title-row { flex-direction: column; align-items: stretch; }
  .admin-view #adminTabs { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 36px; height: auto; }
  .admin-view #adminTabs .filter-btn { border-left: none; font-size: 11px; box-shadow: inset 0 -1px var(--border); }
  .admin-view #adminTabs .filter-btn:nth-child(odd) { box-shadow: inset 0 -1px var(--border), inset -1px 0 var(--border); }
  .admin-toolbar .friend-input, .admin-toolbar select { flex: 1 1 140px; width: auto; }
  .admin-badge-row { grid-template-columns: 1fr auto; }
  .admin-badge-row > .muted { grid-column: 1 / -1; grid-row: 2; }
}

/* Airline special missions and hand-made missions */
.mission-kind-special { background: rgba(255, 91, 91, 0.14); color: #ff8a8a; }
.mission-kind-custom { background: rgba(53, 201, 110, 0.14); color: var(--ok); }
.job-mission { display: flex; flex-direction: column; gap: 8px; }
.job-mission .mission-briefing { white-space: pre-line; }
.job-card .mission-banner { font-size: 13px; }
.tag-dev { color: #c4a5ff; background: rgba(167, 139, 250, 0.14); margin-left: 4px; }

/* ---------- Airline & mission editors ---------- */
.editor-form { display: flex; flex-direction: column; gap: 14px; }
.editor-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.check-group { display: flex; flex-wrap: wrap; gap: 6px 14px; min-height: 40px; align-items: center; }
.editor-errors { margin: 0; padding-left: 18px; }
.editor-errors:empty { display: none; }
.admin-toolbar > select { min-width: 240px; }

.code-box { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.code-input, .route-row .code-input {
  height: 34px; padding: 0 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font: 14px var(--mono); text-transform: uppercase;
}
.code-input:focus { outline: none; border-color: var(--accent); }
.code-input.invalid { border-color: var(--danger); }
.code-names { font-size: 11px; color: var(--text-dim); min-height: 14px; }
.code-names.is-bad { color: var(--danger); }

.route-rows { display: flex; flex-direction: column; gap: 8px; }
.route-row { display: flex; align-items: flex-start; gap: 10px; }
.route-row .check-row { height: 34px; white-space: nowrap; }
.route-arrow { height: 34px; display: grid; place-items: center; color: var(--text-dim); font-size: 16px; }

.network-box { border: 1px solid var(--border); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.network-head { display: flex; gap: 8px; align-items: center; }
.network-head .friend-input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty::before { content: "No airports yet"; color: var(--text-faint); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 8px; background: var(--accent-soft); color: var(--accent); font: 600 12px var(--mono); }
.chip button { border: none; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.chip button:hover { color: var(--danger); }
.chip-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip-add .friend-input { width: 150px; text-transform: uppercase; font-family: var(--mono); }

.load-fields { gap: 6px; }
.load-fields input { height: 34px; padding: 0 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 14px var(--font); }
.load-fields input[hidden] { display: none; }

.mission-map { height: 380px; border: 1px solid var(--border); cursor: crosshair; }
.waypoint-table td { padding: 4px 4px; }
.waypoint-table input:not([type="checkbox"]), .waypoint-table select {
  height: 30px; padding: 0 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--font); width: 130px;
}
.waypoint-table .num-input { width: 90px; font-family: var(--mono); }
.waypoint-table .num-input.short { width: 60px; }
.waypoint-table select { width: auto; }
.wpt-marker { display: grid; place-items: center; }
.wpt-marker span {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: #c4a5ff; color: #120b24; font: 700 11px var(--mono); border: 2px solid #0b0f14;
}

@media (max-width: 768px) {
  .route-row { flex-wrap: wrap; }
  .route-row .code-box { flex: 1 1 120px; }
  .mission-map { height: 280px; }
}

/* ---------- Fuel & performance ---------- */
.fuel-panel { width: min(760px, 100%); }
.fuel-legs { flex-wrap: wrap; }
.fuel-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.fuel-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fuel-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.fuel-table .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.fuel-table .is-total td { font-weight: 700; color: var(--text); border-top: 1px solid var(--text-faint); }
.fuel-table .is-check td:first-child { font-weight: 600; }
.fuel-table .is-over td { color: var(--danger); }
.fuel-extra { width: 80px; height: 26px; padding: 0 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--mono); text-align: right; }
.card .field-inline { max-width: 320px; }
@media (max-width: 768px) {
  .fuel-cols { grid-template-columns: 1fr; }
}

/* Pages scroll as a whole: cards keep their full height instead of being squeezed (which let
   their content spill out). The jobs page keeps its own scrolling list. */
.content:not(.jobs-view) > * { flex-shrink: 0; }
.card .field-inline { flex: none; }

/* Action buttons in table cells: the cell stays a table cell so its row line is drawn */
.flights-table td.admin-actions { display: table-cell; text-align: right; white-space: nowrap; }
.flights-table td.admin-actions > * { vertical-align: middle; }
.flights-table td.admin-actions > * + * { margin-left: 6px; }
.fuel-minutes { width: 56px; margin-left: 6px; }

/* Mission editor legs */
.leg-box { border: 1px solid var(--border); border-left: 3px solid var(--leg-color, var(--accent)); padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.leg-box.is-active { background: rgba(53, 164, 255, 0.04); border-color: var(--leg-color, var(--accent)); }
.leg-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.leg-head strong { color: var(--leg-color, var(--text)); }
.leg-tools { margin-left: auto; display: flex; gap: 4px; }
.load-fields select { height: 34px; padding: 0 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 14px var(--font); }
.code-input[readonly] { color: var(--text-dim); background: var(--panel); }
.fuel-send { align-items: center; }
.fuel-send .btn-primary { flex: none; }

/* Job board: filters dropdown */
.filters-dropdown { position: relative; }
.filters-dropdown > .filter-btn { height: 40px; border: 1px solid var(--border); background: var(--bg); }
.filters-off { color: var(--warn); margin-left: 4px; }
.filters-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 1200; min-width: 220px;
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.filters-menu[hidden] { display: none; }
.filters-menu .check-row { color: var(--text); white-space: nowrap; }
.find-from-aircraft { height: 40px; }
.field.is-unused > span { color: var(--text-faint); text-decoration: line-through; }
.jobs-toolbar { flex-wrap: wrap; }
.jobs-toolbar .filter-btn, .jobs-toolbar .btn-primary, .jobs-toolbar .btn-secondary { white-space: nowrap; flex-shrink: 0; }
.jobs-toolbar .type-filter { flex-shrink: 0; }
.jobs-toolbar .from-airport { flex: 0 0 auto; }
.from-airport input { width: 130px; height: 32px; padding: 0 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--font); text-transform: uppercase; }
.from-airport input::placeholder { text-transform: none; }

/* Mission editor: waypoint explanations; special mission stories */
.wp-note-row td { border-bottom: 1px solid var(--border); padding-top: 0; }
.waypoint-table tr[data-wp]:not(.wp-note-row) td { border-bottom: none; }
.wp-note-row textarea {
  width: 100%; min-height: 34px; padding: 6px 8px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font: 13px var(--font); resize: vertical;
}
.placeholder-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-btn { cursor: pointer; border: 1px solid transparent; }
.chip-btn:hover { border-color: var(--accent); }
.template-preview { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px dashed var(--border); }
.template-preview .mission-briefing { white-space: pre-line; }
.mission-kind-community { background: rgba(90, 209, 209, 0.14); color: #5ad1d1; }
.mission-author { font-size: 12px; color: var(--text-dim); }
.obj-note { display: block; margin: 2px 0 0; color: var(--text-dim); font-size: 12px; white-space: pre-line; }
.objective-list .is-optional .obj-kind { background: transparent; border: 1px solid var(--border); color: var(--text-faint); }

/* Map style dropdown (every map, top right) */
.basemap-select {
  height: 28px; padding: 0 8px; border: 1px solid var(--border); background: rgba(17, 22, 29, 0.9);
  color: var(--text); font: 600 11px var(--font); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.basemap-select:focus { outline: none; border-color: var(--accent); }
/* Light map styles: keep the attribution readable */
[data-basemap="streets"] .leaflet-control-attribution, [data-basemap="terrain"] .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.8) !important; color: #333 !important;
}

/* Community Missions page and starred jobs */
.community-title { display: flex; flex-direction: column; gap: 2px; margin-right: auto; }
.community-title h2 { margin: 0; }
.star-btn.is-starred { color: #f5c542; border-color: rgba(245, 197, 66, 0.6); }
.star-btn.is-starred svg { fill: #f5c542; }
.star-btn:not(.is-starred):hover { color: #f5c542; border-color: #f5c542; }
.card-star { color: #f5c542; font-size: 13px; }

/* Rating popup */
.rate-stars { display: flex; gap: 6px; justify-content: center; margin: 10px 0 4px; }
.rate-stars button {
  border: none; background: none; cursor: pointer; padding: 2px;
  font-size: 34px; line-height: 1; color: var(--border); transition: color 0.1s ease, transform 0.1s ease;
}
.rate-stars button.is-on { color: #f5c542; }
.rate-stars button:hover { transform: scale(1.12); }

/* Plays and rating on mission cards */
.mission-stats { font-size: 12px; color: var(--text-dim); }
.mission-stats .rating-star { color: #f5c542; }
.board-sort { height: 40px; padding: 0 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--font); }

/* Leaderboard: lifetime / season */
.season-switch { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.season-pick { position: relative; display: flex; }
.season-menu { min-width: 160px; gap: 2px; padding: 6px; max-height: 280px; overflow-y: auto; }
.season-option {
  text-align: left; padding: 7px 10px; border: none; background: none; color: var(--text);
  font: 13px var(--mono); cursor: pointer;
}
.season-option:hover { background: var(--panel-hover); }
.season-option.is-current { color: var(--accent); }

/* ---------- Bug reports (next to the notification bell) ---------- */
.bug-panel { width: min(320px, calc(100vw - 32px)); }
.bug-body { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.bug-body p { margin: 0; }
.bug-link { display: grid; place-items: center; text-decoration: none; }
.bug-privacy { align-self: center; }

/* ---------- Privacy page and sign-up note ---------- */
.privacy-card { max-width: 720px; }
.privacy-card h1 { margin: 0 0 8px; font-size: 22px; }
.privacy-card h2 { margin: 22px 0 8px; font-size: 15px; }
.privacy-card p, .privacy-card li { line-height: 1.55; }
.privacy-card ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.auth-note { margin: 0; text-align: center; }
.account-card a, .privacy-card a, .auth-note a { color: var(--accent); }
@media (max-width: 768px) { .bug-panel { width: auto; } }

/* Admin → Revenue */
.rev-heading { margin: 8px 0 0; font-size: 14px; color: var(--text-dim); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.rev-month { width: 170px; }
.rev-rate { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }
.rev-rate .friend-input { width: 110px; }
.rev-rate .rev-date { width: 150px; }
.rev-table td.num, .rev-table th.num, .rev-lines .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.rev-table tfoot td { font-weight: 600; border-top: 1px solid var(--border); }
.rev-editor { display: flex; flex-direction: column; gap: 12px; }
.rev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.rev-editor .field select, .rev-lines select { height: 34px; padding: 0 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--font); }
.rev-lines select { width: 100%; min-width: 150px; }
.rev-lines .friend-input { width: 120px; }
.rev-pct { width: 80px !important; }
#revPctTotal.is-off { color: var(--danger); }
#revEstimate[hidden], .rev-rate[hidden] { display: none; }
.rev-drop { display: flex; align-items: center; justify-content: center; min-height: 56px; margin: 4px 0; border: 1px dashed var(--border); color: var(--text-dim); font-size: 13px; cursor: pointer; }
.rev-drop:hover, .rev-drop.is-over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rev-import-file { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.rev-import-file .admin-toolbar select { height: 34px; padding: 0 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--font); }
.rev-check { width: 32px; }
.rev-table tr.is-excluded td:not(.rev-check):not(.admin-actions) { opacity: 0.4; }
.rev-clickable { cursor: pointer; }
.rev-clickable:hover td { background: var(--panel-hover); }
.rev-table tr.rev-group td { border-top: 1px solid var(--border); }

/* Admin → Analytics */
.an-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 12px 0; }
.an-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); background: var(--bg); }
.an-big { font: 600 19px var(--mono); color: var(--text); white-space: nowrap; }
.an-chart { position: relative; margin: 8px 0 16px; overflow: hidden; }
.an-chart svg { display: block; }
.an-grid { stroke: var(--border); stroke-width: 1; }
.an-axis { fill: var(--text-faint); font: 11px var(--font); }
.an-sub { fill: var(--text-dim); }
.an-bar.an-actual { fill: var(--accent); }
.an-bar.an-estimate { fill: var(--accent); fill-opacity: 0.45; }
.an-bar.an-projected { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; }
.an-bar.is-hover { stroke: var(--text); stroke-width: 2; }
.an-key { display: flex; gap: 14px; font-size: 12px; color: var(--text-dim); }
.an-key span { display: inline-flex; align-items: center; gap: 6px; }
.an-swatch { width: 12px; height: 12px; display: inline-block; border-radius: 2px; }
.an-swatch.an-actual { background: var(--accent); }
.an-swatch.an-estimate { background: var(--accent); opacity: 0.45; }
.an-swatch.an-projected { background: var(--accent-soft); border: 1.5px dashed var(--accent); }
.an-tip { position: absolute; pointer-events: none; padding: 6px 10px; background: var(--card); border: 1px solid var(--border); color: var(--text); font: 12px var(--font); white-space: nowrap; }
.an-tip[hidden] { display: none; }

/* Admin → Revenue → Payouts */
.rev-sort { padding: 0; border: none; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.rev-sort:hover { color: var(--text); }
.rev-payouts td.nowrap { white-space: nowrap; }
.rev-owed { color: var(--danger); }
.rev-proof { white-space: nowrap; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; vertical-align: middle; }
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon-danger:hover { border-color: var(--danger); color: var(--danger); }
.rev-info { position: relative; display: inline-flex; vertical-align: middle; color: var(--text-faint); cursor: help; outline: none; }
.rev-info:hover, .rev-info:focus { color: var(--accent); }
.rev-info-pop { display: none; position: fixed; z-index: 50; padding: 8px 10px; background: var(--card); border: 1px solid var(--border); color: var(--text); font: 12px var(--font); white-space: nowrap; text-transform: none; letter-spacing: 0; }
.rev-info-pop div + div { margin-top: 4px; }
.rev-info:hover .rev-info-pop, .rev-info:focus .rev-info-pop { display: block; }

/* ---------- Beta (admins and developers) ---------- */
.tag-beta { display: inline-block; margin-left: 6px; padding: 1px 5px; border: 1px solid #d946ef; background: rgba(217, 70, 239, 0.16); color: #f0abfc;
  font: 700 10px/1.4 var(--font); letter-spacing: 0.08em; text-transform: uppercase; vertical-align: middle; }
.view-reserved[hidden] { display: none; }

/* CT114 mode: the C212-only parts step aside, and the site turns red */
.theme-ct114 .c212-only { display: none !important; }
html:not(.theme-ct114) .ct114-only { display: none !important; }
:root.theme-ct114 {
  --bg: #120b0c;
  --panel: #1a1113;
  --card: #211518;
  --panel-hover: #362226;
  --border: #3a272b;
  --text-dim: #a8939a;
  --text-faint: #75606a;
  --accent: #ff4d5e;
  --accent-soft: rgba(255, 77, 94, 0.12);
}

/* Top bar: back to projectmax.store */
a.topbar-site { color: var(--text-dim); text-decoration: none; }

/* Admin → Store (js/store.js) */
.tag-live { color: var(--ok); background: rgba(61, 220, 132, 0.12); }
.flights-table tr.clickable { cursor: pointer; }
.flights-table tr.clickable:hover td { background: rgba(255, 255, 255, 0.03); }
.store-title { margin: 0; display: flex; align-items: center; gap: 8px; }
.store-version { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--border); }
.store-version .rev-heading { margin: 0; display: flex; align-items: center; gap: 8px; }
.store-spacer { flex: 1; }
.store-version select, .store-tabs select, #stLicFilter select { height: 34px; padding: 0 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 13px var(--font); }
.store-upload-btn { cursor: pointer; display: inline-flex; align-items: center; }
.store-eula { font: 13px/1.5 var(--font); }
.store-keys { display: flex; flex-direction: column; gap: 8px; }
.store-keylist { width: 100%; padding: 10px 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px; resize: vertical; }
a.btn-small { display: inline-flex; align-items: center; text-decoration: none; }
.store-checks { display: flex; gap: 14px; height: 40px; align-items: center; }
.store-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.store-thumb { position: relative; margin: 0; aspect-ratio: 16 / 10; border: 1px solid var(--border); overflow: hidden; background: var(--bg); }
.store-thumb[draggable] { cursor: grab; }
.store-thumb.dragging { opacity: 0.4; }
.store-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.store-thumb .tag { position: absolute; left: 6px; top: 6px; }
.store-thumb [data-del] { position: absolute; right: 6px; top: 6px; padding: 2px 8px; }
.rev-drop.over { border-color: var(--accent); }
.flights-table tfoot td { border-top: 1px solid var(--border); }
.store-opts { display: flex; flex-direction: column; gap: 12px; }
.store-opt { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--border); }
.store-opt textarea, .store-step textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; resize: vertical; }
.store-steps { display: flex; flex-direction: column; gap: 8px; }
.store-step { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px dashed var(--border); }
