/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: clamp(14px, 0.729vw + 2.67px, 16px);
}

/* ── CSS Variables ───────────────────────────────────────────── */
:root {
  --ab-bg: #f3f4f8;
  --ab-card: #ffffff;
  --ab-surface: #f9fafb;
  --ab-surface2: #f6f8fb;
  --ab-border: #e5e7eb;
  --ab-border2: #c9d5e3;
  --ab-text: #111827;
  --ab-text2: #4b5c72;
  --ab-muted: #6b7280;
  --ab-blue: #1a6fd4;
  --ab-blue-dark: #0f44a0;
  --ab-blue-mid: #2563eb;
  --ab-blue-lite: #dbeafe;
  --ab-sidebar: #1a6fd4;
  --ab-sidebar-w: clamp(180px, 14vw, 280px);
  --ab-green: #16a34a;
  --ab-green-bg: #dcfce7;
  --ab-green-b: #bbf7d0;
  --ab-orange: #ea580c;
  --ab-orange-bg: #fff7ed;
  --ab-orange-b: #fed7aa;
  --ab-red: #dc2626;
  --ab-red-bg: #fee2e2;
  --ab-red-b: #fecaca;
  --ab-amber: #d97706;
  --ab-amber-bg: #fef9c3;
  --ab-amber-b: #fde68a;
  --r: 10px;
  --rs: 6px;
  --sh: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shm: 0 4px 14px rgba(0, 0, 0, .09), 0 2px 4px rgba(0, 0, 0, .04);
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'Courier New', monospace;
}

body {
  font-family: var(--font);
  background: var(--ab-bg);
  color: var(--ab-text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--ab-sidebar-w);
  background: var(--ab-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 200;
  transition: transform .25s ease;
}

/* ── Sidebar User ───────────────────────────────────────────── */
.sidebar-user{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:14px;
  min-width:0;
}

.user-avatar-sm{
  width:32px;
  height:32px;
  border-radius:50%;
  background:linear-gradient(135deg,#1a6fd4,#0ea5e9);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:12px;
  font-weight:700;
  color:#fff;
  flex-shrink:0;
}

.sidebar-username{
  color:rgba(255,255,255,.88);
  font-size:.82rem;
  line-height:1.3;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  min-width:0;
  flex:1;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.4rem 1.3rem 1.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  background: linear-gradient(135deg, #1a6fd4, #0ea5e9);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.07rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.brand-tagline {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, .4);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: rgba(255, 255, 255, .55);
  font-size: 0.93rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .85);
}

.nav-item.active {
  background: rgba(26, 111, 212, .35);
  color: #fff;
}

.sidebar-footer {
  padding: 1.1rem 1.3rem;
  border-top: 1px solid rgba(255,255,255,.07);
  display:flex;
  flex-direction:column;
  gap:2px;
}
.org-chip {
  display: inline-flex;
  align-items: center;
  gap: 40px;
  background: rgba(255, 255, 255, .07);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.79rem;
  font-weight: 500;
  color: rgba(255, 255, 255, .5);
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  margin-left: var(--ab-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  height: 3.85rem;
  background: #fff;
  border-bottom: 1px solid var(--ab-border);
  display: flex;
  align-items: center;
  padding: 0 1.57rem;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ab-muted);
  padding: 4px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.org-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ab-text);
}

.btn-sync {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ab-blue);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0.5rem 1rem;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s;
}

.btn-sync:hover {
  opacity: .88;
}

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

.btn-export-esg {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ab-green);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0.5rem 1rem;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s;
}

.btn-export-esg:hover {
  opacity: .88;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 8px;
  padding: 5px 10px;
}

.user-avatar {
  width: 1.86rem;
  height: 1.86rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a6fd4, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.71rem;
  font-weight: 700;
  color: #fff;
}

.user-name {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ab-text);
}

.logout-btn {
  display: flex;
  align-items: center;
  color: var(--ab-muted);
  padding: 6px;
  border-radius: 6px;
  text-decoration: none;
  transition: color .15s, background .15s;
}

.logout-btn:hover {
  color: #ef4444;
  background: #fef2f2;
}

/* ── Page Body ───────────────────────────────────────────────── */
.page-body {
  padding: 1.71rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 1.14rem;
  margin-bottom: 1.57rem;
}

.page-title {
  font-size: 1.43rem;
  font-weight: 700;
  color: var(--ab-text);
  letter-spacing: -.4px;
}

.page-desc {
  font-size: 0.86rem;
  color: var(--ab-muted);
  margin-top: 3px;
}

.page-desc strong {
  color: var(--ab-blue);
}

/* ── KPI Grid ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1.43rem;
}

.kpi-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--ab-border);
  border-radius: 14px;
  padding: 1.1rem 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: var(--sh);
  transition: box-shadow .2s, transform .15s;
  overflow: hidden;
}

.kpi-card:hover {
  box-shadow: var(--shm);
  transform: translateY(-1px);
}

/* Top row: icon + label */
.kpi-card-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  padding-right: 3.5rem; /* reserve space for the absolute .kpi-status badge */
}

.kpi-icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon--blue   { background: var(--ab-blue-lite); color: var(--ab-blue); }
.kpi-icon--orange { background: var(--ab-orange-bg); color: var(--ab-orange); }
.kpi-icon--green  { background: var(--ab-green-bg);  color: var(--ab-green); }
.kpi-icon--amber  { background: var(--ab-amber-bg);  color: var(--ab-amber); }
.kpi-icon--purple { background: #f3e8ff; color: #a855f7; }

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ab-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1.2;
}

