:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #eef3f6;
  --ink: #18222d;
  --muted: #667789;
  --line: #d7e0e8;
  --accent: #087f70;
  --accent-strong: #06685d;
  --blue: #245ca8;
  --gold: #a66a16;
  --danger: #a51f16;
  --sidebar-bg: #111b24;
  --wave-a: #166534;
  --wave-a-bg: #dcfce7;
  --wave-b: #1e40af;
  --wave-b-bg: #dbeafe;
  --wave-c: #92400e;
  --wave-c-bg: #fef3c7;
  --wave-d: #581c87;
  --wave-d-bg: #f3e8ff;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 4px 14px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background-image: radial-gradient(circle at 100% -10%, rgba(36, 92, 168, 0.08), transparent 40%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

/* ── Layout ─────────────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  overflow: auto;
  max-height: 100vh;
  padding: 18px 16px;
  border-right: 1px solid #0f1d27;
  background: var(--sidebar-bg);
  color: #f8fafc;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px;
  background: var(--accent);
  font-weight: 900;
  font-size: 14px;
  flex-shrink: 0;
}

.brand h1, .brand p, .topbar h2, .eyebrow,
.section-heading h3, .section-heading p, .metric p, dl, dd { margin: 0; }

.brand h1 { font-size: 18px; line-height: 1.1; }
.brand p { margin-top: 3px; color: #c7d4df; font-size: 12px; }

/* ── Nav ─────────────────────────────────────────────────────────────── */

.main-nav {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.nav-button {
  min-height: 34px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px;
  background: rgba(255,255,255,.04);
  color: #dfe8ef;
  text-align: left;
  padding: 0 10px;
  font-weight: 700;
  font-size: 12px;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}

.nav-button.active {
  border-color: rgba(255,255,255,.36);
  background: #ffffff;
  color: #12202c;
  box-shadow: var(--shadow-card);
}

.nav-button:hover:not(.active) {
  background: rgba(255,255,255,.09);
}

/* ── Sidebar panels ──────────────────────────────────────────────────── */

.panel {
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,.16);
}

.panel h2 {
  margin: 0 0 8px;
  color: #dce7f2;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

label, .file-control {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
  color: #e9eef4;
  font-size: 12px;
}

.workspace label, .workspace-label, .inline-select { color: var(--muted); font-weight: 700; }

.workspace-label {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
  font-size: 13px;
}

input, select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #cbd6df;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 5px 9px;
}

input[type="file"] {
  min-height: 0;
  color: #e5edf5;
  background: transparent;
  border-color: rgba(255,255,255,.24);
}

