/* Flugbuch – mobile-first Styles, hell & dunkel */

:root {
  color-scheme: light dark;
  --surface: #fcfcfb;
  --page: #f2f2ef;
  --card: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --danger: #d03b3b;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --nav-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #1a1a19;
    --page: #0d0d0d;
    --card: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --danger: #e66767;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar / Navigation ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: #12233d; color: #fff;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex; align-items: center; gap: 16px;
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a {
  color: #cdd8ea; text-decoration: none; padding: 6px 12px;
  border-radius: 8px; font-size: 15px;
}
.topnav a.active { background: rgba(255, 255, 255, 0.14); color: #fff; }
.logout-form { margin-left: auto; }
.topbar .btn-ghost { color: #cdd8ea; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; text-decoration: none; color: var(--muted); font-size: 11px;
}
.bottomnav a.active { color: var(--accent); }

@media (min-width: 768px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body { padding-bottom: 0; }
}

/* ---------- Seitenlayout ---------- */

.page {
  max-width: 1100px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 90px);
}
@media (min-width: 768px) { .page { padding-bottom: 40px; } }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.toolbar input[type="search"] { flex: 1; min-width: 0; }
.toolbar select { max-width: 130px; }

input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--card);
  border: 1px solid var(--baseline); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}

.btn {
  font: inherit; border: none; border-radius: 10px;
  padding: 10px 14px; cursor: pointer; background: transparent; color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: rgba(128, 128, 128, 0.12); }
.btn-danger { background: var(--danger); color: #fff; font-weight: 600; }
.btn-block { width: 100%; }

/* ---------- Flugliste ---------- */

.month-header {
  margin: 18px 2px 8px; font-size: 13px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; justify-content: space-between;
}
.flight-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
}
.flight-card:hover { border-color: var(--accent); }
.fc-route { font-weight: 650; font-size: 15px; }
.fc-route .arrow { color: var(--muted); font-weight: 400; }
.fc-time { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; }
.fc-sub { color: var(--ink-2); font-size: 13px; grid-column: 1; }
.fc-badges { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: rgba(42, 120, 214, 0.12); color: var(--accent); font-weight: 600;
}
.badge.gray { background: rgba(128, 128, 128, 0.14); color: var(--ink-2); }

.empty-state { text-align: center; color: var(--muted); margin: 60px 0; line-height: 1.7; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 30px; line-height: 1;
  border: none; cursor: pointer; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); z-index: 15;
}
@media (min-width: 768px) { .fab { bottom: 28px; } }

/* ---------- Dialog / Formular ---------- */

dialog {
  border: none; border-radius: 16px; padding: 0;
  width: min(680px, 100vw); max-height: 100dvh;
  background: var(--page); color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
@media (max-width: 767px) {
  dialog { width: 100vw; height: 100dvh; max-width: 100vw; border-radius: 0; margin: 0; }
}
.dialog-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--card); border-bottom: 1px solid var(--border);
}
.dialog-head h2 { margin: 0; font-size: 16px; }
.dialog-body { padding: 14px 16px 30px; overflow-y: auto; }
.dialog-body section { margin-bottom: 20px; }
.dialog-body h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin: 0 0 8px;
}
.dialog-body label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.dialog-body label input, .dialog-body label select, .dialog-body label textarea { margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.calc-line { color: var(--ink-2); font-size: 14px; margin: 4px 2px; }
.dur-wrap { display: flex; gap: 6px; margin-top: 4px; }
.dur-wrap input { margin-top: 0 !important; }
.mini {
  font-size: 11px; border: 1px solid var(--baseline); background: var(--card);
  color: var(--ink-2); border-radius: 8px; padding: 0 8px; cursor: pointer; white-space: nowrap;
}
.mini:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Auth-Seiten ---------- */

.auth-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(160deg, #12233d 0%, #1d3a63 60%, #24507e 100%);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border-radius: 18px; padding: 28px 26px 26px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.auth-logo { font-size: 40px; text-align: center; }
.auth-card h1 { text-align: center; margin: 6px 0 2px; font-size: 22px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.auth-hint { color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.auth-error {
  background: rgba(208, 59, 59, 0.12); color: var(--danger);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.auth-card label { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; }
.auth-card .btn { margin-top: 18px; }
.qr { display: block; margin: 10px auto; border-radius: 8px; background: #fff; padding: 6px; }
.secret-details { text-align: center; font-size: 13px; color: var(--ink-2); }
.secret-details code { user-select: all; word-break: break-all; }

/* ---------- Dashboard ---------- */

.kpi-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px;
}
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px;
}
.kpi .kpi-label { font-size: 12px; color: var(--muted); }
.kpi .kpi-value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.kpi .kpi-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.kpi.ok .kpi-sub { color: #0ca30c; font-weight: 600; }
.kpi.warn .kpi-sub { color: var(--danger); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px 10px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px; }
.card-head h2 { font-size: 15px; margin: 0 0 8px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend .swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 5px; vertical-align: -1px;
}
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; }
.chart text { font-family: inherit; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar-label { fill: var(--ink-2); font-size: 11px; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--baseline); stroke-width: 1; }
.chart .fill-s1 { fill: var(--series-1); }
.chart .fill-s2 { fill: var(--series-2); }
.chart .fill-s3 { fill: var(--series-3); }
.chart .hover-target { fill: transparent; cursor: default; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 11px; font-size: 12.5px; line-height: 1.5;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22); max-width: 260px;
}
.tooltip .tt-title { font-weight: 650; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tooltip .tt-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
