/* Vakuum-Audits – Verwaltung (Desktop-Browser, auch Tablet). Farben und Schrift nach Richter-Hausgestaltung. */

/* Poppins nur für Überschriften und die Marke – die Dateien liegen im Projekt (strenge CSP, kein Google-Abruf) */
@font-face {
  font-family: Poppins; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/fonts/poppins-600.woff2) format('woff2');
}
@font-face {
  font-family: Poppins; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/fonts/poppins-700.woff2) format('woff2');
}

:root {
  --bg: #f4f5f6; --surface: #fff; --surface-2: #eceef0; --text: #1d1c1c; --muted: #5f6a6d; --border: #d5d9db;
  --primary: #005563; --primary-text: #fff; --primary-soft: #dceef1; --danger: #a50c0c; --danger-bg: #fbe3e0;
  --warn-bg: #fff4d6; --warn-text: #6b4b00; --ok: #1b6b46; --ok-bg: #dff0e7; --radius: 12px;
  /* Kopfleiste: in beiden Modi Petrol mit weißer Schrift, wie im Netzauftritt */
  --brand: #005563; --brand-line: #878787; --on-brand: #fff;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: Poppins, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181a; --surface: #1b2326; --surface-2: #232d31; --text: #e6edef; --muted: #9aa7ab; --border: #334043;
    /* auf dunklem Grund aufgehelltes Petrol – sonst zu wenig Kontrast */
    --primary: #4fb3c6; --primary-text: #04222a; --primary-soft: #113a44; --danger: #ff8a80; --danger-bg: #3a1c1a;
    --warn-bg: #3d3212; --warn-text: #ffd97a; --ok: #6fd08f; --ok-bg: #143026; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
h1 { font-size: 1.45rem; margin: 0; font-family: var(--font-head); font-weight: 700; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; font-family: var(--font-head); font-weight: 600; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.warn { color: var(--warn-text); background: var(--warn-bg); padding: 0 0.3rem; border-radius: 4px; }

.topbar { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; padding: 0.55rem 1.25rem;
  background: var(--brand); color: var(--on-brand); border-bottom: 4px solid var(--brand-line);
  position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; color: var(--on-brand); letter-spacing: 0.02em; }
.brand-sub { font-size: 0.72rem; color: rgba(255, 255, 255, 0.75); }
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav a, .nav-soon { padding: 0.45rem 0.9rem; border-radius: 999px; text-decoration: none;
  color: rgba(255, 255, 255, 0.82); font-weight: 600; }
.nav a:hover { background: rgba(255, 255, 255, 0.1); color: var(--on-brand); }
.nav a.active { background: var(--on-brand); color: var(--brand); }
.nav-soon { color: rgba(255, 255, 255, 0.5); font-weight: 400; cursor: default; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.user-chip { font-weight: 600; text-decoration: none; color: var(--on-brand); }
.topbar .btn-ghost { color: var(--on-brand); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.lang-switch { display: inline-flex; border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 999px; overflow: hidden; }
.lang-switch button { border: 0; background: transparent; color: var(--on-brand); padding: 0.35rem 0.7rem; font: inherit; font-weight: 600; cursor: pointer; }
.lang-switch button.active { background: var(--on-brand); color: var(--brand); }

.view { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.empty { padding: 2.5rem; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.notice-error { padding: 0.8rem 1rem; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn-text); }

.btn { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 38px; padding: 0 1rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-small { min-height: 30px; padding: 0 0.6rem; font-size: 0.85rem; font-weight: 500; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-2); color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
tr.inactive td, .inactive > .tree-row { opacity: 0.6; }
.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.badge { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip { padding: 0.05rem 0.5rem; border-radius: 6px; background: var(--surface-2); font-size: 0.85rem; white-space: nowrap; }
.chip-btn { border: 1px solid var(--border); cursor: pointer; color: var(--text); font: inherit; font-size: 0.85rem; }
.chip-btn.inactive { opacity: 0.55; text-decoration: line-through; }

.toolbar { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .input { max-width: 360px; }
.tree { display: grid; gap: 0.75rem; }
.tree-node { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; }
.tree-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tree-sub { margin: 0.6rem 0 0 1.25rem; padding-left: 0.9rem; border-left: 3px solid var(--primary-soft); }
.tree-sub.inactive { opacity: 0.6; }
.machines { margin-top: 0.35rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.req { color: var(--danger); }
.hint { font-size: 0.8rem; color: var(--muted); }
.input { width: 100%; min-height: 38px; padding: 0.4rem 0.7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; }
textarea.input { resize: vertical; }
.input:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 600; }
.form-grid { display: grid; gap: 0.9rem; }
.form-grid.narrow { max-width: 420px; }

.login-box { max-width: 420px; margin: 8vh auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.75rem; display: grid; gap: 1rem; }
.login-box .row { display: flex; justify-content: space-between; gap: 0.75rem; }
.qr { width: 220px; height: 220px; justify-self: center; background: #fff; padding: 6px; border-radius: 8px; }
.secret { font-size: 0.85rem; word-break: break-all; user-select: all; }
.input.code { font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; }

.dialog { border: 0; border-radius: var(--radius); padding: 1.5rem; width: min(560px, calc(100% - 2rem));
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgb(0 0 0 / 0.35); }
.dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.dialog-error { margin: 0.75rem 0 0; color: var(--danger); font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.25rem; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); padding: 0.8rem 1.2rem; border-radius: var(--radius);
  background: var(--text); color: var(--bg); font-weight: 600; z-index: 50; max-width: calc(100% - 2rem); }
.toast[data-type="error"] { background: var(--danger); color: #fff; }

.badge-green { background: var(--ok-bg); color: var(--ok); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.big-code { font: 700 2.4rem/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.12em; text-align: center;
  padding: 1rem; background: var(--surface-2); border-radius: var(--radius); user-select: all; }

/* Vorgaben / Eingang */
.table.clickable tbody tr { cursor: pointer; }
.table.clickable tbody tr:hover td { background: var(--surface-2); }
.status-draft { background: var(--surface-2); color: var(--muted); }
.status-assigned { background: var(--primary-soft); color: var(--primary); }
.status-checked_out { background: var(--warn-bg); color: var(--warn-text); }
.status-returned { background: var(--ok-bg); color: var(--ok); }
.status-cancelled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); border: 0; padding: 0; margin: 0; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.input-inline { width: auto; min-width: 220px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.row-end { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.approval-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.approval-box { display: grid; gap: 0.5rem; justify-items: start; padding: 1rem; border: 2px dashed var(--border); border-radius: var(--radius); }
.approval-box.done { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.back-link { text-decoration: none; margin-right: 0.4rem; }
.chip-check { font-weight: 500; padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 999px; }
tr.sub td { background: var(--surface-2); }
ul.plain { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.25rem; font-size: 0.9rem; }
fieldset:disabled .input { background: var(--surface-2); }
@media (max-width: 800px) { .form-grid.cols-3, .approval-grid { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }

/* Update: Paket hierher ziehen oder anklicken */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.35rem; min-height: 7rem; padding: 1.25rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:hover, .drop:focus-within { border-color: var(--primary); }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop.over * { pointer-events: none; }
.drop-title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.drop .hint { margin: 0; }
.update-out { margin: 0.5rem 0 0; padding: 0.6rem 0.8rem; border-radius: var(--radius); background: var(--surface-2, transparent);
  border: 1px solid var(--border); white-space: pre-wrap; overflow-x: auto; font-size: 0.85rem; }

/* Aufklappbarer Block (Update-Verlauf): bleibt zu, bis man ihn braucht */
details.foldable > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0; user-select: none;
}
details.foldable > summary::-webkit-details-marker { display: none; }
details.foldable > summary::before { content: '▸'; color: var(--muted); }
details.foldable[open] > summary::before { content: '▾'; }
details.foldable[open] > summary { margin-bottom: 0.75rem; }

/* Ergebnis-Ansicht: Fotos aus der hochgeladenen Datei */
.result-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.result-photos figure { margin: 0; }
.result-photos img { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* Messdaten nach dem Papier-Testblatt: Kopf, Blöcke, Messwert-Tabelle (K5) */
.sheet-head { margin: 1.1rem 0 0.3rem; padding-bottom: 0.2rem; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.sheet-table td { white-space: nowrap; vertical-align: top; }
.sheet-table td .small { white-space: normal; }
.sheet-table td.konflikt { background: var(--warn-bg); }
details.rest { margin: 0.6rem 0 0; }
details.rest > summary { color: var(--muted); cursor: pointer; }

/* Auf dem Bildschirm unsichtbar, auf dem Papier der Kopf des Blatts */
.print-head { display: none; }

/* Drucken = PDF: im Druckdialog „Als PDF speichern". Eine eigene Bibliothek im Backend ginge nicht
   über die Update-Seite (node_modules ist dort gesperrt), darum dieser Weg. */
@media print {
  .topbar, .page-head .actions, .actions, button, .back-link, .toast, .log-detail { display: none !important; }
  /* Beschriftung und Wert nebeneinander – wie auf dem Vordruck, spart Papier */
  dl.info { display: grid; grid-template-columns: 62mm 1fr; gap: 0.15rem 0.6rem; margin: 0.2rem 0 0.6rem; }
  dl.info dt { color: #000; }
  dl.info dd { margin: 0; }
  .page-head h1 { font-size: 1.1rem; }
  .print-head { display: block; margin: 0 0 0.8rem; }
  .print-head strong { font-size: 1.15rem; }
  body { background: #fff; }
  .panel { break-inside: avoid; border: none; box-shadow: none; padding: 0; margin: 0 0 0.8rem; background: none; }
  .sheet h2, .sheet h3 { break-after: avoid; }
  .sheet-head { break-after: avoid; }
  details.rest > summary { display: none; }
  .table-wrap { overflow: visible; }
  .sheet-table thead { display: table-header-group; }   /* Spaltenköpfe auf jeder Seite */
  .sheet-table tr { break-inside: avoid; }
  .result-photos { grid-template-columns: repeat(3, 1fr); }
  .result-photos img { height: auto; max-height: 55mm; }
  .result-photos figure { break-inside: avoid; }
  a[href]::after { content: none; }
}
@page { margin: 14mm 12mm; }