/* Status badge pinned to top-right corner */
.kpi-status {
  position: absolute;
  top: 0.75rem;
  right: 0.85rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}
.kpi-status--ok       { background: #dcfce7; color: #16a34a; }
.kpi-status--warning  { background: #fef9c3; color: #854d0e; }
.kpi-status--exceeded { background: #fee2e2; color: #b91c1c; }
.kpi-status--neutral  { background: #f1f5f9; color: #475569; }

/* Body */
.kpi-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.kpi-value {
  font-size: 1.32rem;
  font-weight: 700;
  color: var(--ab-text);
  letter-spacing: -.4px;
  line-height: 1.15;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-sub {
  font-size: 0.73rem;
  color: var(--ab-muted);
  line-height: 1.4;
}

/* Edit budget pencil button */
.btn-edit-budget {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--ab-muted);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  opacity: .7;
  transition: opacity .15s;
}
.btn-edit-budget:hover { opacity: 1; color: var(--ab-blue); }

/* ── Budget Bar ──────────────────────────────────────────────── */
.budget-bar-row {
  margin-top: 8px;
  height: 6px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}

#budgetBarFill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: #22c55e;
  transition: width .8s ease, background .4s;
}

#budgetBarPctBadge {
  font-size: 13px;
  font-weight: 700;
  color: #22c55e;
  transition: color .4s;
}

/* ── Panel ───────────────────────────────────────────────────── */
.panel {
  background: #fff;
  border: 1px solid var(--ab-border);
  border-radius: 12px;
  padding: 1.29rem 1.43rem;
  box-shadow: var(--sh);
  margin-bottom: 18px;
}

.panel:last-child {
  margin-bottom: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--ab-text);
  flex: 1;
}

.panel-badge {
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--ab-muted);
  white-space: nowrap;
}

/* ── Layout Helpers ──────────────────────────────────────────── */
.row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}

.row-2col>.panel {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

/* ── Status Pills ────────────────────────────────────────────── */
/* Status pill: color modifiers only — layout handled by .kpi-status */
.status-pill--within {
  background: #dcfce7;
  color: #15803d;
}

.status-pill--warning {
  background: #fef9c3;
  color: #854d0e;
}

.status-pill--exceeded {
  background: #fee2e2;
  color: #b91c1c;
}

/* ── Route List ──────────────────────────────────────────────── */
.route-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 0;
  border-bottom: 1px solid var(--ab-border);
}

.route-row:last-child {
  border-bottom: none;
}

.route-code {
  font-size: 0.86rem;
  font-weight: 500;
  min-width: 7.86rem;
  color: var(--ab-text);
  font-family: var(--mono);
}

.route-track {
  flex: 1;
  height: 5px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}

.route-fill {
  height: 100%;
  background: var(--ab-blue);
  border-radius: 99px;
}

.route-val {
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--ab-muted);
  white-space: nowrap;
}

/* ── Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  gap: 0.5rem;
  padding: 0.1rem 0;
  border-bottom: 1px solid var(--ab-border);
  margin-bottom: 0.86rem;
  align-items: center;
}

.filter-row-top,
.filter-row-bottom {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-search-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  padding: 7px 10px;
  flex: 1;
  min-width: 200px;
  color: var(--ab-muted);
  transition: border-color .15s, box-shadow .15s;
}

.filter-search-wrap:focus-within {
  border-color: var(--ab-blue);
  box-shadow: 0 0 0 3px rgba(26, 111, 212, .1);
}

.filter-search-wrap input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.86rem;
  color: var(--ab-text);
  width: 100%;
  font-family: inherit;
}

.filter-sel, .filter-date {
  padding: 7px 10px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  background: var(--ab-surface);
  font-size: 0.86rem;
  color: var(--ab-text);
  cursor: pointer;
  font-family: inherit;
  outline: none;
  height: 36px;
  transition: border-color .14s;
}

.filter-sel:focus, .filter-date:focus {
  border-color: var(--ab-blue);
}

/* Period mode toggle buttons (Month / Year) */
.period-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--ab-muted, #94a3b8);
  padding: 3px 8px;
  border-radius: 5px;
  transition: all .15s;
  font-family: inherit;
}
.period-mode-btn--active {
  background: var(--ab-blue, #1a6fd4);
  color: #fff;
}
.period-mode-btn:not(.period-mode-btn--active):hover {
  background: rgba(255, 255, 255, .06);
  color: var(--ab-text, #e2e8f0);
}

.filter-clear {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  background: var(--ab-surface);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ab-muted);
  font-family: inherit;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
  height: 36px;
  flex-shrink: 0;
}

.filter-clear:hover {
  color: #ef4444;
  border-color: #ef4444;
  background: #fff5f5;
}

/* ── Table ───────────────────────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
}

.ab-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font);
  font-size: 0.86rem;
}

.ab-table th {
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--ab-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 12px 18px;
  border-bottom: 1px solid var(--ab-border);
  text-align: left;
  white-space: nowrap;
  background: var(--ab-surface);
}

.ab-table td {
  font-size: 0.86rem;
  color: var(--ab-text);
  padding: 13px 18px;
  border-bottom: 1px solid var(--ab-border);
  vertical-align: middle;
}

.ab-table tbody tr:last-child td {
  border-bottom: none;
}

.ab-table tbody tr:hover {
  background: rgba(26, 111, 212, .03);
}

.ab-table .num {
  text-align: right;
}

/* Extra breathing room on first and last columns */
.ab-table th:first-child,
.ab-table td:first-child {
  padding-left: 22px;
}

.ab-table th:last-child,
.ab-table td:last-child {
  padding-right: 22px;
}

.mono {
  font-family: var(--mono);
}

.fw6 {
  font-weight: 600;
}

/* ── Badges ──────────────────────────────────────────────────── */
.ab-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.71rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  white-space: nowrap;
}

