/* CMS: Designsystem «Swiss Style», dicht für Datenarbeit.
   SSG-Farben: Anthrazit #242424, Rot #FF0000 nur als Markenakzent (nie für Text).
   Keine Inline-Styles (strenge CSP). Hell- und Dunkelmodus über prefers-color-scheme. */

@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --brand: #ff0000;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --surface-hover: #f2f4f6;
  --text: #1a1d21;
  --text-muted: #5b6470;
  --border: #e4e7eb;
  --border-strong: #cdd2d8;
  --primary: #242424;
  --primary-hover: #000000;
  --on-primary: #ffffff;
  --link: #1f5fa8;
  --focus: #1f5fa8;
  --focus-ring: rgba(31, 95, 168, 0.25);
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --success: #17703f;
  --success-soft: #e6f4ec;
  --warning: #8a5a00;
  --warning-soft: #fff4d6;

  --sidebar-bg: #242424;
  --sidebar-text: #e8e9eb;
  --sidebar-muted: #9a9ea5;
  --sidebar-hover: #313131;
  --sidebar-active: #3a3a3a;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --control-height: 36px;
  --sidebar-width: 232px;
  --transition: 150ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1012;
    --surface: #17191c;
    --surface-2: #1c1f23;
    --surface-hover: #22262b;
    --text: #e8eaed;
    --text-muted: #a2a9b3;
    --border: #2a2e34;
    --border-strong: #3a3f46;
    --primary: #eceef1;
    --primary-hover: #ffffff;
    --on-primary: #141518;
    --link: #8ab6f2;
    --focus: #8ab6f2;
    --focus-ring: rgba(138, 182, 242, 0.3);
    --danger: #ff9b92;
    --danger-soft: #3b1d1b;
    --success: #6fd39c;
    --success-soft: #16301f;
    --warning: #f2c45a;
    --warning-soft: #3a3013;
    --sidebar-bg: #0b0c0d;
    --sidebar-hover: #1b1c1f;
    --sidebar-active: #25272b;
    --shadow: none;
  }
}

/* Grundlagen */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 650; line-height: 1.25; }
h2 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.muted { color: var(--text-muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; background: var(--primary); color: var(--on-primary); border-radius: var(--radius);
}
.skip-link:focus { top: 12px; }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-xl { width: 32px; height: 32px; stroke-width: 1.5; }

/* App-Rahmen */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
/* Volle Fensterbreite: Listen und Belege brauchen den Platz. */
.content { padding: 28px 36px 48px; width: 100%; min-width: 0; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-text);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px; color: inherit; text-decoration: none;
}
/* Marke: Kreislauf aus drei Bogen, einer rot (core/_brand_mark.html) */
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-ring { fill: none; stroke: currentColor; stroke-width: 5; stroke-dasharray: 18 51.1; }
.brand-ring-accent { stroke: var(--brand); }
.brand-ring-soft { stroke-opacity: 0.55; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.02em; }
.brand-text small { font-size: 0.72rem; color: var(--sidebar-muted); }

.sidebar-nav { flex: 1; padding: 4px 12px; }
.nav-group { margin-bottom: 18px; }
.nav-title {
  padding: 0 10px 6px; font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--sidebar-muted);
}
.nav-link {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-height: 36px; padding: 0 10px; border-radius: var(--radius);
  color: var(--sidebar-text); text-decoration: none; font-size: 0.92rem;
  transition: background var(--transition);
}
.nav-link .icon { color: var(--sidebar-muted); transition: color var(--transition); }
.nav-link:hover { background: var(--sidebar-hover); }
.nav-link:hover .icon { color: var(--sidebar-text); }
.nav-link[aria-current="page"] { background: var(--sidebar-active); font-weight: 600; }
.nav-link[aria-current="page"] .icon { color: var(--sidebar-text); }
.nav-link[aria-current="page"]::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.env-badge {
  display: block; margin-bottom: 10px; padding: 4px 10px; border-radius: var(--radius);
  background: rgba(242, 196, 90, 0.14); color: #f2c45a; font-size: 0.75rem; font-weight: 600; text-align: center;
}
.user-box { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 6px; }
.user-box form { margin-left: auto; }
.avatar {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: 50%; background: var(--sidebar-active); font-size: 0.75rem; font-weight: 600;
}
.user-name { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--sidebar-muted); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-button:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