.workspace-file { color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.workspace-file span { color: var(--muted); }
.workspace-file input[type="file"] {
  color: var(--ink);
  background: #f8fafc;
  border-color: var(--line);
  min-height: 32px;
}

.full-width { width: 100%; }

.hint-text {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.5;
  margin: 6px 0 0;
}

.hint-text a { color: #7dd3fc; }

/* ── Sidebar time row ────────────────────────────────────────────────── */

.sidebar-time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.sidebar-time-row label { margin-bottom: 0; }

/* ── Workspace ───────────────────────────────────────────────────────── */

.workspace {
  min-width: 0;
  padding: 22px 24px;
}

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

.eyebrow {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.topbar h2 { margin-top: 2px; font-size: 26px; }

/* ── DB Status Badge ────────────────────────────────────────────────── */

.db-badge {
  font-size: 16px;
  line-height: 1;
  cursor: default;
  user-select: none;
}
.db-badge--unknown  { color: var(--muted); }
.db-badge--ok       { color: #22c55e; }
.db-badge--cache    { color: #f59e0b; }
.db-badge--error    { color: var(--danger); }
.db-badge--offline  { color: var(--muted); }

/* ── Status Strip ────────────────────────────────────────────────────── */

.status-strip {
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
  box-shadow: var(--shadow-card);
}

/* ── Stats ───────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stats-grid.small { margin-bottom: 12px; }

.metric {
  min-height: 78px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.metric span {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.metric p, .section-heading p { color: var(--muted); font-size: 13px; }

/* ── Views ───────────────────────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }

/* ── Layouts ─────────────────────────────────────────────────────────── */

.split-layout {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.aircraft-layout { grid-template-columns: 310px minmax(0, 1fr); }
.hubwellen-layout { grid-template-columns: 270px minmax(0, 1fr); }

.tool-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }

/* ── Section headings ────────────────────────────────────────────────── */

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.section-heading.compact { align-items: start; }
.section-heading h3 { font-size: 17px; }

.subsection-title {
  margin: 20px 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.subsection-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
  margin-left: 8px;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

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

.primary-action, .secondary-action, .danger-action, .table-action {
  min-height: 34px;
  border-radius: 6px;
  font-weight: 700;
  padding: 0 12px;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.primary-action   { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.secondary-action { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.danger-action    { border: 1px solid #ffc9c3; background: #fff3f1; color: var(--danger); }

.table-action {
  min-height: 26px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  padding: 0 8px;
  font-size: 12px;
}

.table-action.danger { color: var(--danger); border-color: #ffc9c3; }

.save-status { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ── Tables ──────────────────────────────────────────────────────────── */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tall-table { max-height: calc(100vh - 240px); }

table { width: 100%; min-width: 700px; border-collapse: collapse; }

th, td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: #405163;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #e2eaf2; }

.sort-icon { opacity: .35; margin-left: 4px; font-size: 11px; }
.sort-icon.active { opacity: 1; color: var(--blue); }

tbody tr:hover { background: #f8fbfc; }

.action-cell { white-space: nowrap; }
.action-cell .table-action + .table-action { margin-left: 4px; }

/* ── Badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e7f5f2;
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 12px;
}

/* ── Registration badge (fleet) ──────────────────────────────────────── */

.reg-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f3e8ff;
  color: var(--wave-d);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .03em;
}

/* ── Days cell (table) ───────────────────────────────────────────────── */

.days-cell { white-space: nowrap; }

.day-dot {
  display: inline-block;
  width: 22px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  background: #f0f4f7;
  color: #9aabb9;
  margin-right: 1px;
}

.day-dot.active { background: var(--accent); color: #fff; }

/* ── Day buttons (planner form) ──────────────────────────────────────── */

.day-btn-row { display: flex; gap: 4px; flex-wrap: wrap; }

.day-btn {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0f4f7;
  color: #7a95a7;
  font-weight: 700;
  font-size: 12px;
  transition: background .1s, color .1s, border-color .1s;
}

.day-btn.active {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #fff;
}

.label-text {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
}

/* ── Input with suggestion hint ──────────────────────────────────────── */

.input-hint {
  display: block;
  font-size: 12px;
  color: var(--accent-strong);
  min-height: 16px;
  margin-top: 2px;
}

.suggestion-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  min-height: 0;
  cursor: pointer;
}

/* ── Route / city display ────────────────────────────────────────────── */

.route-cell { display: block; font-weight: 700; }

.route-city {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

/* ── Wave badges ─────────────────────────────────────────────────────── */

.wave-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
}

.wave-a { background: var(--wave-a-bg); color: var(--wave-a); }
.wave-b { background: var(--wave-b-bg); color: var(--wave-b); }
.wave-c { background: var(--wave-c-bg); color: var(--wave-c); }
.wave-d { background: var(--wave-d-bg); color: var(--wave-d); }
.wave-none { background: #f1f5f9; color: #94a3b8; }

/* ── Wave config ─────────────────────────────────────────────────────── */

.wave-config-row {
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.wave-label-tag {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 900;
}

.wave-label-tag.wave-a { background: var(--wave-a-bg); color: var(--wave-a); }
.wave-label-tag.wave-b { background: var(--wave-b-bg); color: var(--wave-b); }
.wave-label-tag.wave-c { background: var(--wave-c-bg); color: var(--wave-c); }
.wave-label-tag.wave-d { background: var(--wave-d-bg); color: var(--wave-d); }

.compact-label {
  display: grid;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 0 !important;
}

.compact-label input { min-height: 30px; font-size: 13px; padding: 4px 8px; }

.wave-legend {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Hubwellen grid ──────────────────────────────────────────────────── */

.hubwellen-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.hubwellen-table {
  min-width: 1100px;
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.hubwellen-table th, .hubwellen-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
}

.hubwellen-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-soft);
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
}

/* dest / standalone column headers */
.hw-dest-col {
  min-width: 140px;
  text-align: left !important;
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface-soft) !important;
}

.hw-standalone-col { min-width: 120px; }

/* sticky dest cell in rows */
.hw-dest-cell {
  position: sticky;
  left: 0;
  background: var(--surface) !important;
  z-index: 1;
  min-width: 140px;
}

.hw-city {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.hw-country {
  display: block;
  font-size: 10px;
  color: #94a3b8;
}

.wave-header { font-weight: 900; }
.wave-header-a { background: var(--wave-a-bg) !important; color: var(--wave-a); }
.wave-header-b { background: var(--wave-b-bg) !important; color: var(--wave-b); }
.wave-header-c { background: var(--wave-c-bg) !important; color: var(--wave-c); }
.wave-header-d { background: var(--wave-d-bg) !important; color: var(--wave-d); }

.wave-sub { font-weight: 600; font-size: 10px; }
.wave-sub-a { background: color-mix(in srgb, var(--wave-a-bg) 50%, white) !important; color: var(--wave-a); }
.wave-sub-b { background: color-mix(in srgb, var(--wave-b-bg) 50%, white) !important; color: var(--wave-b); }
.wave-sub-c { background: color-mix(in srgb, var(--wave-c-bg) 50%, white) !important; color: var(--wave-c); }
.wave-sub-d { background: color-mix(in srgb, var(--wave-d-bg) 50%, white) !important; color: var(--wave-d); }

.wave-cell { min-width: 110px; vertical-align: top; }
.wave-cell-a { background: color-mix(in srgb, var(--wave-a-bg) 15%, white); }
.wave-cell-b { background: color-mix(in srgb, var(--wave-b-bg) 15%, white); }
.wave-cell-c { background: color-mix(in srgb, var(--wave-c-bg) 15%, white); }
.wave-cell-d { background: color-mix(in srgb, var(--wave-d-bg) 15%, white); }

.cell-empty { color: #c8d4de; font-size: 13px; }

.wave-flight-entry {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--line);
}

.wave-flight-entry:last-child { border-bottom: none; }

.wf-no   { font-weight: 800; font-size: 12px; color: var(--ink); }
.wf-type { font-size: 11px; color: var(--muted); }
.wf-time { font-size: 11px; color: var(--accent-strong); font-variant-numeric: tabular-nums; }

/* ── Hubwellen toolbar ───────────────────────────────────────────────── */

.hw-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

/* ── Hubwellen toggle icon ───────────────────────────────────────────── */

.hw-toggle-icon {
  display: inline-block;
  width: 16px;
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Hubwellen region rows (Übergruppe) ──────────────────────────────── */

.hw-region-row {
  cursor: pointer;
  user-select: none;
}

.hw-region-row:hover .hw-region-cell { background: #e6eef5 !important; }

.hw-region-cell {
  padding: 8px 14px !important;
  background: #1a2a38 !important;
  color: #f8fafc !important;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--line) !important;
}

.hw-region-id {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,.18);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  margin-right: 8px;
}

.hw-region-label {
  font-weight: 700;
  font-size: 13px;
  color: #f8fafc;
}

/* ── Hubwellen subgroup rows (Länder) ────────────────────────────────── */

.hw-sg-row {
  cursor: pointer;
  user-select: none;
}

.hw-sg-row:hover .hw-sg-cell { background: #edf4f9 !important; }

.hw-sg-cell {
  padding: 6px 18px !important;
  background: var(--surface-soft) !important;
  font-size: 12px;
  border-bottom: 1px solid var(--line) !important;
}

/* ── Fleet type sub-header rows ──────────────────────────────────────── */

.type-header-row { background: #f0f6fa !important; }

.type-header-cell {
  padding: 6px 12px !important;
  border-bottom: 1px solid var(--line) !important;
  border-top: 2px solid var(--line) !important;
}

.type-name-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  margin-right: 8px;
}

.type-seats-label {
  font-size: 11px;
  color: var(--muted);
  margin-right: 8px;
}

.type-count-label {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: #dbeafe;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

/* ── Hubwellen group separator rows ──────────────────────────────────── */

.group-header-row { background: #f8f5ff !important; }

.group-header-cell {
  padding: 6px 12px !important;
  border-bottom: 1px solid var(--line) !important;
}

.group-id {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 5px;
  background: var(--wave-d-bg);
  color: var(--wave-d);
  font-size: 11px;
  font-weight: 800;
  margin-right: 8px;
}

.group-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  margin-right: 8px;
}

.group-range {
  font-size: 11px;
  color: var(--muted);
}

/* ── Routes ──────────────────────────────────────────────────────────── */

.route-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-inline {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
}

.filter-inline select, .filter-inline input {
  min-height: 30px;
  font-size: 13px;
  padding: 4px 8px;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.route-list table { min-width: 600px; }

.route-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.route-card strong { display: block; margin-bottom: 4px; font-size: 15px; }
.route-card span   { color: var(--muted); font-size: 13px; }

.route-card dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.route-card dt { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.route-card dd { margin-top: 2px; font-size: 17px; font-weight: 900; }

.route-group-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 700;
  margin-top: 3px;
}

/* ── Route bar chart ─────────────────────────────────────────────────── */

.route-chart-wrap {
  padding: 4px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* ── Family grouping rows (aircraft + fleet tables) ──────────────────── */

.family-header-row { background: var(--surface-soft) !important; }

.family-header-cell {
  padding: 6px 11px !important;
  border-bottom: 2px solid var(--line) !important;
}

.family-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  margin-right: 8px;
}

.family-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.fleet-count {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

/* ── Analytics ───────────────────────────────────────────────────────── */

.analysis-controls {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.analysis-controls label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
  min-width: 160px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

/* ── Competition ─────────────────────────────────────────────────────── */

.recommend-btn { font-weight: 700; color: var(--accent-strong) !important; border-color: var(--accent) !important; }

/* ── Import diff ─────────────────────────────────────────────────────── */

.diff-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.diff-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.diff-badge.added     { background: #dcfce7; color: #166534; }
.diff-badge.changed   { background: #fef3c7; color: #92400e; }
.diff-badge.removed   { background: #fee2e2; color: #991b1b; }
.diff-badge.unchanged { background: #f1f5f9; color: #64748b; }
.diff-badge-warn      { background: #fff7e6; color: #92400e; border: 1px solid #f59e0b; }

.diff-section-title { margin: 16px 0 8px; font-size: 14px; font-weight: 800; }
.added-title   { color: #166534; }
.changed-title { color: #92400e; }
.removed-title { color: #991b1b; }
.warn-title    { color: #92400e; }

.fn-fix-input {
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  min-height: 28px;
  border: 1px solid #f59e0b;
  border-radius: 5px;
  background: #fffbeb;
  width: 90px;
}

.diff-field { display: inline-block; margin-right: 8px; font-size: 12px; }
.diff-field del { color: var(--danger); }
.diff-field ins { color: var(--accent-strong); text-decoration: none; }

.diff-reg-select, .diff-reg-manual {
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

/* ── Ländergruppen ───────────────────────────────────────────────────── */

.lg-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.lg-region { margin-bottom: 24px; }

.lg-collapsible { cursor: pointer; user-select: none; }

.lg-region-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  border-radius: 6px 6px 0 0;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.lg-region-id {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 5px;
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.lg-region-label {
  flex: 1;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.lg-region-range {
  font-size: 11px;
  color: rgba(255,255,255,.7);
  font-weight: 600;
  margin-right: 8px;
}

.lg-region-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.lg-region-actions .table-action {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.3);
  color: #fff;
  font-size: 11px;
  min-height: 22px;
}

.lg-region-actions .table-action.danger {
  background: rgba(255,80,60,.25);
  border-color: rgba(255,120,100,.5);
  color: #ffd5d0;
}

.lg-add-sg-row td {
  padding: 6px 12px !important;
  background: #f8fafc;
}

.apt-list-cell {
  white-space: normal !important;
  max-width: 360px;
}

.lg-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: none;
  font-size: 13px;
}

.lg-table th, .lg-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: normal;
}

.lg-table th {
  position: static;
  background: var(--surface-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #405163;
}

.apt-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  margin: 2px 2px;
  border-radius: 5px;
  background: #e7f5f2;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  cursor: default;
}

/* ── Import / Export layout ──────────────────────────────────────────── */

.import-export-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.import-export-grid .ie-full { grid-column: 1 / -1; }

.panel-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

/* ── AirlineSim Direkt-Import (Crawl-Panel) ─────────────────────────── */

.crawl-panel {
  border: 2px solid var(--accent);
  background: linear-gradient(135deg, #f7fdfb 0%, #eef8f5 100%);
}

.crawl-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}

.crawl-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crawl-actions {
  display: flex;
  flex-direction: column;
}

.crawl-setup-hint summary {
  font-size: 12px;
  color: var(--muted);
  list-style: none;
}
.crawl-setup-hint summary::-webkit-details-marker { display: none; }
.crawl-setup-hint summary::before { content: "▸ "; }
.crawl-setup-hint[open] summary::before { content: "▾ "; }

.code-block {
  margin: 4px 0 0;
  padding: 8px 12px;
  background: #1e2428;
  color: #c9d1d9;
  border-radius: 6px;
  font: 12px/1.6 monospace;
  white-space: pre;
  overflow-x: auto;
}

.crawl-spinner { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #c5d0db;
  border-radius: 4px;
  background: #f3f6f8;
  font: 12px monospace;
  color: var(--ink);
}

/* ── Misc ────────────────────────────────────────────────────────────── */

.inline-select {
  display: grid;
  grid-template-columns: auto 200px;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.text-danger { color: var(--danger); }

.mono { font-variant-numeric: tabular-nums; }

/* ── Database / Sync View ────────────────────────────────────────────── */

.db-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.db-status-panel, .db-counts-panel {
  font-size: 13px;
}

.db-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.db-status-row:last-child { border-bottom: none; }

.db-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.db-status-dot.ok     { background: #22c55e; }
.db-status-dot.warn   { background: #f59e0b; }
.db-status-dot.error  { background: var(--danger); }

.db-count-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.db-count-row:last-child { border-bottom: none; }
.db-count-row .label  { color: var(--muted); }
.db-count-row .value  { font-weight: 700; font-variant-numeric: tabular-nums; }

.db-migrate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.db-migrate-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
}
.db-migrate-table tr:last-child td { border-bottom: none; }
.db-migrate-table td:first-child    { color: var(--muted); }
.db-migrate-table td:last-child     { font-weight: 700; text-align: right; }

.db-error-banner {
  padding: 10px 14px;
  border-radius: 7px;
  background: #fff3f1;
  border: 1px solid #ffc9c3;
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

.db-success-banner {
  padding: 10px 14px;
  border-radius: 7px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Multi-select filter ─────────────────────────────────────────────── */

.ms-filter-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 110px;
}
.ms-filter-wrap .filter-label-text {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.ms-search {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  background: var(--surface);
  width: 100%;
}
.ms-select {
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  background: var(--surface);
  width: 100%;
  padding: 2px;
}
.ms-select option { padding: 2px 4px; }
.ms-select:focus { outline: 2px solid var(--blue); }

/* ── Flight grouping ─────────────────────────────────────────────────── */

.flight-group-master {
  cursor: pointer;
  position: relative;
}
.flight-group-master td {
  background: var(--surface) !important;
  border-top: 2px solid var(--line) !important;
}
.flight-group-master:hover td { background: var(--surface-soft) !important; }
.flight-group-master td:first-child { font-weight: 700; }
.flight-group-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
  padding: 0 3px 0 0;
  line-height: 1;
  vertical-align: middle;
  display: inline-block;
}
.flight-variant-count {
  display: inline-block;
  font-size: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}
.flight-group-variant td {
  background: var(--bg);
  border-top: none !important;
  font-size: 12px;
  color: var(--muted);
}
.flight-group-variant td:first-child { padding-left: 26px; }

/* ── Ländergruppen airport editor ────────────────────────────────────── */

.lg-apt-row td { padding: 0; border-top: none !important; }
.lg-apt-editor {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0 8px 8px;
}
.apt-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
  min-height: 26px;
}
.apt-chip-editable {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 500;
}
.apt-chip-remove {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.apt-chip-remove:hover { color: var(--danger); }
.lg-apt-add-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.lg-apt-input {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 13px;
  width: 90px;
  text-transform: uppercase;
}

/* ── Ländergruppen subgroup sub-ranges ───────────────────────────────── */

.lg-sg-subranges td {
  padding: 0 !important;
  border-top: none !important;
  background: var(--bg);
}
.lg-subranges-wrap {
  padding: 0 0 4px 0;
  border-bottom: 1px solid var(--line);
}
.lg-subrange {
  padding: 7px 12px 7px 24px;
  border-top: 1px solid rgba(0,0,0,.05);
}
.lg-subrange:first-child { border-top: none; }
.lg-sr-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}
.lg-sr-code {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
  letter-spacing: .04em;
}
.lg-sr-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.lg-sr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 20px;
}

/* Subgroup row: collapsed vs expanded */
.lg-sg-row.is-collapsible { cursor: pointer; }
.lg-sg-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
  padding: 0 3px 0 0;
  line-height: 1;
  vertical-align: middle;
}
.lg-sg-code-label {
  font-weight: 700;
  font-size: 13px;
}
.lg-sg-code {
  font-size: 11px;
  font-weight: 700;
  font-family: monospace;
  color: var(--blue);
  margin-right: 4px;
}

/* ── Ländergruppen neue Stile ────────────────────────── */
.lg-region-body { margin: 0 0 4px 0; }
.lg-sg-label { margin-left: 4px; }
.lg-apt-list { list-style: none; margin: 0; padding: 0; }
.lg-apt-item { display: flex; align-items: center; gap: 8px; padding: 2px 4px; border-radius: 4px; white-space: nowrap; overflow: hidden; max-width: 100%; }
.lg-apt-item:hover { background: rgba(0,0,0,.04); }
.lg-apt-iata { font-family: monospace; font-weight: 700; font-size: 13px; min-width: 36px; color: var(--blue); }
.lg-apt-name { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.lg-apt-country { color: var(--muted); font-size: 12px; }
.lg-add-row { padding: 6px 8px; }
.lg-inline-input { padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; background: var(--bg); color: var(--text); }
.lg-editing td { background: rgba(0,120,200,.06) !important; }
.table-action.ok { background: var(--accent); color: #fff; }
.lg-new-region-form { padding: 8px 12px; }
.lg-apt-rows td { padding-top: 0 !important; padding-bottom: 2px !important; }
.lg-add-apt-row td { padding-top: 4px !important; }
/* Import failed IDs */
.apt-failed-ids-list { font-size: 12px; font-family: monospace; word-break: break-all; color: var(--muted); max-height: 80px; overflow-y: auto; }

/* ── Competitor controls ─────────────────────────────────────────────── */

.competitor-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Route chart mini ────────────────────────────────────────────────── */

.route-chart-mini { padding: 2px 0; }

/* ── Airports view ───────────────────────────────────────────────────── */

.apt-cols-toggle {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
}
.apt-cols-summary {
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  user-select: none;
  list-style: none;
}
.apt-cols-summary::marker,
.apt-cols-summary::-webkit-details-marker { display: none; }
.apt-cols-summary::before { content: "▶ "; font-size: 11px; }
.apt-cols-toggle[open] .apt-cols-summary::before { content: "▼ "; }
.apt-col-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 8px 12px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.apt-col-check {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  padding: 2px 8px 2px 5px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--muted);
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
}
.apt-col-check:has(input:checked) {
  background: #e7f5f2;
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}
.apt-col-check input {
  cursor: pointer;
  width: 11px;
  height: 11px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Country group rows */
.apt-country-header td {
  background: var(--surface-soft);
  padding: 5px 10px !important;
  font-size: 12px;
  border-top: 2px solid var(--line) !important;
}
.apt-country-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.apt-country-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  padding: 0 2px;
  line-height: 1;
}
.apt-country-toggle:hover { color: var(--blue); }
.apt-row td { font-size: 13px; }
.apt-row td:first-child { font-weight: 600; }

/* Airport import panel */
.apt-import-panel {
  border: 1px solid var(--line);
}
.apt-progress-bar {
  height: 10px;
  background: var(--surface-soft);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.apt-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 0.4s ease;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .app-shell, .split-layout, .analysis-grid, .hubwellen-layout, .db-section-grid {
    grid-template-columns: 1fr;
  }
  .import-export-grid { grid-template-columns: 1fr; }
  .crawl-grid { grid-template-columns: 1fr; }
  .sidebar { max-height: none; border-right: 0; position: static; }
}

@media (max-width: 760px) {
  .workspace, .sidebar { padding: 14px; }
  .topbar, .section-heading, .button-row { align-items: stretch; flex-direction: column; }
  .stats-grid, .form-grid, .form-grid.three, .analysis-controls { grid-template-columns: 1fr; }
  .route-filter-bar { flex-direction: column; }
}

/* ── Draft flights (unbekannte IATA-Codes) ───────────────────────────── */
.flight-draft {
  background: rgba(165, 31, 22, 0.07) !important;
}
.flight-draft td:first-child {
  border-left: 3px solid var(--danger, #a51f16);
}
.draft-badge {
  display: inline-block;
  font-size: 0.68rem;
  background: var(--danger, #a51f16);
  color: #fff;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
  font-weight: 600;
}

/* ── Import/Export Tabs ──────────────────────────────────────────────── */
.ie-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 20px;
}
.ie-tab {
  padding: 8px 22px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.ie-tab:hover { color: var(--blue); }
.ie-tab--active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}
.ie-tab-content { }

/* ── Airport table country header – full-width grey background ───────── */
.apt-country-header {
  background: var(--surface-soft);
}
.apt-country-header td {
  background: inherit;
  padding: 5px 10px !important;
  font-size: 12px;
  border-top: 2px solid var(--line) !important;
}

/* ── Ländergruppen builtin sub-ranges (Excel-derived) ───────────────── */
.lg-builtin-sg td {
  background: rgba(0,0,0,0.02);
  font-size: 12px;
}
.lg-builtin-code {
  font-family: monospace;
  font-size: 11px;
  color: var(--muted);
  margin-right: 4px;
}
.lg-apt-iata-hint {
  font-size: 11px;
  background: var(--blue);
  color: #fff;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
}

/* ── Airport Autocomplete Dropdown ──────────────────────────────────── */

.apt-ac-dropdown {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 6px 20px rgba(0,0,0,.14);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  max-height: 220px;
  min-width: 180px;
}

.apt-ac-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

.apt-ac-item:hover,
.apt-ac-item.apt-ac-active {
  background: var(--surface-soft);
}

.apt-ac-iata {
  font-family: monospace;
  font-weight: 800;
  font-size: 13px;
  color: var(--blue);
  min-width: 36px;
  flex-shrink: 0;
}

.apt-ac-city {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.apt-ac-country {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Input in error state (unknown IATA) */
input.apt-ac-invalid {
  border-color: var(--danger) !important;
  background: #fff5f5 !important;
}
input.apt-ac-invalid:focus {
  outline-color: var(--danger) !important;
}
.primary-action:hover,
.secondary-action:hover,
.danger-action:hover,
.table-action:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}