.ab-badge--ow {
  background: #e0f2fe;
  color: #0369a1;
}

.ab-badge--rt {
  background: #f3e8ff;
  color: #7c3aed;
}

.ab-badge--within {
  background: var(--ab-green-bg);
  color: #15803d;
}

.ab-badge--warning {
  background: var(--ab-amber-bg);
  color: #a16207;
}

.ab-badge--exceeded {
  background: var(--ab-red-bg);
  color: #b91c1c;
}

.badge-icao {
  background: var(--ab-blue-lite);
  color: #1e40af;
  border-radius: 4px;
  font-size: 0.71rem;
  font-weight: 600;
  padding: 2px 6px;
  white-space: nowrap;
}

.badge-defra {
  background: var(--ab-amber-bg);
  color: #854d0e;
  border-radius: 4px;
  font-size: 0.71rem;
  font-weight: 600;
  padding: 2px 6px;
  white-space: nowrap;
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.86rem;
}

.pg-info {
  font-size: 0.79rem;
  color: var(--ab-muted);
}

.pg-btns {
  display: flex;
  align-items: center;
  gap: 3px;
}

.pg-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 6px;
  border: 1px solid var(--ab-border);
  border-radius: 6px;
  background: none;
  font-size: 0.86rem;
  cursor: pointer;
  color: var(--ab-text);
  font-family: inherit;
  transition: background .12s, color .12s;
}

.pg-btn:hover:not(:disabled) {
  background: var(--ab-blue);
  color: #fff;
  border-color: var(--ab-blue);
}

.pg-btn.active {
  background: var(--ab-blue);
  color: #fff;
  border-color: var(--ab-blue);
  font-weight: 600;
}

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

.pg-arrow {
  font-size: 1.14rem;
  line-height: 1;
}

.pg-ellipsis {
  font-size: 0.86rem;
  color: var(--ab-muted);
  padding: 0 3px;
}

.loading-cell {
  text-align: center;
  padding: 2rem;
  color: var(--ab-muted);
  font-size: 0.86rem;
}

/* ── Select ──────────────────────────────────────────────────── */
.ab-select {
  padding: 5px 9px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  background: var(--ab-surface);
  font-size: 0.86rem;
  color: var(--ab-text);
  cursor: pointer;
  font-family: inherit;
  outline: none;
}

/* ── Sortable Columns ────────────────────────────────────────── */
.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable:hover {
  background: rgba(26, 111, 212, .05);
}

.sort-icon {
  font-size: 0.71rem;
  opacity: .35;
  margin-left: 2px;
  transition: opacity .15s;
}

.sort-icon.asc,
.sort-icon.desc {
  opacity: 1;
  color: #1a6fd4;
  font-weight: 700;
}

#sort-co2e_kg {
  opacity: 1;
  color: #1a6fd4;
  font-weight: 700;
}

/* ── Misc ────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 2rem 0;
  color: var(--ab-muted);
  font-size: 0.86rem;
  text-align: center;
}

.offender-card {
  background: var(--ab-surface);
  border: 1px solid rgba(239, 68, 68, .22);
  border-radius: 8px;
  padding: 12px 14px;
}

/* ── Breakdown Tabs ──────────────────────────────────────────── */
.bktab {
  padding: 4px 12px;
  font-size: 0.79rem;
  font-weight: 500;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  color: var(--ab-muted);
  transition: all .15s;
  font-family: inherit;
}

.bktab:hover {
  color: var(--ab-text);
}

.bktab--active {
  background: var(--ab-blue);
  color: #fff !important;
}

/* ── Breakdown Share Bar ─────────────────────────────────────── */
.bk-share-track {
  height: 5px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}

.bk-share-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--ab-blue);
  transition: width .7s ease;
}

/* ── Breakdown Table ─────────────────────────────────────────── */
#bkTable td.num, #bkTable th.num,
#bkTable2 td.num, #bkTable2 th.num {
  text-align: center;
}

#bkTable tfoot td, #bkTable2 tfoot td {
  font-size: 0.86rem;
}

.bk-col-intensity {
  padding-right: 32px !important;
  border-right: 1px solid var(--ab-border);
}

.bk-col-share {
  padding-left: 32px !important;
  min-width: 200px;
}

/* ── View More Button ────────────────────────────────────────── */
.view-more-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--ab-blue);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--ab-blue);
  font-family: inherit;
  transition: background .15s, color .15s;
  white-space: nowrap;
  text-decoration: none;
}

.view-more-btn:hover {
  background: var(--ab-blue);
  color: #fff;
}

/* ── Table Pages ─────────────────────────────────────────────── */
.table-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--ab-bg);
  width: 100%;
}

.table-page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.14rem 1.71rem;
  background: #fff;
  border-bottom: 1px solid var(--ab-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.table-page-title {
  font-size: 1.21rem;
  font-weight: 700;
  color: var(--ab-text);
  letter-spacing: -.3px;
}

.table-page-body {
  padding: 1rem;
  flex: 1;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  background: none;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ab-muted);
  font-family: inherit;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.back-btn:hover {
  color: var(--ab-text);
  border-color: var(--ab-text);
}

.btn-export {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  font-size: 0.86rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--ab-border);
  background: var(--ab-surface);
  color: var(--ab-text);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}

