:root {
  --bg-page: #f4f7f9;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --emerald: #059669;
  --emerald-bg: #d1fae5;
  --emerald-border: #6ee7b7;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --amber-border: #fcd34d;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* ==================== Topbar ==================== */
.topbar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 16px 0;
  border-bottom: 1px solid #334155;
  box-shadow: var(--shadow-md);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

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

.brand-badge {
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 2px;
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  min-width: 115px;
}

.stat-pill.stat-official {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.12);
}

.stat-pill.stat-r2 {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.12);
}

.stat-pill.stat-queue {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.12);
}

.stat-label {
  font-size: 0.72rem;
  color: #cbd5e1;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ==================== Guide & Demo Banner ==================== */
.main-content {
  flex: 1;
  padding-top: 20px;
  padding-bottom: 40px;
}

.guide-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.guide-steps {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  flex: 1;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 280px;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-item strong {
  font-size: 0.88rem;
  display: block;
  color: var(--text-main);
}

.step-item p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.demo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.demo-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.demo-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==================== Tabs ==================== */
.mode-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 2px;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 18px;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -4px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ==================== Cards & Layout ==================== */
.single-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 20px;
  align-items: start;
}

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.card-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ==================== Forms & Controls ==================== */
.segmented-control {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.seg-btn.active {
  background: var(--primary);
  color: #fff;
}

.lookup-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.airport-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: start;
}

.btn-swap {
  margin-top: 26px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  width: 36px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.btn-swap:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.94rem;
  color: var(--text-main);
  background: #fff;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.field-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  min-height: 18px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-routes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chip,
.chip-sm {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover,
.chip-sm:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.input-with-presets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ==================== Buttons ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
  padding: 11px 16px;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #0f172a;
  color: #fff;
}

.btn-secondary:hover:not(:disabled) {
  background: #1e293b;
}

.btn-outline {
  background: #fff;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-subtle);
}

.btn-danger-outline {
  background: #fff;
  border-color: #fca5a5;
  color: var(--danger);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-demo-cargo {
  background: #0284c7;
  color: #fff;
}

.btn-demo-cargo:hover {
  background: #0369a1;
}

.btn-demo-pax {
  background: #059669;
  color: #fff;
}

.btn-demo-pax:hover {
  background: #047857;
}

/* ==================== Single Result Panel ==================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.source-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.source-badge.badge-official {
  background: var(--emerald-bg);
  color: var(--emerald);
  border-color: var(--emerald-border);
}

.source-badge.badge-fallback {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: var(--amber-border);
}

.route-summary-banner {
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.route-airports {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.route-node {
  display: flex;
  flex-direction: column;
}

.airport-code {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.airport-icao {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
}

.airport-name {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.route-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
}

.route-mode-tag {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
}

.arrow-line {
  color: #64748b;
  font-size: 0.85rem;
  margin: 4px 0;
  letter-spacing: -1px;
}

.route-dist-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

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

.kpi-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.kpi-box.kpi-highlight {
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.kpi-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.kpi-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 4px 0 2px;
}

.kpi-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.mrv-meta-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}

.meta-key {
  color: var(--text-secondary);
  min-width: 220px;
}

.meta-val {
  color: var(--text-main);
  word-break: break-all;
}

.meta-val a {
  color: var(--primary);
  text-decoration: underline;
}

/* ==================== Screenshot Preview ==================== */
.image-preview-wrap {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
}

.image-toolbar {
  background: #f1f5f9;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.image-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.image-frame {
  padding: 12px;
  background: #0f172a;
  text-align: center;
}

.image-frame img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid #334155;
}

.fallback-notice {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-md);
  padding: 16px;
  color: #92400e;
}

.fallback-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.fallback-notice p {
  font-size: 0.83rem;
  margin-bottom: 12px;
}

/* ==================== Batch Section ==================== */
.batch-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 18px;
  transition: all 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.dropzone-icon {
  font-size: 2rem;
}

.dropzone strong {
  font-size: 0.95rem;
  display: block;
}

.dropzone p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.batch-summary-bar {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.summary-metrics {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.metric-item {
  display: flex;
  flex-direction: column;
}

.metric-item span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.metric-item strong {
  font-size: 1.05rem;
  color: var(--text-main);
}

.metric-official strong {
  color: var(--emerald);
}

.metric-fallback strong {
  color: var(--amber);
}

.metric-co2 strong {
  color: var(--primary);
}

.batch-export-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-zip {
  background: linear-gradient(135deg, #0284c7 0%, #059669 100%);
  border: none;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

.btn-zip:hover:not(:disabled) {
  filter: brightness(1.06);
}

/* ==================== Progress Bar ==================== */
.zip-progress-box {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.zip-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  margin-bottom: 6px;
  color: #1e3a8a;
}

.progress-track {
  height: 8px;
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #10b981);
  transition: width 0.2s;
}

/* ==================== Data Table ==================== */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.col-check {
  width: 36px;
  text-align: center;
}

.empty-row td {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
}

.table-input {
  width: 100%;
  min-width: 75px;
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.thumb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #7dd3fc;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.thumb-btn:hover {
  background: #bae6fd;
}

/* ==================== Modal ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 1050px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 16px;
  background: #0f172a;
  overflow-y: auto;
  text-align: center;
}

.modal-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.modal-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-secondary);
}

/* ==================== Footer ==================== */
.footer {
  background: #fff;
  border-top: 1px solid var(--border-color);
  padding: 16px 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
