/* Flugbuch Web-App – bewusst schlicht: lesbar auf Desktop und Handy. */

:root {
  --rahmen: #d4d4d4;
  --linie: #e5e5e5;
  --text: #1a1a1a;
  --sekundaer: #666;
  --akzent: #0a7d43;
  --warnung-bg: #fff8e1;
  --warnung: #8a6d00;
  --flaeche: #f5f5f4;
  --karte: #ffffff;
  --radius: .5rem;
  --schatten: 0 1px 3px rgba(0, 0, 0, .1);
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0 auto;
  max-width: 64rem;
  padding: 1rem;
  background: var(--flaeche);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.35rem; margin: 0 0 .2rem; }
.unterzeile { font-size: .8rem; color: var(--sekundaer); margin: 0 0 1rem; }

/* ---------------- Status-Hinweis ---------------- */
.status {
  background: var(--karte);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: .6rem .8rem;
  margin: .8rem 0;
  font-size: .88rem;
}
.status.ok  { background: #e8f5ec; border-color: #b2d8c0; }
.status.err { background: #fdeaea; border-color: #e5b3b3; }

/* ---------------- Aktionsleiste ---------------- */
nav { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }

button {
  padding: .65rem 1rem;
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
  background: var(--karte);
  cursor: pointer;
  font-size: .95rem;
  color: var(--text);
  min-height: 2.6rem;              /* ausreichende Touch-Fläche */
}
button:disabled { opacity: .45; cursor: not-allowed; }
button:not(:disabled):hover { background: #ececec; }
button.gefahr { border-color: #c0392b; color: #c0392b; }

/* ---------------- Tabelle ---------------- */
.tabelle-wrap {
  background: var(--karte);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  overflow-x: auto;                /* horizontales Scrollen auf dem Handy */
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 52rem;                /* erzwingt Scrollen statt Quetschen */
  border-collapse: collapse;
  font-size: .82rem;
}

th, td { border-bottom: 1px solid var(--linie); padding: .45rem .55rem; text-align: left; }
th {
  background: var(--karte);
  font-weight: 600;
  font-size: .78rem;
  position: sticky;                /* Kopf bleibt beim Scrollen sichtbar */
  top: 0;
  border-bottom: 2px solid var(--rahmen);
}
tbody tr:nth-child(even) { background: #fafafa; }
tbody tr:hover { background: #f0f4f1; }

td.zahl { text-align: center; white-space: nowrap; }
td.aktion { text-align: center; white-space: nowrap; }
td.aktion button { padding: .25rem .5rem; font-size: .8rem; min-height: 2rem; }

tr.pruefen td { background: var(--warnung-bg); }
tr.pruefen td:first-child { color: var(--warnung); cursor: help; }

/* ---------------- Summen ---------------- */
.summen {
  background: var(--karte);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: .7rem 1rem;
  margin: 1rem 0;
  font-size: .9rem;
  display: flex; flex-wrap: wrap; gap: .4rem 1.5rem;
}
.summen b { font-weight: 600; }
.summen .warnung { color: var(--warnung); cursor: help; }

/* ---------------- Dialog (Flug eintragen/bearbeiten) ---------------- */
dialog {
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  padding: 1rem 1.2rem;
  /* Zentriert & nie größer als der Viewport -> nichts wird abgeschnitten */
  width: min(30rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  max-height: calc(100dvh - 1.5rem);
  overflow-y: auto;
  inset: 0;
  margin: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }

dialog h2 { font-size: 1.05rem; margin: 0 0 .8rem; }

form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
form label {
  display: flex; flex-direction: column;
  font-size: .76rem; color: var(--sekundaer); gap: .25rem;
}
form input, form select {
  width: 100%;
  min-width: 0;                    /* verhindert Grid-Überlauf nach rechts */
  padding: .5rem;
  font-size: 1rem;                 /* verhindert Auto-Zoom auf iOS */
  border: 1px solid var(--rahmen);
  border-radius: .35rem;
  background: var(--karte);
  color: var(--text);
}
form input:focus, form select:focus {
  outline: 2px solid var(--akzent);
  outline-offset: -1px;
  border-color: var(--akzent);
}
form menu {
  grid-column: 1 / -1;
  display: flex; justify-content: flex-end; gap: .5rem;
  margin: .4rem 0 0; padding: 0;
}

footer { margin: 1.5rem 0 2rem; text-align: center; }

/* ---------------- Handy ---------------- */
@media (max-width: 40rem) {
  body { padding: .75rem; }
  h1 { font-size: 1.2rem; }
  nav button { flex: 1 1 45%; }
  form { grid-template-columns: 1fr; }
  table { font-size: .78rem; }
  th, td { padding: .4rem .4rem; }
}
