:root {
  color-scheme: dark;
  --bg: #0a1020;
  --surface: #111a2e;
  --surface-2: #17223a;
  --border: #24314d;
  --text: #e8edf7;
  --muted: #8b9bb8;
  --accent: #f5a524;
  --accent-dark: #d98c0f;
  --accent-ink: #1a1203;
  --success: #3ccf8e;
  --warning: #f5a524;
  --danger: #f2655a;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

h1, h2 { margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); margin: 0; }

.brand-mark {
  font-weight: 800;
  font-size: 20px;
  color: var(--accent);
  letter-spacing: 0.08em;
}
.brand-mark span { color: var(--text); }
.brand-mark.small { font-size: 16px; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.login-hero {
  position: relative;
  overflow: hidden;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 20% 20%, rgba(245, 165, 36, 0.18), transparent 45%),
    linear-gradient(160deg, #13234a 0%, #0a1020 70%);
  border-right: 1px solid var(--border);
}
.hero-copy h1 { font-size: 40px; line-height: 1.1; max-width: 420px; }
.hero-copy p { color: var(--muted); margin-top: 12px; font-size: 17px; }

.hero-route { width: 100%; height: 160px; }
.hero-route path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 8;
  vector-effect: non-scaling-stroke;
}
.hero-route circle { fill: var(--accent); }

.hero-codes {
  display: flex;
  gap: 24px;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 0.1em;
  color: rgba(232, 237, 247, 0.18);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.login-form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 28px; margin-bottom: 6px; }
.login-form .muted { margin-bottom: 20px; }

.test-accounts {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.test-buttons { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Form fields ---------- */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 16px 0 6px;
}

input, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
}
input::placeholder { color: #5b6a86; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 165, 36, 0.2);
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: rgba(242, 101, 90, 0.4); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(242, 101, 90, 0.12); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 24px; padding: 12px; }

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Alerts ---------- */
.alert {
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 16px;
  white-space: pre-line;
  background: rgba(242, 101, 90, 0.12);
  color: #ffb4ad;
  border: 1px solid rgba(242, 101, 90, 0.35);
}
.alert.success {
  background: rgba(60, 207, 142, 0.12);
  color: #9ff0c9;
  border-color: rgba(60, 207, 142, 0.35);
}

.note {
  margin: 0 0 18px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--muted);
}

/* ---------- App layout ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: rgba(17, 26, 46, 0.85);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  z-index: 1;
}
.user-box { display: flex; align-items: center; gap: 12px; }

.role-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(139, 155, 184, 0.15);
  color: var(--text);
}
.role-chip.admin { background: rgba(245, 165, 36, 0.15); color: var(--accent); }

.container { max-width: 980px; margin: 32px auto; padding: 0 20px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 30px; }
.page-head .muted { margin-top: 4px; }
.actions { display: flex; gap: 8px; }

/* ---------- Flight cards (boarding pass style) ---------- */
.flight-list { display: grid; gap: 14px; }

.flight-card {
  display: grid;
  grid-template-columns: 1fr auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.flight-main { padding: 18px 22px; }

.flight-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.flight-no { font-weight: 800; letter-spacing: 0.06em; }
.flight-id { color: var(--muted); font-size: 12px; margin-left: 8px; }

.route {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}
.stop .code { font-size: 28px; font-weight: 800; letter-spacing: 0.04em; }
.stop .city { color: var(--muted); font-size: 13px; }
.stop .time { margin-top: 6px; font-weight: 600; }
.stop.end { text-align: right; }

.route-line {
  position: relative;
  border-top: 2px dashed var(--border);
  height: 0;
}
.route-line::after {
  content: "✈";
  position: absolute;
  left: 50%;
  top: -13px;
  transform: translateX(-50%);
  color: var(--accent);
  background: var(--surface);
  padding: 0 6px;
}

.flight-stub {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  border-left: 2px dashed var(--border);
  background: var(--surface-2);
  min-width: 120px;
}

.status {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(139, 155, 184, 0.15);
}
.status-scheduled { background: rgba(60, 207, 142, 0.14); color: var(--success); }
.status-delayed { background: rgba(245, 165, 36, 0.14); color: var(--warning); }
.status-cancelled { background: rgba(242, 101, 90, 0.14); color: var(--danger); }

.empty { text-align: center; padding: 40px 0; }

/* ---------- Seats (inside a flight card) ---------- */
.seat-panel {
  grid-column: 1 / -1;
  padding: 14px 22px 18px;
  border-top: 1px dashed var(--border);
}
.seat-summary { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.seat-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.seat {
  min-width: 48px;
  text-align: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.seat-available { color: var(--success); border-color: rgba(60, 207, 142, 0.4); }
.seat-reserved { color: var(--muted); text-decoration: line-through; opacity: 0.7; }

.seat-book { cursor: pointer; font: inherit; font-weight: 700; font-size: 13px; }
.seat-book:hover { background: rgba(60, 207, 142, 0.16); border-color: var(--success); }
.seat-hint { font-size: 12px; margin-top: 10px; }

/* ---------- Login / register switch ---------- */
.switch-auth { margin-top: 16px; font-size: 14px; }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Flight search ---------- */
.search-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 170px auto;
  gap: 12px;
  align-items: end;
}
.search-bar label { margin-top: 0; }
.search-actions { display: flex; gap: 8px; }

/* ---------- Booking and reservations ---------- */
.booking-summary { margin: 4px 0 8px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.info-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.info-value { font-weight: 600; font-size: 14px; }

.reservation-card.cancelled { opacity: 0.6; }
.status-confirmed { background: rgba(60, 207, 142, 0.14); color: var(--success); }
.pay-paid { background: rgba(60, 207, 142, 0.14); color: var(--success); }
.pay-pending { background: rgba(245, 165, 36, 0.14); color: var(--warning); }
.pay-refunded, .pay-cancelled { background: rgba(139, 155, 184, 0.15); color: var(--muted); }
.flight-stub .status { text-align: center; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Panels and tables ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 18px;
}
.table-wrap { overflow-x: auto; }
.panel.table-wrap { padding: 6px 10px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: none; }
.code-cell { font-weight: 800; letter-spacing: 0.06em; }
.cell-actions { text-align: right; }

.airport-form .alert { margin-bottom: 12px; }
.airport-fields {
  display: grid;
  grid-template-columns: 90px 1.6fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.report h2 { font-size: 18px; margin-bottom: 4px; }
.report .table-wrap { margin-top: 12px; }
.report-filter { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.report-filter label { margin: 0; }
.report-filter select { width: auto; min-width: 140px; }
.sql {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: #c9d6ee;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
}
.sql span { color: var(--accent); }
.small-note { font-size: 12px; margin-top: 6px; }
.small-note code { color: var(--text); }
.empty-small { padding: 8px 0; }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  width: min(560px, calc(100% - 32px));
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(3, 6, 14, 0.7); }
dialog h2 { margin-bottom: 4px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* ---------- Small screens ---------- */
@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 220px; padding: 28px; }
  .hero-copy h1 { font-size: 28px; }
  .hero-route, .hero-codes { display: none; }
}

@media (max-width: 820px) {
  .airport-fields { grid-template-columns: 1fr 1fr; }
  .search-bar { grid-template-columns: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .row { grid-template-columns: 1fr; }
  .airport-fields { grid-template-columns: 1fr; }
  .search-bar { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  #user-email { display: none; }
  .flight-card { grid-template-columns: 1fr; }
  .flight-stub {
    flex-direction: row;
    align-items: center;
    border-left: none;
    border-top: 2px dashed var(--border);
  }
  .stop .code { font-size: 22px; }
}
