:root {
  --bg: #F4F4F4;
  --surface: #FFFFFF;
  --gold: #B8960C;
  --gold-light: #F5E9C0;
  --gold-dark: #8B6F09;
  --text-primary: #1A1A1A;
  --text-secondary: #6B6B6B;
  --success: #2D7A4F;
  --success-light: #E8F5E9;
  --danger: #C0392B;
  --danger-light: #FDECEA;
  --amber: #E6A817;
  --border: #E0E0E0;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --gold: #B8960C;     
  --text-primary: #1A1A1A;
  --radius: 10px;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 0.5rem; }
.header-left .tagline { color: var(--text-secondary); font-size: 0.8rem; display: none; }
@media(min-width:768px) { .header-left .tagline { display: inline; } }
.header-right { display: flex; gap: 0.5rem; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  font-family: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; border: 2px solid transparent;
  transition: all 150ms ease;
  text-decoration: none;
}
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-dark); }
.btn-outline { background: transparent; border-color: var(--gold); color: var(--gold); }
.btn-outline:hover { background: var(--gold-light); }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-text { background: none; border: none; color: var(--gold); padding: 0.3rem 0.5rem; }

.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  text-decoration: none;
}
.logo span { color: var(--gold); }

    /* --- Nav links (extensible) --- */
    .nav-links { display: flex; align-items: center; gap: 0; list-style: none; margin: 0; padding: 0; flex-shrink: 0; }
    .nav-links li { display: flex; align-items: center; }
    .nav-links li:not(:last-child)::after { content: ''; display: block; width: 1px; height: 14px; background: var(--border); margin: 0 0.1rem; }
    .nav-links a { font-size: 0.8rem; color: var(--text-secondary); text-decoration: none; padding: 0.35rem 0.55rem; border-radius: var(--radius-sm); transition: var(--transition); white-space: nowrap; }
    .nav-links a:hover { color: var(--gold); background: var(--gold-light); }
    /* --- Responsive --- */
    @media (max-width: 480px) {
      .nav-links { display: none; }
    }

/* Main layout */
.main { max-width: 1400px; margin: 0 auto; padding: 1rem; }

/* Quick search boxes */
.quick-search-row {
  display: grid; grid-template-columns: 1fr; gap: 1rem;
  margin-bottom: 1.5rem;
}
@media(min-width:768px) { .quick-search-row { grid-template-columns: 1fr 1fr; } }
.quick-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
  border-left: 4px solid var(--gold);
}
.quick-box h3 { font-size: 0.9rem; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.4rem; }
.quick-box .inputs { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-end; }
.quick-box input, .quick-box select {
  padding: 0.45rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 0.85rem; flex: 1; min-width: 100px;
}
.quick-box .btn { flex-shrink: 0; }

/* Desktop layout: sidebar + content */
.content-layout { display: flex; gap: 1.5rem; align-items: flex-start; }
.filter-sidebar {
  width: 320px; flex-shrink: 0;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
  position: sticky; top: 76px;
  max-height: calc(100vh - 92px); overflow-y: auto;
}
.results-area { flex: 1; min-width: 0; }

/* Mobile: hide sidebar, show filter button */
@media(max-width:767px) {
  .filter-sidebar { display: none; }
  .filter-sidebar.mobile-open {
    display: block; position: fixed; bottom: 0; left: 0; right: 0;
    top: auto; width: 100%; max-height: 80vh; z-index: 200;
    border-radius: 16px 16px 0 0; padding-bottom: 5rem;
    animation: slideUp 200ms ease;
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .mobile-filter-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 199; display: none;
  }
  .mobile-filter-backdrop.show { display: block; }
}
.mobile-filter-btn {
  display: none; position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  z-index: 150; background: var(--gold); color: #fff;
  padding: 0.7rem 1.5rem; border-radius: 50px; border: none;
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2); cursor: pointer;
}
.mobile-filter-btn .badge {
  background: #fff; color: var(--gold); border-radius: 50%;
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.7rem; margin-left: 0.4rem;
}
@media(max-width:767px) { .mobile-filter-btn { display: flex; align-items: center; } }

