/* Betriebstagebuch – Layout und Komponenten. Farben ausschließlich aus tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
/* Links: Dunkelgrün im hellen Theme, im dunklen Theme Textfarbe (wie Referenz-Screen) */
:root { --link: var(--brand-dark); }
:root[data-theme="dark"] { --link: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --link: var(--text); } }
a { color: var(--link); }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 .75em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 14px/1 var(--font-sans); text-decoration: none; cursor: pointer; white-space: nowrap;
}
a.btn { color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .choice:focus-within {
  outline: none; box-shadow: var(--focus-ring); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
a.btn-primary { color: var(--on-brand); }
.btn-primary:hover { background: #a6cf2c; }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-lg { min-height: 52px; font-size: 16px; padding: 0 20px; width: 100%; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* --- Badges ------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.badge-offen { background: var(--warn-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--warn); }
.badge-erledigt { background: var(--brand); color: var(--on-brand); }
.badge-sofort, .badge-hoch { background: var(--danger-soft); color: var(--danger); }
.badge-mittel { background: var(--warn-soft); color: var(--text); }
.badge-ausgeblendet { background: var(--surface-2); color: var(--text-faint); text-decoration: line-through; }

/* --- Karten, Hinweise -------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.card-tight { padding: 14px 16px; }
.card h2 { margin-bottom: 4px; }
.hint { border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; }
.hint-ok { border-left-color: var(--brand); background: var(--success-soft); }
.hint-danger { border-left-color: var(--danger); background: var(--danger-soft); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat .label { font-size: 13px; color: var(--text-muted); }
.stat .value { font-size: 22px; font-weight: 600; }

/* --- Formulare --------------------------------------------------------- */
.field { display: block; }
.field + .field, .field + .grid2, .grid2 + .field, .grid2 + .grid2 { margin-top: 16px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.req { color: var(--danger); }
.field .help { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.field .error { font-size: 13px; color: var(--danger); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date],
input[type=datetime-local], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--input-bg); color: var(--text);
  font: 16px/1.4 var(--font-sans); /* 16px: kein Auto-Zoom auf iOS */
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); }
.grid2 { display: grid; gap: 16px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* Auswahl-Kacheln (Radio) wie im Referenz-Screen */
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { position: relative; flex: 1 1 0; min-width: 72px; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--input-bg); font-weight: 500; text-align: center; }
.choice span::before { content: ""; width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--border-strong); background: var(--surface); }
.choice input:checked + span { border: 2px solid var(--brand); box-shadow: var(--focus-ring); }
.choice input:checked + span::before { border: 5px solid var(--brand-dark); background: #fff; }

/* Fotos */
.photo-pick { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2);
  font-weight: 600; cursor: pointer; padding: 12px; text-align: center; }
.photo-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-pick:focus-within { box-shadow: var(--focus-ring); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(15,26,44,.75); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.thumb .busy { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--text-muted); }
a.thumb { display: block; }

/* --- Mobile Erfassung -------------------------------------------------- */
.mobile-header { background: var(--sidebar); color: var(--sidebar-text-active); padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top)); }
.mobile-header .inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.mobile-header img { height: 18px; width: auto; }
.mobile-header .app-name { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-text); }
.mobile-main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
.ort { display: flex; gap: 12px; align-items: flex-start; }
.ort .icon { width: 22px; height: 22px; margin-top: 2px; color: var(--brand-dark); }
.ort .titel { font-weight: 600; font-size: 17px; }
.arten { display: grid; gap: 10px; }
.art-btn { display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  color: var(--text) !important; text-decoration: none; }
.art-btn:hover, .art-btn:focus-visible { border-color: var(--brand); box-shadow: var(--focus-ring); outline: none; }
.art-btn .icon { width: 26px; height: 26px; color: var(--brand-dark); }
.art-btn .t { font-weight: 600; font-size: 17px; display: block; }
.art-btn .k { font-size: 13px; color: var(--text-muted); display: block; }
.art-btn.art-defekt .icon { color: var(--danger); }
.backlink { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted) !important;
  text-decoration: none; font-size: 14px; min-height: 40px; }
.form-actions { position: sticky; bottom: 0; margin: 20px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent); }
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.summary dt { font-size: 13px; color: var(--text-muted); }
.summary dd { margin: 0 0 10px; white-space: pre-wrap; word-break: break-word; }
.check-big { width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center; margin: 8px auto 12px; }
.check-big .icon { width: 30px; height: 30px; stroke-width: 2.4; }
.neutral { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.neutral .box { max-width: 380px; }
.neutral img { height: 26px; width: auto; margin: 0 auto 28px; }
.neutral .icon { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--text-muted); }