.btn-export:hover {
  background: var(--ab-border);
}

/* ── Budget Modal ────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, .45);
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-weight: 600;
  font-size: 15px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ab-muted);
  font-size: 20px;
  line-height: 1;
}

.modal-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ab-muted);
  display: block;
  margin-bottom: 6px;
}

.modal-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  font-size: 14px;
  background: var(--ab-surface);
  color: var(--ab-text);
  box-sizing: border-box;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

.modal-input:focus {
  border-color: var(--ab-blue);
}

.modal-hint {
  font-size: 11px;
  color: var(--ab-muted);
  margin-top: 5px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn-cancel {
  padding: 8px 18px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--ab-text);
  font-family: inherit;
}

.btn-save {
  padding: 8px 18px;
  border: none;
  border-radius: 7px;
  background: var(--ab-blue);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s;
}

.btn-save:hover {
  opacity: .88;
}

/* ── Budget Edit Button ──────────────────────────────────────── */
.btn-edit-budget {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 4px;
  color: var(--ab-muted);
  vertical-align: middle;
}

/* ── Airline Efficiency Row ──────────────────────────────────── */
.airline-eff-card {
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 8px;
  padding: 9px 11px;
  transition: box-shadow .15s;
}

.airline-eff-card:hover {
  box-shadow: var(--sh);
}

/* ── Top 5 Side-by-Side Row ──────────────────────────────────── */
.top5-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.top5-row>.panel {
  display: flex;
  flex-direction: column;
}

/* ── Top 5 Grid ──────────────────────────────────────────────── */
.top5-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 4px;
}

/* Half-width panels: stack cards in a single column as compact rows */
.top5-grid--half {
  grid-template-columns: 1fr;
  gap: 7px;
}

.top5-grid--half .top5-card,
.top5-grid--half .traveller-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  min-height: 72px;
}

.top5-grid--half .top5-card-info,
.top5-grid--half .traveller-card-info {
  flex: 1;
  min-width: 0;
}

.top5-grid--half .top5-order {
  margin-bottom: 2px;
}

.top5-grid--half .top5-route {
  margin-bottom: 2px;
  font-size: 13px;
}

.top5-grid--half .top5-meta {
  margin-bottom: 0;
}

.top5-grid--half .top5-value {
  font-size: 17px;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

.top5-card {
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 10px;
  padding: 13px 15px;
  overflow: hidden;
  transition: box-shadow .18s, border-color .18s;
}

.top5-card:hover {
  box-shadow: var(--shm);
  border-color: #c4cfe0;
}

.top5-order {
  font-size: 10px;
  color: var(--ab-muted);
  margin-bottom: 3px;
  font-weight: 500;
  letter-spacing: .03em;
  font-family: var(--mono);
}

.top5-route {
  font-size: 13px;
  font-weight: 600;
  color: var(--ab-text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top5-meta {
  font-size: 10px;
  color: var(--ab-muted);
  margin-bottom: 8px;
}

.top5-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.top5-unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--ab-muted);
  margin-left: 3px;
}

/* ── Donut Legend ────────────────────────────────────────────── */
.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--ab-surface);
  border-radius: 8px;
  border: 1px solid var(--ab-border);
}

.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.donut-name {
  font-size: 13px;
  color: var(--ab-text);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.donut-pct {
  font-size: 14px;
  font-weight: 700;
  color: var(--ab-text);
  flex-shrink: 0;
}

.donut-kg {
  font-size: 11px;
  color: var(--ab-muted);
  flex-shrink: 0;
  min-width: 80px;
  text-align: right;
}

/* ── Traveller Card ──────────────────────────────────────────── */
.traveller-card {
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 10px;
  padding: 13px 15px;
  overflow: hidden;
  transition: box-shadow .18s, border-color .18s;
}

.traveller-card:hover {
  box-shadow: var(--shm);
  border-color: #c4cfe0;
}

/* ── Spin Animation ──────────────────────────────────────────── */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ── Login Page ──────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--ab-bg);
}

.login-card {
  background: #fff;
  border: 1px solid var(--ab-border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shm);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--ab-blue-lite);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--ab-text);
}

.login-sub {
  font-size: 12px;
  color: var(--ab-muted);
  margin-top: 2px;
}

.login-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ab-text2);
  display: block;
  margin-bottom: 6px;
}

.login-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ab-surface);
  border: 1px solid var(--ab-border2);
  color: var(--ab-text);
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .15s;
}

.login-input:focus {
  border-color: var(--ab-blue);
}

.login-btn {
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  border: none;
  background: var(--ab-blue);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  font-family: inherit;
  transition: background .15s;
}

.login-btn:hover {
  background: var(--ab-blue-dark);
}

.login-error {
  background: var(--ab-red-bg);
  border: 1px solid var(--ab-red-b);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--ab-red);
  margin-bottom: 16px;
}

