:root {
  --bg: oklch(97.5% 0.004 180); --panel: oklch(100% 0 0); --panel-2: oklch(96% 0.006 180);
  --ink: oklch(22% 0.02 200); --ink-2: oklch(38% 0.015 200); --muted: oklch(52% 0.012 200);
  --line: oklch(90% 0.008 190); --line-2: oklch(84% 0.01 190);
  --brand: oklch(38% 0.07 185); --brand-2: oklch(31% 0.06 185); --brand-soft: oklch(94% 0.03 185); --on-brand: oklch(99% 0 0);
  --green: oklch(55% 0.15 150); --green-soft: oklch(94% 0.05 150);
  --yellow: oklch(72% 0.15 80); --yellow-soft: oklch(95% 0.06 90); --yellow-ink: oklch(42% 0.09 70);
  --red: oklch(55% 0.18 25); --red-soft: oklch(95% 0.03 25);
  --focus: oklch(55% 0.14 230);
  --font: ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 10px; --r-sm: 7px;
  --shadow: 0 1px 2px oklch(20% 0.02 200 / 0.06), 0 8px 24px oklch(20% 0.02 200 / 0.06);
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.boot { padding: 3rem; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 0.85rem; }
.hidden { display: none !important; }

/* Layout */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--brand-2); color: var(--on-brand); padding: 1.25rem 0.9rem; display: flex; flex-direction: column; gap: 0.25rem; position: sticky; top: 0; height: 100vh; }
.logo { font-weight: 700; font-size: 1.1rem; padding: 0.2rem 0.6rem 1.2rem; display: flex; gap: 0.5rem; align-items: center; }
.side a { color: oklch(92% 0.02 185); text-decoration: none; padding: 0.55rem 0.7rem; border-radius: var(--r-sm); display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: oklch(100% 0 0 / 0.08); }
.side a.active { background: oklch(100% 0 0 / 0.14); color: var(--on-brand); font-weight: 600; }
.side .count { background: oklch(100% 0 0 / 0.18); border-radius: 99px; padding: 0 0.5rem; font-size: 0.78rem; }
.side .spacer { flex: 1; }
.side button { background: none; border: 0; color: oklch(85% 0.02 185); text-align: left; padding: 0.55rem 0.7rem; cursor: pointer; border-radius: var(--r-sm); }
.side button:hover { background: oklch(100% 0 0 / 0.08); }
main.content { padding: 1.75rem 2rem 4rem; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin-right: auto; }

/* Cards & forms */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 0.9rem 1rem; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.88rem; }
a.stat:hover { border-color: var(--brand); }
label { display: block; font-weight: 600; margin: 0.9rem 0 0.35rem; font-size: 0.92rem; }
label:first-child { margin-top: 0; }
.hint { color: var(--muted); font-size: 0.84rem; font-weight: 400; margin: 0.25rem 0 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel); }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; margin: 0.4rem 0; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.row .grow { flex: 1 1 200px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.55rem 1rem; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; transition: background-color 120ms, border-color 120ms; }
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.big { padding: 0.8rem 1.2rem; font-size: 1rem; }
.btn.good { background: var(--green); border-color: var(--green); color: var(--on-brand); }
.btn.bad { color: var(--red); border-color: oklch(85% 0.06 25); }
.btn.bad:hover { background: var(--red-soft); }
.btn.ghost { background: none; border-color: transparent; color: var(--brand); padding-inline: 0.5rem; }
.btn.ghost:hover { background: var(--brand-soft); }

/* Chips (Branchen) */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { border: 1px solid var(--line-2); background: var(--panel); border-radius: 99px; padding: 0.3rem 0.75rem; cursor: pointer; font-size: 0.88rem; user-select: none; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; }
.seg label { margin: 0; font-weight: 500; padding: 0.45rem 0.9rem; cursor: pointer; border-right: 1px solid var(--line-2); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--brand-soft); color: var(--brand-2); font-weight: 700; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }

