/* ==========================================================================
   Gebrauchtwagen-Portal – Verwaltungsoberfläche
   Responsiv (Desktop, Tablet, Smartphone), heller und dunkler Modus.
   ========================================================================== */

:root {
  --brand: #1d4ed8;
  --brand-600: color-mix(in srgb, var(--brand) 88%, black);
  --brand-50: color-mix(in srgb, var(--brand) 8%, white);
  --brand-100: color-mix(in srgb, var(--brand) 16%, white);
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #1b2230;
  --text-2: #4b5565;
  --text-3: #7a8494;
  --sidebar-bg: #111827;
  --sidebar-text: #c7cdd8;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255,255,255,.06);
  --green: #15803d; --green-bg: #e7f6ec;
  --red: #b91c1c; --red-bg: #fdecec;
  --orange: #c2410c; --orange-bg: #fff1e6;
  --yellow: #a16207; --yellow-bg: #fef7dc;
  --blue: #1d4ed8; --blue-bg: #e8effe;
  --purple: #7e22ce; --purple-bg: #f4eafe;
  --gray: #4b5565; --gray-bg: #eef0f3;
  --dark: #f9fafb; --dark-bg: #374151;
  --chart-1: var(--brand);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  --topbar-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b23; --surface-2: #1c212b; --surface-3: #222833;
    --border: #2a303c; --border-strong: #3a4250; --text: #e7eaf0; --text-2: #b4bcc8; --text-3: #8a94a4;
    --sidebar-bg: #0b0e13; --brand-50: color-mix(in srgb, var(--brand) 18%, #171b23); --brand-100: color-mix(in srgb, var(--brand) 28%, #171b23);
    --green-bg: #12301d; --red-bg: #3a1616; --orange-bg: #3a2312; --yellow-bg: #362c0e; --blue-bg: #15254a; --purple-bg: #2c1844; --gray-bg: #262c37;
    --green: #4ade80; --red: #f87171; --orange: #fb923c; --yellow: #facc15; --blue: #93b4fd; --purple: #d8b4fe; --gray: #b4bcc8;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b23; --surface-2: #1c212b; --surface-3: #222833;
  --border: #2a303c; --border-strong: #3a4250; --text: #e7eaf0; --text-2: #b4bcc8; --text-3: #8a94a4;
  --sidebar-bg: #0b0e13; --brand-50: color-mix(in srgb, var(--brand) 18%, #171b23); --brand-100: color-mix(in srgb, var(--brand) 28%, #171b23);
  --green-bg: #12301d; --red-bg: #3a1616; --orange-bg: #3a2312; --yellow-bg: #362c0e; --blue-bg: #15254a; --purple-bg: #2c1844; --gray-bg: #262c37;
  --green: #4ade80; --red: #f87171; --orange: #fb923c; --yellow: #facc15; --blue: #93b4fd; --purple: #d8b4fe; --gray: #b4bcc8;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
p { margin: 0 0 .8em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
small, .small { font-size: 12px; }
.muted { color: var(--text-3); }
.text-right { text-align: right; } .text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -4px; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 36px; height: 36px; }
.green { color: var(--green); } .red { color: var(--red); } .orange { color: var(--orange); }

/* ---------- App-Gerüst ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; transition: transform .2s;
}
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; color: #fff; font-weight: 700; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-brand img { max-height: 30px; max-width: 150px; }
.sidebar-brand .logo-dot { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; }
.sidebar nav { overflow-y: auto; flex: 1; padding: 10px 10px 24px; }
.nav-group { margin-top: 14px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: #7c8596; padding: 6px 10px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--sidebar-text); font-size: 13.5px; }
.nav-link:hover { background: var(--sidebar-hover); text-decoration: none; color: #fff; }
.nav-link.active { background: color-mix(in srgb, var(--brand) 85%, black); color: var(--sidebar-active); }
.nav-link .badge { margin-left: auto; }
.sidebar-footer { padding: 12px 18px; font-size: 11px; color: #6b7384; border-top: 1px solid rgba(255,255,255,.06); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.topbar .menu-toggle { display: none; }
.global-search { flex: 1; max-width: 520px; position: relative; }
.global-search input { width: 100%; padding: 8px 12px 8px 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }
.global-search .icon { position: absolute; left: 10px; top: 9px; color: var(--text-3); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 70vh; overflow-y: auto; z-index: 50; }
.search-results .group { padding: 8px 12px 4px; font-size: 11px; text-transform: uppercase; color: var(--text-3); letter-spacing: .05em; }
.search-results a { display: block; padding: 7px 12px; color: var(--text); }
.search-results a:hover, .search-results a.focus { background: var(--brand-50); text-decoration: none; }
.search-results a small { display: block; color: var(--text-3); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; line-height: 16px; padding: 0 4px; font-weight: 700; }
.user-menu { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; cursor: pointer; color: var(--text); background: none; border: 0; font: inherit; }
.user-menu:hover { background: var(--surface-3); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-100); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 12px; }

.content { padding: 22px 24px 60px; max-width: 1480px; width: 100%; }
.page-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--text-3); margin-top: 2px; font-size: 13px; }
.page-header .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumbs { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.breadcrumbs a { color: var(--text-3); }

/* ---------- Karten & Raster ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; }
.card-header .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 18px; }
.card-body.p0 { padding: 0; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.grid { display: grid; gap: 14px 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-full { grid-column: 1 / -1; }
.layout-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.layout-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.stack > * + * { margin-top: 10px; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Kennzahlen ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); }
a.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat-label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.stat.warn { border-left: 3px solid var(--orange); }
.stat.danger { border-left: 3px solid var(--red); }
.stat.ok { border-left: 3px solid var(--green); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .thumb { width: 64px; height: 46px; object-fit: cover; border-radius: 6px; background: var(--surface-3); display: block; }
.table .thumb-ph { width: 64px; height: 46px; border-radius: 6px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table-compact td, .table-compact th { padding: 6px 10px; }
.sort-link { color: inherit; }
.row-title { font-weight: 600; color: var(--text); }
.row-sub { font-size: 12px; color: var(--text-3); }
.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.pagination { display: flex; gap: 4px; align-items: center; justify-content: flex-end; padding: 12px; flex-wrap: wrap; }
.pagination a, .pagination span.current, .pagination .gap { min-width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 6px; padding: 0 8px; }
.pagination a { border: 1px solid var(--border); color: var(--text); }
.pagination a:hover { border-color: var(--brand); text-decoration: none; }
.pagination span.current { background: var(--brand); color: #fff; }
.pagination-info { margin-right: auto; color: var(--text-3); font-size: 12.5px; padding: 12px; }

/* ---------- Filterleiste ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.filters .field { margin: 0; min-width: 140px; }
.filters .field label { font-size: 11.5px; }
.filters .input { padding: 6px 9px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12.5px; }
.chip.active { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }
a.chip:hover { text-decoration: none; border-color: var(--brand); }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--red); }
.field-help { font-size: 12px; color: var(--text-3); }
.field-error { font-size: 12px; color: var(--red); }
.has-error .input { border-color: var(--red); }
.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; min-height: 38px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.input[readonly], .input:disabled { background: var(--surface-3); color: var(--text-2); }
textarea.input { min-height: 80px; resize: vertical; }
select.input { padding-right: 28px; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .input-prefix + .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-suffix, .input-prefix { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text-3); font-size: 13px; }
.input-suffix { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-prefix { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-money { text-align: right; font-variant-numeric: tabular-nums; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; font-size: 14px; color: var(--text); min-height: 30px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-section { margin-bottom: 22px; }
.form-section > h3 { padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 10px; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; min-height: 36px;
  text-decoration: none !important; transition: background .15s, border-color .15s; line-height: 1.2;
}
.btn .icon { width: 16px; height: 16px; vertical-align: 0; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-link { background: none; border: 0; color: var(--brand); padding: 0; min-height: 0; font-weight: 500; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; min-height: 28px; }
.btn-lg { padding: 12px 20px; font-size: 15px; min-height: 46px; }
.btn-block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn + .btn { margin-left: -1px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-dark { background: var(--dark-bg); color: var(--dark); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; }
.nav-link .count { margin-left: auto; }

/* ---------- Hinweise ---------- */
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid transparent; font-size: 13.5px; align-items: flex-start; }
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.alert-error, .alert-danger { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.alert-warning { background: var(--orange-bg); color: var(--orange); border-color: color-mix(in srgb, var(--orange) 25%, transparent); }
.alert-info { background: var(--blue-bg); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.alert a { color: inherit; text-decoration: underline; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toasts .alert { box-shadow: var(--shadow-lg); margin: 0; animation: slidein .2s ease-out; }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs a, .tabs button { padding: 10px 14px; color: var(--text-2); border: 0; background: none; border-bottom: 2px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Dropdown & Modal ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; gap: 8px; align-items: center; width: 100%; padding: 8px 10px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-menu .divider { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-menu form { margin: 0; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,18,24,.5); z-index: 80; display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); }
.modal.modal-lg { max-width: 920px; }
.modal-header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; }
.modal-header .icon-btn { margin-left: auto; }
.modal-body { padding: 18px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Leerer Zustand, Zeitleiste ---------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty-state .icon-lg { color: var(--border-strong); margin-bottom: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ""; position: absolute; left: 8px; top: 22px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .tl-icon { position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--brand-100); color: var(--brand); display: grid; place-items: center; }
.timeline .tl-icon .icon { width: 11px; height: 11px; vertical-align: 0; }
.timeline .tl-meta { font-size: 12px; color: var(--text-3); }
.timeline .tl-body { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Kanban-Board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.board-col { flex: 0 0 280px; background: var(--surface-3); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.board-col-head { display: flex; justify-content: space-between; align-items: center; font-weight: 650; font-size: 13px; padding: 2px 4px 10px; }
.board-col.drag-over { outline: 2px dashed var(--brand); }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; font-size: 13px; }
.board-card:active { cursor: grabbing; }
.board-card.dragging { opacity: .5; }
.board-card .title { font-weight: 600; }
.board-card .meta { font-size: 12px; color: var(--text-3); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Galerie / Fotos ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery-item { position: relative; border-radius: 8px; overflow: hidden; background: var(--surface-3); aspect-ratio: 4/3; border: 1px solid var(--border); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item .gi-actions { position: absolute; inset: auto 0 0 0; display: flex; gap: 4px; padding: 6px; background: linear-gradient(transparent, rgba(0,0,0,.6)); opacity: 0; transition: opacity .15s; }
.gallery-item:hover .gi-actions, .gallery-item:focus-within .gi-actions { opacity: 1; }
.gallery-item .gi-actions .btn { background: rgba(255,255,255,.92); color: #111; border: 0; }
.gallery-item .gi-badge { position: absolute; top: 6px; left: 6px; }
.gallery-item.sortable-ghost { opacity: .4; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--text-3); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.over, .dropzone:hover { border-color: var(--brand); background: var(--brand-50); }
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.file-list li:last-child { border-bottom: 0; }
.file-list .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Fahrzeug-Kopf ---------- */
.vehicle-hero { display: grid; grid-template-columns: 280px 1fr; gap: 18px; }
.vehicle-hero .hero-img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); background: var(--surface-3); display: block; }
.vehicle-hero .hero-ph { width: 100%; aspect-ratio: 4/3; border-radius: var(--radius); background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.price-big { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: 13.5px; margin: 8px 0 12px; }
.facts span { display: inline-flex; gap: 6px; align-items: center; }
.margin-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.margin-box > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.margin-box .lbl { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.margin-box .val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.status-steps { display: flex; gap: 0; overflow-x: auto; margin: 6px 0 4px; }
.status-steps .step { flex: 1; min-width: 100px; text-align: center; font-size: 12px; padding: 8px 4px; position: relative; color: var(--text-3); border-bottom: 3px solid var(--border); }
.status-steps .step.done { color: var(--text-2); border-bottom-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.status-steps .step.current { color: var(--brand); font-weight: 700; border-bottom-color: var(--brand); }

/* ---------- Checkliste (Ankauf/Endkontrolle) ---------- */
.checklist-group { margin-bottom: 16px; }
.checklist-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rating { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.rating label { padding: 6px 10px; cursor: pointer; font-size: 12.5px; border-right: 1px solid var(--border-strong); user-select: none; }
.rating label:last-child { border-right: 0; }
.rating input { display: none; }
.rating input:checked + span { font-weight: 700; }
.rating label:has(input:checked) { background: var(--brand-50); color: var(--brand); }
.rating label.r-ok:has(input:checked) { background: var(--green-bg); color: var(--green); }
.rating label.r-warn:has(input:checked) { background: var(--orange-bg); color: var(--orange); }
.rating label.r-bad:has(input:checked) { background: var(--red-bg); color: var(--red); }

/* ---------- Unterschrift ---------- */
.signature-pad { border: 1px dashed var(--border-strong); border-radius: 8px; background: #fff; touch-action: none; width: 100%; height: 180px; display: block; }
.signature-wrap { position: relative; }
.signature-wrap .clear { position: absolute; top: 6px; right: 6px; }

/* ---------- Diagramme ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--chart-1); }
.chart-bar:hover { fill: var(--brand-600); }
.chart-line { stroke: var(--chart-1); stroke-width: 2.5; }
.chart-dot { fill: var(--surface); stroke: var(--chart-1); stroke-width: 2; }
.chart-axis { stroke: var(--border-strong); }
.chart-label { font-size: 11px; fill: var(--text-3); }
.chart-value { font-size: 10.5px; fill: var(--text-2); font-weight: 600; }
.chart-empty { color: var(--text-3); padding: 30px; text-align: center; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: minmax(80px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--chart-1); border-radius: 5px; }
.hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 60px; text-align: right; }
.progress { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }

/* ---------- Dokumentvorschau ---------- */
.doc-preview { background: #fff; color: #111; padding: 40px 48px; border-radius: 6px; box-shadow: var(--shadow); max-width: 820px; margin: 0 auto; font-size: 13.5px; }
.doc-preview h2 { font-size: 20px; } .doc-preview h3 { font-size: 15px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; }
.doc-table th, .doc-table td { border-bottom: 1px solid #ddd; padding: 6px 8px; text-align: left; }
.doc-table th { background: #f3f4f6; }
.doc-box { background: #f6f7f9; padding: 10px 12px; border-radius: 6px; margin: 8px 0; }
.doc-signatures { display: flex; gap: 30px; margin-top: 30px; flex-wrap: wrap; }
.doc-sign { flex: 1; min-width: 180px; font-size: 12px; }
.doc-sign .line { border-bottom: 1px solid #555; height: 40px; margin-bottom: 4px; }

/* ---------- Auth-Seiten ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(135deg, var(--brand-50), var(--bg)); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 30px; border: 1px solid var(--border); }
.auth-card.wide { max-width: 760px; }
.auth-card h1 { font-size: 21px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; font-size: 16px; }
.auth-logo .logo-dot { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.otp-input { font-size: 26px; letter-spacing: .4em; text-align: center; font-family: var(--mono); }
.qr-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr-box svg, .qr-box img { width: 180px; height: 180px; background: #fff; border-radius: 8px; padding: 6px; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: var(--mono); background: var(--surface-2); padding: 12px; border-radius: 8px; }

/* ---------- Offline / PWA ---------- */
.offline-banner { position: fixed; top: 0; left: 0; right: 0; background: var(--orange); color: #fff; text-align: center; padding: 6px; font-size: 13px; z-index: 200; display: none; }
body.is-offline .offline-banner { display: block; }
.sync-badge { display: none; }
body.has-pending .sync-badge { display: inline-flex; }

/* ---------- Druck ---------- */
@media print {
  .sidebar, .topbar, .page-header .actions, .no-print, .filters, .pagination { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}

/* ---------- Responsiv ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .layout-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main { margin-left: 0; }
  .topbar .menu-toggle { display: inline-grid; }
  .content { padding: 16px 14px 70px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-1-1 { grid-template-columns: 1fr; }
  .vehicle-hero { grid-template-columns: 1fr; }
  .user-menu .user-name { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; }
  .col-2, .col-3, .col-4 { grid-column: auto; }
  .page-header h1 { font-size: 19px; }
  .page-header .actions { width: 100%; margin-left: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 19px; }
  .card-body { padding: 14px; }
  .input { font-size: 16px; min-height: 44px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 32px; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 12px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--text-3); font-size: 12px; text-align: left; }
  .table.responsive td.num { text-align: right; }
  .global-search { max-width: none; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 8px; }
  .hbar-row { grid-template-columns: 90px 1fr auto; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ---------- Mobile Werkstatt-/Hofansicht ---------- */
.mobile-list .m-item { display: flex; gap: 12px; align-items: center; padding: 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.mobile-list .m-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.mobile-list .m-item .m-main { flex: 1; min-width: 0; }
.big-check { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; background: var(--surface); cursor: pointer; flex: none; color: transparent; }
.big-check.done { background: var(--green); border-color: var(--green); color: #fff; }
.timer-display { font-family: var(--mono); font-size: 20px; font-weight: 700; }

/* ---------- Ergänzungen ---------- */
dl.kv { margin: 0; }
@media (max-width: 640px) {
  .filters .field { flex: 1 1 45%; min-width: 0; }
  .filters .field[style*="flex:2"] { flex: 1 1 100%; }
}
.sidebar-brand .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- Hilfe (Knopf, Seitenfenster, Artikel) ---------- */
.help-btn { width: auto; padding: 0 10px; gap: 6px; grid-auto-flow: column; font: inherit; font-size: 13px; font-weight: 600; }
.page-help-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: 4px; vertical-align: middle; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-3); cursor: pointer; padding: 0; }
.page-help-btn:hover { color: var(--brand); border-color: var(--brand); }
.help-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 70; display: flex; flex-direction: column; transform: translateX(100%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
.help-drawer.open { transform: none; visibility: visible; }
.help-drawer [hidden] { display: none !important; }
@media (min-width: 761px) { .help-drawer { top: var(--topbar-h); z-index: 29; } } /* unter der oberen Leiste (z 30), damit deren Menüs darüber aufklappen */
.help-drawer-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.help-drawer-head strong { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; }
.help-drawer-search { display: flex; align-items: center; gap: 8px; margin: 10px 16px 0; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm, 8px); background: var(--surface-2); color: var(--text-3); }
.help-drawer-search input { flex: 1; border: 0; background: transparent; padding: 8px 0; font: inherit; color: var(--text); outline: none; min-width: 0; }
.help-drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; outline: none; }
.help-panel-title { font-size: 19px; margin: 2px 0 10px; }
.help-panel-more { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.help-panel-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.help-article { line-height: 1.6; }
.help-article > :first-child { margin-top: 0; }
.help-article h2 { font-size: 17px; margin: 22px 0 6px; }
.help-article h3 { font-size: 15px; margin: 16px 0 4px; }
.help-article h4 { font-size: 14px; margin: 12px 0 4px; }
.help-article p { margin: 0 0 10px; }
.help-article ul, .help-article ol { margin: 0 0 10px; padding-left: 20px; }
.help-article li { margin: 2px 0; }
.help-article .table-wrap { margin: 6px 0 12px; }
.help-article .help-table td, .help-article .help-table th { vertical-align: top; }
.help-callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin: 8px 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.help-callout .icon { flex: none; margin-top: 3px; }
.help-callout-tip { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.help-callout-tip .icon { color: var(--green); }
.help-callout-warn { background: var(--orange-bg, #fff4e5); border-color: color-mix(in srgb, var(--orange, #c2410c) 30%, transparent); }
.help-callout-warn .icon { color: var(--orange, #c2410c); }
.help-callout-info .icon { color: var(--brand); }
kbd { display: inline-block; min-width: 20px; padding: 1px 6px; border: 1px solid var(--border-strong, var(--border)); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 600 12px/1.5 var(--mono); text-align: center; color: var(--text); }
.help-search .card-body { gap: 10px; color: var(--text-3); }
.help-search .input { flex: 1; }
.help-topic-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.help-topic-list li { display: grid; gap: 1px; }
.help-topic-list a { font-weight: 600; }
.help-topic-list.compact { gap: 6px; }
.help-topic-list.compact a { font-weight: 500; }
.help-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.help-results .badge { margin-left: 6px; }
@media (max-width: 760px) { .help-btn-label { display: none; } .help-btn { width: 36px; padding: 0; } }
@media (prefers-reduced-motion: reduce) { .help-drawer { transition: none; } }
@media print {
  .help-drawer, .page-help-btn, .help-btn { display: none !important; }
  .help-article { font-size: 12pt; }
}
