/* LFZlog – technisches Logbuch-Layout. Keine externen Schriften (DSGVO). */
:root {
  --paper: #f3f5f7;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #5d6b79;
  --line: #d6dde4;
  --accent: #1d5a8c;
  --accent-ink: #ffffff;
  --ok: #2c7a4b;
  --soon: #a86a12;
  --tol: #c2410c;
  --bad: #b42318;
  --unknown: #66758a;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f151b; --surface: #17202a; --ink: #e5ebf0; --muted: #94a3b3; --line: #2b3946;
    --accent: #5ea3dc; --accent-ink: #0b1620; --ok: #4fb47a; --soon: #e0a641; --tol: #f0874f; --bad: #f06a5f; --unknown: #8d9bad;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2 { line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; margin-bottom: .6rem; letter-spacing: .01em; }
.num, table.list td { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
code { font-family: var(--mono); font-size: .85em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .6rem max(16px, 3vw); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: .02em; }
.brand .logo { width: 32px; height: 32px; flex: none; }
.logo-bg { fill: var(--accent); }
.logo-fg { fill: var(--accent-ink); }
.wordmark { display: grid; line-height: 1.15; }
.topnav { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; font-size: .92rem; }
.topnav a { text-decoration: none; color: var(--ink); }
.inline { display: inline; margin: 0; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }

.page { max-width: 1180px; margin: 0 auto; padding: 1rem max(16px, 3vw) 3rem; display: grid; gap: 1rem; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.card.narrow { max-width: 420px; width: 100%; margin: 2rem auto; }
.card.empty { color: var(--muted); }
.cardhead { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }

.flash { padding: .6rem .9rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.flash-ok { border-left: 4px solid var(--ok); }
.flash-error { border-left: 4px solid var(--bad); }

.btn { display: inline-flex; align-items: center; gap: .3rem; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: .5rem .9rem; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: .25rem .55rem; font-size: .85rem; font-weight: 500; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Flotte */
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.accard { min-width: 0; display: grid; gap: .35rem; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--ok);
  border-radius: var(--radius); padding: .9rem 1rem; color: var(--ink); text-decoration: none; }
.accard:hover { border-color: var(--accent); }
.accard.status-bald { border-left-color: var(--soon); }
.accard.status-toleranz { border-left-color: var(--tol); }
.accard.status-ueberfaellig { border-left-color: var(--bad); }
.accard.status-unbekannt { border-left-color: var(--unknown); }
.accard-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.accard-top .chip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg { font-family: var(--mono); font-weight: 700; font-size: 1.35rem; letter-spacing: .04em; }
.chip { font-size: .75rem; border: 1px solid var(--line); border-radius: 99px; padding: .05rem .5rem; color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .8rem; margin: .3rem 0 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: .25rem; align-items: baseline; }
.kv .pill { white-space: normal; }

.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .08rem .5rem; border-radius: 99px; white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--ok)) 14%, transparent); color: var(--c, var(--ok)); border: 1px solid color-mix(in srgb, var(--c, var(--ok)) 35%, transparent); }
.s-ok { --c: var(--ok); }
.s-bald { --c: var(--soon); }
.s-toleranz { --c: var(--tol); }
.s-ueberfaellig, .s-befund { --c: var(--bad); }
.s-unbekannt, .s-na, .s- { --c: var(--unknown); }

