:root {
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, "Roboto Mono", monospace;
  --bg: #f2f1ec; --surface: #fff; --surface-2: #f8f7f4; --surface-3: #eeece6;
  --ink: #17181b; --ink-2: #44464b; --muted: #7a7c80; --line: #dcd9d1; --line-2: #eae7e0;
  --accent: #d9531e; --accent-2: #b8431394; --accent-ink: #fff; --yellow: #f4c20d;
  --ok: #2c6b3b; --ok-bg: #e2eee0; --warn: #8a5800; --warn-bg: #f7ebcf; --bad: #a3261b; --bad-bg: #f7e0dc; --info: #24518f; --info-bg: #e2eaf6;
  --focus: #1f5fbf;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* Marke */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-box { background: var(--ink); color: #fff; font: 800 15px/1 var(--display); letter-spacing: .06em; padding: 7px 8px 6px; border-bottom: 3px solid var(--yellow); }
.brand-name { font: 600 15px var(--display); }
.brand-name small { display: block; font: 400 11px var(--sans); color: var(--muted); letter-spacing: .02em; }
.dark .brand-name small { color: #9a9b9f; }

/* Formulare */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; min-height: 40px; width: 100%; }
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input:focus, select:focus, textarea:focus { border-color: transparent; }
input[readonly] { background: var(--surface-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; color: var(--ink); cursor: pointer; }
label.check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--ink); }
.form-error { color: var(--bad); background: var(--bad-bg); padding: 9px 12px; border-radius: 4px; font-size: 13.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px; }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .spanall { grid-column: 1 / -1; }
.section { grid-column: 1 / -1; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line-2); padding-bottom: 5px; margin-top: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 7px 15px; border-radius: 4px; cursor: pointer; min-height: 40px; white-space: nowrap; text-decoration: none; }
.btn .ic { width: 17px; height: 17px; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 3px 11px; font-size: 13px; }
.btn.big { min-height: 52px; padding: 10px 24px; font-size: 16px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { border: 0; background: none; padding: 6px; border-radius: 4px; cursor: pointer; color: var(--muted); display: inline-flex; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.link { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

/* Tabellen, Panels */
.panel { background: var(--surface); border: 1px solid var(--line); }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.panel-head h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); }
.panel-head .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.panel-body { padding: 16px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
table.t th { text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tbody tr:hover td { background: #fbfaf7; }
table.t tr.clickable { cursor: pointer; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t td.actions { text-align: right; white-space: nowrap; }
table.t .empty { text-align: center; color: var(--muted); padding: 36px; }
.t-wrap { border: 1px solid var(--line); overflow: auto; background: var(--surface); }
.t-wrap table.t { border: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--surface); margin-bottom: 18px; }
.kpis > div { padding: 16px 18px; border-right: 1px solid var(--line-2); }
.kpis > div:last-child { border-right: 0; }
.kpis small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; }
.kpis strong { font: 500 28px/1.25 var(--display); font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 3px; white-space: nowrap; }
.tag.ok { color: var(--ok); background: var(--ok-bg); } .tag.warn { color: var(--warn); background: var(--warn-bg); } .tag.bad { color: var(--bad); background: var(--bad-bg); }
.tag.info { color: var(--info); background: var(--info-bg); } .tag.plain { color: var(--ink-2); background: var(--surface-3); } .tag.ink { color: #fff; background: var(--ink); }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--warn-bg); color: var(--warn); border-radius: 3px; font-size: 13.5px; }
.callout.info { background: var(--info-bg); color: var(--info); }
.callout.ok { background: var(--ok-bg); color: var(--ok); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.timeline li::after { content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li:first-child::before { background: var(--accent); box-shadow: 0 0 0 4px #d9531e22; }
.timeline b { display: block; font-weight: 600; }
.timeline small { color: var(--muted); }

/* App-Rahmen (Verwaltung, Versender) */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: #16171a; color: #d9d8d4; display: flex; flex-direction: column; padding: 18px 0 14px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 0 18px 16px; border-bottom: 1px solid #26272b; }
.side .brand-name { color: #fff; }
.side nav { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 1px; }
.side nav .grp { color: #5f6065; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; padding: 14px 10px 6px; }
.side nav a { display: flex; align-items: center; gap: 11px; color: #bdbcb8; text-decoration: none; padding: 8px 10px; border-radius: 3px; font-size: 14px; }
.side nav a .ic { width: 18px; height: 18px; color: #77787d; }
.side nav a:hover { background: #202125; color: #fff; }
.side nav a.active { background: #26272b; color: #fff; box-shadow: inset 2px 0 0 var(--yellow); }
.side nav a.active .ic { color: var(--yellow); }
.side .who { padding: 12px 18px 0; border-top: 1px solid #26272b; font-size: 13px; }
.side .who b { color: #fff; font-weight: 500; display: block; }
.side .who small { color: #7d7e82; }
.side .who .row { margin-top: 8px; gap: 14px; }
.side .who button { background: none; border: 0; color: #9d9ca0; padding: 0; cursor: pointer; text-decoration: underline; font-size: 12.5px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.head { display: flex; align-items: center; gap: 14px; padding: 14px 26px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.head h1 { font: 600 20px var(--display); }
.head .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page { padding: 22px 26px 60px; }
.menu-btn { display: none; }

/* Anmeldung */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--ink); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.auth-card h1 { font: 600 22px var(--display); }
.code-input { font: 500 26px var(--mono); letter-spacing: .4em; text-align: center; }
.qr { display: flex; justify-content: center; padding: 8px; background: #fff; border: 1px solid var(--line); }
.qr img { width: 190px; height: 190px; image-rendering: pixelated; }

/* Dialog, Toast */
.dlg { border: 0; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); border-radius: 6px; }
.dlg.wide { width: min(900px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(16, 17, 19, .55); }
.dlg header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; }
.dlg header h3 { font-size: 17px; }
.dlg-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 190px); overflow: auto; }
.dlg .form-error { margin: 0 20px 12px; }
.dlg footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 6px 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 4px; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }

/* Kamera-Scanner (Browser) */
.cam { position: fixed; inset: 0; background: #000; z-index: 200; display: flex; flex-direction: column; }
.cam video { flex: 1; object-fit: cover; width: 100%; min-height: 0; }
.cam .frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 22%; border: 3px solid var(--yellow); border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.cam .bar { padding: 14px; display: flex; justify-content: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .18s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .head { padding: 12px 16px; }
  .page { padding: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis > div:nth-child(2) { border-right: 0; }
  .kpis > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .t-wrap { overflow-x: auto; }
}

/* Preisvorschau */
.price-box:empty { display: none; }
.price-lines { display: grid; grid-template-columns: 1fr auto; gap: 3px 16px; background: var(--surface-2); border: 1px solid var(--line-2); padding: 12px 14px; font-variant-numeric: tabular-nums; }
.price-lines span:nth-child(even), .price-lines b:last-child { text-align: right; }
.price-lines b { border-top: 1px solid var(--line); padding-top: 5px; margin-top: 3px; }
/* Detailansicht */
.detail-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.proofs { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.proofs img { max-height: 90px; max-width: 180px; border: 1px solid var(--line); background: #fff; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.weights { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px 10px; align-items: end; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* Code-Beispiele (API-Doku) */
.codeblock { background: #17181b; color: #e9e6df; font: 12.5px/1.55 ui-monospace, Consolas, monospace; padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 6px 0 14px; border-radius: 2px; }
.api-doc h4 { margin: 16px 0 4px; font-size: 14px; }
.kpis span.muted { display: block; font-size: 12px; margin-top: 2px; }