/* Filter panel internals */
.filter-group { margin-bottom: 1.25rem; }
.filter-group-title {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  color: var(--text-secondary); margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.filter-chip {
  padding: 0.3rem 0.65rem; border-radius: 50px; font-size: 0.78rem;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-secondary); cursor: pointer; font-weight: 500;
  transition: all 150ms ease; user-select: none;
  font-family: inherit;
}
.filter-chip:hover { border-color: var(--gold); color: var(--gold); }
.filter-chip.active {
  background: var(--gold); color: #fff; border-color: var(--gold);
}
.filter-search-input {
  width: 100%; padding: 0.45rem 0.7rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-family: inherit; font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.filter-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.filter-tag {
  display: inline-flex; align-items: center; gap: 0.25rem;
  background: var(--gold-light); color: var(--gold-dark);
  padding: 0.2rem 0.5rem; border-radius: 50px; font-size: 0.75rem; font-weight: 500;
}
.filter-tag button {
  background: none; border: none; cursor: pointer; color: var(--gold-dark);
  font-size: 0.85rem; line-height: 1; padding: 0; font-weight: 700;
}
.logic-toggle {
  display: flex; gap: 0; border: 1.5px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 1rem;
}
.logic-toggle button {
  flex: 1; padding: 0.4rem; font-family: inherit; font-size: 0.78rem;
  font-weight: 600; border: none; cursor: pointer;
  background: var(--surface); color: var(--text-secondary);
  transition: all 150ms;
}
.logic-toggle button.active { background: var(--gold); color: #fff; }
.filter-clear {
  width: 100%; padding: 0.5rem; border: 1.5px solid var(--danger);
  background: transparent; color: var(--danger); border-radius: var(--radius);
  font-family: inherit; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all 150ms;
}
.filter-clear:hover { background: var(--danger-light); }

/* Active filters bar */
.active-filters-bar {
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
  margin-bottom: 1rem; min-height: 0;
}
.active-filter-chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  background: var(--gold); color: #fff; padding: 0.25rem 0.6rem;
  border-radius: 50px; font-size: 0.75rem; font-weight: 500;
}
.active-filter-chip button {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 0.85rem; padding: 0; line-height: 1; margin-left: 0.15rem;
}

/* Results summary bar */
.results-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem;
}
.results-count { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.sort-select {
  padding: 0.4rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 0.8rem; background: var(--surface);
}

/* Pilot cards */
.cards-grid {
  display: grid; grid-template-columns: 1fr; gap: 1rem;
}
@media(min-width:600px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media(min-width:1024px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }

.pilot-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
  transition: box-shadow 150ms;
}
.pilot-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.6rem; }
.card-name { font-weight: 700; font-size: 1rem; }
.card-badges { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.badge {
  padding: 0.15rem 0.5rem; border-radius: 50px; font-size: 0.7rem;
  font-weight: 600; display: inline-block;
}
.badge-rank { background: var(--gold-light); color: var(--gold-dark); }
.badge-fleet { background: #E3F2FD; color: #1565C0; }
.badge-base { background: #F3E5F5; color: #7B1FA2; }
.card-meta { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 0.75rem; }
.freshness-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.25rem;
  vertical-align: middle;
}
.fresh-green { background: var(--success); }
.fresh-amber { background: var(--amber); }
.fresh-red { background: var(--danger); }

.card-section { margin-bottom: 0.5rem; }
.card-section-label {
  font-size: 0.68rem; text-transform: uppercase; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 0.25rem; letter-spacing: 0.03em;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.chip-want {
  padding: 0.15rem 0.45rem; border-radius: 50px; font-size: 0.7rem; font-weight: 500;
  background: var(--success-light); color: var(--success); border: 1px solid #C8E6C9;
}
.chip-avoid {
  padding: 0.15rem 0.45rem; border-radius: 50px; font-size: 0.7rem; font-weight: 500;
  background: var(--danger-light); color: var(--danger); border: 1px solid #F5C6CB;
}
.chip-dest-want {
  padding: 0.15rem 0.45rem; border-radius: 50px; font-size: 0.7rem; font-weight: 500;
  background: var(--gold-light); color: var(--gold-dark); border: 1px solid #EBD48A;
}
.chip-dest-avoid {
  padding: 0.15rem 0.45rem; border-radius: 50px; font-size: 0.7rem; font-weight: 500;
  background: #ECEFF1; color: #546E7A; border: 1px solid #CFD8DC;
}
.chip-more {
  padding: 0.15rem 0.45rem; font-size: 0.7rem; color: var(--text-secondary);
  cursor: pointer; font-weight: 500;
}
.chip-more:hover { text-decoration: underline; }
.card-note {
  font-size: 0.78rem; font-style: italic; color: var(--text-secondary);
  margin-top: 0.4rem; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%;
}
.card-prefs-row {
  font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.3rem;
}
.card-footer { margin-top: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.card-footer a {
  color: var(--gold); font-size: 0.8rem; font-weight: 600; text-decoration: none;
}
.card-footer a:hover { text-decoration: underline; }

/* Skeleton loader */
.skeleton-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
}
.skeleton-line {
  height: 14px; border-radius: 4px; background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
  margin-bottom: 0.6rem;
}
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w100 { width: 100%; }
.skeleton-line.h8 { height: 8px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* Empty state */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-secondary);
}
.empty-state i { margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text-primary); }
.empty-state p { font-size: 0.9rem; }

/* Toast */
.toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 500;
  display: flex; flex-direction: column; gap: 0.5rem;
}
@media(max-width:767px) { .toast-container { left: 1rem; right: 1rem; align-items: center; } }
.toast {
  padding: 0.75rem 1.25rem; border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 200ms ease;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--gold); color: #fff; }
@keyframes toastIn { from { opacity:0; transform: translateY(-10px); } to { opacity:1; transform: translateY(0); } }

/* Tooltip for ops codes */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: #fff; padding: 0.25rem 0.5rem;
  border-radius: 4px; font-size: 0.7rem; white-space: nowrap;
  z-index: 10; font-style: normal; font-weight: 400;
  pointer-events: none;
}

/* Scrollbar */
.filter-sidebar::-webkit-scrollbar { width: 4px; }
.filter-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Intro.js custom skin to match SwapDesk gold theme */
.swapdesk-intro-tooltip .introjs-tooltip-title { color: var(--gold); font-weight: 700; }
.introjs-button {
  font-family: 'Inter', sans-serif !important;
  border-radius: 8px !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
}
.introjs-nextbutton, .introjs-donebutton {
  background: var(--gold) !important;
  border-color: var(--gold-dark) !important;
  color: #fff !important;
  text-shadow: none !important;
}
.introjs-nextbutton:hover, .introjs-donebutton:hover {
  background: var(--gold-dark) !important;
}
.introjs-prevbutton { color: var(--text-primary) !important; text-shadow: none !important; }
.introjs-progressbar { background: var(--gold) !important; }
.introjs-helperLayer { border-radius: 10px !important; }