/* --- App-Shell (Büro, Admin) ------------------------------------------ */
.shell { min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; }
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.sidebar-logo img { height: 18px; width: auto; }
.sidebar-logo .app-name { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-text); }
.sidebar nav { padding: 8px; display: none; }
.sidebar.open nav { display: block; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius);
  color: var(--sidebar-text); text-decoration: none; font-weight: 500; position: relative; }
.sidebar nav a:hover { color: var(--sidebar-text-active); }
.sidebar nav a.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.sidebar nav a.active::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 2px; background: var(--brand); }
.sidebar nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint);
  padding: 16px 12px 6px; }
.menu-toggle { margin-left: auto; background: transparent; border: 1px solid #2C3D5A; color: var(--sidebar-text);
  border-radius: var(--radius); min-height: 36px; padding: 0 10px; cursor: pointer; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-wrap: wrap; }
.crumbs { font-size: 14px; color: var(--text-muted); }
.crumbs b { color: var(--text); font-weight: 600; }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--sidebar); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.user .rolle { color: var(--text-muted); font-size: 12px; }
.content { padding: 20px 16px 48px; max-width: 1240px; }
.page-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
  margin-bottom: 20px; }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); }
.segmented button { border: 0; background: transparent; color: var(--text-muted); font: 500 13px var(--font-sans);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; }
  .sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--sidebar-active); }
  .sidebar nav { display: block; flex: 1; }
  .menu-toggle { display: none; }
  .sidebar-logo { flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 20px 16px; border-bottom: 1px solid #1B2840; }
  .topbar { padding: 10px 24px; min-height: 56px; }
  .content { padding: 24px 24px 64px; }
}

/* --- Tabellen / Listen ------------------------------------------------- */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); align-items: end; }
.filters label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; font-weight: 500; }
.filters input, .filters select { min-height: 38px; padding: 7px 10px; font-size: 14px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td a.rowlink { color: var(--text); text-decoration: none; font-weight: 600; }
td a.rowlink:hover { text-decoration: underline; }
.ellipsis { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 14px; }
.list-cards { display: grid; gap: 10px; }
.entry-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; color: var(--text) !important; text-decoration: none; }
.entry-card:hover { border-color: var(--brand); }
.entry-card .meta { font-size: 13px; color: var(--text-muted); }
@media (max-width: 760px) { .hide-sm { display: none; } }

/* --- Detail ------------------------------------------------------------ */
.detail-grid { display: grid; gap: 16px; }
@media (min-width: 1000px) { .detail-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; } }
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 16px; font-size: 14px; margin: 12px 0 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li.t-status::before { border-color: var(--brand); background: var(--brand); }
.timeline li.t-ausgeblendet::before { border-color: var(--danger); }
.timeline .when { font-size: 12px; color: var(--text-muted); }
.timeline .text { white-space: pre-wrap; word-break: break-word; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
details.box { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
details.box > summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; display: flex; gap: 8px; align-items: center; }
details.box > summary::-webkit-details-marker { display: none; }
details.box > summary::after { content: "+"; margin-left: auto; color: var(--text-muted); font-size: 18px; }
details.box[open] > summary::after { content: "–"; }
details.box > .body { padding: 0 16px 16px; }

/* Lightbox */
dialog.lightbox { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
dialog.lightbox::backdrop { background: rgba(5, 10, 18, .92); }
dialog.lightbox img { max-width: 96vw; max-height: 86vh; margin: 0 auto; border-radius: 4px; }
dialog.lightbox .lb-bar { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
dialog.lightbox .lb-bar button, dialog.lightbox .lb-bar a { background: rgba(255,255,255,.12); color: #fff; border: 0;
  border-radius: var(--radius); padding: 8px 14px; font: 500 14px var(--font-sans); cursor: pointer; text-decoration: none; }

/* Admin */
.lg-block + .lg-block { margin-top: 16px; }
.zentrale-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border); }
.qr-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.qr-card { text-align: center; }
.qr-card img { width: 180px; height: 180px; margin: 8px auto; image-rendering: pixelated; background: #fff; border-radius: 6px; }
.qr-card .url { font-size: 11px; word-break: break-all; color: var(--text-faint); }
.inline-form { display: inline; }

/* Abstände (CSP erlaubt keine style-Attribute) */
.mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; } .mb-12 { margin-bottom: 12px; }
.center { text-align: center; }

/* Listen: Tabelle auf breiten, Karten auf schmalen Bildschirmen */
.list-cards { display: none; }
@media (max-width: 760px) { .list-cards { display: grid; } }
