:root {
  --bg: #edf3f8;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(107, 130, 154, 0.22);
  --text: #13283d;
  --muted: #597086;
  --accent: #0f3553;
  --accent-soft: #d9e7f3;
  --warm: #f2c46d;
  --shadow: 0 18px 48px rgba(22, 41, 58, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-display: "Space Grotesk", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(242, 196, 109, 0.2), transparent 24%),
    radial-gradient(circle at top right, rgba(130, 173, 213, 0.18), transparent 28%),
    linear-gradient(180deg, #f8fbfe 0%, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 24px 16px 36px;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 28px;
  background: linear-gradient(135deg, rgba(15, 53, 83, 0.98), rgba(24, 65, 99, 0.88));
  color: #fff;
}

.hero-copy {
  max-width: 860px;
}

.hero h1,
.summary-card h2,
.panel h2,
.details-card h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2rem, 3.5vw, 4.1rem);
  line-height: 0.98;
}

.hero .lede,
.summary-card .lede {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.82);
  max-width: 68ch;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--warm);
}

.hero-meta {
  display: grid;
  gap: 12px;
  min-width: 240px;
  align-self: end;
}

.meta-item,
.stat,
.panel,
.summary-card,
.table-card,
.details-card {
  border: 1px solid rgba(255, 255, 255, 0.76);
  background: var(--panel);
}

.meta-item {
  border-radius: 18px;
  padding: 16px 18px;
}

.meta-item span,
.stat-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(19, 40, 61, 0.6);
}

.meta-item strong,
.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.stat {
  padding: 20px;
  border-radius: 22px;
}

.stat p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 16px;
  padding: 16px;
}

.content {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 16px;
  border-radius: var(--radius-lg);
}

.panel + .panel {
  margin-top: 14px;
}

.panel-head,
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-head h2,
.summary-card h2,
.details-card h2 {
  font-size: 1.22rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #e8f0f7;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.input {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input:focus {
  border-color: rgba(15, 53, 83, 0.45);
  box-shadow: 0 0 0 4px rgba(15, 53, 83, 0.08);
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: block;
}

.field span {
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.field-wide {
  grid-column: 1 / -1;
}

.toggle-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.95rem;
  color: var(--muted);
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.button {
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--line);
}

.button.danger {
  background: #ffe8ea;
  color: #8a2130;
  border: 1px solid rgba(138, 33, 48, 0.16);
}

.stack {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.item-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 15px 16px;
  text-align: left;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.94);
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.item-card:hover {
  transform: translateY(-1px);
  background: #f8fbfe;
}

.item-card.active {
  background: linear-gradient(135deg, #103d61, #1b527f);
  color: #fff;
  border-color: rgba(12, 33, 52, 0.2);
}

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.item-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}

.item-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.item-card.active p {
  color: rgba(255, 255, 255, 0.78);
}

.item-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: inherit;
}

.summary-card,
.table-card,
.details-card {
  padding: 20px;
  border-radius: var(--radius-xl);
}

.table-toolbar {
  padding-bottom: 14px;
}

.table-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding-bottom: 16px;
}

.input.input-compact {
  margin-top: 6px;
}

.table-shell {
  overflow: auto;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

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

thead {
  background: rgba(242, 247, 251, 0.98);
}

th,
td {
  padding: 14px 14px;
  border-bottom: 1px solid rgba(107, 130, 154, 0.14);
  vertical-align: top;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: inherit;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

tbody tr {
  cursor: pointer;
  background: #fff;
}

tbody tr:hover {
  background: #f8fbfe;
}

tbody tr.active {
  background: #e9f1f8;
}

.price {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
}

.subtle {
  color: var(--muted);
  font-size: 0.9rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef5fb;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.pill.direct {
  background: #dff4ea;
  color: #116a44;
}

.pill.warn {
  background: #f5efd8;
  color: #895500;
}

.details-panel {
  margin-top: 16px;
}

.details-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
}

.detail-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
}

.detail-summary,
.detail-leg {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
}

.detail-summary {
  padding: 18px;
}

.detail-summary h3 {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.detail-summary dl {
  margin: 14px 0 0;
}

.detail-summary dt {
  margin-top: 10px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.detail-summary dd {
  margin: 4px 0 0;
}

.detail-legs {
  display: grid;
  gap: 14px;
}

.detail-leg {
  padding: 16px;
}

.detail-leg-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.detail-leg-head h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.04rem;
}

.detail-leg-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.detail-segments {
  width: 100%;
  margin-top: 14px;
  overflow: auto;
}

.detail-segments table {
  min-width: 800px;
}

.loading {
  padding: 18px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

/* ── Mobile sidebar toggle elements — hidden on desktop ── */
.mobile-topbar {
  display: none;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-close-btn {
  display: none;
}

/* ── Tablet (769px – 1200px): sidebar stacks above content ── */
@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Phone (≤768px): sidebar becomes a slide-in drawer ── */
@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 8px;
    z-index: 10;
  }

  .mobile-topbar-brand .eyebrow {
    margin: 0;
  }

  .mobile-topbar-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
  }

  .mobile-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border: 0;
    border-radius: 16px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: 0.88rem;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(15, 53, 83, 0.3);
  }

  .sidebar-close-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(15, 53, 83, 0.07);
    color: var(--accent);
    font-weight: 800;
    font-size: 0.88rem;
    cursor: pointer;
    width: 100%;
    font: inherit;
  }

  /* Hide the big hero — mobile topbar replaces it */
  .hero {
    display: none;
  }

  .app-shell {
    padding-top: 8px;
    padding-inline: 10px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 0;
  }

  .stat {
    padding: 14px;
  }

  .stat strong {
    font-size: 1.05rem;
  }

  .workspace {
    margin-top: 12px;
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes a fixed full-height drawer */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100dvh;
    width: min(340px, 92vw);
    z-index: 100;
    transform: translateX(-110%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Prevent body scroll when drawer is open */
  body.sidebar-open {
    overflow: hidden;
  }

  .summary-card,
  .table-card,
  .details-card,
  .panel {
    padding: 14px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .table-filters {
    grid-template-columns: 1fr;
  }
}