.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--ab-muted);
  margin-top: 20px;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .row-2col {
    grid-template-columns: 1fr;
  }

  .top5-row {
    grid-template-columns: 1fr;
  }

  .top5-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-btn {
    display: flex;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .top5-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Standalone Page Layout (Records & Breakdown) ─────────────── */
.main-content {
  margin-left: var(--ab-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar (standalone pages) ────────────────────────────────── */
.topbar {
  height: 3.85rem;
  background: #fff;
  border-bottom: 1px solid var(--ab-border);
  display: flex;
  align-items: center;
  padding: 0 1.57rem;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.page-body-inner {
  padding: 1.4rem 1.57rem;
  flex: 1;
}

/* ── Page header row ──────────────────────────────────────────── */
.page-header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.21rem;
  font-weight: 700;
  color: var(--ab-text);
  letter-spacing: -.3px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Back button ──────────────────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  background: none;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ab-muted);
  font-family: inherit;
  text-decoration: none;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.back-btn:hover {
  color: var(--ab-text);
  border-color: var(--ab-text);
}

/* ── Export button ────────────────────────────────────────────── */
.btn-export {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  font-size: 0.86rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--ab-border);
  background: var(--ab-surface);
  color: var(--ab-text);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}

.btn-export:hover {
  background: var(--ab-border);
}

/* ── Records badge ────────────────────────────────────────────── */
.panel-badge {
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--ab-muted);
  white-space: nowrap;
}

/* ── Filter bar ───────────────────────────────────────────────── */
.filter-bar {

  margin-bottom: 16px;

}

.filter-row-top {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-row-bottom {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.filter-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ab-muted);
  pointer-events: none;
}

.filter-search-wrap input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border-radius: 7px;
  font-size: 0.86rem;
  background: var(--ab-surface);
  color: var(--ab-text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

.filter-search-wrap input:focus {
  border-color: var(--ab-blue);
}

.filter-date, .filter-sel {
  padding: 7px 10px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  font-size: 0.86rem;
  background: var(--ab-surface);
  color: var(--ab-text);
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.filter-date-label {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  background: var(--ab-surface);
  overflow: hidden;
}

.filter-date-text {
  padding: 7px 8px 7px 10px;
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--ab-muted);
  white-space: nowrap;
  pointer-events: none;
  border-right: 1px solid var(--ab-border);
}

.filter-date-label .filter-date {
  border: none;
  border-radius: 0;
  background: transparent;
  padding-left: 8px;
}

.filter-clear {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  background: none;
  cursor: pointer;
  font-size: 0.79rem;
  color: var(--ab-muted);
  font-family: inherit;
  transition: color .15s;
  white-space: nowrap;
}

.filter-clear:hover {
  color: var(--ab-red);
  border-color: var(--ab-red);
}

/* ── Table card ───────────────────────────────────────────────── */
.table-card {
  background: #fff;
  border: 1px solid var(--ab-border);
  border-radius: var(--r);
  box-shadow: var(--sh);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.ab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.ab-table th {
  background: var(--ab-surface);
  font-weight: 600;
  color: var(--ab-muted);
  text-align: left;
  padding: 12px 18px;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--ab-border);
  white-space: nowrap;
}

/* Extra breathing room on first and last columns */
.ab-table th:first-child,
.ab-table td:first-child {
  padding-left: 22px;
}

.ab-table th:last-child,
.ab-table td:last-child {
  padding-right: 22px;
}

.ab-table th.num {
  text-align: right;
}

.ab-table td {
  padding: 13px 18px;
  border-bottom: 1px solid #f0f2f5;
  color: var(--ab-text);
  vertical-align: middle;
}

.ab-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ab-table tbody tr:last-child td {
  border-bottom: none;
}

.ab-table tbody tr:hover {
  background: #f9fafb;
}

.ab-table tfoot td {
  font-size: 0.86rem;
  background: var(--ab-surface);
  border-top: 2px solid var(--ab-border);
}

.mono {
  font-family: var(--mono);
}

.fw6 {
  font-weight: 600;
}

/* ── Badges ───────────────────────────────────────────────────── */
.ab-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}

.ab-badge--within {
  background: var(--ab-green-bg);
  color: var(--ab-green);
}

.ab-badge--warning {
  background: var(--ab-amber-bg);
  color: var(--ab-amber);
}

.ab-badge--exceeded {
  background: var(--ab-red-bg);
  color: var(--ab-red);
}

.ab-badge--ow {
  background: #eff6ff;
  color: #1d4ed8;
}

.ab-badge--rt {
  background: #f3e8ff;
  color: #7c3aed;
}

.badge-icao {
  background: var(--ab-blue-lite);
  color: #1e40af;
  border-radius: 4px;
  font-size: 0.71rem;
  font-weight: 600;
  padding: 2px 6px;
  white-space: nowrap;
}

/* ── Pagination (standalone) ──────────────────────────────────── */
.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 22px;
  border-top: 1px solid var(--ab-border);
}

.pg-info {
  font-size: 0.79rem;
  color: var(--ab-muted);
}

.pg-btns {
  display: flex;
  align-items: center;
  gap: 3px;
}

.pg-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 6px;
  border: 1px solid var(--ab-border);
  border-radius: 6px;
  background: none;
  font-size: 0.86rem;
  cursor: pointer;
  color: var(--ab-text);
  font-family: inherit;
  transition: background .12s, color .12s;
}

.pg-btn:hover:not(:disabled) {
  background: var(--ab-blue);
  color: #fff;
  border-color: var(--ab-blue);
}

.pg-btn.active {
  background: var(--ab-blue);
  color: #fff;
  border-color: var(--ab-blue);
  font-weight: 600;
}

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

.pg-arrow {
  font-size: 1.14rem;
  line-height: 1;
}

.pg-ellipsis {
  font-size: 0.86rem;
  color: var(--ab-muted);
  padding: 0 3px;
}

/* ── Sort icons ───────────────────────────────────────────────── */
.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable:hover {
  background: rgba(26, 111, 212, .05);
}

