/* Farben nach dem Wappen der BRK Bereitschaft Schwandorf: Dunkelblau, Rautenblau, Kreuzrot */
:root {
  --navy: #0c2548;
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #e9eef5;
  --text: #0c2548;
  --muted: #5a6880;
  --border: #d3dbe6;
  --accent: #0079b8;
  --accent-text: #ffffff;
  --ok: #1a7f4b;
  --ok-bg: #e3f4ea;
  --warn: #9a5b00;
  --warn-bg: #fdf0d5;
  --bad: #c41e16;
  --bad-bg: #fbe3e1;
  --none-bg: #e4e9f0;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07152b;
    --surface: #0e2140;
    --surface-2: #15294d;
    --text: #e9eff8;
    --muted: #9db0cb;
    --border: #233a61;
    --accent: #2aa9e6;
    --accent-text: #04101f;
    --ok: #5fd08f;
    --ok-bg: #12352a;
    --warn: #f2be5c;
    --warn-bg: #3b2c0d;
    --bad: #ff8a80;
    --bad-bg: #4a1a1c;
    --none-bg: #1b3157;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 12px;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.ghost { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Kopf */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid #d9261c;
}
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 6px;
  max-width: 1100px;
  margin: 0 auto;
}
h1 { font-size: 18px; margin: 0; display: flex; align-items: center; gap: 10px; line-height: 1.15; }
h1 img { height: 44px; width: auto; flex: none; }
h1 .sub { display: block; font-weight: 400; color: rgba(255, 255, 255, .7); font-size: 12.5px; }
.top button.ghost { color: #fff; border-color: rgba(255, 255, 255, .3); }
.top button.ghost:hover { background: rgba(255, 255, 255, .12); }
.top-actions { display: flex; gap: 6px; align-items: center; }
.sync { font-size: 12.5px; color: rgba(255, 255, 255, .75); margin-right: 4px; text-align: right; }
.sync.ok::before, .sync.busy::before, .sync.off::before { content: "● "; }
.sync.ok::before { color: #5fd08f; }
.sync.busy::before { color: #f2be5c; }
.sync.off { color: #ffb4ab; }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px; width: min(360px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog form { display: grid; gap: 10px; }
dialog h2, dialog p { margin: 0; }
dialog input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 16px; }
.error { color: var(--bad); font-weight: 600; }
.top-actions button { padding: 5px 10px; font-size: 13px; }

a { color: inherit; text-decoration-color: var(--border); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 10px;
  max-width: 1100px;
  margin: 0 auto;
}
.tab {
  flex: none;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
}
.tab:hover { background: rgba(255, 255, 255, .2); }
.tab[aria-current="page"] { background: #fff; color: var(--navy); font-weight: 600; }
.menu-btn { flex: 1 1 auto; min-width: 0; justify-content: space-between; }
.menu-btn span:first-child { overflow: hidden; text-overflow: ellipsis; margin-right: auto; }
.menu-btn .caret { opacity: .7; }
.menu-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.tab.step { width: 40px; padding: 0; font-size: 20px; line-height: 1; }
.tab.step.off { opacity: .35; }

.fach-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 3px;
  background: var(--navy);
  box-shadow: 0 12px 24px rgba(0, 0, 0, .35);
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}
.fach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 16px;
}
.fach {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  text-decoration: none;
}
.fach:hover { background: rgba(255, 255, 255, .2); }
.fach[aria-current="page"] { background: #fff; color: var(--navy); font-weight: 600; }
.fach span:first-child { margin-right: auto; }
.fach[aria-current="page"] .tick { color: #1a7f4b; }

.badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #d9261c;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }

/* Übersicht */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
a.stat { display: block; color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--accent); }
a.stat span::after { content: " ›"; }
.row.flash { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: var(--warn-bg); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .row.flash { animation: none; background: var(--warn-bg); } }
.stat.bad b { color: var(--bad); }
.stat.warn b { color: var(--warn); }
.stat.ok b { color: var(--ok); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.card-head .count { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.card-head button { padding: 4px 10px; font-size: 13px; }
.card-body { padding: 12px 14px; }
.empty { padding: 14px; color: var(--muted); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 22px 0 10px; }
.section-head h2 { margin: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; width: 64px; }
td.amount { width: 90px; white-space: nowrap; }
td.loc { color: var(--muted); font-size: 13px; }

/* Monatscheck */
.check { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-left: 4px solid var(--warn); }
.check.done { border-left-color: var(--ok); }
.check.done b { color: var(--ok); }
.check div { display: grid; gap: 2px; }
.check span { font-size: 13px; }
.tick { color: #7be0a6; font-weight: 700; }
.tab[aria-current="page"] .tick { color: #1a7f4b; }
td.act { text-align: right; }
td.act button { padding: 4px 10px; font-size: 13px; }

.credit { display: none; font-size: 11.5px; letter-spacing: .04em; color: rgba(255, 255, 255, .45); margin-right: 10px; }
@media (min-width: 761px) { .credit { display: inline; } }

a.btn { display: inline-block; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 12px; text-decoration: none; }
a.btn:hover { background: var(--surface-2); }

/* Anmeldung */
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
dialog label input { color: var(--text); }
.linklike { border: 0; background: none; padding: 4px; color: var(--accent); text-decoration: underline; justify-self: center; }
.linklike:hover { background: none; }

/* Notizen */
.note { display: grid; gap: 6px; padding: 12px 14px; margin-bottom: 20px; }
.note label { font-weight: 600; }
.note textarea { width: 100%; min-height: 84px; resize: vertical; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.note span { font-size: 12.5px; }
.section-head .actions { align-items: center; }

/* Fahrzeugauswahl */
[hidden] { display: none !important; }
h1 a { display: flex; }
.top-row { padding-bottom: 10px; }
.top-actions .tab { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.cars { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.car { display: block; color: inherit; text-decoration: none; margin: 0; }
a.car:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(0, 0, 0, .15); }
.car img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.car-body { display: grid; gap: 4px; padding: 12px 14px 14px; }
.car-body h3 { font-size: 20px; }
.car-body .chips { margin-top: 6px; }
.car.soon img { filter: grayscale(.7); opacity: .55; }
.car.soon h3 { color: var(--muted); }

/* Fahrzeug: Bestand / Checklisten */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); margin-bottom: 20px; }
.tile { display: grid; gap: 6px; align-content: start; padding: 16px 18px; color: inherit; text-decoration: none; margin: 0; }
.tile h3 { font-size: 19px; }
a.tile:hover { border-color: var(--accent); }

/* Checklisten */
.fields { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.card.fields { padding: 12px 14px; margin-bottom: 14px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 15px; }
.field input.saved { border-color: var(--ok); }
.cl-form { display: grid; gap: 12px; padding: 14px; margin-bottom: 6px; }
.cl-form h3 { font-size: 16px; }
.cl-form h4 { margin: 0 0 2px; font-size: 14px; }
.cl-form > .primary { justify-self: start; padding: 9px 22px; }
.checks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check:has(input:checked) { border-color: var(--ok); background: var(--ok-bg); }
button.small { justify-self: start; padding: 4px 10px; font-size: 13px; }
.second { border-top: 1px solid var(--border); padding-top: 10px; }
.small-note { font-size: 12.5px; margin: 0; }
.ok-msg { color: var(--ok); font-weight: 600; margin: 0; }
.cl-form .error { margin: 0; }
.cl-table th, .cl-table td { padding: 7px 8px; }
.cl-table th { white-space: normal; vertical-align: bottom; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.cl-table td:first-child { white-space: nowrap; }
.check span { margin-right: auto; text-align: left; color: var(--text); }
.cl-table tr.storno td { color: var(--muted); text-decoration: line-through; }
.cl-table tr.storno td:last-child, .cl-table tr.storno .muted { text-decoration: none; }
#cl-history { overflow-x: auto; }
@media (max-width: 900px) {
  .cl-table thead { display: none; }
  .cl-table tr { display: block; padding: 8px 12px; border-bottom: 1px solid var(--border); }
  .cl-table td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; white-space: normal; text-align: right; }
  .cl-table td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .cl-table td.act { justify-content: flex-end; }
  .cl-table td.act::before { content: none; }
}

/* Verwaltung */
.toolbar select { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.info { margin: 0; padding: 8px 12px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 6px; font-size: 13.5px; }

.create-user { display: grid; grid-template-columns: minmax(0, 320px) max-content; justify-content: start; align-items: end; gap: 6px 10px; padding: 12px 14px; margin-bottom: 14px; }
.create-user > .primary { height: 38px; }
@media (max-width: 760px) { .create-user { grid-template-columns: 1fr; } .create-user > .primary { justify-self: start; } }
.create-user p { grid-column: 1 / -1; margin: 0; font-size: 13px; }
.admin-table tr.disabled td { color: var(--muted); }
button.danger { color: var(--bad); border-color: var(--bad-bg); }
button.danger:hover { background: var(--bad-bg); }

/* Auf- und Zuklappen */
details.fold { margin: 14px 0; }
details.fold > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
details.fold > summary::-webkit-details-marker, details.sub-fold > summary::-webkit-details-marker, details.loc-fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; font-size: 18px; }
details.fold > summary::after, details.sub-fold > summary h3::before, details.loc-fold > summary h3::before { content: "›"; display: inline-block; transition: transform .15s; color: var(--muted); }
details.fold > summary::after { margin-left: auto; font-size: 22px; line-height: 1; }
details.fold[open] > summary::after, details.sub-fold[open] > summary h3::before, details.loc-fold[open] > summary h3::before { transform: rotate(90deg); }
details.sub-fold > summary h3::before, details.loc-fold > summary h3::before { margin-right: 8px; width: 10px; }
details.fold[open] > summary { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
details.fold > summary:hover, details.sub-fold > summary:hover, details.loc-fold > summary:hover { background: var(--surface-2); }
.fold-count { min-width: 26px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; text-align: center; }
.fold-body { padding-top: 10px; }
.fold-actions { margin-bottom: 10px; }
details.sub-fold > summary, details.loc-fold > summary { cursor: pointer; list-style: none; }
details.sub-fold:not([open]) > summary, details.loc-fold:not([open]) > summary { border-bottom: 0; }
.small-link { font-size: 13px; color: var(--accent); }
.fold-all { display: flex; gap: 6px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { details summary::after, details summary h3::before { transition: none; } }

/* Dashboard */
.dash { display: grid; gap: 14px; grid-template-columns: minmax(0, 3fr) minmax(240px, 2fr); grid-template-areas: "news tiles"; align-items: start; }
.news { grid-area: news; padding: 14px 16px; min-height: 360px; margin: 0; }
.dash-tiles { grid-area: tiles; display: grid; gap: 12px; }
.dash-tiles .tile { min-height: 96px; }
.tile.soon h3 { color: var(--muted); }
.news-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.news-head h3 { font-size: 19px; }
.news-post { padding: 12px 0; border-top: 1px solid var(--border); }
.news-post h4 { margin: 0; font-size: 16px; }
.news-meta { margin: 2px 0 6px; font-size: 12.5px; color: var(--muted); }
.news-text { margin: 0 0 8px; white-space: pre-wrap; }
.news-form { display: grid; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.news-form textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; resize: vertical; }
@media (max-width: 760px) {
  .dash { grid-template-columns: 1fr; grid-template-areas: "tiles" "news"; }
  .news { min-height: 0; }
}

/* Mängelmeldung */
.m-form { display: grid; gap: 12px; padding: 14px; margin-bottom: 14px; }
.m-form h3 { font-size: 16px; }
.m-form textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; resize: vertical; }
.m-form > button { justify-self: start; }
.prio { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.prio legend { font-size: 13px; color: var(--muted); margin-bottom: 4px; padding: 0; }
.prio-opt { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.prio-opt input { accent-color: var(--accent); }
.prio-opt:has(input:checked) { border-color: var(--accent); background: var(--surface-2); font-weight: 600; }
.prio-opt.prio-kritisch:has(input:checked), .prio-opt.prio-hoch:has(input:checked) { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.tickets { display: grid; gap: 10px; }
.ticket { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin: 0; color: inherit; text-decoration: none; border-left: 5px solid var(--border); }
a.ticket:hover { border-color: var(--accent); }
.ticket.prio-kritisch, .ticket-info.prio-kritisch { border-left-color: var(--bad); }
.ticket.prio-hoch, .ticket-info.prio-hoch { border-left-color: #e5774f; }
.ticket.prio-mittel, .ticket-info.prio-mittel { border-left-color: var(--warn); }
.ticket.closed { opacity: .65; }
.ticket-main { display: grid; gap: 2px; min-width: 0; }
.ticket-main h3 { font-size: 16px; }
.ticket-main .muted { font-size: 13px; }
.ticket-no { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .03em; }
.ticket-head { display: grid; gap: 2px; margin-bottom: 10px; }
.ticket-head h2 { margin: 0; }
.ticket-info { display: grid; gap: 8px; padding: 14px; margin-bottom: 14px; border-left: 5px solid var(--border); }
.ticket-info p { margin: 0; }
.ticket-text { white-space: pre-wrap; margin: 4px 0 0; }
.timeline { padding: 4px 14px; margin-bottom: 14px; }
.tl-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: 0; }
.tl-meta { font-size: 13.5px; color: var(--muted); }
.tl-meta b { color: var(--text); }
.tl-status .tl-meta, .tl-priority .tl-meta, .tl-assignee .tl-meta { color: var(--accent); }

/* Fristarbeiten */
.fr-year { font-size: 17px; min-width: 48px; text-align: center; }
.fr-months { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.fr-month { display: grid; gap: 8px; align-content: start; padding: 12px 14px; margin: 0; color: inherit; text-decoration: none; min-height: 150px; }
a.fr-month:hover { border-color: var(--accent); }
.fr-month.current { border: 2px solid var(--accent); }
.fr-month-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fr-month ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; }
.fr-month li { display: flex; align-items: center; gap: 6px; }
.fr-month li.is-done { color: var(--muted); text-decoration: line-through; }
.fr-overdue { font-size: 12.5px; font-weight: 600; color: var(--bad); }
.tgt { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--border); flex: none; }
.chip.tgt { width: auto; height: auto; border-radius: 999px; }
.tgt-blue { background: #bfe0f5; color: #0b4a73; }
.tgt-orange { background: #f5c49a; color: #7a3d0c; }
.tgt-green { background: #c6efcb; color: #1f5f2a; }
.tgt-pink { background: #f1c9ec; color: #6e2463; }
.fr-progress { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; }
.fr-progress .bar { flex: 1 1 200px; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.fr-progress .bar span { display: block; height: 100%; background: var(--ok); }
.fr-group { margin-bottom: 14px; }
.fr-task, .fr-plan-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.fr-task:last-child, .fr-plan-row:last-child { border-bottom: 0; }
.fr-task-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; flex: 1 1 260px; }
.fr-check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-weight: 700; color: #fff; }
.fr-task.is-done .fr-check { background: var(--ok); border-color: var(--ok); }
.fr-task.is-done b { color: var(--muted); }
.fr-meta { font-size: 13px; }
.fr-done { font-size: 13px; color: var(--ok); margin-top: 2px; }
.fr-done b { color: var(--ok) !important; }
.fr-done-form { display: flex; gap: 6px; flex: 1 1 260px; justify-content: flex-end; }
.fr-done-form input { flex: 1 1 140px; max-width: 260px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.fr-form { display: grid; gap: 12px; padding: 14px; margin: 10px; }
.fr-month-pick { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.fr-month-pick legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.fr-month-pick label { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.fr-month-pick label:has(input:checked) { border-color: var(--accent); background: var(--surface-2); font-weight: 600; }
.fr-dots { display: flex; gap: 3px; }
.fr-dots span { width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; font-size: 11px; color: var(--muted); background: var(--surface-2); }
.fr-dots span.on { background: var(--accent); color: var(--accent-text); font-weight: 700; }

/* Bilder an Mängeln */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumbs:empty { display: none; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.image-pick input { padding: 6px 0; height: auto; border: 0; background: none; }

/* To-Do */
.todos { display: grid; gap: 6px; padding: 10px 0 12px; border-top: 1px solid var(--border); }
.todos h4 { margin: 0 0 2px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.todo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.todo label { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1 1 200px; }
.todo input { width: 18px; height: 18px; accent-color: var(--ok); flex: none; }
.todo.is-done span:not(.chip) { color: var(--muted); }
.todo.is-done label span { text-decoration: line-through; }
.todo-meta { font-size: 12px; }
.todo-add { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.todo-add input { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.todo-add input[name="text"] { flex: 1 1 180px; }

/* Dokumente */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.upload-btn { cursor: pointer; }
label.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); margin-bottom: 14px; font-size: 13.5px; }
.drop.over { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }
.crumbs { margin-bottom: 10px; font-size: 14px; }
.crumbs button { border: 0; background: none; padding: 2px 4px; color: var(--accent); text-decoration: underline; }
.doc-folders { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); margin-bottom: 14px; }
.doc-folder { display: grid; gap: 6px; padding: 10px 12px; margin: 0; }
.doc-folder-open { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: left; border: 0; background: none; padding: 4px 0; }
.doc-folder-open .doc-icon { grid-row: span 2; font-size: 26px; }
.doc-folder-open .muted { font-size: 12.5px; }
.doc-files { padding: 0; }
.doc-file { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.doc-file:last-child { border-bottom: 0; }
.doc-icon { font-size: 24px; width: 48px; text-align: center; flex: none; }
.doc-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; }
.doc-main { display: grid; gap: 2px; flex: 1 1 240px; min-width: 0; }
.doc-main a { color: var(--text); }
.doc-main .muted { font-size: 12.5px; }
.doc-desc { font-size: 13.5px; }
.chip.tag { border: 0; cursor: pointer; }
a.small-btn { padding: 4px 10px; font-size: 13px; }
.gallery { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
.gallery figure { margin: 0; overflow: hidden; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.gallery figcaption { padding: 8px 10px; display: grid; gap: 4px; font-size: 13px; }
.doc-edit, .doc-folder-form { display: grid; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.doc-folder-form { margin-bottom: 14px; }
.doc-edit input, .doc-edit select { height: 36px; }
.uploads { padding: 8px 14px; margin-bottom: 14px; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 13.5px; padding: 4px 0; }
.upload-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.upload-row .bar span { display: block; height: 100%; background: var(--accent); }
@media (max-width: 760px) { .upload-row { grid-template-columns: 1fr; } }

/* Fachbilder */
.pics { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.pic { margin: 0; }
.pic figcaption { padding: 10px 14px; font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.pic a { display: block; }
.pic img { display: block; width: 100%; height: auto; }

/* Modulansicht */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] {
  flex: 1 1 220px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.toolbar label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.rows { display: grid; }
.row, .row-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 44px 132px 150px 170px;
  gap: 10px;
  align-items: center;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row-head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-top: 6px; padding-bottom: 6px; }
.row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.row-head .n { text-align: right; }
.row .lbl { display: none; }

.stepper { display: flex; align-items: stretch; }
.stepper button { padding: 0; width: 36px; height: 36px; font-size: 18px; line-height: 1; }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper input {
  width: 56px;
  min-width: 0;
  height: 36px;
  text-align: center;
  border: 1px solid var(--border);
  border-left: 0;
  border-right: 0;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.row input[type="date"] {
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.none { background: var(--none-bg); color: var(--muted); }

@media (max-width: 760px) {
  main { padding: 12px; }
  .row-head { display: none; }
  .row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "name name" "soll chips" "ist exp";
    gap: 8px 10px;
    padding: 10px 12px;
  }
  .row .name { grid-area: name; font-weight: 600; }
  .row .n.min { display: none; }
  .row .n.soll { grid-area: soll; text-align: left; }
  .row .ist { grid-area: ist; }
  .row .exp { grid-area: exp; }
  .row .chips { grid-area: chips; justify-content: flex-end; }
  .row .lbl { display: inline; }
  .stepper input { flex: 1; }
  th, td { padding: 8px 10px; }
  h1 .sub { display: none; }
  h1 img { height: 36px; }
  .tabs { padding-left: 12px; padding-right: 12px; }
  .tab { padding: 8px 10px; }
  .fach-grid { grid-template-columns: repeat(2, 1fr); padding: 10px 12px 14px; }
}

#print-area { display: none; }
.section-head select { height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }

@media print {
  /* Checkliste drucken: nur der Druckbereich, quer, schwarz auf weiß */
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; color: #000; font-size: 10.5pt; }
  #print-area .print-head { display: flex; align-items: center; gap: 12px; border: 1px solid #000; padding: 6px 10px; }
  #print-area .print-head img { height: 54px; }
  #print-area h1 { font-size: 20pt; margin: 0; }
  #print-area .print-head p { margin: 2px 0 0; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area .print-meta td { border: 1px solid #000; border-top: 0; padding: 4px 8px; }
  #print-area .print-meta span { color: #444; }
  #print-area .print-table { margin-top: 14px; }
  #print-area .print-table th { background: #bbb !important; color: #000; text-transform: none; letter-spacing: 0; font-size: 9.5pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-area .print-table th, #print-area .print-table td { border: 1px solid #555; padding: 4px 6px; text-align: left; vertical-align: top; }
  #print-area .print-table tr { break-inside: avoid; }
  #print-area .print-table td:first-child { white-space: nowrap; }
  #print-area .print-table tr.storno td { text-decoration: line-through; color: #555; }
  #print-area .print-table tr.storno small { text-decoration: none; display: inline-block; }
  #print-area .print-foot { margin-top: 10px; font-size: 8.5pt; color: #444; }
  .top, .toolbar, .actions, .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  main { max-width: none; padding: 0; }
  .card { break-inside: avoid; border-color: #999; }
  .stats { grid-template-columns: repeat(5, 1fr); }
}
