/* CRM – Oberfläche (mobil zuerst, White-Label über CSS-Variablen) */
:root {
  --navy: #0f2a4a;
  --navy-2: #173a63;
  --accent: #f5b301;
  --accent-ink: #3a2a00;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #142033;
  --ink-2: #4a5a70;
  --muted: #7a8799;
  --line: #e1e6ed;
  --line-2: #cfd7e2;
  --blue: #1d6fd8;
  --green: #138a52;
  --green-bg: #e6f6ee;
  --red: #c8302b;
  --red-bg: #fdecea;
  --amber: #b26a00;
  --amber-bg: #fff5e0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 2px 8px rgba(16, 32, 56, .05);
  --accent-hover: #ffc21f;
  --sidebar: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1520; --surface: #152131; --surface-2: #1a2839; --ink: #e6edf5; --ink-2: #b4c0cf; --muted: #8796a8;
    --line: #243447; --line-2: #2f4259; --green-bg: #0f2e22; --red-bg: #3a1716; --amber-bg: #33260b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ico.big { width: 44px; height: 44px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.lead { color: var(--ink-2); margin: 0 0 16px; }
.pre { white-space: pre-wrap; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.req { color: var(--red); }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--navy); color: #cfdbea;
  display: flex; flex-direction: column; z-index: 40; transform: translateX(-100%); transition: transform .2s ease;
  padding-top: env(safe-area-inset-top);
}
.sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
.backdrop { position: fixed; inset: 0; background: rgba(5, 15, 30, .45); z-index: 39; display: none; }
.backdrop.show { display: block; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; text-decoration: none !important; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--navy); display: grid; place-items: center; font-size: 20px; flex: none; }
.brand-mark .ico { width: 22px; height: 22px; }
.brand-mark.big { width: 52px; height: 52px; border-radius: 14px; font-size: 28px; }
.brand-mark.big .ico { width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text small { color: #9fb2c9; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; padding: 8px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.nav a, .nav-user a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: #cfdbea; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.active { background: color-mix(in srgb, var(--accent) 18%, transparent); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-user { display: flex; align-items: center; border-top: 1px solid rgba(255,255,255,.08); padding: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.nav-user > a:first-child { flex: 1; min-width: 0; }
.nav-user .who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.nav-user .who strong { color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-user .who small { color: #9fb2c9; font-size: 12px; }
.nav-user .logout { padding: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-2); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }

.main { min-width: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); min-height: 56px;
}
.topbar h1 { font-size: 18px; font-weight: 650; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; }
.topbar-actions .btn span { display: none; }
.content { padding: 14px; max-width: 1280px; margin: 0 auto; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: flex-end; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted);
  background: none; border: 0; padding: 4px 0; font-family: inherit; text-decoration: none !important; cursor: pointer;
}
.bottom-nav .ico { width: 22px; height: 22px; }
.bottom-nav .active { color: var(--navy); font-weight: 600; }
@media (prefers-color-scheme: dark) { .bottom-nav .active { color: var(--accent); } }
.bottom-nav .fab .ico { background: var(--accent); color: var(--navy); width: 44px; height: 44px; padding: 11px; border-radius: 50%; margin-top: -22px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }

@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .main { margin-left: var(--sidebar); padding-bottom: 40px; }
  .bottom-nav, .only-mobile, .backdrop { display: none !important; }
  .topbar { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); padding: 14px 28px; }
  .topbar h1 { font-size: 21px; }
  .topbar-actions .btn span { display: inline; }
  .content { padding: 24px 28px; }
}

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card-title { font-size: 16px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head .card-title { margin-bottom: 4px; }
.card-head h3 { font-size: 15px; }
.card-warn { border-color: #f0c36b; background: linear-gradient(var(--amber-bg), var(--amber-bg)); }
.card-ok { border-color: #9fd9bb; background: var(--green-bg); }
.card.empty { text-align: center; padding: 40px 16px; color: var(--ink-2); }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 10px; }
.grid-2 { display: grid; gap: 16px; margin-top: 16px; }
.grid-2.align-start { align-items: start; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.table-card { padding: 0; overflow: hidden; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none !important; white-space: nowrap; min-height: 40px; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { background: none; border: 0; color: inherit; padding: 8px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn .ico { width: 22px; height: 22px; }
form.inline { display: inline; }

/* Formulare */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 14px; }
.field { grid-column: span 12; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
@media (min-width: 700px) {
  .col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
  .col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; }
}
@media (max-width: 699px) { .col-2, .col-3 { grid-column: span 6; } }
.col-12 { grid-column: span 12; }
label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 9px 11px; min-height: 42px; transition: border-color .15s, box-shadow .15s;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--navy); flex: none; }
input[type=file] { padding: 7px; font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 111, 216, .18); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-2); }
textarea { resize: vertical; }
.input-sm { min-height: 34px; padding: 5px 9px; font-size: 14px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .unit { position: absolute; right: 10px; color: var(--muted); font-size: 13px; pointer-events: none; }
.input-wrap input:not(:placeholder-shown) ~ .unit { opacity: .9; }
.hint { color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); cursor: pointer; font-size: 14px; }
.field-check { justify-content: center; }
.check-row { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 12px; }
.check-grid { display: grid; gap: 8px; }
@media (min-width: 700px) { .check-grid { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(6px); padding: 10px 0; }
@media (min-width: 1024px) { .sticky-actions { bottom: 0; } }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; padding: 12px; }
.filters select { width: auto; flex: 1 1 160px; }
.search-box { position: relative; flex: 2 1 260px; }
.search-box .ico { position: absolute; left: 11px; top: 12px; color: var(--muted); }
.search-box input { padding-left: 36px; }
.file-current { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.logo-prev { max-height: 48px; max-width: 160px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }

/* Meldungen */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; border: 1px solid; font-size: 14px; }
.alert-success { background: var(--green-bg); border-color: #9fd9bb; color: var(--green); }
.alert-error { background: var(--red-bg); border-color: #f2b8b5; color: var(--red); }
.alert-warn { background: var(--amber-bg); border-color: #f0c36b; color: var(--amber); }
.alert-info { background: var(--surface-2); border-color: var(--line-2); color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Badges & Status */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); vertical-align: middle; }
.badge-red { background: var(--red-bg); color: var(--red); border-color: #f2b8b5; }
.badge-green { background: var(--green-bg); color: var(--green); border-color: #9fd9bb; }
.badge-blue { background: #e8f1fd; color: var(--blue); border-color: #b9d3f6; }
.role-admin { background: var(--navy); color: #fff; border-color: var(--navy); }
.status { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: #e8f1fd; color: var(--blue); white-space: nowrap; }
.progress { height: 5px; background: var(--line); border-radius: 9px; overflow: hidden; margin-top: 6px; min-width: 80px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #57b26a); border-radius: 9px; }
.progress.lg { height: 8px; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--line); color: var(--ink-2); font-size: 11.5px; text-align: center; font-weight: 600; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; text-decoration: none !important; color: var(--ink); border-top: 4px solid var(--navy); }
.stat.warn { border-top-color: var(--accent); } .stat.ok { border-top-color: var(--green); }
.stat-n { font-size: 30px; font-weight: 750; line-height: 1.1; }
.stat-l { color: var(--ink-2); font-size: 13px; }
.pipeline { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.pipe { flex: 0 0 118px; scroll-snap-align: start; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); text-decoration: none !important; min-height: 92px; }
.pipe.has { background: #fff8e1; border-color: #f0d27a; color: var(--ink); }
@media (prefers-color-scheme: dark) { .pipe.has { background: #33290d; border-color: #6b5413; } }
.pipe-n { font-size: 24px; font-weight: 750; }
.pipe-l { font-size: 12px; line-height: 1.3; }
.case-list { list-style: none; margin: 0; padding: 0; }
.case-list li + li { border-top: 1px solid var(--line); }
.case-list a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 2px; color: var(--ink); text-decoration: none !important; }
.case-list a:hover { background: var(--surface-2); }
.cl-main { display: flex; flex-direction: column; min-width: 0; }
.cl-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--surface-2); }
tr.inactive td { opacity: .55; }
.table .actions { white-space: nowrap; text-align: right; }
.spec { display: inline-block; margin-right: 10px; color: var(--ink-2); }
@media (max-width: 799px) {
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table.responsive td { display: flex; gap: 10px; padding: 3px 0; border: 0; }
  .table.responsive td::before { content: attr(data-l); flex: 0 0 34%; color: var(--muted); font-size: 12px; padding-top: 2px; }
  .table.responsive td.actions::before { content: ""; }
  .table.responsive td.actions { justify-content: flex-end; }
}
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 4px; }
.chips a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; font-weight: 600; font-size: 13.5px; text-decoration: none !important; }
.chips a.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chips a.active .count { background: rgba(255,255,255,.2); color: #fff; }

/* Vorgang */
.case-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.ch-title { display: flex; align-items: center; gap: 10px; }
.ch-title h2 { font-size: 20px; }
.ch-main p { margin: 4px 0 8px; font-size: 14px; }
.ch-status { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; margin: 0 -14px 14px; padding: 0 14px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; white-space: nowrap; color: var(--ink-2); font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; text-decoration: none !important; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
@media (min-width: 1024px) { .tabs { margin: 0 0 16px; padding: 0; } }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; align-items: center; gap: 12px; padding: 9px 0; position: relative; flex-wrap: wrap; }
.step + .step { border-top: 1px dashed var(--line); }
.step-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; flex: none; background: var(--surface); }
.step.done .step-dot { background: var(--green); border-color: var(--green); color: #fff; }
.step-dot .ico { width: 15px; height: 15px; }
.step-body { flex: 1; display: flex; flex-direction: column; min-width: 160px; }
.step-body strong { font-weight: 600; font-size: 14.5px; }
.step.done .step-body strong { color: var(--ink-2); }
.step-form { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.step-form input[type=date] { width: 150px; }
.missing { margin: 0; padding-left: 18px; font-size: 14px; columns: 1; }
.missing li { margin: 3px 0; }
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.danger-zone { border-style: dashed; }
details summary { cursor: pointer; color: var(--muted); }

.type-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .type-picker { grid-template-columns: repeat(4, 1fr); } }
.type-opt input { position: absolute; opacity: 0; }
.type-opt span { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border: 2px solid var(--line-2); border-radius: 12px; cursor: pointer; text-align: center; font-size: 14px; transition: all .15s; background: var(--surface); }
.type-opt span .ico { width: 30px; height: 30px; }
.type-opt input:checked + span { border-color: var(--navy); background: #eef3fa; box-shadow: 0 0 0 3px rgba(15, 42, 74, .1); }
@media (prefers-color-scheme: dark) { .type-opt input:checked + span { background: #1d3150; border-color: var(--accent); } }
.type-opt input:focus-visible + span { outline: 2px solid var(--blue); }
.type-picker.small span { padding: 8px 6px; font-size: 13px; }

/* Komponenten */
.comp-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.comp { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.comp-info { display: flex; flex-direction: column; gap: 2px; min-width: 200px; flex: 1; }
.comp-info .badge { align-self: flex-start; }
.comp-ctrl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.comp-ctrl .qty { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.comp-ctrl .qty input { width: 80px; min-height: 36px; }
.comp-note { width: 180px; min-height: 36px; font-size: 14px; }
.comp-add { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.comp-add .grow { flex: 1 1 280px; }
.comp-add .grow .input-sm { margin-bottom: 4px; }
.qty-field { width: 100px; }
.summary-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.summary-strip span { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 14px; }

/* Fotos */
.photo-cats { display: grid; gap: 12px; }
@media (min-width: 800px) { .photo-cats { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1300px) { .photo-cats { grid-template-columns: 1fr 1fr 1fr; } }
.photo-cat.is-missing { border-left: 4px solid var(--accent); }
.photo-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.photo-head h3 { font-size: 15px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-bottom: 10px; }
.thumb { position: relative; margin: 0; }
.thumb a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb figcaption { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.thumb-del { position: absolute; top: 3px; right: 3px; }
.thumb-del .icon-btn { background: rgba(0,0,0,.55); color: #fff; padding: 3px; border-radius: 50%; }
.thumb-del .icon-btn .ico { width: 14px; height: 14px; }
.file-ico { display: grid; place-items: center; height: 100%; color: var(--ink-2); }
.file-ico .ico { width: 30px; height: 30px; }
.upload-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload-form label.btn { color: var(--ink); font-weight: 600; }
.upload-progress { flex-basis: 100%; height: 6px; background: var(--line); border-radius: 9px; overflow: hidden; }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }

/* Unterlagen */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.doc-actions { display: flex; gap: 4px; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { padding: 7px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-list li:first-child { border-top: 0; }

/* Ausfüllhilfe */
.portal-card { margin-bottom: 14px; }
.hilfe-filter { margin-top: 10px; }
.hilfe-grid { display: grid; gap: 12px; }
@media (min-width: 900px) { .hilfe-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1400px) { .hilfe-grid { grid-template-columns: 1fr 1fr 1fr; } }
.copy-list { margin: 0; }
.copy-row { display: grid; grid-template-columns: minmax(110px, 42%) 1fr; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; align-items: center; }
.copy-row + .copy-row { border-top: 1px solid var(--line); }
.copy-row:hover, .copy-row:focus { background: #fff8e1; outline: none; }
@media (prefers-color-scheme: dark) { .copy-row:hover, .copy-row:focus { background: #33290d; } }
.copy-row dt { color: var(--muted); font-size: 13px; }
.copy-row dd { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; font-weight: 600; word-break: break-word; }
.copy-ico { color: var(--muted); opacity: .5; width: 15px; height: 15px; }
.copy-row.copied { background: var(--green-bg); }
.copy-row.copied .copy-ico { color: var(--green); opacity: 1; }

/* Verlauf */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.timeline li.note::before { background: var(--accent); }
.timeline li.note .tl-msg { background: var(--amber-bg); padding: 8px 10px; border-radius: 8px; }
.tl-meta { font-size: 12px; color: var(--muted); }
.tl-msg { font-size: 14px; }

/* Login / Gast */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, #1f4d82 0, transparent 60%), var(--navy); }
.login-wrap { width: 100%; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 400px; padding: 26px; }
.login-card.wide { max-width: 640px; }
.login-card > * + * { margin-top: 14px; }
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.login-brand h1 { font-size: 22px; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.syscheck { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); font-size: 14px; }
.syscheck .ok { color: var(--green); } .syscheck .bad { color: var(--red); }
.install-hint { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.install-hint h3 { font-size: 15px; margin-bottom: 4px; }

@media print {
  .sidebar, .bottom-nav, .topbar-actions, .tabs, .form-actions, .upload-form { display: none !important; }
  .main { margin: 0; }
}

/* ================= CRM-Erweiterungen ================= */
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.text-red { color: var(--red) !important; }
.text-green { color: var(--green) !important; }
.text-amber { color: var(--amber) !important; }
.strong { font-weight: 650; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; font: inherit; }
.badge-amber { background: var(--amber-bg); color: var(--amber); border-color: #f0c36b; }
.field-end { justify-content: flex-end; }
.is-active { background: var(--surface-2); }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 13px; }
.copy-line { display: block; word-break: break-all; padding: 8px 10px; margin: 6px 0; user-select: all; }

/* Branding */
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: #fff; display: grid; place-items: center; overflow: hidden; flex: none; }
.brand-logo img { max-width: 32px; max-height: 32px; object-fit: contain; }
.login-logo { max-height: 56px; max-width: 160px; object-fit: contain; }
.brand-preview { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 10px; background: var(--p); color: #fff; }
.brand-preview .btn-primary { background: var(--a); border-color: var(--a); }
.nav-search { padding: 0 12px 6px; }
.nav-search input { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; min-height: 36px; font-size: 14px; }
.nav-search input::placeholder { color: #9fb2c9; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }

/* Marge */
.margin { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.m-good { background: var(--green-bg); color: var(--green); }
.m-mid { background: var(--amber-bg); color: var(--amber); }
.m-bad { background: var(--red-bg); color: var(--red); }

/* Pipeline-Status */
.status.s-anfrage { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); }
.status.s-angebot { background: #eef0fd; color: #4b46c8; }
.status.s-auftrag { background: #e8f1fd; color: var(--blue); }
.status.s-bestellt, .status.s-lager { background: var(--amber-bg); color: var(--amber); }
.status.s-versand, .status.s-geliefert { background: #e7f4fb; color: #0b6a96; }
.status.s-berechnet { background: #f3e9fb; color: #7b3fb0; }
.status.s-bezahlt { background: var(--green-bg); color: var(--green); }
.status.s-lost { background: var(--red-bg); color: var(--red); }

.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.legend { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-left: 8px; }
.lg-bar { background: var(--navy); } .lg-bar2 { background: var(--line-2); } .lg-line { background: var(--accent); height: 3px !important; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--navy); }
.chart .bar2 { fill: var(--line-2); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart text { font-size: 11px; fill: var(--muted); }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { padding: 7px 0 7px 12px; border-left: 3px solid var(--line-2); margin-bottom: 4px; font-size: 14px; }
.todo li.t-red { border-left-color: var(--red); }
.todo li.t-amber { border-left-color: var(--accent); }

/* Stepper im Vorgang */
.pipeline-card { padding: 12px; margin-bottom: 14px; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; overflow-x: auto; scrollbar-width: thin; }
.stepper li { flex: 1 0 92px; position: relative; }
.stepper li::before { content: ""; position: absolute; top: 15px; left: -50%; right: 50%; height: 2px; background: var(--line-2); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper li.done::before, .stepper li.current::before { background: var(--green); }
.stepper form { margin: 0; }
.stepper button { position: relative; z-index: 1; width: 100%; background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 2px; font: inherit; color: var(--ink-2); }
.stepper button:disabled { cursor: default; }
.stepper .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line-2); font-size: 12px; font-weight: 700; }
.stepper .dot .ico { width: 15px; height: 15px; }
.stepper .done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.stepper .current .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.stepper .lbl { font-size: 11.5px; text-align: center; line-height: 1.2; }
.stepper .current .lbl { color: var(--ink); font-weight: 700; }
.next-step { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 9px 12px; border-radius: 9px; background: var(--amber-bg); color: var(--ink); font-size: 14px; }

/* Belegkette */
.chain { display: flex; flex-direction: column; gap: 8px; }
.chain-item { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--line-2); }
.chain-item.t-offer { border-left-color: #6b66e0; }
.chain-item.t-order { border-left-color: var(--blue); }
.chain-item.t-delivery { border-left-color: #0b8aa6; }
.chain-item.t-invoice { border-left-color: var(--green); }
.chain-item.t-credit { border-left-color: var(--red); }
.chain-item.is-void { opacity: .6; }
.chain-main { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--ink); text-decoration: none !important; flex-wrap: wrap; }
.chain-main .cl-main { flex: 1; min-width: 160px; }
.chain-main .cl-side { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.chain-ico { width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--surface); border: 1px solid var(--line); flex: none; }
.chain-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 10px 54px; }
.ship-row { padding: 6px 0; border-top: 1px dashed var(--line); font-size: 14px; }

/* Kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; scroll-snap-type: x proximity; }
.kcol { flex: 0 0 272px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 210px); scroll-snap-align: start; }
.kcol header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.kcol header .ksum { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.kcards { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; }
.kcol.drop .kcards { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 0 0 12px 12px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; box-shadow: var(--shadow); cursor: grab; }
.kcard.dragging { opacity: .5; }
.kcard-title { font-weight: 650; color: var(--ink); display: block; line-height: 1.3; }
.kcard-meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; font-weight: 600; }
.kcard-icons { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.kcard-icons .ico { width: 15px; height: 15px; }
.kcard-date { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kcard-date .ico { width: 13px; height: 13px; }
.kcard-move { margin-top: 8px; display: none; }
@media (hover: none), (max-width: 699px) { .kcard-move { display: block; } .kcol { flex-basis: 84vw; } }

/* Auswahl/Suche (Picker) */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 10px 30px rgba(10, 25, 45, .18); max-height: 380px; overflow-y: auto; }
.picker-list button { display: flex; width: 100%; text-align: left; gap: 10px; justify-content: space-between; align-items: center; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 9px 12px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.picker-list button:hover, .picker-list button.hl { background: var(--surface-2); }
.picker-list .pl-main { display: flex; flex-direction: column; min-width: 0; }
.picker-list .pl-main small { color: var(--muted); }
.picker-list .pl-side { text-align: right; white-space: nowrap; font-size: 13px; }
.picker-list .empty { padding: 12px; color: var(--muted); font-size: 14px; }
.article-search { display: flex; align-items: center; margin-bottom: 12px; }
.article-search > .ico { position: absolute; left: 11px; color: var(--muted); }
.article-search .picker-input { padding-left: 36px; }

/* Beleg-Editor */
.items { display: flex; flex-direction: column; }
.item-head, .item-row { display: grid; gap: 6px; align-items: start; grid-template-columns: 18px minmax(0, 1fr) 76px 58px 96px 64px 74px 92px 104px; }
.items.no-prices .item-head, .items.no-prices .item-row { grid-template-columns: 18px minmax(0, 1fr) 90px 70px 104px; }
.item-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--line); }
.item-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.item-row input, .item-row select, .item-row textarea { min-height: 36px; padding: 6px 8px; font-size: 14px; }
.item-row .drag { color: var(--line-2); padding-top: 8px; user-select: none; }
.item-row .i-wide { grid-column: 2 / -2; }
.item-row.k-title .i-name { font-weight: 700; }
.item-row.k-title { background: var(--surface-2); }
.i-sub { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.i-sku { width: 140px; min-height: 30px !important; font-size: 12.5px !important; }
.i-longtext { margin-top: 4px; }
.i-total { padding-top: 8px; font-weight: 650; }
.i-ctrl { display: flex; justify-content: flex-end; }
.i-ctrl .icon-btn { padding: 6px; color: var(--muted); }
.i-ctrl .icon-btn .ico { width: 17px; height: 17px; }
.i-info .margin { margin-left: 4px; }
@media (max-width: 899px) {
  .item-head { display: none; }
  .item-row, .items.no-prices .item-row { grid-template-columns: 1fr 1fr 1fr; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
  .item-row .drag { display: none; }
  .item-row .i-desc, .item-row .i-wide { grid-column: 1 / -1; }
  .item-row .i-ctrl { grid-column: 1 / -1; justify-content: space-between; }
  .item-row .i-total { text-align: right; }
}
.totals { margin-top: 14px; margin-left: auto; max-width: 380px; display: flex; flex-direction: column; gap: 4px; font-size: 14.5px; }
.totals > div { display: flex; justify-content: space-between; gap: 12px; }
.totals [data-t="taxes"] { flex-direction: column; gap: 4px; }
.totals [data-t="taxes"] > div { display: flex; justify-content: space-between; color: var(--ink-2); }
.totals .grand { border-top: 2px solid var(--ink); padding-top: 6px; font-size: 17px; }
.totals .muted { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 4px; }

/* Einkauf / Import / Kunden */
.po-items input { min-width: 70px; }
.table-scroll { overflow-x: auto; }
.import-preview th select { min-width: 150px; }
.import-preview td { white-space: nowrap; font-size: 13px; }
.import-preview tr.is-header td { background: var(--amber-bg); font-weight: 650; }
.addr-item { border-top: 1px solid var(--line); padding: 10px 0; }
.addr-item summary { color: var(--ink); }
.rule-add { border-top: 1px dashed var(--line); padding-top: 12px; }
.table td.num, .totals strong { white-space: nowrap; }