.sort-icon {
  font-size: 0.71rem;
  opacity: .35;
  margin-left: 2px;
  transition: opacity .15s;
}

.sort-icon.asc,
.sort-icon.desc {
  opacity: 1;
  color: #1a6fd4;
  font-weight: 700;
}

/* ── Loading / empty cell ─────────────────────────────────────── */
.loading-cell {
  text-align: center;
  padding: 2.5rem;
  color: var(--ab-muted);
  font-size: 0.86rem;
}

/* ── Breakdown tab bar ────────────────────────────────────────── */
.tab-export-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.tab-group {
  display: flex;
  gap: 2px;
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 7px;
  padding: 3px;
}

.bktab {
  padding: 4px 12px;
  font-size: 0.79rem;
  font-weight: 500;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  color: var(--ab-muted);
  transition: all .15s;
  font-family: inherit;
}

.bktab:hover {
  color: var(--ab-text);
}

.bktab--active {
  background: var(--ab-blue);
  color: #fff !important;
}

/* ── Breakdown share bar ──────────────────────────────────────── */
.bk-share-track {
  height: 5px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}

.bk-share-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--ab-blue);
  transition: width .7s ease;
}

.bk-share-fill--purple {
  background: #7c3aed;
}

.bk-col-intensity {
  padding-right: 32px !important;
  border-right: 1px solid var(--ab-border);
}

.bk-col-share {
  padding-left: 32px !important;
  min-width: 200px;
}

/* ── Responsive (standalone) ──────────────────────────────────── */
@media (max-width: 680px) {
  .tab-export-row {
    margin-left: 0;
  }

  .bk-col-intensity {
    padding-right: 14px !important;
    border-right: none;
  }

  .bk-col-share {
    padding-left: 14px !important;
    min-width: 0;
  }
}
/* ── DEFRA Rate Card (always visible) ───────────────────────── */
.defra-rate-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--ab-card, #fff);
    border: 0.5px solid var(--ab-border);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 16px;
}
.defra-rate-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.defra-rate-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--ab-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.defra-rate-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}
.defra-rate-value--within   { color: #22c55e; }
.defra-rate-value--warning  { color: #f59e0b; }
.defra-rate-value--exceeded { color: #ef4444; }
.defra-rate-sub {
    font-size: 12px;
    color: var(--ab-muted);
}
.defra-rate-right {
    flex: 1;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.defra-rate-pill {
    align-self: flex-start;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 99px;
}
.defra-rate-pill--within   { background: #dcfce7; color: #166534; }
.defra-rate-pill--warning  { background: #fef3c7; color: #92400e; }
.defra-rate-pill--exceeded { background: #fee2e2; color: #991b1b; }

/* ─────────────────────────────────────────────────────────────────────────────
   Threshold / Period Selector additions
   Add these rules to your existing stylesheet (e.g. static/style.css or
   inside your base.html <style> block).
───────────────────────────────────────────────────────────────────────────── */

/* ── Period selector in topbar ───────────────────────────────────────────── */
.period-selector-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--ab-card, #fff);
  border: 1px solid var(--ab-border, #e5e7eb);
  border-radius: 7px;
  padding: 4px 8px;
}

.period-selector-wrap .period-select {
  border: none;
  background: transparent;
  outline: none;
  font-size: 12px;
  color: var(--ab-text, #111827);
  cursor: pointer;
  min-width: 110px;
}

/* ── Modal enhancements ───────────────────────────────────────────────────── */

/* Scrollable modal body for longer content */
.modal-box {
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Section grouping inside modal */
.modal-section {
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--ab-border, #e5e7eb);
}
.modal-section:last-of-type {
  border-bottom: none;
}

.modal-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ab-muted, #6b7280);
  margin-bottom: 10px;
}

/* Route caps table inside modal */
#routeCapsBody tr:hover {
  background: var(--ab-hover, #f9fafb);
}
#routeCapsBody td {
  padding: 5px 6px;
  vertical-align: middle;
  border-bottom: 1px solid var(--ab-border, #e5e7eb);
}
#routeCapsBody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   PREMIUM CONFIGURATION & ROUTE TRIP CAPS STYLES
   ========================================================================== */

/* ── Tab sub-navigation ── */
.cfg-nav, .rc-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.cfg-nav a, .rc-nav a {
  font-size: 13px;
  font-weight: 600;
  color: var(--ab-text2);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--ab-card);
  border: 1px solid var(--ab-border);
  box-shadow: var(--sh);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cfg-nav a:hover, .rc-nav a:hover {
  background: var(--ab-surface);
  color: var(--ab-blue);
  border-color: var(--ab-blue-lite);
  transform: translateY(-1px);
  
}

.cfg-nav a.active, .rc-nav a.active {
  background: linear-gradient(135deg, var(--ab-blue), #0ea5e9);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(26, 111, 212, 0.25);
}

/* ── Configuration Page Layout & Row-wise grid ── */
.cfg-body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.cfg-page-header, .rc-page-header {
  margin-bottom: 32px;
}

.cfg-page-header h1, .rc-page-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--ab-text);
  margin: 0 0 6px;
  letter-spacing: -.5px;
}

.cfg-page-header p, .rc-page-header p {
  font-size: 14px;
  color: var(--ab-muted);
  margin: 0;
}

/* Row-wise configuration cards grid */
.cfg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 28px;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .cfg-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

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

/* Premium Configuration Cards */
.cfg-card {
  background: var(--ab-card);
  border: 1px solid var(--ab-border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--sh);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.cfg-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(26, 111, 212, 0.08);
  border-color: rgba(26, 111, 212, 0.25);
}

.cfg-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ab-border);
}

.cfg-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cfg-card-icon--blue {
  background: rgba(26, 111, 212, 0.1);
  color: var(--ab-blue);
}

.cfg-card-icon--amber {
  background: rgba(217, 119, 6, 0.1);
  color: var(--ab-amber);
}

.cfg-card-icon--purple {
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
}

.cfg-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ab-text);
  margin: 0 0 4px;
}

.cfg-card-desc {
  font-size: 13px;
  color: var(--ab-muted);
  line-height: 1.4;
  margin: 0;
}

/* Fields & Inputs */
.cfg-fields-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-grow: 1;
}

.cfg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cfg-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ab-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.cfg-input-wrap {
  position: relative;
}

.cfg-input {
  width: 100%;
  padding: 10px 42px 10px 14px;
  border: 1px solid var(--ab-border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--ab-text);
  background: var(--ab-surface2);
  box-sizing: border-box;
  transition: all 0.2s;
}

.cfg-input:focus {
  outline: none;
  background: var(--ab-card);
  border-color: var(--ab-blue);
  box-shadow: 0 0 0 4px rgba(26, 111, 212, 0.12);
}

.cfg-input-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--ab-muted);
  pointer-events: none;
  font-weight: 600;
}

