:root {
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --border: #e2e6ea;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --primary: #4361ee;
  --primary-hover: #3a56d4;
  --pass: #22c55e;
  --pass-bg: #dcfce7;
  --variance: #f59e0b;
  --variance-bg: #fef3c7;
  --fail: #ef4444;
  --fail-bg: #fee2e2;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Layout */
.app-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.app-header .nav-links a {
  margin-left: 1.25rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.app-header .nav-links a:hover { color: var(--primary); }

.container { max-width: 100%; margin: 0 auto; padding: 1.5rem 2rem; }
.container-wide { max-width: 100%; margin: 0 auto; padding: 1.5rem 2rem; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.card-muted { color: var(--text-muted); font-size: 0.85rem; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-pass { background: var(--pass-bg); color: #15803d; }
.badge-variance { background: var(--variance-bg); color: #92400e; }
.badge-fail { background: var(--fail-bg); color: #b91c1c; }
.badge-pending { background: #e2e8f0; color: #475569; }
.badge-booking-pending { background: #e2e8f0; color: #475569; }
.badge-booking-passed { background: var(--pass-bg); color: #15803d; }

/* Big status */
.status-hero {
  text-align: center;
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.status-hero.pass { background: var(--pass-bg); border: 2px solid var(--pass); }
.status-hero.variance { background: var(--variance-bg); border: 2px solid var(--variance); }
.status-hero.fail { background: var(--fail-bg); border: 2px solid var(--fail); }
.status-hero .status-label { font-size: 1.5rem; font-weight: 800; }
.status-hero .status-sub { font-size: 0.85rem; margin-top: 0.25rem; color: var(--text-muted); }

/* Stat cards */
.stat-card { text-align: center; padding: 1rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Forms */
input[type="text"], input[type="password"] {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--primary); }
label { display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.85rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
}
.drop-zone:hover, .drop-zone.over {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary);
}
.drop-zone .icon { font-size: 2rem; margin-bottom: 0.5rem; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
th {
  background: #f1f5f9;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
tr:hover td { background: #f8fafc; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Row statuses */
tr.row-pass td { background: #f0fdf4; }
tr.row-variance td { background: #fffbeb; }
tr.row-fail td { background: #fef2f2; }

/* Progress steps */
.progress-steps {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
}
.step {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.step.active { color: var(--primary); font-weight: 600; }
.step.done { color: var(--pass); }
.step-arrow { color: var(--border); }

/* Two-panel layout for result */
.result-panels {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) { .result-panels { grid-template-columns: 1fr; } }

.pdf-panel {
  position: sticky;
  top: 60px;
}
.pdf-panel iframe {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Key-value pairs */
.kv-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  font-size: 0.85rem;
}
.kv-grid dt { color: var(--text-muted); font-weight: 500; }
.kv-grid dd { font-weight: 600; }

/* Collapsible */
.collapsible-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--primary);
  padding: 0;
  font-weight: 500;
}
.collapsible-content { display: none; margin-top: 0.5rem; }
.collapsible-content.open { display: block; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tabs */
.tabs-header {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Full-width table cards */
.table-card.full-width { width: 100%; max-width: 100%; }
.table-wrap {
  overflow-x: auto;
  margin: 0 -0.25rem;
}
.air-table { min-width: 100%; }
.air-table thead th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  z-index: 1;
  white-space: nowrap;
}
.pdf-iframe {
  width: 100%;
  height: 60vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Utils */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.hidden { display: none; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ── Nav active link ─────────────────────────────────────────────────── */
.app-header .nav-links a.nav-active { color: var(--primary); }

/* ── Config bar ─────────────────────────────────────────────────────── */
.config-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
}

/* ── Section header (title + actions row) ───────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 1rem;
}

/* ── Booking status tabs (PENDING / CLOSED) ─────────────────────────── */
.booking-tabs-bar {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid var(--border);
}
.booking-tab {
  padding: 0.45rem 1.1rem;
  border: none;
  background: none;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-transform: uppercase;
  transition: color 0.15s;
}
.booking-tab:hover { color: var(--primary); }
.booking-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Empty cell ─────────────────────────────────────────────────────── */
.empty-cell { padding: 1.75rem; text-align: center; color: var(--text-muted); }

/* ── Upload spinner ─────────────────────────────────────────────────── */
.upload-spinner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0 0.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.spinner-md {
  width: 20px;
  height: 20px;
  border-width: 3px;
}

/* ── Upload error message ───────────────────────────────────────────── */
.upload-error-msg {
  margin-top: 0.5rem;
  color: var(--fail);
  font-size: 0.85rem;
}

/* ── Result header bar ──────────────────────────────────────────────── */
.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 0;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.result-bar.pass     { background: var(--pass-bg);     border: 2px solid var(--pass); }
.result-bar.variance { background: var(--variance-bg); border: 2px solid var(--variance); }
.result-bar.fail     { background: var(--fail-bg);     border: 2px solid var(--fail); }

.result-bar-left { display: flex; flex-direction: column; gap: 0.2rem; }
.result-bar-status { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.02em; }
.result-bar-sub { font-size: 0.85rem; color: var(--text-muted); }
.result-bar-sub.nomatch { color: var(--fail); }

.result-bar-right { display: flex; gap: 1.5rem; }
.result-stat { text-align: right; }
.result-stat-val { font-size: 1.1rem; font-weight: 700; }
.result-stat-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

.stat-over  { color: var(--fail); }
.stat-under { color: var(--pass); }

/* ── Tab section title ──────────────────────────────────────────────── */
.tab-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Matched tab indicator ──────────────────────────────────────────── */
.tab-btn.tab-matched.active { color: #15803d; border-bottom-color: var(--pass); }

/* ── Match banner (AWB ↔ Booking) ───────────────────────────────────── */
.match-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--pass-bg);
  border: 1px solid var(--pass);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.match-arrow { font-size: 1.2rem; color: var(--pass); }
.match-badge { margin-left: auto; }

/* ── Variance cell ──────────────────────────────────────────────────── */
.variance-cell { font-weight: 600; }

/* ── Totals bar ─────────────────────────────────────────────────────── */
.totals-bar {
  display: flex;
  gap: 2rem;
  padding: 0.6rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

/* ── Close booking action ───────────────────────────────────────────── */
.close-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

/* ── No match panel ─────────────────────────────────────────────────── */
.no-match-panel {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.no-match-icon { font-size: 2.5rem; color: var(--fail); margin-bottom: 0.5rem; }
.no-match-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 0.4rem; }
.no-match-sub { font-size: 0.85rem; margin-bottom: 0.75rem; line-height: 1.6; }
.no-match-awbs { font-size: 0.85rem; }
.no-match-awbs code { background: #f1f5f9; padding: 0.1rem 0.4rem; border-radius: 4px; }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 2rem; color: var(--pass); margin-bottom: 0.4rem; }

/* ── PDF card ───────────────────────────────────────────────────────── */
.pdf-card { padding: 0.75rem; }

/* ── Inline code ────────────────────────────────────────────────────── */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8em;
  background: #f1f5f9;
  padding: 0.1em 0.4em;
  border-radius: 3px;
}
