:root {
  --accent:  #22c55e;
  --card:    #141414;
  --card2:   #1c1c1e;
  --border:  #2a2a2a;
  --hint:    #6b7280;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { background: #0a0a0a; }

body {
  background: #0a0a0a;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  overscroll-behavior: none;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ── */
.screen { display: none; flex-direction: column; min-height: 100vh; }
.screen.active { display: flex; }

/* ── Header ── */
header {
  padding: 16px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #0a0a0a;
  z-index: 10;
}
header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #ffffff;
}
#back-btn {
  background: var(--card2);
  border: none;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#back-btn:active { background: #333; }

/* ── Loading ── */
.loading {
  padding: 48px 24px;
  text-align: center;
  color: var(--hint);
  font-size: 14px;
}

/* ── Flight cards ── */
#flights-list {
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.flight-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  border-left: 4px solid;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  gap: 12px;
  transition: transform 0.12s, opacity 0.12s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.flight-card:active { transform: scale(0.98); opacity: 0.85; }
.flight-card-info { flex: 1; min-width: 0; }

.flight-name {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flight-pairs {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 3px;
  letter-spacing: -0.5px;
  line-height: 1;
  color: #ffffff;
}
.flight-pairs-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  margin-bottom: 6px;
}
.flight-date {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
}
.flight-sparkline { flex-shrink: 0; opacity: 0.9; }

/* ── Tabs ── */
.tabs {
  display: flex;
  background: #0a0a0a;
  position: sticky;
  top: 57px;
  z-index: 9;
  padding: 0 16px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 12px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255,255,255,0.4);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab.active {
  color: #ffffff;
  border-bottom-color: var(--accent);
}

/* ── Tab content ── */
.tab-content { display: none; flex: 1; overflow: auto; }
.tab-content.active { display: block; }

/* ── Seatmap ── */
#seatmap-container {
  padding: 14px 10px 0;
  overflow-x: auto;
}
.seat-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 5px;
}
.row-label {
  width: 22px;
  text-align: right;
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.seat-gap { width: 14px; flex-shrink: 0; }
.seat {
  width: 30px;
  height: 32px;
  border-radius: 7px 7px 4px 4px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.seat:active { transform: scale(0.88); }
.seat-taken { background: #ef4444; border-color: #dc2626; }
.seat-new-taken {
  background: repeating-linear-gradient(
    45deg,
    #ef4444, #ef4444 4px,
    #7f1d1d 4px, #7f1d1d 8px
  );
  border-color: #dc2626;
  color: #ffffff;
}
.seat-available { color: #ffffff; }

/* ── Legend ── */
.seatmap-legend {
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
  background: var(--card);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}
.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}
.legend-swatch-stripe {
  background: repeating-linear-gradient(45deg, #ef4444, #ef4444 3px, #7f1d1d 3px, #7f1d1d 6px);
}

/* ── History Chart ── */
#tab-history {
  padding: 20px 16px;
  padding-bottom: calc(20px + var(--safe-bottom));
}
#chart-wrapper {
  position: relative;
  height: 260px;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
}

/* ── Tooltip ── */
.tooltip {
  position: fixed;
  background: #2a2a2a;
  color: #ffffff;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #3a3a3a;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #2a2a2a;
}
.tooltip.hidden { display: none; }
