:root {
  --color-bg: #ffffff;
  --color-bg-subtle: #f5f7fa;
  --color-card-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #5c6570;
  --color-border: #e1e4e8;
  --color-primary: #0060df;
  --color-primary-dark: #003eaa;
  --color-primary-soft: #e8f0fe;
  --color-danger: #b00020;
  --color-danger-soft: #fdecea;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #14171c;
    --color-bg-subtle: #1b1f26;
    --color-card-bg: #1e222a;
    --color-text: #e8eaed;
    --color-text-muted: #9aa4b2;
    --color-border: #2c333d;
    --color-primary: #5b9bff;
    --color-primary-dark: #8ebaff;
    --color-primary-soft: #1d2b45;
    --color-danger: #ff6b6b;
    --color-danger-soft: #3a1f22;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --color-bg: #14171c;
  --color-bg-subtle: #1b1f26;
  --color-card-bg: #1e222a;
  --color-text: #e8eaed;
  --color-text-muted: #9aa4b2;
  --color-border: #2c333d;
  --color-primary: #5b9bff;
  --color-primary-dark: #8ebaff;
  --color-primary-soft: #1d2b45;
  --color-danger: #ff6b6b;
  --color-danger-soft: #3a1f22;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  margin: 0;
  color: var(--color-text);
  background-color: var(--color-bg);
}

h1 {
  margin: 0 0 1.25rem;
  font-size: 1.75rem;
}

h2 {
  margin: 2rem 0 1rem;
  font-size: 1.25rem;
}

h3 {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.05rem;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

.icon {
  flex-shrink: 0;
  vertical-align: -4px;
  margin-right: 0.4rem;
}

.sidebar nav a .icon,
.tile-metric-header .icon {
  margin-right: 0;
}

/* Layout: sidebar + content */

.layout {
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  background: var(--color-bg-subtle);
  border-right: 1px solid var(--color-border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Gleiche Marke wie im Landingpage-Header (.landing-brand). */
.sidebar-brand a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--color-text);
}

.sidebar-brand .icon {
  margin-right: 0;
  color: var(--color-primary);
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  color: var(--color-text);
  text-decoration: none;
}

.sidebar nav a:hover {
  background: var(--color-primary-soft);
}

.sidebar nav a.active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}

/* Nur in der mobilen Kopfleiste sichtbar (siehe unten). */
.user-menu-toggle {
  display: none;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
  font-size: 0.9rem;
}

.sidebar-user {
  color: var(--color-text-muted);
  /* E-Mail-Adressen sind lang und haben keine Leerzeichen */
  overflow-wrap: anywhere;
}

.theme-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--color-text-muted);
  cursor: pointer;
}

/* Der Schalter ist ein <button>: die allgemeine Button-Hover-Fläche hier
   aufheben, sonst bleibt sie auf dem Handy nach dem Antippen stehen */
.theme-switch:hover,
.theme-switch:active {
  background: none;
  border-color: transparent;
}

@media (hover: hover) {
  .theme-switch:hover {
    color: var(--color-primary);
  }
}

.theme-switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #8e8e93;
  flex-shrink: 0;
  transition: background 0.2s;
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-switch-track {
    background: var(--color-primary);
  }

  :root:not([data-theme="light"]) .theme-switch-thumb {
    transform: translateX(20px);
  }
}

:root[data-theme="dark"] .theme-switch-track {
  background: var(--color-primary);
}

:root[data-theme="dark"] .theme-switch-thumb {
  transform: translateX(20px);
}

.content {
  container: content / inline-size;
  margin-left: 230px;
  padding: 1.75rem 2.5rem;
  max-width: 1100px;
}

.layout.no-sidebar .content {
  margin-left: 0;
}

/* Kopfzeile für die Seiten ohne Sidebar (Login, Registrierung). */
.auth-header {
  padding: 1rem 2.5rem;
  border-bottom: 1px solid var(--color-border);
}

.auth-header a {
  color: var(--color-text);
  text-decoration: none;
}

/* Handy: Sidebar wird zur fixierten Kopfleiste mit reinen Symbolen. User,
   Logout und Farbschema liegen in einem Aufklappmenü hinter dem User-Symbol. */
