:root {
  --ink: #14213d;
  --ink-2: #2b3a5c;
  --accent: #fca311;
  --accent-ink: #1a1300;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #dfe2e9;
  --line-strong: #c4c9d4;
  --text: #1b2130;
  --muted: #677086;
  --danger: #c0392b;
  --ok: #1e8a5a;
  --focus: #3d6bff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 14px rgba(20, 33, 61, .06);
  --tap: 48px;
  --sel: #14213d;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #0d1526;
    --ink-2: #1c2842;
    --bg: #0f1420;
    --surface: #171e2d;
    --surface-2: #1d2536;
    --line: #2a344a;
    --line-strong: #3a4661;
    --text: #e6e9f0;
    --muted: #97a0b5;
    --danger: #ff6b5b;
    --ok: #3ec98a;
    --focus: #7d9bff;
    --sel: #3b4f80;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
a { color: inherit; }
.muted { color: var(--muted); margin: .25rem 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* --- Brand / Topbar --- */
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: -.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 6 26 11v10l-10 5-10-5V11z' fill='none' stroke='%2314213d' stroke-width='2.4' stroke-linejoin='round'/%3E%3Cpath d='M6 11l10 5 10-5M16 16v10' fill='none' stroke='%2314213d' stroke-width='2.4' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat;
}
.brand-lg { font-size: 1.1rem; margin-bottom: 1.5rem; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem max(16px, env(safe-area-inset-right)) .65rem max(16px, env(safe-area-inset-left));
  background: var(--ink); color: #fff;
}
.mainnav { display: flex; gap: .25rem; margin-left: 1rem; flex: 1; }
.mainnav a {
  text-decoration: none; padding: .55rem 1rem; border-radius: 999px; color: rgba(255,255,255,.75); font-weight: 600;
  min-height: 40px; display: inline-flex; align-items: center;
}
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.mainnav a.is-active { background: rgba(255,255,255,.14); color: #fff; }
.topbar .btn-ghost { color: rgba(255,255,255,.85); border-color: rgba(255,255,255,.25); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.08); }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 16px 7rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: 0 1.25rem; border-radius: 10px;
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn-sm { min-height: 38px; padding: 0 .9rem; font-size: .92rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(.96); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost:disabled { opacity: .4; cursor: default; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-icon {
  flex: none; width: var(--tap); height: var(--tap); border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-size: 1.2rem; cursor: pointer; display: grid; place-items: center; text-decoration: none;
}
.btn-icon:hover { background: var(--surface-2); }

/* --- Page head / Toolbar --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-bottom: .9rem; }
.search { flex: 1 1 320px; }
.search input {
  width: 100%; min-height: var(--tap); padding: 0 1rem 0 2.6rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23677086' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 1rem center/18px no-repeat;
  color: var(--text); font: inherit;
}
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.chip {
  min-height: 40px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem;
}
.chip small { color: var(--muted); font-weight: 600; }
.chip.is-active { background: var(--sel); border-color: var(--sel); color: #fff; }
.chip.is-active small { color: rgba(255,255,255,.7); }

/* --- Adressliste --- */
.rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .8rem; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: .9rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); text-decoration: none; color: inherit; transition: border-color .15s, transform .15s;
  min-height: 110px; align-content: start;
}
.row:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.row.is-invalid { opacity: .62; }
.row-nr { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: .82rem; color: var(--muted); }
.row-title { grid-column: 1 / -1; font-weight: 700; font-size: 1.08rem; line-height: 1.25; overflow-wrap: anywhere; }
.row-sub { grid-column: 1 / -1; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.row-contact { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .2rem 1rem; font-size: .9rem; margin-top: .35rem; }
.row-contact span { overflow-wrap: anywhere; }
.badges { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: .74rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.badge-kat { background: color-mix(in srgb, var(--focus) 13%, transparent); border-color: transparent; color: var(--focus); }
.badge-bad { background: color-mix(in srgb, var(--danger) 13%, transparent); border-color: transparent; color: var(--danger); }
.badge-mail { background: color-mix(in srgb, var(--ok) 14%, transparent); border-color: transparent; color: var(--ok); }
.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* --- Form head --- */
.form-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.form-title { min-width: 0; }
.form-title h1 { overflow-wrap: anywhere; }
.back {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  text-decoration: none; font-size: 1.8rem; line-height: 1; border: 1px solid var(--line-strong); background: var(--surface);
}
.vnr {
  display: inline-block; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: .85rem;
  background: var(--ink); color: var(--accent); padding: .15rem .55rem; border-radius: 6px; margin-bottom: .3rem; letter-spacing: .04em;
}
.vnr.is-invalid { background: var(--danger); color: #fff; }

/* --- Tabs --- */
.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; padding: .35rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 1rem;
  position: sticky; top: 62px; z-index: 10; box-shadow: var(--shadow);
}
.tab {
  min-height: 52px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .5rem; position: relative; padding: 0 .4rem;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] { background: var(--sel); color: #fff; }
.tab-num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .82rem; flex: none;
  border: 2px solid currentColor;
}
.tab[aria-selected="true"] .tab-num { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: none; flex: none; }
.tab.has-error .tab-dot { display: block; }
.tab-mark { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.tab-short { display: none; }

/* --- Panels / Fields --- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow);
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem 1.4rem; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .4rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > span, .field > label, .field > legend { font-weight: 600; font-size: .9rem; color: var(--ink-2); padding: 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .field > span, :root:not([data-theme="light"]) .field > label, :root:not([data-theme="light"]) .field > legend { color: var(--muted); } }
.field > legend { margin-bottom: .4rem; }
.field small { color: var(--muted); font-size: .8rem; font-weight: 500; }
.field input, .field select, .master input {
  width: 100%; min-height: var(--tap); padding: 0 .9rem; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 1rem;
  appearance: none; -webkit-appearance: none;
}
.field input[type="date"] { display: block; line-height: var(--tap); }
.field select {
  padding-right: 2.4rem;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23677086' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right .8rem center/18px no-repeat;
}
.field input:focus, .field select:focus, .field textarea:focus, .master input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.field input.readonly { background: var(--surface-2); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; color: var(--muted); }
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: .82rem; font-weight: 600; }
.field textarea {
  width: 100%; padding: .8rem .9rem; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; resize: vertical; min-height: 280px; line-height: 1.5;
}
.field-group {
  margin: .4rem 0 -.3rem; padding-top: 1rem; border-top: 1px solid var(--line);
  font-weight: 700; font-size: 1rem;
}
.plz-ort { display: grid; grid-template-columns: minmax(90px, 1fr) 3fr; gap: .8rem; min-width: 0; }
.input-action { display: flex; gap: .5rem; }
.input-action input { flex: 1; min-width: 0; }
.affix { display: flex; align-items: stretch; }
.affix input { border-radius: 10px 0 0 10px; }
.affix-post {
  display: grid; place-items: center; padding: 0 .9rem; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 10px 10px 0; font-weight: 600; font-size: .9rem;
}
.quick { display: flex; gap: .4rem; flex-wrap: wrap; }
.quick button {
  min-height: 36px; min-width: 48px; padding: 0 .7rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.quick button.is-active { background: var(--sel); border-color: var(--sel); color: #fff; }
.ok-hint { color: var(--ok) !important; font-weight: 600 !important; }
.meta { font-size: .85rem; margin-top: 1rem; }

/* Ja/Nein */
.segmented { display: inline-grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; width: 100%; max-width: 280px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; min-height: var(--tap); font-weight: 700; color: var(--muted); background: var(--surface); cursor: pointer; }
.segmented label + label span { border-left: 1px solid var(--line-strong); }
.segmented input:checked + span { background: var(--sel); color: #fff; }
.segmented input[value="1"]:checked + span { background: var(--ok); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

/* Mehrfachauswahl (Stammdaten, Fahrausweis) */
.toggles { display: flex; flex-wrap: wrap; gap: .55rem; }
.toggle { position: relative; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.toggle span {
  display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); padding: 0 1.1rem 0 .9rem;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; cursor: pointer;
}
.toggle span::before {
  content: ""; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-strong); flex: none;
}
.toggle input:checked + span { border-color: var(--sel); background: var(--sel); color: #fff; }
.toggle input:checked + span::before {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314213d' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center/14px no-repeat;
}
.toggle input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.toggles-sm .toggle span { min-height: 42px; padding: 0 .9rem 0 .7rem; font-size: .92rem; }
.toggles-sm .toggle span::before { width: 16px; height: 16px; border-radius: 5px; }
.liste-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.liste-head a { font-size: .82rem; font-weight: 600; color: var(--focus); text-decoration: none; }
.liste-empty { color: var(--muted); font-size: .9rem; }

/* Action bar */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: flex; gap: .6rem; align-items: center;
  padding: .75rem max(16px, env(safe-area-inset-right)) calc(.75rem + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.actionbar .spacer { flex: 1; }
.actionbar .btn-primary { min-width: 150px; }

/* --- Stammdaten --- */
.master-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.master { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .6rem; }
.master h2 { margin: 0; }
.master-add { display: flex; gap: .4rem; }
.master-add input { min-height: 44px; }
.master-add .btn-icon { width: 44px; height: 44px; }
.master-list { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow: auto; border-top: 1px solid var(--line); }
.master-list li { display: flex; justify-content: space-between; align-items: center; gap: .4rem; padding: .3rem 0 .3rem .2rem; border-bottom: 1px solid var(--line); min-height: 48px; }
.m-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.m-use { color: var(--muted); font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .45rem; }
.m-btns { display: flex; gap: .1rem; flex: none; }
.master-list button { border: 0; background: transparent; color: var(--muted); width: 36px; height: 38px; border-radius: 8px; cursor: pointer; font-size: 1rem; }
.master-list button:hover { color: var(--focus); background: color-mix(in srgb, var(--focus) 10%, transparent); }
.master-list .m-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.master-list button:disabled, .master-list button:disabled:hover { opacity: .3; cursor: not-allowed; background: transparent; color: var(--muted); }
.m-edit { display: flex; gap: .4rem; align-items: center; width: 100%; }
.m-edit input { flex: 1; min-height: 40px; }
.master-list .m-save { background: var(--accent); color: var(--accent-ink); }

/* --- Auth --- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; padding: 2rem; display: flex; flex-direction: column; gap: 1rem; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card h1 { font-size: 1.4rem; }
.form-error { color: var(--danger); font-weight: 600; margin: 0; min-height: 1.2em; font-size: .92rem; }

/* --- Dialog / Toast --- */
dialog { border: 0; border-radius: 16px; padding: 1.5rem; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 16, 30, .5); }
dialog form { display: flex; flex-direction: column; gap: 1rem; }
dialog h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: .8rem 1.2rem; border-radius: 10px; font-weight: 600; z-index: 50;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* --- Responsive --- */
@media (max-width: 900px) {
  .tab-num { display: none; }
  .tab { font-size: .95rem; }
}
@media (max-width: 720px) {
  .grid, .grid-3 { grid-template-columns: 1fr; }
  .brand-text { display: none; }
  .topbar { gap: .4rem; }
  .mainnav { margin-left: 0; gap: 0; min-width: 0; }
  .mainnav a { padding: .5rem .7rem; font-size: .95rem; }
  .topbar .btn-sm { padding: 0 .65rem; font-size: .85rem; }
  #btn-pw { display: none; }
  .actionbar { gap: .4rem; }
  .actionbar .btn { padding: 0 .9rem; }
  .actionbar .btn-danger-ghost { padding: 0 .5rem; }
  #btn-prev, #btn-next { display: none; }
  .actionbar .btn-primary { min-width: 0; flex: 1; }
  h1 { font-size: 1.35rem; }
  .panel { padding: 1rem; }
  .tabs { top: 58px; gap: .2rem; padding: .25rem; }
  .tab { font-size: .82rem; gap: .25rem; padding: 0 .15rem; min-height: 46px; }
  .tab-long { display: none; }
  .tab-short { display: inline; }
  .segmented { max-width: none; }
  .rows { grid-template-columns: 1fr; }
}
.field-label { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .field-label { color: var(--muted); } }
.empty-full { grid-column: 1 / -1; text-align: center; }


/* ===================== Artikelverwaltung ===================== */
.btn:disabled { opacity: .4; cursor: not-allowed; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem 1.4rem; }
.field-spacer { min-height: 0; }
.field textarea.ta-sm { min-height: 90px; }
.field textarea.ta-md { min-height: 130px; }
.field input.num, .rabatt input.num { text-align: right; font-variant-numeric: tabular-nums; }
.field select:disabled { opacity: .6; }
.field-group small { font-weight: 600; }
.panel > .field-group:first-of-type { margin-top: 1.2rem; }
.panel > .field-group { margin: 1.4rem 0 .9rem; }
.panel > .grid + .grid { margin-top: 1.1rem; }
.chip-warn:not(.is-active) { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.tab-warn { background: var(--danger); }

/* Ja/Nein mit drei Feldern (Qualität A/B/C) */
.segmented-3 { grid-template-columns: repeat(3, 1fr); }
.segmented-3 input:checked + span { background: var(--sel); }
.grid-yn { grid-template-columns: repeat(4, 1fr); }
.grid-yn .segmented { max-width: none; }
.preise { margin-top: 1.4rem; }

/* Präfix «CHF» vor dem Eingabefeld */
.affix-pre .affix-post { order: -1; border-left: 1px solid var(--line-strong); border-right: 0; border-radius: 10px 0 0 10px; }
.affix-pre input { border-radius: 0 10px 10px 0; }

/* Liste (Tabelle, sortierbar) */
main:has(#view-list:not([hidden])), main:has(#view-lager:not([hidden])) { max-width: 1600px; }
.vt-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.vt-flat { box-shadow: none; }
.vt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.vt th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 0; border-bottom: 1px solid var(--line-strong); white-space: nowrap; z-index: 1; vertical-align: bottom; }
.vt th button, .vt th > span {
  display: flex; align-items: flex-end; gap: .3rem; width: 100%; min-height: 44px; padding: .45rem .55rem; border: 0; background: transparent;
  font: inherit; font-size: .78rem; font-weight: 700; color: var(--muted); cursor: pointer; text-align: left; line-height: 1.15;
}
.vt th > span { cursor: default; }
.vt th button:hover { color: var(--text); }
.vt th[aria-sort="ascending"] button, .vt th[aria-sort="descending"] button { color: var(--text); }
.vt th.c-num button, .vt th.c-num > span { justify-content: flex-end; }
.sort-ind { font-size: .7rem; opacity: .45; }
.vt th[aria-sort="ascending"] .sort-ind, .vt th[aria-sort="descending"] .sort-ind { opacity: 1; color: var(--focus); }
.vt td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.vt tbody tr { cursor: pointer; transition: background .1s; }
.vt tbody tr:hover, .vt tbody tr:focus-visible { background: color-mix(in srgb, var(--focus) 6%, transparent); outline: none; }
.vt tbody tr:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--focus); }
.vt tbody tr:last-child td { border-bottom: 0; }
.vt .c-nr { position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 1px 0 0 var(--line); }
.vt th.c-nr { background: var(--surface-2); z-index: 2; }
.vt tbody tr:hover td.c-nr { background: color-mix(in srgb, var(--focus) 6%, var(--surface)); }
.vt .c-nr a { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; text-decoration: none; color: var(--text); }
.vt td.c-bez { white-space: normal; min-width: 180px; max-width: 360px; }
.vt .c-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .86rem; }
.vt .c-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.vt .c-q { text-align: center; }
.vt .c-status .badge { font-size: .7rem; margin-right: .2rem; }
.vt td.is-warn { color: var(--danger); }
.vt td.is-warn::before { content: "▼ "; font-size: .7rem; }
.vt-empty { color: var(--line-strong); }
.q { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font-weight: 800; font-size: .8rem; }
.q-A { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.q-B { background: color-mix(in srgb, var(--accent) 22%, transparent); color: color-mix(in srgb, var(--accent) 55%, var(--text)); }
.q-C { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.empty-full { text-align: center; margin-top: 1rem; }
#list-empty, #lager-empty { margin-top: .5rem; }

/* Passend für Fahrzeugmodell */
.modelle { display: flex; flex-direction: column; gap: .7rem; }
.modell-tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.search-sm { flex: 1 1 260px; }
.search-sm input { min-height: 42px; }
.modell-tools .is-active { background: var(--sel); border-color: var(--sel); color: #fff; }
.modell-gruppen { display: flex; flex-direction: column; gap: .5rem; max-height: 460px; overflow: auto; padding: .1rem .2rem .1rem 0; }
.modell-gruppe { border: 1px solid var(--line); border-radius: 12px; padding: .6rem .75rem .75rem; background: var(--surface-2); }
.modell-gruppe.has-sel { border-color: color-mix(in srgb, var(--sel) 55%, var(--line)); }
.modell-reihe { display: flex; align-items: center; gap: .6rem; min-height: 40px; cursor: pointer; margin-bottom: .4rem; }
.modell-reihe input { width: 20px; height: 20px; accent-color: var(--sel); flex: none; margin: 0; }
.modell-reihe small { color: var(--muted); font-weight: 600; margin-left: .3rem; }
.modell-weg { cursor: default; color: var(--danger); }
.modell-gruppe .toggles-sm .toggle span { background: var(--surface); }
.modell-gruppe .toggles-sm .toggle input:checked + span { background: var(--sel); }
.inhalt-text { margin: -.3rem 0 0; font-size: .9rem; }

/* Rabattstufen */
.rabatt-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.rabatt-hint { font-size: .85rem; margin: -.4rem 0 .8rem; }
.rabatte { display: flex; flex-direction: column; gap: .6rem; }
.rabatt {
  display: grid; grid-template-columns: 76px 1fr 1fr 1.3fr 1.3fr var(--tap); gap: .4rem .7rem; align-items: end;
  padding: .75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
}
.rabatt.is-alt { opacity: .65; }
.rabatt.is-invalid { border-color: var(--danger); }
.rabatt .err { grid-column: 1 / -1; color: var(--danger); font-size: .82rem; font-weight: 600; }
.rabatt .field > span { font-size: .8rem; }
.r-info { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; }
.r-info:empty { display: none; }
.r-del { color: var(--muted); }
.r-del:hover { color: var(--danger); }

/* Lager-Reiter */
.stepper { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); }
.stepper input { border-radius: 0; text-align: center !important; font-weight: 700; }
.stepper button {
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.3rem; font-weight: 700; cursor: pointer;
}
.stepper button:first-child { border-radius: 10px 0 0 10px; border-right: 0; }
.stepper button:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.stepper button:hover { background: var(--line); }
.bestand { margin: 1.2rem 0 .4rem; }
.bestand-info { margin: .6rem 0 1.1rem; padding: .55rem .8rem; border-radius: 10px; font-weight: 600; font-size: .92rem;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.bestand-info.is-ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border-color: transparent; }
.bestand-info.is-warn { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: transparent; }
.lp-links { margin: -.4rem 0 0; font-size: .88rem; }
.lp-links a { color: var(--focus); font-weight: 600; text-decoration: none; }

/* Lager-Seite */
.subtabs { display: inline-flex; gap: .25rem; padding: .3rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 1rem; }
.subtab { min-height: 40px; padding: 0 1.1rem; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.subtab[aria-selected="true"] { background: var(--sel); color: #fff; }
.select-pill {
  min-height: var(--tap); padding: 0 2.4rem 0 1rem; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text); font: inherit;
  appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23677086' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right .8rem center/18px no-repeat;
}
.master-wide { max-width: 720px; }
.raum-add { display: grid; grid-template-columns: 90px 1fr auto; gap: .5rem; }
.raum-add input { min-height: var(--tap); }
.master-list .m-nr { font-weight: 700; width: 3.2rem; flex: none; }
.raum-edit input[name="nummer"] { flex: 0 0 80px; }
.lp-teile { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.lp-teile input { text-align: center; font-weight: 700; }
.lp-gross { font-size: 1.9rem; font-weight: 800; letter-spacing: .06em; color: var(--ink-2); padding: .2rem 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lp-gross { color: var(--accent); } }
.lp-artikel-panel { margin-top: 1rem; }
.lp-artikel-panel h2 small { font-weight: 600; }
.field-label a, .field small a { color: var(--focus); }

@media (max-width: 900px) {
  .grid-yn { grid-template-columns: 1fr 1fr; }
  .rabatt { grid-template-columns: 1fr 1fr; }
  .rabatt .r-del { justify-self: end; }
}
@media (max-width: 720px) {
  .tabs { top: 58px; }
  .grid-yn { grid-template-columns: 1fr 1fr; }
  .field-spacer { display: none; }
  .lp-teile { grid-template-columns: 1fr 1fr; }
  .lp-gross { font-size: 1.5rem; }
  #btn-copy { display: none; }
  .vt { font-size: .86rem; }
  .raum-add { grid-template-columns: 70px 1fr; }
  .raum-add .btn { grid-column: 1 / -1; }
  .toolbar .select-pill { flex: 1 1 100%; }
  #btn-desktop { display: none; }
  .mainnav { overflow-x: auto; scrollbar-width: none; }
  .mainnav a { padding: .5rem .55rem; }
}
a.brand { text-decoration: none; color: inherit; }
@media (max-width: 420px) {
  .topbar .brand { display: none; }
  .mainnav a { padding: .5rem .5rem; font-size: .92rem; }
}