/* Luftfahrzeug */
.achead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tabs { display: flex; flex-wrap: wrap; gap: 0 .1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .45rem .55rem; text-decoration: none; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tiles { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.tile { display: grid; }
.tile span:last-child { color: var(--muted); font-size: .82rem; }
.big { font-size: 1.6rem; font-weight: 700; }
.duelist { list-style: none; margin: 0; padding: 0; display: grid; }
.duelist li { display: grid; grid-template-columns: 7.5rem 1fr; gap: .1rem .7rem; padding: .45rem 0; border-top: 1px solid var(--line); align-items: baseline; }
.duelist li > .muted { grid-column: 2; font-size: .85rem; }
.duelabel { font-weight: 500; }
.duelist .pill { justify-self: start; }

/* Tabellen */
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
table.list td { padding: .5rem .6rem; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
tr.void td { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
tr.void td .small { text-decoration: none; display: inline-block; }

/* Schmale Bildschirme: Tabellenzeilen als Karten statt seitlich scrollen */
@media (max-width: 960px) {
  .tablewrap { background: none; border: 0; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; }
  table.list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.list tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .75rem; margin-bottom: .6rem; }
  table.list td, table.list tr:last-child td { border: 0; padding-top: .2rem; padding-bottom: .2rem; padding-right: 0; text-align: left; }
  table.list td:not([data-label]) { padding-left: 0; }
  /* Beschriftung links als Float: lange Beschriftungen brechen um und die Zeile wächst mit (flow-root) */
  table.list td[data-label] { display: flow-root; padding-left: 8.5rem; }
  table.list td[data-label]::before { content: attr(data-label); float: left; width: 8rem; margin-left: -8.5rem;
    color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding-top: .1rem;
    hyphens: auto; overflow-wrap: anywhere; }
  table.list td:empty { display: none; }
  table.list td:not([data-label]) { padding-top: .4rem; }
  details.pop[open] > form { right: auto; left: 0; max-width: calc(100vw - 3rem); }
}
@media (max-width: 420px) {
  table.list td[data-label] { padding-left: 7rem; }
  table.list td[data-label]::before { width: 6.5rem; margin-left: -7rem; }
}
@media (max-width: 340px) {
  table.list td[data-label] { padding-left: 0; }
  table.list td[data-label]::before { float: none; display: block; width: auto; margin: 0; padding: 0; }
}

/* Formulare */
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem 1rem; }
.formgrid.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.field { display: grid; gap: .25rem; align-content: start; min-width: 0; }
.field.wide, .formgrid > .wide { grid-column: 1 / -1; }
.formhead { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .3rem; }
.formhead h2 { font-size: 1rem; margin: 0; }
.formhead .help { margin: .2rem 0 0; }
.calc { display: grid; gap: .35rem; }
.calc li { list-style: none; }
.calc ul { margin: 0; padding: 0; display: grid; gap: .3rem; }
.field label, legend { font-size: .85rem; font-weight: 600; }
.req { color: var(--bad); }
.help { color: var(--muted); font-size: .8rem; }
.error { color: var(--bad); font-size: .82rem; font-weight: 600; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .45rem .55rem; width: 100%; min-width: 0; }
input:disabled, select:disabled, textarea:disabled { background: var(--paper); color: var(--ink); }
textarea { resize: vertical; }
label.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; font-size: .92rem; line-height: 1.4; cursor: pointer; }
/* Alle Checkboxen/Radios gleich groß: nicht schrumpfen lassen (Flex), kein Feld-Padding/-Breite erben */
input[type="checkbox"], input[type="radio"] { flex: none; width: 1.15rem; height: 1.15rem; min-width: 1.15rem; padding: 0;
  margin: .1rem 0 0; border-radius: 3px; accent-color: var(--accent); cursor: pointer; }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { cursor: default; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; margin: 0; min-width: 0; }
.multi { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; }
.stack { display: grid; gap: .5rem; }
.checklist { display: grid; gap: .1rem; }
.checkrow { display: grid; grid-template-columns: 1fr 7rem minmax(10rem, 18rem); gap: .5rem; align-items: start; padding: .55rem 0; border-top: 1px solid var(--line); }
.checklabel { font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.key { font-family: var(--mono); font-weight: 700; color: var(--accent); margin-right: .2rem; }
.hint { font-size: .8rem; margin-top: .25rem; color: var(--c); }
details > summary { cursor: pointer; }
details.pop { position: relative; }
details.pop[open] > form { position: absolute; right: 0; z-index: 5; width: 260px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .8rem; box-shadow: 0 8px 24px rgb(0 0 0 / .14); }
details.pop > summary { list-style: none; }
details.pop > summary::-webkit-details-marker { display: none; }

.history { list-style: none; padding: 0; margin: 0; display: grid; gap: .1rem; }
.history > li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; }
.changes { margin: .3rem 0 0; padding-left: 1.1rem; }
del { color: var(--muted); }

@media (max-width: 640px) {
  .checkrow { grid-template-columns: 1fr 6.5rem; }
  .checkrow input { grid-column: 1 / -1; }
  .duelist li { grid-template-columns: 1fr; }
  .duelist li > .muted { grid-column: 1; }
  h1 { font-size: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.subform { border-top: 1px solid var(--line); padding-top: .8rem; }
.subform > summary { font-weight: 600; margin-bottom: .8rem; }

.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.inline-form input { width: auto; }

/* PDF-Vorschau */
.pdfdlg { width: min(1100px, 96vw); height: 94vh; max-height: 94vh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: 0 12px 40px rgb(0 0 0 / .3); }
.pdfdlg[open] { display: flex; flex-direction: column; }
.pdfdlg::backdrop { background: rgb(0 0 0 / .45); }
.pdfbar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
.pdfbar strong { overflow-wrap: anywhere; }
.pdfdlg iframe { flex: 1; width: 100%; border: 0; background: #525659; }
.pdfdlg iframe[hidden], .imgview[hidden] { display: none; }
.imgview { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; background: #525659; padding: .5rem; }
.imgview img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }

/* Sortierbare Tabellen */
.sortbtn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; font: inherit; color: inherit;
  text-transform: inherit; letter-spacing: inherit; }
.sortbtn:hover { color: var(--ink); }
.sortbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.sorticon::after { content: "↕"; opacity: .35; font-size: .9em; }
th[aria-sort="ascending"] .sorticon::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .sorticon::after { content: "↓"; opacity: 1; }
th[aria-sort] { color: var(--ink); }
.sortbar { display: none; align-items: center; gap: .5rem; flex-wrap: wrap; }
.sortbar label { font-size: .85rem; color: var(--muted); }
.sortbar select { flex: 1 1 12rem; width: 100%; min-width: 0; max-width: 100%; text-overflow: ellipsis; }
@media (max-width: 960px) { .sortbar { display: flex; } }

/* Buttons nie mitten im Wort umbrechen (Tabellenzellen erlauben sonst Umbruch überall) */
.btn, summary.btn { white-space: nowrap; overflow-wrap: normal; word-break: normal; }

/* Flugbuch: Gesamtstand mit Zuwachs */
.delta { display: block; font-size: .75rem; color: var(--muted); }

/* Flotte: Suche mittig oben */
.fleethead { display: grid; grid-template-columns: 1fr minmax(0, 30rem) 1fr; align-items: center; gap: .75rem 1rem; }
.fleethead h1 { margin: 0; }
.fleethead .headactions { justify-self: end; }
.fleetsearch { display: grid; gap: .25rem; }
.searchbox { position: relative; }
.searchbox input { padding-left: 2.2rem; padding-right: 2.4rem; border-radius: 999px; height: 2.6rem; font-size: 1rem; }
.searchbox svg { position: absolute; left: .8rem; top: 50%; width: 1rem; height: 1rem; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.searchbox kbd { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); font: .75rem var(--mono);
  color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 .35rem; pointer-events: none; }
.searchbox input:focus ~ kbd, .searchbox input:not(:placeholder-shown) ~ kbd { display: none; }
.searchcount { text-align: center; font-size: .8rem; color: var(--muted); min-height: 1.2em; }
.accard .owner { font-size: .82rem; color: var(--muted); }
@media (max-width: 760px) {
  .fleethead { grid-template-columns: 1fr auto; }
  .fleethead .fleetsearch { grid-column: 1 / -1; grid-row: 2; }
  .searchbox kbd { display: none; }
}

[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.btnrow { display: flex; flex-wrap: wrap; gap: .3rem; }

/* Freigabe / Einfrieren */
.lockbar { border-left: 5px solid var(--ok); }
.lockbar.draft { border-left-color: var(--soon); }
.blockers.has-blockers { border-left: 5px solid var(--bad); }
.blockers.clear { border-left: 5px solid var(--ok); }
.blockers h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
.blockers ul { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .35rem; }
.blockers li { overflow-wrap: anywhere; }