/* Searches */
.search-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.search-item:last-child { border-bottom: 0; }
.search-item .title { font-weight: 600; }
.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 0.4rem; grid-column: 1 / -1; }
.bar i { display: block; height: 100%; background: var(--brand); transition: transform 300ms; transform-origin: left; }
.status { font-size: 0.8rem; padding: 0.1rem 0.5rem; border-radius: 99px; background: var(--panel-2); color: var(--ink-2); }
.status.fertig { background: var(--green-soft); color: oklch(38% 0.1 150); }
.status.fehler { background: var(--red-soft); color: var(--red); }

/* Lead table */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.filters select, .filters input[type=search] { width: auto; min-width: 140px; padding: 0.45rem 0.6rem; }
.filters .check { margin: 0 0.4rem; font-size: 0.9rem; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.82rem; color: var(--muted); font-weight: 600; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; }
td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.lead { cursor: pointer; }
tr.lead:hover td { background: var(--panel-2); }
tr.lead.sel td { background: var(--brand-soft); }
tr.lead.done td { opacity: 0.6; }
td .name { font-weight: 600; }
td .reason { color: var(--ink-2); font-size: 0.87rem; max-width: 420px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.score { display: inline-grid; place-items: center; min-width: 2.6rem; height: 2rem; border-radius: var(--r-sm); font-weight: 800; font-variant-numeric: tabular-nums; }
.score.green { background: var(--green-soft); color: oklch(38% 0.12 150); box-shadow: inset 0 0 0 1px oklch(80% 0.08 150); }
.score.yellow { background: var(--yellow-soft); color: var(--yellow-ink); box-shadow: inset 0 0 0 1px oklch(85% 0.09 85); }
.score.red { background: var(--red-soft); color: var(--red); box-shadow: inset 0 0 0 1px oklch(86% 0.05 25); }
.score.none { background: var(--panel-2); color: var(--muted); }
.tag { display: inline-block; font-size: 0.78rem; padding: 0.08rem 0.5rem; border-radius: 99px; background: var(--panel-2); color: var(--ink-2); white-space: nowrap; }
.tag.k-none, .tag.k-down, .tag.k-parked { background: var(--red-soft); color: var(--red); }
.tag.k-social, .tag.k-baukasten, .tag.k-blocked { background: var(--yellow-soft); color: var(--yellow-ink); }
.tag.k-site { background: var(--green-soft); color: oklch(38% 0.1 150); }
.tag.s-interesse, .tag.s-angebot { background: var(--brand-soft); color: var(--brand-2); }
.tag.s-kunde { background: var(--green); color: var(--on-brand); }
.tag.s-abgesagt { background: var(--panel-2); color: var(--muted); text-decoration: line-through; }
.tag.s-nicht_relevant { background: var(--panel-2); color: var(--muted); }
.due { color: var(--red); font-weight: 600; }
.tag.due-tag { background: var(--red); color: var(--on-brand); }
.wv-note { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td .note-cell { color: var(--ink-2); font-size: 0.85rem; max-width: 240px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mob-notes { display: none; color: var(--ink-2); margin-top: 0.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.pick { display: none; width: 2.4rem; }
.editing .pick { display: table-cell; }
.pick input { width: 1.1rem; height: 1.1rem; margin: 0; }
tr.lead.picked td { background: var(--brand-soft); }
.bulkbar { position: sticky; top: 0.5rem; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 0.6rem 0.8rem; margin-bottom: 0.8rem; }
.bulkbar[hidden] { display: none; }
.bulkbar #pickedCount { font-weight: 600; margin-right: auto; }
.status-fix { margin-top: 0.9rem; padding-top: 0.8rem; border-top: 1px dashed var(--line); }
.wv-form { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 0.4rem; }
.wv-form .grow { flex: 1 1 14rem; }
.popup { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(0.96); opacity: 0; display: flex; align-items: center; gap: 0.7rem; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 18px 50px oklch(20% 0.02 200 / 0.25); padding: 1rem 1.3rem; font-weight: 600; z-index: 60; transition: opacity 180ms ease, transform 180ms ease; pointer-events: none; }
.popup svg { color: var(--green); flex: none; }
.popup.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tag.s-nicht_erreicht { background: var(--yellow-soft); color: var(--yellow-ink); }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* Detail drawer */
.drawer { position: fixed; inset: 0 0 0 auto; width: min(760px, 100vw); background: var(--bg); border-left: 1px solid var(--line); box-shadow: -12px 0 40px oklch(20% 0.02 200 / 0.12); overflow-y: auto; z-index: 20; transform: translateX(0); transition: transform 200ms ease; }
.drawer.closed { transform: translateX(105%); }
.drawer-head { position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; z-index: 2; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.9rem; align-items: center; }
.drawer-head .score { width: 3.4rem; height: 3.4rem; font-size: 1.3rem; }
.drawer-head h2 { font-size: 1.25rem; overflow-wrap: anywhere; }
.drawer-body { padding: 1.25rem; display: grid; gap: 1rem; }
.drawer .card { margin: 0; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 0.35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.phone-big { font-size: 1.35rem; font-weight: 800; text-decoration: none; color: var(--ink); }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; margin-bottom: 1rem; }
.steps div { text-align: center; font-size: 0.82rem; padding: 0.4rem; border-radius: var(--r-sm); background: var(--panel-2); color: var(--muted); }
.steps div.on { background: var(--brand-soft); color: var(--brand-2); font-weight: 700; }
.steps div.done { background: var(--green-soft); color: oklch(38% 0.1 150); }
.actions-big { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.reasons { margin: 0; padding-left: 1.2rem; }
.reasons li { margin-bottom: 0.4rem; }
.opener { background: var(--panel-2); border-radius: var(--r-sm); padding: 0.75rem 0.9rem; font-style: normal; margin: 0.75rem 0 0; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: grid; grid-template-columns: 1.4rem minmax(0, 1fr); gap: 0.4rem; padding: 0.3rem 0; border-bottom: 1px dashed var(--line); }
.ok { color: var(--green); font-weight: 800; } .no { color: var(--red); font-weight: 800; } .na { color: var(--muted); }
.parts { font-size: 0.86rem; color: var(--ink-2); margin: 0.6rem 0 0; padding-left: 1.1rem; }
.shot { max-width: 220px; border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 0.6rem; }
.events { list-style: none; margin: 0; padding: 0; font-size: 0.88rem; }
.events li { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.thumbs figure { margin: 0; position: relative; }
.thumbs img { width: 92px; height: 92px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.thumbs button { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 99px; width: 24px; height: 24px; background: oklch(20% 0 0 / 0.7); color: var(--on-brand); cursor: pointer; line-height: 1; }
.callout { background: var(--yellow-soft); border: 1px solid oklch(88% 0.07 85); border-radius: var(--r-sm); padding: 0.7rem 0.9rem; font-size: 0.9rem; color: var(--yellow-ink); }
.callout.info { background: var(--brand-soft); border-color: oklch(88% 0.04 185); color: var(--brand-2); }
.spin { display: inline-block; width: 0.9em; height: 0.9em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 700ms linear infinite; vertical-align: -0.1em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--brand-2); }
.auth .card { width: min(420px, 100%); padding: 2rem; }
.auth h1 { margin-bottom: 0.4rem; }
.auth .btn { width: 100%; margin-top: 1.25rem; }
.err { color: var(--red); font-size: 0.9rem; min-height: 1.2em; margin: 0.6rem 0 0; }

#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(150%); background: var(--ink); color: var(--on-brand); padding: 0.7rem 1.1rem; border-radius: var(--r-sm); box-shadow: var(--shadow); z-index: 50; transition: transform 200ms ease; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 0.6rem; }
  .side .logo { padding: 0.4rem 0.6rem; } .side .spacer { display: none; }
  main.content { padding: 1rem; }
  .grid-2, .stats { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-hide { display: none; }
  .mob-notes { display: block; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

.side .logo .spur { color: #FB923C; }
.auth-logo { margin: 0 0 0.5rem; line-height: 0; }
.auth-logo img { width: min(100%, 320px); height: auto; }
