:root {
  color-scheme: dark;
  --bg: #071012;
  --panel: #0d171a;
  --panel-2: #101d21;
  --line: #2a3a3f;
  --line-strong: #3e545b;
  --text: #eef4f0;
  --muted: #9aa9a8;
  --green: #79d66d;
  --green-soft: rgba(121, 214, 109, 0.13);
  --amber: #f4bd1a;
  --blue: #2e80db;
  --danger: #ff6b68;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(46, 128, 219, 0.08), transparent 38%),
    radial-gradient(circle at 86% 12%, rgba(121, 214, 109, 0.08), transparent 26%),
    var(--bg);
  color: var(--text);
  min-width: 320px;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(13, 23, 26, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
}

.mark {
  align-items: center;
  background: var(--amber);
  border-radius: 6px;
  color: #111;
  display: flex;
  font-weight: 900;
  height: 44px;
  justify-content: center;
  letter-spacing: 0;
  width: 44px;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: 0;
  line-height: 1;
  margin: 0;
}

.brand p,
.small-note {
  color: var(--muted);
  margin: 6px 0 0;
}

.top-status {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  min-width: 280px;
}

.live-dot {
  animation: livePulse 1.8s ease-in-out infinite;
  background: var(--green);
  border-radius: 999px;
  box-shadow: 0 0 0 5px rgba(121, 214, 109, 0.1);
  height: 9px;
  width: 9px;
}

.divider {
  background: var(--line-strong);
  height: 22px;
  width: 1px;
}

.icon-button,
.primary-button,
.preset {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  background: var(--panel-2);
  padding: 9px 12px;
}

.primary-button {
  background: linear-gradient(180deg, #216dc5, #1550a2);
  font-weight: 800;
  margin-top: 18px;
  padding: 14px 16px;
  width: 100%;
}

.ticker-panel,
.controls-panel,
.chart-card,
.table-card,
.detail-panel,
.footer-card {
  background: rgba(13, 23, 26, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticker-panel {
  margin-top: 14px;
  padding: 14px;
}

.section-heading {
  align-items: center;
  color: var(--text);
  display: flex;
  font-size: 13px;
  font-weight: 800;
  justify-content: space-between;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.section-heading span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
}

.best-deal-panel {
  align-items: center;
  animation: panelEnter 420ms ease-out both, bestGlow 4s ease-in-out infinite;
  background: linear-gradient(135deg, rgba(255, 199, 23, 0.16), rgba(33, 131, 238, 0.12));
  border: 1px solid rgba(255, 199, 23, 0.45);
  border-radius: 7px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 16px 18px;
}

.best-deal-eyebrow {
  color: var(--amber);
  display: block;
  font-size: clamp(18px, 2.2vw, 28px);
  font-weight: 900;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.best-deal-panel h2 {
  color: var(--text);
  font-size: 26px;
  line-height: 1.1;
  margin: 0;
}

.best-deal-panel p {
  color: var(--muted);
  font-weight: 800;
  margin: 8px 0 0;
}

.best-deal-link {
  background: var(--amber);
  border-radius: 6px;
  color: #111;
  flex: 0 0 auto;
  font-weight: 900;
  padding: 12px 16px;
  text-decoration: none;
}

.last-minute-panel {
  align-items: center;
  background: rgba(13, 23, 26, 0.82);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 13px 16px;
  transition: background 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.last-minute-panel.available {
  animation: panelEnter 420ms ease-out both, lastMinuteGlow 2.4s ease-in-out infinite;
  background: linear-gradient(135deg, rgba(121, 214, 109, 0.28), rgba(33, 131, 238, 0.12));
  border-color: rgba(121, 214, 109, 0.9);
  box-shadow: inset 0 0 0 1px rgba(121, 214, 109, 0.24);
}

.last-minute-eyebrow {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.last-minute-panel.available .last-minute-eyebrow {
  color: var(--green);
}

.last-minute-panel.available h2 {
  color: #dfffd8;
}

.last-minute-panel.available p {
  color: #c3d4cf;
}

.last-minute-panel h2 {
  color: var(--text);
  font-size: 22px;
  line-height: 1.12;
  margin: 0;
}

.last-minute-panel p {
  color: var(--muted);
  font-weight: 800;
  margin: 7px 0 0;
}

.last-minute-link {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  flex: 0 0 auto;
  font-weight: 900;
  padding: 11px 15px;
  text-decoration: none;
}

.last-minute-panel.available .last-minute-link {
  background: linear-gradient(180deg, #8be77e, #55bd50);
  border-color: var(--green);
  color: #071012;
}

.month-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.month-pill {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  padding: 9px 12px;
  text-decoration: none;
}

.month-pill.active {
  border-color: var(--blue);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(33, 131, 238, 0.25);
}

.ticker {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(170px, 1fr));
  overflow-x: auto;
}

.ticker-card {
  animation: cardEnter 360ms ease-out both;
  background: linear-gradient(180deg, rgba(16, 29, 33, 0.98), rgba(9, 17, 19, 0.98));
  border: 1px solid var(--line);
  border-radius: 7px;
  min-width: 170px;
  padding: 12px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.ticker-card:hover {
  transform: translateY(-2px);
}

.ticker-card.best {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(121, 214, 109, 0.18);
}

.date-line {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.airport-line {
  color: var(--amber);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  margin-top: 5px;
}

.total-price-main,
.pp-price-sub,
.detail-total {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

.mini-times {
  color: var(--muted);
  display: grid;
  font-size: 10px;
  gap: 2px;
  line-height: 1.25;
  margin-top: 7px;
}

.total-price-main {
  color: var(--green);
  font-size: 32px;
  font-weight: 900;
  margin-top: 10px;
}

.ticker-card:not(.best) .total-price-main {
  color: var(--text);
}

.pp-price-sub {
  color: var(--blue);
  font-size: 14px;
  font-weight: 800;
  margin-top: 2px;
}

.deal-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  margin-top: 6px;
  text-transform: uppercase;
}

.component-mini-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
}

.component-mini-list div {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  justify-content: space-between;
}

.component-mini-list strong {
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

.tile-time-grid {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
}

.tile-time-group {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: 30px minmax(0, 1fr);
}

.tile-time-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tile-time-options {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tile-time-option {
  background: #081215;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  min-width: 0;
  padding: 5px 4px;
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease;
}

.tile-time-option:active {
  transform: scale(0.97);
}

.tile-time-option span,
.tile-time-option small {
  display: block;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
  line-height: 1.1;
}

.tile-time-option span {
  font-size: 11px;
  font-weight: 900;
}

.tile-time-option small {
  font-size: 8px;
  font-weight: 900;
  margin-top: 2px;
  text-transform: uppercase;
}

.tile-time-option.price-up small {
  color: var(--danger);
}

.tile-time-option.price-down small,
.tile-time-option.price-best small {
  color: var(--green);
}

.tile-time-option.active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(121, 214, 109, 0.2);
}

.ticker-meta {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  color: var(--muted);
  margin-top: 12px;
  padding-top: 10px;
}

.movement {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  padding: 4px 7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.movement-down {
  background: rgba(121, 214, 109, 0.13);
  color: var(--green);
}

.movement-up {
  background: rgba(255, 107, 104, 0.13);
  color: var(--danger);
}

.movement-flat,
.movement-new {
  background: rgba(154, 169, 168, 0.12);
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 310px minmax(560px, 1fr) 330px;
  margin-top: 12px;
}

.controls-panel,
.detail-panel {
  min-width: 0;
  padding: 16px;
}

.field {
  display: block;
  margin: 0 0 18px;
}

.switch-field {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 0 18px;
  padding: 12px;
}

.switch-field strong,
.switch-field small {
  display: block;
}

.switch-field strong {
  color: var(--text);
  font-size: 13px;
}

.switch-field small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.switch-field input {
  accent-color: var(--green);
  flex: 0 0 auto;
  height: 22px;
  width: 22px;
}

.field > span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.time-pair {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

input,
select {
  background: #081215;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  height: 42px;
  padding: 0 10px;
  width: 100%;
}

.money-input {
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  display: flex;
  overflow: hidden;
}

.money-input span {
  background: #111f23;
  color: var(--muted);
  font-weight: 800;
  padding: 11px 12px;
}

.money-input input {
  border: 0;
  border-radius: 0;
}

.preset-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.preset {
  background: #0a1518;
  padding: 10px 8px;
}

.preset.active {
  background: #124c99;
  border-color: #2f85ed;
}

.market-panel {
  display: grid;
  gap: 12px;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.chart-card,
.table-card {
  min-width: 0;
  overflow: hidden;
  padding: 16px;
}

#historyChart {
  background: linear-gradient(180deg, rgba(121, 214, 109, 0.04), rgba(0, 0, 0, 0));
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 300px;
  width: 100%;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

table {
  border-collapse: collapse;
  min-width: 100%;
  table-layout: fixed;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  word-break: normal;
}

th:nth-child(1),
td:nth-child(1),
th:nth-child(2),
td:nth-child(2) {
  width: 26%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 12%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 13%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 13%;
}

th:nth-child(6),
td:nth-child(6) {
  width: 10%;
}

th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: rgba(121, 214, 109, 0.08);
}

.route-cell strong {
  display: block;
  font-size: 14px;
}

.route-cell span {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.money-cell {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 18px;
  font-weight: 900;
}

.sub-money {
  color: var(--muted);
  display: block;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 800;
  margin-top: 4px;
}

.detail-total {
  color: var(--green);
  font-size: 46px;
  font-weight: 900;
  margin: 18px 0 2px;
}

.detail-pp {
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 20px;
}

.breakdown {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

.breakdown h3 {
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.breakdown-row {
  align-items: center;
  border-bottom: 1px solid rgba(42, 58, 63, 0.7);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 0;
}

.breakdown-row strong,
.breakdown-row span {
  display: block;
}

.breakdown-row strong {
  font-size: 13px;
}

.breakdown-row span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  margin-top: 3px;
}

.breakdown-row a {
  color: var(--green);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
}

.leg {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}

.leg h3 {
  font-size: 14px;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.leg-route {
  display: flex;
  font-size: 18px;
  font-weight: 900;
  justify-content: space-between;
}

.leg-time {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr auto;
  margin: 14px 0;
}

.leg-time .line {
  border-top: 1px solid var(--line-strong);
}

.flight-number {
  color: var(--amber);
  font-weight: 900;
}

.book-button,
.copy-button,
.inline-book {
  align-items: center;
  border-radius: 6px;
  display: flex;
  font-weight: 900;
  justify-content: center;
  min-height: 48px;
  text-decoration: none;
}

.book-button {
  background: var(--amber);
  color: #111;
  margin-top: 8px;
}

.copy-button {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
  margin-top: 10px;
  width: 100%;
}

.inline-book {
  background: rgba(244, 189, 26, 0.14);
  border: 1px solid rgba(244, 189, 26, 0.42);
  color: var(--amber);
  min-height: 34px;
  padding: 6px 10px;
}

.selected-empty,
.empty-state {
  color: var(--muted);
  padding: 24px 0;
}

.error {
  color: var(--danger);
  font-weight: 800;
}

@keyframes livePulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(121, 214, 109, 0.09);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(121, 214, 109, 0.03);
    transform: scale(1.08);
  }
}

@keyframes panelEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bestGlow {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(255, 199, 23, 0);
  }
  50% {
    box-shadow: 0 0 24px rgba(255, 199, 23, 0.08);
  }
}

@keyframes lastMinuteGlow {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(121, 214, 109, 0);
  }
  50% {
    box-shadow: 0 0 26px rgba(121, 214, 109, 0.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 1180px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    order: 1;
  }

  .detail-panel {
    order: 2;
  }

  .market-panel {
    order: 3;
  }

  .ticker {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 8px;
  }

  .topbar,
  .brand,
  .top-status {
    align-items: flex-start;
    flex-direction: column;
    width: 100%;
  }

  .topbar {
    gap: 12px;
    padding: 14px;
  }

  .mark {
    height: 38px;
    width: 38px;
  }

  h1 {
    font-size: 28px;
    line-height: 1.05;
  }

  .brand p {
    font-size: 15px;
    line-height: 1.25;
  }

  .top-status {
    display: grid;
    font-size: 14px;
    gap: 8px;
    grid-template-columns: auto 1fr;
  }

  .top-status .icon-button {
    grid-column: 1 / -1;
    justify-self: start;
    padding: 8px 11px;
  }

  .divider {
    display: none;
  }

  .best-deal-panel {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 10px;
    padding: 14px;
  }

  .best-deal-panel h2 {
    font-size: 21px;
    line-height: 1.15;
  }

  .best-deal-panel p {
    font-size: 14px;
    line-height: 1.35;
    margin-top: 7px;
  }

  .best-deal-eyebrow {
    font-size: 10px;
  }

  .best-deal-link {
    padding: 11px 14px;
    text-align: center;
  }

  .last-minute-panel {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
    padding: 12px 14px;
  }

  .last-minute-panel h2 {
    font-size: 18px;
  }

  .last-minute-panel p {
    font-size: 13px;
    line-height: 1.35;
  }

  .last-minute-eyebrow {
    font-size: 10px;
  }

  .last-minute-link {
    padding: 10px 14px;
    text-align: center;
  }

  .month-nav {
    gap: 7px;
    margin-bottom: 10px;
  }

  .month-pill {
    font-size: 11px;
    padding: 8px 10px;
  }

  .section-heading {
    align-items: flex-start;
    gap: 10px;
    grid-template-columns: 115px minmax(0, 1fr);
  }

  .section-heading span:first-child {
    font-size: 13px;
  }

  .section-heading span:last-child {
    font-size: 11px;
    line-height: 1.25;
  }

  .ticker {
    display: flex;
    gap: 8px;
  }

  .ticker-card {
    flex: 0 0 205px;
    padding: 10px;
  }

  .date-line {
    font-size: 12px;
    line-height: 1.2;
  }

  .airport-line {
    font-size: 10px;
    margin-top: 4px;
  }

  .mini-times {
    font-size: 9px;
    margin-top: 6px;
  }

  .total-price-main {
    font-size: 27px;
    margin-top: 8px;
  }

  .pp-price-sub {
    font-size: 11px;
  }

  .tile-time-grid {
    gap: 5px;
    margin-top: 8px;
    padding-top: 7px;
  }

  .tile-time-group {
    gap: 5px;
    grid-template-columns: 25px minmax(0, 1fr);
  }

  .tile-time-title {
    font-size: 9px;
  }

  .tile-time-options {
    gap: 3px;
  }

  .tile-time-option {
    padding: 4px 3px;
  }

  .tile-time-option span {
    font-size: 10px;
  }

  .tile-time-option small {
    font-size: 7px;
  }

  .ticker-meta {
    margin-top: 9px;
    padding-top: 8px;
  }

  .movement {
    font-size: 9px;
    padding: 4px 6px;
  }

  .time-pair,
  .preset-row {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 100%;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100% !important;
  }

  tbody tr {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }

  td {
    border-bottom: 0;
    display: grid;
    gap: 12px;
    grid-template-columns: 72px minmax(0, 1fr);
    padding: 7px 8px;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}