.cfg-hint {
  font-size: 12px;
  color: var(--ab-muted);
  line-height: 1.5;
  margin: 4px 0 0 0;
}

/* Current active value badge */
.cfg-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ab-blue);
  background: rgba(26, 111, 212, 0.08);
  border: 1px solid rgba(26, 111, 212, 0.15);
  border-radius: 20px;
  padding: 4px 12px;
  align-self: flex-start;
  margin-top: 8px;
  font-weight: 500;
  animation: fadeIn 0.2s ease-in-out;
}

.cfg-current strong {
  color: var(--ab-text);
  font-weight: 700;
}

/* Footers & Buttons */
.cfg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--ab-border);
}

.btn-cfg-save {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--ab-blue), #0ea5e9);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(26, 111, 212, 0.15);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-cfg-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(26, 111, 212, 0.25);
  opacity: 0.95;
}

.btn-cfg-save:active {
  transform: translateY(0);
}

.btn-cfg-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-cfg-reset {
  padding: 10px 16px;
  background: transparent;
  color: var(--ab-muted);
  border: 1px solid var(--ab-border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cfg-reset:hover {
  background: var(--ab-surface);
  color: var(--ab-text);
  border-color: var(--ab-border2);
}

/* Toast styling */
#cfgToast, #rcToast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #1e293b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#cfgToast.show, #rcToast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#cfgToast.error, #rcToast.error {
  background: #ef4444;
  border-color: rgba(255, 255, 255, 0.15);
}

/* ── Route Caps Page Layout & Elements ── */
.rc-body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.rc-card {
  background: var(--ab-card);
  border: 1px solid var(--ab-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--sh);
  transition: box-shadow 0.2s;
}

.rc-card:hover {
  box-shadow: var(--shm);
}

/* Global cap card upper layout */
.rc-global-card {
  background: var(--ab-card);
  border: 1px solid var(--ab-border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--sh);
  transition: all 0.2s;
}

.rc-global-card:hover {
  box-shadow: var(--shm);
}

.rc-global-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(26, 111, 212, 0.1);
  color: var(--ab-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rc-global-text {
  flex: 1;
  min-width: 240px;
}

.rc-global-text h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ab-text);
  margin: 0 0 4px;
}

.rc-global-text p {
  font-size: 13px;
  color: var(--ab-muted);
  margin: 0;
  line-height: 1.4;
}

.rc-global-inputs {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.rc-input {
  padding: 10px 14px;
  border: 1px solid var(--ab-border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ab-text);
  background: var(--ab-surface2);
  transition: all 0.2s;
  height: 38px;
  box-sizing: border-box;
}

.rc-input:focus {
  outline: none;
  background: var(--ab-card);
  border-color: var(--ab-blue);
  box-shadow: 0 0 0 4px rgba(26, 111, 212, 0.12);
}

.rc-input-route {
  width: 100px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .5px;
  text-align: center;
}

.rc-input-kg {
  width: 120px;
}

.rc-input-pct {
  width: 80px;
}

.rc-input-label {
  font-size: 11px;
  color: var(--ab-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.btn-rc-global-save {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--ab-blue), #0ea5e9);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(26, 111, 212, 0.15);
  height: 38px;
}

.btn-rc-global-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(26, 111, 212, 0.25);
}

/* Add Route Top Bar in Card */
.rc-add-bar {
  padding: 24px;
  background: var(--ab-surface2);
  border-bottom: 1px solid var(--ab-border);
}

.rc-add-bar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ab-muted);
  margin-bottom: 14px;
}

.rc-add-bar-fields {
  display: grid;
  grid-template-columns: 1fr auto 1fr 140px 100px auto;
  gap: 16px;
  align-items: flex-end;
}

.rc-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.rc-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ab-muted);
  white-space: nowrap;
}

.rc-field-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  color: var(--ab-muted);
  padding: 0;
}

.rc-field-action {
  display: flex;
  align-items: center;
}

.rc-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.rc-input-wrap .rc-input {
  width: 100%;
  padding-right: 32px; /* make room for suffix */
}