/* Seitenkopf */
.breadcrumb { margin-bottom: 6px; font-size: 0.85rem; }
.breadcrumb a { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .icon { width: 16px; height: 16px; }
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 20px;
}
.page-subtitle { margin-top: 4px; color: var(--text-muted); }
.title-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

/* Bausteine */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.section { padding: 18px 20px; margin-bottom: 16px; }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 0.95rem; }
.section-title .icon { width: 16px; height: 16px; color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--control-height); padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius);
  font: 500 0.9rem/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-icon { width: var(--control-height); padding: 0; }
/* In schmalen Spalten brechen lange Beschriftungen um, statt über den Rand zu ragen. */
.btn { max-width: 100%; }
.detail-side .btn, .btn-block { white-space: normal; line-height: 1.25; padding-block: 8px; text-align: left; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-block { width: 100%; }

.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-success { background: var(--success-soft); color: var(--success); }
.code {
  display: inline-block; padding: 1px 6px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font: 500 0.8rem/1.5 var(--font-mono); color: var(--text); white-space: nowrap;
}

.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px;
  border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
}
.alert .icon { margin-top: 2px; }
.alert-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: transparent; color: var(--danger); margin-bottom: 16px; }

/* Listen */
.toolbar { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); }
.search-field { position: relative; flex: 0 1 420px; }
.search-field .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-field input[type="search"] { padding-left: 36px; }
.toolbar-select { flex: 0 1 260px; }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--surface-2); color: var(--link); border: 1px solid var(--border); }

.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-tabs a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); text-decoration: none; font-size: 0.85rem;
}
.filter-tabs a:hover { border-color: var(--border-strong); }
.filter-tabs a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.filter-tabs .count { font-variant-numeric: tabular-nums; opacity: 0.7; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.kpi-inline { padding: 8px 14px; }
.kpi-value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--text-muted); font-size: 0.8rem; }
a.kpi-link { color: var(--text); text-decoration: none; transition: border-color var(--transition); }
a.kpi-link:hover { border-color: var(--border-strong); }
.kpi.is-alert { border-color: var(--danger); }
.kpi.is-alert .kpi-value { color: var(--danger); }

/* Startseite: Audits nach Status, Spalten für Abholungen und Einkauf */
.section-count { margin-left: auto; font-size: 0.82rem; font-weight: 500; }
.section-heading { margin: 8px 0 12px; font-size: 0.95rem; }
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.pipeline-step {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2);
  color: var(--text); text-decoration: none; transition: border-color var(--transition);
}
.pipeline-step:hover { border-color: var(--border-strong); }
.pipeline-count { font-size: 1.6rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pipeline-label { font-size: 0.9rem; font-weight: 600; }
.pipeline-meta { color: var(--text-muted); font-size: 0.8rem; }
.pipeline-step.is-empty .pipeline-count, .pipeline-step.is-empty .pipeline-label { color: var(--text-muted); }
.pipeline-step.is-late { border-color: var(--warning); background: var(--warning-soft); }
.dashboard-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: 16px; }