@media (max-width: 768px) {
  /* Sprungmarken (#anker) nicht unter der Leiste verstecken */
  html {
    scroll-padding-top: 4.5rem;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    height: auto;
    min-height: 56px;
    overflow: visible;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.5rem;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    background: color-mix(in srgb, var(--color-bg-subtle) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
  }

  .sidebar-brand {
    display: none;
  }

  .sidebar nav {
    flex: 1;
  }

  .sidebar nav ul {
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
  }

  .sidebar nav a {
    position: relative;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    color: var(--color-text-muted);
  }

  .sidebar nav a .icon {
    width: 24px;
    height: 24px;
  }

  .sidebar nav a:hover,
  .sidebar nav a.active {
    background: none;
  }

  .sidebar nav a.active {
    color: var(--color-primary);
  }

  .sidebar nav a.active::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 3px;
    height: 3px;
    border-radius: 3px;
    background: var(--color-primary);
  }

  /* Beschriftung bleibt für Screenreader erhalten */
  .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .user-menu-toggle,
  .user-menu-toggle:hover {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--color-text-muted);
  }

  .user-menu-toggle[aria-expanded="true"] {
    background: var(--color-primary-soft);
    color: var(--color-primary);
  }

  .user-menu-toggle .icon {
    margin-right: 0;
  }

  .sidebar-footer {
    display: none;
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0.5rem;
    min-width: 220px;
    margin-top: 0;
    padding: 0.9rem 1rem;
    gap: 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-card-bg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    font-size: 1rem;
  }

  .sidebar.user-menu-open .sidebar-footer {
    display: flex;
  }

  .content {
    margin-left: 0;
    padding: 1rem 1rem 2rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  /* Eingabefelder auf dem Handy volle Breite */
  form input,
  form select,
  form textarea {
    max-width: none;
  }

  /* Übrige Tabellen (Detailseiten): enger und lange Werte umbrechen statt
     die Seite seitlich scrollen zu lassen */
  table th,
  table td {
    padding: 0.45rem 0.4rem;
  }

  table td {
    overflow-wrap: anywhere;
  }
}

/* Buttons */

button,
.btn {
  font: inherit;
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  line-height: 1.2;
}

/* Hover-Farben nur mit Maus: auf Touch-Geräten bliebe der Zustand nach dem
   Antippen stehen */
@media (hover: hover) {
  button:hover,
  .btn:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
  }
}

/* Link-Buttons: ohne Unterstreichung, Icon und Text sauber auf einer Linie */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
}

.btn .icon {
  margin-right: 0;
}

button.btn-small,
.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
}

button.btn-danger,
.btn-danger {
  background: transparent;
  border-color: var(--color-danger);
  color: var(--color-danger);
}

@media (hover: hover) {
  button.btn-danger:hover,
  .btn-danger:hover {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
  }
}

button.btn-secondary,
.btn-secondary {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

@media (hover: hover) {
  button.btn-secondary:hover,
  .btn-secondary:hover {
    background: var(--color-bg-subtle);
    border-color: var(--color-text-muted);
  }
}

button:disabled,
button:disabled:hover {
  cursor: not-allowed;
  opacity: 0.5;
  background: var(--color-text-muted);
  border-color: var(--color-text-muted);
  color: var(--color-bg);
}

.btn-link,
button.btn-link {
  font: inherit;
  border: none;
  background: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.btn-link:hover,
button.btn-link:hover {
  background: none;
  color: var(--color-primary);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}

/* Feedback */

.error {
  color: var(--color-danger);
  background: var(--color-danger-soft);
  border: 1px solid var(--color-danger);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  /* Zeilenumbrüche (\n) in Meldungen aus dem Code übernehmen */
  white-space: pre-line;
}

/* Warnbalken oben auf dem Dashboard, springt per Klick zur betroffenen Sektion */

a.warn-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-danger);
  background: var(--color-danger-soft);
  border: 1px solid var(--color-danger);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}

a.warn-banner .icon {
  margin-right: 0;
}

a.warn-banner span {
  flex: 1;
}

a.warn-banner:hover span {
  text-decoration: underline;
}

.empty-state {
  color: var(--color-text-muted);
  padding: 1.5rem 0;
}