.rc-input-suffix {
  position: absolute;
  right: 12px;
  font-size: 12px;
  color: var(--ab-muted);
  pointer-events: none;
  font-weight: 600;
}

.btn-add-route {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--ab-blue), #0ea5e9);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(26, 111, 212, 0.15);
  height: 38px;
}

.btn-add-route:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(26, 111, 212, 0.25);
}

@media (max-width: 860px) {
  .rc-add-bar-fields {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .rc-field-connector {
    display: none;
  }
  .rc-add-bar-fields > * {
    grid-column: 1 / -1;
  }
  .btn-add-route {
    width: 100%;
    justify-content: center;
  }
}

/* Route Caps Table inside card */
.rc-table-wrap {
  overflow-x: auto;
}

.rc-table {
  width: 100%;
  border-collapse: collapse;
}

.rc-table thead th {
  text-align: left;
  padding: 14px 24px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ab-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--ab-border);
  background: var(--ab-surface2);
  white-space: nowrap;
}

.rc-table tbody tr {
  transition: background 0.15s;
}

.rc-table tbody tr:hover {
  background: rgba(26, 111, 212, 0.02);
}

.rc-table td {
  padding: 14px 24px;
  vertical-align: middle;
  border-bottom: 1px solid var(--ab-border);
}

.rc-table tbody tr:last-child td {
  border-bottom: none;
}

/* Route badge MAA -> JFK */
.rc-route-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ab-text);
  font-family: var(--mono);
  background: var(--ab-bg);
  border: 1px solid var(--ab-border);
  border-radius: 8px;
  padding: 6px 12px;
}

.rc-route-arrow {
  color: var(--ab-muted);
  font-size: 12px;
}

/* Inline inputs in Table Rows */
.rc-inline-input {
  padding: 8px 12px;
  border: 1px solid var(--ab-border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ab-text);
  background: var(--ab-surface);
  transition: all 0.15s;
  box-sizing: border-box;
}

.rc-inline-input:focus {
  outline: none;
  background: var(--ab-card);
  border-color: var(--ab-blue);
  box-shadow: 0 0 0 3px rgba(26, 111, 212, 0.12);
}

.rc-inline-input--kg {
  width: 120px;
}

.rc-inline-input--pct {
  width: 70px;
  text-align: center;
}

.rc-pct-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rc-pct-suffix {
  font-size: 13px;
  color: var(--ab-muted);
  font-weight: 600;
}

/* Save / Delete actions in table */
.btn-rc-save {
  padding: 8px 16px;
  background: var(--ab-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-rc-save:hover {
  background: var(--ab-blue-dark);
}

.btn-rc-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-rc-del {
  padding: 8px 10px;
  background: transparent;
  border: 1px solid var(--ab-border);
  border-radius: 8px;
  font-size: 14px;
  color: #ef4444;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s;
}

.btn-rc-del:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

/* Empty caps state list */
.rc-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ab-muted);
  font-size: 14px;
}

.rc-empty svg {
  display: block;
  margin: 0 auto 16px;
  color: var(--ab-muted);
  opacity: 0.45;
}

/* Info footer inside card */
.rc-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 24px;
  border-top: 1px solid var(--ab-border);
  background: var(--ab-surface2);
  font-size: 13px;
  color: var(--ab-muted);
  line-height: 1.5;
}

.rc-info svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--ab-blue);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.rc-saving {
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ── Airport Search Styles ── */
.ap-search-wrap {
  position: relative;
  width: 100%;
}

.ap-input-row {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--ab-border);
  border-radius: 10px;
  background: var(--ab-surface2);
  transition: all 0.2s;
  overflow: hidden;
  height: 38px;
  box-sizing: border-box;
  width: 100%;
}

.ap-input-row:focus-within {
  background: var(--ab-card);
  border-color: var(--ab-blue);
  box-shadow: 0 0 0 4px rgba(26, 111, 212, 0.12);
}

.ap-input-icon {
  display: flex;
  align-items: center;
  padding: 0 8px 0 10px;
  color: var(--ab-muted);
  flex-shrink: 0;
}

.ap-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12.5px;
  color: var(--ab-text);
  padding: 7px 4px;
  min-width: 0;
  height: 100%;
}

.ap-input::placeholder {
  color: var(--ab-muted);
}

.ap-badge {
  display: inline-flex;
  align-items: center;
  background: var(--ab-blue, #3b82f6);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
  margin-right: 4px;
}

.ap-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ab-muted);
  font-size: 12px;
  padding: 0 8px;
  flex-shrink: 0;
  line-height: 1;
  transition: color .12s;
}

.ap-clear:hover {
  color: #ef4444;
}

.ap-status {
  display: none;
}

.ap-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--ab-surface);
  border: 1.5px solid var(--ab-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 1200;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
}

.ap-dropdown.open {
  display: block;
}

.ap-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--ab-border);
}

.ap-dd-item:last-child {
  border-bottom: none;
}

.ap-dd-item:hover, .ap-dd-item--active {
  background: var(--ab-hover, rgba(59,130,246,.07));
}

.ap-dd-iata {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--ab-blue, #3b82f6);
  min-width: 32px;
  flex-shrink: 0;
}

.ap-dd-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ap-dd-name {
  font-size: 12px;
  color: var(--ab-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-dd-sub {
  font-size: 10.5px;
  color: var(--ab-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-dd-empty {
  font-size: 12px;
  color: var(--ab-muted);
  text-align: center;
  padding: 12px;
  cursor: default;
}

.ap-route-preview {
  display: none !important;
}