.seal-row { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.inline-form { display: flex; gap: 8px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* Etikett-Foto in der Vor-Ort-Erfassung (static/js/label-photo.js) */
.photo-panel { margin-bottom: 16px; border-color: var(--warning); }
.photo-form { display: grid; gap: 10px; margin: 12px 0; }
.photo-button { cursor: pointer; justify-content: center; }
.photo-button:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.photo-form.is-busy .photo-button { opacity: 0.6; pointer-events: none; }
.photo-manual { flex-wrap: wrap; }
.photo-manual input { flex: 1 1 160px; }
.finish-form, .confirm-form { margin-top: 16px; display: grid; gap: 10px; }

.scan-panel { display: grid; gap: 14px; }
.scan-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.scan-form label { width: 100%; font-weight: 600; }
.scan-form input { flex: 1 1 260px; font-size: 1.2rem; min-height: 48px; }
.scan-form .btn { min-height: 48px; }
.store-form .field { flex: 1 1 220px; }

/* Testing (Touchscreen): grosse Ziele, Auswahl ohne JavaScript über :has(:checked) */
.testing-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.compact-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px 14px; }
.device-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ssg-id { font: 700 1.6rem/1.1 var(--font-mono); letter-spacing: 0.02em; }
.device-title { font-size: 1.1rem; font-weight: 600; }
.device-card .muted { margin-bottom: 14px; }
.code-category { margin: 14px 0 8px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.code-category:first-of-type { margin-top: 0; }
.code-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile-toggle {
  position: relative; display: flex; flex-direction: column; gap: 2px; min-height: 64px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; user-select: none; transition: background var(--transition), border-color var(--transition);
}
.tile-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.tile-toggle:hover { border-color: var(--text-muted); }
.tile-toggle:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.tile-toggle:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tile-toggle:has(input:checked) .tile-grade { color: inherit; opacity: 0.8; }
.tile-code { font: 600 0.75rem/1 var(--font-mono); opacity: 0.75; }
.tile-text { font-size: 0.9rem; font-weight: 500; line-height: 1.25; }
.tile-grade { font-size: 0.72rem; color: var(--text-muted); margin-top: auto; }
.tile-wide { min-height: 56px; justify-content: center; margin-bottom: 14px; }
.grade-box { display: grid; gap: 12px; }
.grade-suggestion { font-size: 0.95rem; }
.grade-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.grade-option { position: relative; }
.grade-option input { position: absolute; opacity: 0; }
.grade-option span {
  display: grid; place-items: center; min-height: 56px; padding: 0 6px; text-align: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius); font-weight: 650; cursor: pointer;
}
.grade-option input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.grade-option input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.grade-pill { display: inline-grid; place-items: center; min-width: 30px; height: 24px; padding: 0 8px; border-radius: 999px; font-weight: 700; font-size: 0.8rem; background: var(--surface-2); border: 1px solid var(--border); }
.grade-a { background: var(--success-soft); color: var(--success); border-color: transparent; }
.grade-a-, .grade-b { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.grade-d { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.bin-field { margin-bottom: 14px; }
.btn-xl { min-height: 56px; font-size: 1rem; }
.carrier-row, .carrier-action { padding: 10px 0; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.carrier-row:last-child, .carrier-action:last-of-type { border-bottom: 0; }
.field-end { justify-content: flex-end; }
.small { font-size: 0.85rem; }
@media (max-width: 1100px) { .testing-grid { grid-template-columns: minmax(0, 1fr); } }

.progress { display: flex; align-items: center; gap: 12px; }
.progress progress { flex: 1; height: 10px; accent-color: var(--success); }
.actions-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.field-count { font-weight: 600; color: var(--text); }
.rows { transition: opacity var(--transition); }
.rows.htmx-request { opacity: 0.55; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.table th {
  padding: 10px 14px; text-align: left; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tbody tr { position: relative; transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .cell-wrap { white-space: normal; min-width: 12ch; }
.row-link { color: inherit; text-decoration: none; }
.row-link::after { content: ''; position: absolute; inset: 0; }
.row-link:focus-visible { outline: none; }
.table tbody tr:has(.row-link:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.table-compact th, .table-compact td { padding: 8px 10px; }
.table input.price-input { width: 110px; min-height: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.table input.price-input.has-error { border-color: var(--danger); }
.table-actions { justify-content: flex-end; margin-top: 14px; }
.form-section .table-actions { grid-column: 1 / -1; margin-top: 0; }
.section .table-wrap { margin: 0 -20px -18px; border-top: 1px solid var(--border); }
.section .table th:first-child, .section .table td:first-child { padding-left: 20px; }

.table-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted);
}
.pagination { display: flex; align-items: center; gap: 6px; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 48px 24px; text-align: center; color: var(--text-muted);
}

/* Detailseiten */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.field-list { margin: 0; }
.field-row {
  display: grid; grid-template-columns: minmax(130px, 32%) minmax(0, 1fr); gap: 16px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.field-row:last-child { border-bottom: 0; padding-bottom: 0; }
.field-row:first-child { padding-top: 0; }
.field-row dt { color: var(--text-muted); font-size: 0.88rem; }
.field-row dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--border); margin-left: 4px; }
.timeline-item:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline-item::before {
  content: ''; position: absolute; left: -6px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline-head { display: flex; flex-direction: column; font-size: 0.88rem; }
.timeline-head .muted { font-size: 0.8rem; }
.changes { list-style: none; margin: 6px 0 0; padding: 0; font-size: 0.85rem; display: grid; gap: 2px; }
.changes del { color: var(--text-muted); }
.changes ins { text-decoration: none; font-weight: 600; }

/* Formulare */
.form-section {
  display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 24px; align-items: start;
  padding: 20px; margin-bottom: 16px;
}
.form-section .section-title { margin: 6px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field > label { font-size: 0.85rem; font-weight: 500; }
.field > label.required::after { content: ' *'; color: var(--danger); }
.hint { color: var(--text-muted); font-size: 0.8rem; }
.field-error { color: var(--danger); font-size: 0.8rem; font-weight: 500; }

input[type="text"], input[type="email"], input[type="number"], input[type="password"],
input[type="search"], input[type="tel"], input[type="url"], input[type="date"], select, textarea {
  width: 100%; min-height: var(--control-height); padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.92rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { min-height: 88px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a919b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.checkbox { display: inline-flex; align-items: center; gap: 10px; min-height: var(--control-height); font-size: 0.92rem; cursor: pointer; }
.form-grid .field:has(.checkbox) { justify-content: flex-end; }

.form-actions {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; justify-content: flex-end; gap: 8px;
  margin: 0 -36px 16px; padding: 14px 36px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-top: 1px solid var(--border); backdrop-filter: blur(6px);
}
/* Nur wenn das Formular zuunterst steht, reicht die Leiste bis an den Fensterrand. Sonst würde der negative
   Rand den folgenden Inhalt unter die Leiste ziehen. */
.content > form:last-child > .form-actions:last-child { margin-bottom: -48px; }

/* Startseite */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; transition: border-color var(--transition);
}
.tile:hover { border-color: var(--border-strong); }
.tile-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius); background: var(--surface-2); color: var(--text); }
.tile-body { display: flex; flex-direction: column; line-height: 1.2; }
.tile-count { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--text-muted); font-size: 0.88rem; }

/* Anmeldung: immer dunkel, schwarzer Hintergrund mit bewegten Linien (static/js/login-background.js) */
.auth {
  --bg: #000000;
  --surface: rgba(20, 21, 24, 0.72);
  --surface-2: #1c1f23;
  --surface-hover: #22262b;
  --text: #e8eaed;
  --text-muted: #a2a9b3;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);
  --primary: #eceef1;
  --primary-hover: #ffffff;
  --on-primary: #141518;
  --link: #8ab6f2;
  --focus: #8ab6f2;
  --focus-ring: rgba(138, 182, 242, 0.3);
  --danger: #ff9b92;
  --danger-soft: rgba(180, 35, 24, 0.22);
  --warning: #f2c45a;
  color-scheme: dark;
  position: relative; isolation: isolate; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: 24px; background: var(--bg); color: var(--text);
}
.auth-background { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; display: block; pointer-events: none; }
.auth-card {
  width: 100%; max-width: 380px; padding: 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.auth input { background: rgba(0, 0, 0, 0.35); }
/* vom Browser eingefüllte Felder nicht hellblau */
.auth input:-webkit-autofill, .auth input:-webkit-autofill:hover {
  -webkit-text-fill-color: var(--text); caret-color: var(--text);
  box-shadow: 0 0 0 1000px #15171a inset; transition: background-color 9999s;
}
.auth input:-webkit-autofill:focus { box-shadow: 0 0 0 1000px #15171a inset, 0 0 0 3px var(--focus-ring); }
body:has(> .auth) { background: #000000; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand .brand-text small { color: var(--text-muted); }
.auth-card h1 { font-size: 1.25rem; margin-bottom: 16px; }
.auth-form { display: grid; gap: 16px; }
.auth-env { margin-top: 20px; text-align: center; font-size: 0.8rem; color: var(--warning); }
.auth-microsoft { justify-content: center; min-height: 44px; }
.ms-logo { width: 18px; height: 18px; flex: none; }
.auth-divider { margin: 20px 0 12px; text-align: center; font-size: 0.8rem; color: var(--text-muted); }

/* Schmale Bildschirme */
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: flex-start; }
  .brand { padding: 12px 16px; }
  .brand-text small { display: none; }
  .sidebar-nav { order: 3; flex: 1 0 100%; display: flex; gap: 4px; padding: 0 12px 10px; overflow-x: auto; }
  .nav-group { display: flex; gap: 4px; margin: 0; }
  .nav-title { display: none; }
  .nav-link { white-space: nowrap; }
  .nav-link[aria-current="page"]::before { display: none; }
  .sidebar-footer { margin-left: auto; border-top: 0; padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
  .env-badge { margin: 0; }
  .user-name { display: none; }
  .content { padding: 20px 16px 32px; }
  .form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .form-actions { margin: 0 -16px 16px; padding: 12px 16px; }
  .content > form:last-child > .form-actions:last-child { margin-bottom: -32px; }
  .page-header { flex-wrap: wrap; align-items: flex-start; }
}
@media (pointer: coarse) {
  :root { --control-height: 44px; }
  .nav-link { min-height: 44px; }
  .icon-button { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Kundensuche mit Vorschlägen (Abholung planen) */
.customer-block { display: grid; gap: 16px; }
.customer-search { position: relative; max-width: 560px; }
.suggestions {
  position: absolute; top: calc(100% - 2px); left: 0; right: 0; z-index: 20; max-height: 340px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
}
.suggestions:empty { display: none; }
.suggestion {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 10px 12px;
  border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover, .suggestion:focus-visible { background: var(--surface-hover); outline: none; }
.suggestion-title { font-weight: 600; }
.suggestion-meta, .suggestion-empty { font-size: 0.82rem; color: var(--text-muted); }
.suggestion-empty { margin: 0; padding: 10px 12px; }
.selected-customer { display: flex; align-items: center; gap: 10px; min-height: var(--control-height); flex-wrap: wrap; }
.field .label { font-size: 0.85rem; font-weight: 500; }
.field .label.required::after { content: ' *'; color: var(--danger); }
.address-fields { display: grid; gap: 8px; }

/* Disposition: Auftrag, Einsatzkalender, Auslastung, Fahrer-App */
.board [data-board-error][hidden], .form [data-only-for][hidden] { display: none; }
.alert-info { background: var(--surface-2); border-color: var(--border); color: var(--text); margin-bottom: 16px; }
.plain-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.assign-form { display: flex; gap: 8px; flex-wrap: wrap; }
.assign-form select { flex: 1 1 160px; }
.day-plan-actions { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.day-plan-actions label { align-self: center; color: var(--text-muted); font-size: 0.85rem; }
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.calendar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); gap: 10px; overflow-x: auto; }
.calendar-day {
  min-height: 320px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); display: flex; flex-direction: column; gap: 8px;
}
.calendar-day.is-today { border-color: var(--primary); }
.calendar-day.is-weekend { background: var(--surface-2); }
.calendar-day-title { font-size: 0.9rem; margin: 0 0 4px; display: flex; justify-content: space-between; }
.calendar-empty { font-size: 0.82rem; }
.is-drop-target { outline: 2px dashed var(--primary); outline-offset: -4px; }
.entry-card {
  padding: 8px 10px; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius);
  background: var(--surface); display: grid; gap: 2px; font-size: 0.85rem;
}
.entry-card[draggable="true"] { cursor: grab; }
.entry-card.is-dragging { opacity: 0.5; }
.entry-card.kind-pickup { border-left-color: var(--warning); }
.entry-card.kind-delivery { border-left-color: var(--success); }
.entry-card.kind-service { border-left-color: var(--text-muted); }
.entry-card.is-done { opacity: 0.6; }
.entry-card.status-cancelled .entry-title { text-decoration: line-through; }
.entry-head { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.78rem; }
.entry-head .icon { width: 14px; height: 14px; color: var(--success); }
.entry-time { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.entry-title { font-weight: 600; color: var(--text); text-decoration: none; }
.entry-title:hover { text-decoration: underline; }
.entry-meta { color: var(--text-muted); font-size: 0.78rem; }
.entry-move summary { cursor: pointer; color: var(--text-muted); font-size: 0.78rem; }
.entry-move form { margin-top: 6px; }
.workload th, .workload td { vertical-align: top; white-space: normal; }
.workload-cell { min-width: 150px; }
.workload-cell .entry-card { margin-bottom: 6px; }
.workload-unassigned.has-open th { color: var(--danger); }
.workload-load { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; }
.load-bar { flex: 0 0 36px; height: 6px; border-radius: 3px; background: var(--border); }
.level-normal .load-bar { background: var(--success); }
.level-high .load-bar { background: var(--warning); }
.level-full .load-bar { background: var(--danger); }
.workload-list { list-style: none; margin: 4px 0 0; padding: 0; font-size: 0.8rem; display: grid; gap: 2px; }
.workload-list .icon { width: 12px; height: 12px; color: var(--success); }
.driver-app { max-width: 720px; }
.app-days { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.app-card { padding: 16px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.app-card.is-done { opacity: 0.65; }
.app-card-head { display: flex; align-items: center; gap: 10px; }
.app-time { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.app-customer { margin: 8px 0 4px; font-size: 1.1rem; }
.app-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.app-actions .btn { min-height: 48px; }
.signature-form { display: grid; gap: 14px; }
.signature-pad { width: 100%; height: 200px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: #fff; touch-action: none; }