.hint {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Forms */

form label {
  display: block;
  margin-bottom: 1rem;
}

form input,
form select,
form textarea {
  display: block;
  width: 100%;
  max-width: 320px;
  padding: 0.45rem 0.6rem;
  margin-top: 0.3rem;
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

form input:focus,
form select:focus,
form textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

form label:has(input[type="checkbox"]),
form label:has(input[type="radio"]) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

form label:has(input[type="checkbox"]) input,
form label:has(input[type="radio"]) input {
  width: auto;
}

form.igc-upload-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

form.igc-upload-form label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

form.igc-upload-form input[type="file"] {
  display: inline-block;
  width: auto;
  margin-top: 0;
}

.igc-data-table {
  margin-top: 1.5rem;
}

form.form-grid .form-section-title {
  margin: 1.5rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

form.form-grid .form-section-title:first-child {
  margin-top: 0;
}

@media (min-width: 640px) {
  form.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 2rem;
    align-items: start;
  }

  form.form-grid label:has(textarea),
  form.form-grid label:has(input[type="file"]),
  form.form-grid .form-section-title,
  form.form-grid .map-widget,
  form.form-grid button[type="submit"] {
    grid-column: 1 / -1;
  }

  form.form-grid input,
  form.form-grid select,
  form.form-grid textarea {
    max-width: none;
  }
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

table th,
table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

table th {
  color: var(--color-text-muted);
  font-weight: 600;
  vertical-align: top;
}

table form {
  display: inline;
}

table button {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
}

tbody tr:hover {
  background: var(--color-bg-subtle);
}

.stats-table td {
  font-weight: 600;
}

/* Dashboard tiles */

.tile-row {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* minmax(0, …) statt 1fr: sonst hält ein einmal breit gezeichnetes Chart-
   Canvas (z. B. nach Drehen des Handys) die Spalte breit und die ganze Seite
   scrollt seitlich. */
/* Vier Kacheln pro Zeile erst, wenn der Inhaltsbereich (nicht das Fenster)
   breit genug ist — mit Sidebar ist er gut 300 px schmaler als das Fenster */
.tile-row-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@container content (min-width: 680px) {
  .tile-row-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.tile-row-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tile-row-1 {
  grid-template-columns: minmax(0, 1fr);
}

.tile {
  min-width: 0;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 1.25rem 1.4rem;
}

/* Kachel als Ganzes klickbar (z. B. "Längster Flug" → Flug): Der Link spannt
   sich über die Kachel, das Info-Symbol liegt darüber. */
.tile-link {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.tile-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.tile-metric:has(.tile-link:active) {
  border-color: var(--color-primary);
}

@media (hover: hover) {
  .tile-metric:has(.tile-link:hover) {
    border-color: var(--color-primary);
  }
}

/* Metric tiles (dashboard). Die Kachel ist ein Size-Container: schmal
   (Handy, oder vier Kacheln auf kleinem Bildschirm) Icon über dem Wert,
   linksbündig; ab genug Breite Icon links, Werte rechtsbündig. */

.tile-metric {
  container-type: inline-size;
  position: relative;
}

/* Info hinter dem Symbol in der Ecke unten links: Antippen öffnet sie (tile-hint.js),
   mit der Maus reicht das Überfahren. Der eigene Stacking-Kontext hält die
   offene Info über den Nachbarkacheln. */
.tile-info {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tile-info .icon {
  width: 16px;
  height: 16px;
}

.tile-hint {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  padding: 0.5rem 0.65rem;
  background: var(--color-card-bg);
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.35;
  visibility: hidden;
  pointer-events: none;
}

.tile-metric.is-hint-open {
  z-index: 10;
}

.tile-metric.is-hint-open .tile-info {
  color: var(--color-primary);
}

.tile-metric.is-hint-open .tile-hint {
  visibility: visible;
}

/* Schmal ist der Text linksbündig: Platz für das Symbol unter der letzten Zeile */
.tile-metric:has(.tile-info) .tile-metric-inner {
  padding-bottom: 1.1rem;
}

@media (hover: hover) {
  .tile-info:hover {
    background: none;
    color: var(--color-primary);
  }

  .tile-metric:has(.tile-info:hover) {
    z-index: 10;
  }

  .tile-info:hover ~ .tile-hint {
    visibility: visible;
  }
}

.tile-metric-inner {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tile-metric-icon {
  color: var(--color-primary);
  flex-shrink: 0;
}

.tile-metric-icon .icon {
  width: 22px;
  height: 22px;
  margin-right: 0;
}

.tile-metric-body {
  flex: 1;
  min-width: 0;
}

.tile-metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@container (min-width: 11rem) {
  .tile-metric:has(.tile-info) .tile-metric-inner {
    padding-bottom: 0;
  }

  .tile-metric-inner {
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
  }

  .tile-metric-icon .icon {
    width: 32px;
    height: 32px;
  }

  .tile-metric-body {
    text-align: right;
  }

  .tile-metric-value {
    font-size: 1.5rem;
  }
}

.tile-unit {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-left: 0.2rem;
}

.tile-label {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 0.4rem;
}

.tile-sub {
  color: var(--color-primary);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.tile.chart-tile h2 {
  margin-top: 0;
}

.chart-container {
  position: relative;
  min-width: 0;
  height: 280px;
}

.chart-container--wide {
  height: 240px;
}

/* Handy: Kacheln kompakter */
@media (max-width: 700px) {
  .tile-row {
    gap: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .tile {
    padding: 0.9rem 1rem;
  }

  .tile-label {
    margin-top: 0.15rem;
    font-size: 0.85rem;
  }

  .tile-sub {
    font-size: 0.75rem;
  }

  .tile.chart-tile h2 {
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
  }

  .chart-container {
    height: 200px;
  }
}

/* Ausrüstungs-Status (Dashboard, Ausrüstungsseite): überfällige Werte in roter Schrift */

.cell-alert {
  color: var(--color-danger);
  font-weight: 600;
}

/* Seitenkopf: Titel links, Hauptaktion rechts auf derselben Zeile */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin: 0;
}

.page-title h1 {
  margin-bottom: 0.15rem;
}

.page-header .page-title h1 {
  margin-bottom: 0.15rem;
}

.page-sub {
  margin: 0;
  color: var(--color-text-muted);
}

.page-title {
  margin-bottom: 1.25rem;
}

.page-header .page-title {
  margin-bottom: 0;
}

/* Mehrere Aktionen im Seitenkopf (z. B. Bearbeiten / Löschen) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-actions form {
  margin: 0;
}

/* Bemerkung zum Flug: letzte Tabellenzeile über die ganze Breite,
   Bezeichnung wie die übrigen Zeilenköpfe, Zeilenumbrüche wie erfasst */
.remarks-label {
  display: block;
  color: var(--color-text-muted);
  font-weight: 600;
}

.remarks-text {
  margin-top: 0.25rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* IGC-Import im Flug-Formular */
.igc-import {
  margin-bottom: 1.25rem;
}

.igc-import .actions {
  margin: 0;
}

.igc-import .hint {
  margin: 0.4rem 0 0;
}

.igc-import .hint:empty {
  display: none;
}

/* Zwischentitel mit Aktion rechts (z. B. "Platz hinzufügen") */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 2rem 0 0.75rem;
}

.section-header h2 {
  margin: 0;
}

/* Navigation am Seitenende (z. B. "Alle Fluggebiete") */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Speichern / Abbrechen am Formularende */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

form.form-grid .form-actions {
  grid-column: 1 / -1;
}

/* Login/Registrierung: Alternative unter dem Formular */
.auth-alt {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.auth-alt .hint {
  margin: 0 0 0.6rem;
}

/* Löschen abgesetzt unter dem Formular */
.danger-zone {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.danger-zone .hint {
  margin: 0.5rem 0 0;
}

/* Karten (Leaflet) */
.map-box {
  height: 380px;
  border-radius: 6px;
}

/* Leaflet stapelt seine Ebenen mit z-index 400–1000; ohne eigenen Stacking-
   Kontext würde die Karte beim Scrollen über die fixierte Kopfleiste ragen. */
.leaflet-container {
  isolation: isolate;
}

.map-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.map-search input {
  flex: 1;
  max-width: none;
  margin-top: 0;
}

@media (max-width: 700px) {
  .map-box {
    height: 260px;
  }
}

/* Kartenliste: ein Block, Einträge durch Linien getrennt. Die Liste ist ein
   Size-Container: die Karten richten sich nach ihrer eigenen Breite, nicht
   nach dem Fenster (schmal nur Symbole, breit mit Bezeichnungen). */

.card-list {
  container-type: inline-size;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
}

.card-list > li + li {
  border-top: 1px solid var(--color-border);
}

/* Gemeinsam für alle Karten, die als Ganzes ein Link sind */
.card-link {
  color: var(--color-text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.card-link:active {
  background: var(--color-bg-subtle);
}

@media (hover: hover) {
  .card-link:hover {
    background: var(--color-bg-subtle);
  }
}

.card-chevron {
  display: flex;
  align-self: center;
  color: var(--color-text-muted);
}

.card-chevron .icon {
  margin-right: 0;
}

/* Kennzahl: Bezeichnung (klein) über dem Wert */
.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.stat-label .icon {
  margin-right: 0;
  color: var(--color-primary);
}

.stat-value {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat.is-empty .stat-value {
  color: var(--color-text-muted);
}

/* Flug-Karte. Schmal: Nr./Datum | Gebiet, Route | Pfeil, darunter die
   Kennzahlen nur mit Symbol. */

.flight-card {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr) auto;
  grid-template-areas:
    "meta main chevron"
    "stats stats stats";
  column-gap: 0.75rem;
  row-gap: 0.6rem;
  padding: 0.85rem 0.9rem 0.8rem;
}

.flight-card-meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.flight-card-number {
  font-size: 1.05rem;
  font-weight: 700;
}

.flight-card-meta time {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.flight-card-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  line-height: 1.35;
}

.flight-card-title,
.flight-card-route {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flight-card-title {
  font-weight: 600;
}

.flight-card-route {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.flight-card-chevron {
  grid-area: chevron;
}

.flight-card-stats {
  grid-area: stats;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.25rem;
}

/* Schmal: Symbol und Wert auf einer Zeile, Bezeichnung nur für Screenreader */
.flight-card .stat {
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
}

.flight-card .stat-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.flight-card .stat-value {
  font-size: 0.85rem;
}

/* Mittel: Kennzahlen mit Bezeichnung */
@container (min-width: 520px) {
  .flight-card .stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .flight-card .stat-text {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }

  .flight-card .stat-value {
    font-size: 0.9rem;
  }
}

/* Breit: alles auf einer Zeile */
@container (min-width: 820px) {
  .flight-card {
    grid-template-columns: 6rem minmax(0, 1fr) auto auto;
    grid-template-areas: "meta main stats chevron";
    column-gap: 1.25rem;
    align-items: center;
  }

  .flight-card-stats {
    grid-template-columns: 5.5rem 6.5rem 5.5rem 6rem;
    gap: 0 1rem;
  }
}

/* Zeilen-Karte (Fluggebiete, Start-/Landeplätze): Name links, Kennzahlen
   und Pfeil rechts */

.row-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
}

.row-card-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.row-card-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-card-meta {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.row-card-stats {
  display: grid;
  grid-template-columns: repeat(2, 4rem);
  gap: 0 0.75rem;
}

@container (min-width: 520px) {
  .row-card-stats {
    grid-template-columns: repeat(2, 6rem);
    gap: 0 1.25rem;
  }
}

/* Ausrüstungs-Karte. Schmal: Typ/Name (Pfeil oben rechts), darunter
   Kennzahlen in drei festen Spalten und die Aktionen. Breit: alles auf einer
   Zeile, Pfeil ganz rechts nach den Aktionen. Der Link deckt per ::after die
   ganze Karte ab; Aktionen liegen darüber und bleiben klickbar. */

.equip-card {
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.equip-card:active {
  background: var(--color-bg-subtle);
}

@media (hover: hover) {
  .equip-card:hover {
    background: var(--color-bg-subtle);
  }
}

.equip-card-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "title"
    "facts";
  gap: 0.6rem 0.75rem;
  padding: 0.8rem 2.5rem 0.8rem 0.9rem;
  color: var(--color-text);
  text-decoration: none;
}

.equip-card-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.equip-card-title {
  grid-area: title;
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.equip-card-type {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.equip-card-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.equip-card.is-inactive .equip-card-name {
  color: var(--color-text-muted);
}

.equip-card-chevron {
  position: absolute;
  top: 1.2rem;
  right: 0.9rem;
  pointer-events: none;
}

.badge {
  flex-shrink: 0;
  padding: 0 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  line-height: 1.5;
  white-space: nowrap;
}

/* Feste Spalten, damit die Werte über alle Karten hinweg untereinander
   stehen: Flüge | Alter | Check, darunter Kaufdatum | Preis. Typen ohne Check
   haben dort eine leere Zelle (.fact-placeholder). */
.equip-card-facts {
  grid-area: facts;
  display: grid;
  grid-template-columns: 5.5rem 6rem minmax(0, 1fr);
  gap: 0.45rem 1rem;
  margin: 0;
}

.equip-card-facts dt {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.equip-card-facts dd {
  margin: 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Aktionen (Check, Löschen): schmal als Zeile unter der Karte, über dem
   Karten-Link (z-index), damit sie eigene Klicks bekommen */
.equip-card-side {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 0.9rem 0.8rem;
}

.equip-card-side:empty {
  display: none;
}

.equip-card-side form {
  margin: 0;
}

.equip-card-side button {
  white-space: nowrap;
}

@container (min-width: 900px) {
  .equip-card {
    display: flex;
    align-items: center;
  }

  .equip-card-link {
    flex: 1;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title facts";
    align-items: center;
    gap: 0 1.25rem;
    padding-right: 0;
  }

  .equip-card-facts {
    grid-template-columns: 3.5rem 5.5rem 7.5rem 6rem 5rem;
    gap: 0 0.75rem;
  }

  /* Spalte für die Aktionen nur, wenn es überhaupt welche gibt — dann aber
     in jeder Zeile, damit die Kennzahlen bündig bleiben */
  .has-actions .equip-card-side,
  .has-actions .equip-card-side:empty {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    width: 11rem;
    padding: 0.5rem 0 0.5rem 1rem;
  }

  .card-list:not(.has-actions) .equip-card-side {
    display: none;
  }

  .equip-card-chevron {
    position: static;
    padding: 0 0.9rem 0 1rem;
  }
}

/* Landingpage (öffentlich, ohne Sidebar) */

.landing {
  width: 100%;
}

.landing .btn {
  text-decoration: none;
}

.landing-inner {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.landing-narrow {
  max-width: 640px;
}

.landing-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.landing-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.landing-brand .icon {
  margin-right: 0;
  color: var(--color-primary);
}

.landing-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.landing-hero {
  padding: 4.5rem 0 3.5rem;
  background:
    radial-gradient(circle at 15% 0%, var(--color-primary-soft), transparent 55%),
    var(--color-bg);
  text-align: center;
}

/* Titelbild hinter dem Kopfbereich: der dunkle Verlauf darüber hält den Text
   lesbar (das Foto hat helle Wolken) und blendet unten in die Seite über.
   Der Kopfbereich bleibt dadurch in beiden Farbschemas dunkel, deshalb sind
   Schrift- und Button-Farben hier fix statt über die Theme-Variablen. */
.landing-hero-image {
  position: relative;
  background:
    linear-gradient(
      180deg,
      rgba(6, 10, 16, 0.35) 0%,
      rgba(6, 10, 16, 0.72) 45%,
      rgba(6, 10, 16, 0.93) 100%
    ),
    var(--hero-image) center 55% / cover no-repeat,
    var(--color-bg);
}

.landing-hero-image .landing-hero-title {
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

.landing-hero-image .landing-lead {
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}

.landing-hero-image .landing-badge {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.landing-hero-image .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.landing-hero-image .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #fff;
}

.landing-hero-credit {
  position: absolute;
  right: 0.9rem;
  bottom: 0.5rem;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
}

.landing-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.landing-hero-title {
  margin: 1.1rem auto 0.9rem;
  max-width: 18ch;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
}

.landing-lead {
  margin: 0 auto;
  max-width: 60ch;
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

.landing-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

.landing-hero-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  text-decoration: none;
  font-weight: 600;
}

.landing-hero-actions .icon {
  margin-right: 0;
}

/* Animierte Demos (landing-demos/). Das Gefäss hält die Höhe schon vor dem
   Laden frei, damit nichts springt; die Bühne setzt danach die genaue Höhe. */
.landing-demo {
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

.landing-section {
  padding: 3.5rem 0;
}

.landing-section-alt {
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.landing-section-title {
  margin: 0 0 1.75rem;
  font-size: 1.6rem;
  text-align: center;
}

/* Funktion mit Demo: Text und Demo nebeneinander, jede zweite Zeile
   gespiegelt; auf schmalen Bildschirmen untereinander. */
.feature-spotlight {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 600px;
  align-items: center;
  gap: 3rem;
  margin-bottom: 3.5rem;
}

.feature-spotlight-flip {
  grid-template-columns: 600px minmax(0, 1fr);
}

.feature-spotlight-flip .feature-spotlight-text {
  order: 2;
}

.feature-spotlight-text h3 {
  margin: 0.9rem 0 0.5rem;
  font-size: 1.35rem;
}

.feature-spotlight-text p {
  margin: 0;
  max-width: 42ch;
  color: var(--color-text-muted);
  font-size: 1.05rem;
}

.landing-demo-card {
  max-width: 600px;
  aspect-ratio: 600 / 560;
}

.landing-demo-card[data-demo="gear"] {
  aspect-ratio: 600 / 440;
}

/* Die letzte Zeile braucht keinen Abstand mehr nach unten */
.feature-spotlight:last-child {
  margin-bottom: 0;
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.feature-icon .icon {
  margin-right: 0;
}

.landing-narrow .landing-lead {
  text-align: center;
}

.beta-form {
  margin-top: 1.75rem;
}

.beta-form input,
.beta-form textarea {
  max-width: none;
}

.beta-form button[type="submit"] {
  padding: 0.65rem 1.5rem;
  font-weight: 600;
}

.landing-success {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.landing-success .icon {
  margin-right: 0;
}

/* Bestätigungsseite für Beta-Anfragen (Link aus der Benachrichtigungsmail) */
.beta-review-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1.25rem;
}

.beta-review-facts dt {
  color: var(--color-text-muted);
}

.beta-review-facts dd {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Honeypot: für Menschen unsichtbar, Bots füllen das Feld gerne aus. */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.landing-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.75rem 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.landing-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

@media (max-width: 900px) {
  .feature-spotlight {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  .feature-spotlight-flip .feature-spotlight-text {
    order: 0;
  }
}

@media (max-width: 607px) {
  .landing-demo-card {
    max-width: 358px;
    aspect-ratio: 358 / 500;
  }

  .landing-demo-card[data-demo="flights"] {
    aspect-ratio: 358 / 460;
  }

  .landing-demo-card[data-demo="gear"] {
    aspect-ratio: 358 / 420;
  }

  .landing-demo-card[data-demo="stats"] {
    aspect-ratio: 358 / 680;
  }

  .landing-demo-card[data-demo="analyze"] {
    aspect-ratio: 358 / 500;
  }
}

@media (max-width: 640px) {
  .landing-brand {
    white-space: nowrap;
  }

  /* Auf dem Handy reicht der CTA im Hero — sonst bricht die Kopfzeile um.
     Der Login-Button bleibt, sonst führt vom Handy kein Weg zur Anmeldung. */
  .landing-header-actions .landing-header-cta {
    display: none;
  }

  .landing-header-actions {
    gap: 0.6rem;
  }

  .landing-hero {
    padding: 3rem 0 2.5rem;
  }

  .landing-section {
    padding: 2.5rem 0;
  }
}


/* Kartenstil-Auswahl auf Leaflet-Karten (app/static/js/map-tiles.js) */
.map-style-control select {
  display: block;
  border: 0;
  border-radius: 2px;
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: #333;
  cursor: pointer;
}

/* Flugdetail: Platzhalter in der Kartenkachel, wenn die IGC-Datei fehlt */
.map-box--missing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  text-align: center;
  color: var(--color-danger);
  background: var(--color-danger-soft);
  border: 1px dashed var(--color-danger);
}

.map-box--missing p {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-weight: 600;
}

/* Flugformular: Bewertung 1–10 als Schieberegler */
.rating-field {
  margin-bottom: 1rem;
}

.rating-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.3rem;
}

form .rating-control input[type="range"] {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--color-primary);
}

.rating-value {
  min-width: 2ch;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.rating-control.is-unset input[type="range"] {
  opacity: 0.4;
}

.rating-control.is-unset .rating-value {
  color: var(--color-text-muted);
}

.rating-control.is-unset .rating-clear {
  visibility: hidden;
}

/* Zeitraum-Auswahl im Dashboard-Kopf */

form.range-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

form.range-picker select,
form.range-picker input {
  width: auto;
  margin-top: 0;
}

form.range-picker .range-custom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

form.range-picker .range-custom[hidden],
form.range-picker .range-submit[hidden] {
  display: none;
}

form.range-picker label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: var(--color-text-muted);
}
