/* EcomPilot UI: bewusst nüchtern. Weiß, Grau, ein Blau. Keine Verläufe, kein Leuchten, keine Bewegung außer dem Ein- und Ausfahren von Panels.
   Regel: Wer es zum ersten Mal sieht, soll ohne Erklärung wissen, was er tun kann. Eine Hauptaktion je Seite. */

:root {
  --bg: #f6f7f9; --side-bg: #ffffff; --surface: #ffffff; --surface-2: #f3f4f6; --surface-3: #e9ebef;
  --line: #e5e7eb; --line-strong: #d1d5db; --ink: #111827; --ink-2: #374151; --muted: #6b7280; --faint: #9ca3af;
  --accent: #1d6fc1; --accent-hover: #155da6; --accent-deep: #155da6; --accent-soft: #e8f1fb; --accent-line: #bcd6f1; --accent-text: #14589c;
  --ring: rgba(29, 111, 193, .3); --focus: #1d6fc1;
  --radius: 12px; --r-md: 10px; --r-sm: 8px;
  --shadow-xs: none; --shadow-sm: none; --shadow-md: 0 8px 28px rgba(17, 24, 39, .14);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sb-w: 240px; --sb-w-rail: 68px; --tb-h: 56px;
  --grad: none; --glow: transparent;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f14; --side-bg: #11151b; --surface: #141920; --surface-2: #1a2029; --surface-3: #232a35;
    --line: #232a35; --line-strong: #323b49; --ink: #f3f4f6; --ink-2: #d1d5db; --muted: #9ca3af; --faint: #6b7280;
    --accent: #4da3f2; --accent-hover: #70b5f5; --accent-deep: #3d92e0; --accent-soft: rgba(77, 163, 242, .14); --accent-line: rgba(77, 163, 242, .35); --accent-text: #93c9f9;
    --ring: rgba(77, 163, 242, .4); --focus: #70b5f5;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f14; --side-bg: #11151b; --surface: #141920; --surface-2: #1a2029; --surface-3: #232a35;
  --line: #232a35; --line-strong: #323b49; --ink: #f3f4f6; --ink-2: #d1d5db; --muted: #9ca3af; --faint: #6b7280;
  --accent: #4da3f2; --accent-hover: #70b5f5; --accent-deep: #3d92e0; --accent-soft: rgba(77, 163, 242, .14); --accent-line: rgba(77, 163, 242, .35); --accent-text: #93c9f9;
  --ring: rgba(77, 163, 242, .4); --focus: #70b5f5;
}
body { font: 15px/1.55 var(--font); background: var(--bg); background-image: none; letter-spacing: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; }
.page, .toast, .pal, .ep-modal, .pop { animation: none !important; }

/* ===== Hülle ===== */
.shell { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; }
.shell.rail { grid-template-columns: var(--sb-w-rail) minmax(0, 1fr); }
.sb { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 14px 12px; background: var(--side-bg); border-right: 1px solid var(--line); z-index: 50; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; text-decoration: none; color: var(--ink); }
.sb-brand .brandmark { flex: none; box-shadow: none; }
.sb-brand .brand-text b { font-size: 1.1rem; }
.sb-brand .brand-text small { color: var(--muted); }
.sb-nav { display: grid; gap: 2px; }
.sb-item { position: relative; display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .95rem; border: 0; background: transparent; cursor: pointer; width: 100%; text-align: left; white-space: nowrap; }
.sb-item .ico { flex: none; color: var(--muted); }
.sb-item:hover { background: var(--surface-2); color: var(--ink); }
.sb-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.sb-item[aria-current="page"] .ico { color: var(--accent-text); }
.sb-item .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-item .badge { margin-left: auto; background: var(--ink); color: var(--bg); }
.sb-item .badge.alert { background: var(--bad-solid); color: #fff; animation: none; }
.sb-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.sb-grow { flex: 1; }
.sb-foot { display: grid; gap: 2px; }
.sb-mode { padding: 8px 12px; font-size: .78rem; font-weight: 650; color: var(--muted); white-space: nowrap; }
.sb-mode.demo { color: var(--warn); }
.shell.rail .sb { padding-inline: 10px; }
.shell.rail .sb-brand { justify-content: center; padding-inline: 0; }
.shell.rail .brand-text, .shell.rail .sb-item .lbl, .shell.rail .sb-mode { display: none; }
.shell.rail .sb-item { justify-content: center; padding: 0; }
.shell.rail .sb-item .badge { position: absolute; top: 2px; right: 4px; margin: 0; min-width: 17px; height: 17px; font-size: .62rem; padding: 0 4px; }
.shell.rail .sb-item:hover::after { content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: .82rem; font-weight: 600; white-space: nowrap; pointer-events: none; z-index: 90; }
.mainwrap { min-width: 0; display: flex; flex-direction: column; }
.tb { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; height: var(--tb-h); padding: 0 clamp(16px, 2.4vw, 32px); background: var(--bg); border-bottom: 1px solid var(--line); backdrop-filter: none; }
.tb .iconbtn { border-color: transparent; background: transparent; color: var(--muted); }
.tb .iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.tb-title { font-weight: 650; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb .grow { flex: 1; }
.tb-search { position: relative; width: min(380px, 40vw); }
.tb-search input { width: 100%; height: 38px; padding: 0 12px 0 38px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); }
.tb-search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.avatar-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-weight: 700; font-size: .85rem; cursor: pointer; }
.content { padding: 28px clamp(16px, 2.6vw, 40px) 80px; max-width: 1280px; width: 100%; outline: none; }
.sec-head h1 { margin: 0 0 2px; }
.sec-head p { margin: 0; color: var(--muted); }
.subnav { display: flex; gap: 2px; margin: 16px 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subnav a { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 11px 14px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; }
.subnav a:hover { color: var(--ink); }
.subnav a[aria-current="page"] { color: var(--ink); }
.subnav a[aria-current="page"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--accent); }
.subnav .cnt { font-size: .75rem; font-weight: 700; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); line-height: 20px; }
.subnav .cnt.alert { background: var(--bad-solid); color: #fff; }
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.snav { position: sticky; top: calc(var(--tb-h) + 20px); display: grid; gap: 1px; }
.snav h3 { margin: 14px 12px 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.snav h3:first-child { margin-top: 0; }
.snav a { display: block; padding: 8px 12px; border-radius: 8px; font-weight: 580; color: var(--ink-2); text-decoration: none; }
.snav a:hover { background: var(--surface-2); }
.snav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }

/* ===== Bausteine ===== */
.pagehead { margin-bottom: 22px; align-items: flex-start; gap: 14px; }
.pagehead h1 { margin: 0 0 3px; }
.pagehead p { margin: 0; color: var(--muted); }
.pagehead.compact { margin-bottom: 18px; align-items: center; }
.pagehead.compact h1 { font-size: 1.15rem; margin: 0; }
.helpbtn { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); cursor: pointer; vertical-align: middle; margin-left: 8px; padding: 0; }
.helpbox { margin: -8px 0 18px; padding: 14px 16px; border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--ink-2); }
.card { border-radius: var(--radius); padding: 22px; border: 1px solid var(--line); box-shadow: none; background: var(--surface); }
.card-hd h2 { font-size: 1.05rem; }
.card + .card { margin-top: 16px; }
.tile { padding: 20px 22px; }
.tile .label { font-size: .9rem; font-weight: 600; color: var(--muted); }
.tile .value { font-size: 2.4rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
table { font-size: .95rem; }
th { font-size: .76rem; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 12px 16px; background: transparent; border-bottom: 1px solid var(--line); text-transform: uppercase; }
td { padding: 14px 16px; border-bottom: 1px solid var(--line); }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.tablecard { padding: 0; overflow: hidden; }
.tablecard .tablewrap { margin: 0; padding: 0; }
.btn { height: 38px; min-height: 38px; padding: 0 16px; border-radius: 9px; font-weight: 620; font-size: .92rem; box-shadow: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: none; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #06121f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #06121f; } }
.btn.big { height: 48px; min-height: 48px; font-size: 1rem; padding: 0 22px; border-radius: 10px; }
.btn.small { height: 32px; min-height: 32px; padding: 0 12px; font-size: .86rem; }
.btn.danger-solid { background: var(--bad-solid); border-color: var(--bad-solid); color: #fff; }
input[type=text], input[type=number], input[type=email], input[type=password], input[type=search], input[type=date], select, textarea { border-radius: 9px; min-height: 40px; border-color: var(--line-strong); box-shadow: none; }
.chip { font-size: .78rem; padding: 1px 10px; min-height: 24px; border: 0; background: var(--surface-3); color: var(--ink-2); font-weight: 650; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.accent { background: var(--accent-soft); color: var(--accent-text); }
.chip-dot { display: none; }
.notice { border-radius: var(--r-md); }
.empty { border-radius: var(--radius); padding: 44px 20px; background: transparent; }
.empty-ico { background: var(--surface-3); color: var(--muted); }
.seg { background: var(--surface-3); border: 0; border-radius: 10px; padding: 3px; }
.seg button { border-radius: 8px; font-size: .9rem; padding: 7px 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: none; color: var(--ink); }
.seg .count { background: transparent; color: var(--muted); }
.seg .count.hot { background: var(--bad-solid); color: #fff; }
.filterbar { margin-bottom: 18px; }
.drawer { width: min(680px, 100vw); border-radius: 0; box-shadow: var(--shadow-md); animation: none; }
.drawer-head { padding: 16px 24px; backdrop-filter: none; background: var(--bg); }
.drawer-body { padding: 22px 24px 64px; }
.ep-modal { border-radius: 14px; }
.ep-modal-foot { border-radius: 0 0 14px 14px; }
.ep-backdrop, .drawer-backdrop, .pal-backdrop, .sheet-backdrop, .sb-backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; animation: none; }
.badge { background: var(--ink); color: var(--bg); }
.badge.alert { animation: none; background: var(--bad-solid); color: #fff; }
.meter { height: 8px; background: var(--surface-3); border: 0; }
.meter i { background: var(--accent); }
.pop { position: fixed; z-index: 230; min-width: 220px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; }
.pop-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; background: transparent; border-radius: 8px; font: inherit; font-weight: 580; color: var(--ink); cursor: pointer; text-align: left; text-decoration: none; }
.pop-item:hover { background: var(--surface-2); }
.pop-item small { display: block; color: var(--muted); font-weight: 500; font-size: .84rem; }
.pop-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.pop-hd { padding: 8px 12px 4px; font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.pop-user { padding: 8px 12px; } .pop-user b { display: block; } .pop-user span { color: var(--muted); font-size: .88rem; }

/* ===== Handy: Navigation schiebt von links herein ===== */
.sb-backdrop { display: none; }
@media (max-width: 960px) {
  .shell, .shell.rail { grid-template-columns: minmax(0, 1fr); }
  .sb { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-md); }
  .shell.nav-open .sb { transform: none; }
  .shell.nav-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: var(--scrim); }
  .shell.rail .brand-text, .shell.rail .sb-item .lbl, .shell.rail .sb-mode { display: revert; }
  .shell.rail .sb-item { justify-content: flex-start; padding: 0 12px; }
  .shell.rail .sb-item .badge { position: static; margin-left: auto; }
  .tb-search { flex: 1; width: auto; }
  .settings { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .snav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .snav h3 { display: none; }
  .snav a { border: 1px solid var(--line); background: var(--surface); }
  .content { padding-top: 18px; }
}
@media (min-width: 961px) { .only-mobile-nav { display: none !important; } }

/* Listenzeilen (Start, Einstellungen): links Text, rechts eine Aktion oder ein Status */
.todo { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.todo:last-child { border-bottom: 0; padding-bottom: 0; }
.todo-text { flex: 1; font-size: 1rem; }
.todo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: none; }
.todo-dot.bad { background: var(--bad-solid); } .todo-dot.warn { background: var(--warn-dot); }
.line { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; padding-bottom: 0; }
.demo-banner { padding: 6px 16px; font-size: .86rem; gap: 12px; justify-content: flex-start; flex-wrap: wrap; }
.demo-banner .btn { height: 26px; min-height: 26px; font-size: .78rem; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .g3 { grid-template-columns: 1fr; } .todo { flex-wrap: wrap; } }

.selbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px; border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.cell-sub.why { white-space: normal; max-width: 340px; margin-top: 3px; }

/* Bestellung ansehen */
.statusbox { padding: 16px 18px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 12px; }
.statusbox.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.statustext { font-size: 1.02rem; font-weight: 560; }
.dsec { display: grid; gap: 10px; }
.dsec h2 { font-size: .78rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 0; }
.dsec h3 { font-size: .85rem; margin: 0 0 4px; }
.artline { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.artline .qty { font-size: 1.15rem; }
.kv2 { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv2 > span { color: var(--muted); }
.more summary { cursor: pointer; font-weight: 650; color: var(--accent-text); }
.addr { padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-md); border: 1px solid var(--line); }

/* Dringend: eine Zeile je Bestellung */
.urgent { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto; gap: 16px; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.urgent:last-child { border-bottom: 0; }
.urgent-text { color: var(--muted); font-size: .92rem; margin-top: 3px; }
.urgent-age { font-size: 1.15rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .urgent { grid-template-columns: 1fr; gap: 8px; } .urgent-age { text-align: left; } }

/* Handy: Listen als Karten statt seitlich scrollender Tabelle */
@media (max-width: 700px) {
  table.m-cards, table.m-cards tbody, table.m-cards tr, table.m-cards td { display: block; width: 100%; }
  table.m-cards thead { display: none; }
  table.m-cards tr { padding: 12px 14px; border-bottom: 1px solid var(--line); position: relative; }
  table.m-cards tr:last-child { border-bottom: 0; }
  table.m-cards td { padding: 2px 0; border: 0; text-align: left !important; }
  table.m-cards td.actions { padding-top: 8px; }
  table.m-cards td.actions .table-actions { justify-content: flex-start; flex-wrap: wrap; }
  table.m-cards td:first-child:has(input[type=checkbox]) { position: absolute; right: 12px; top: 12px; width: auto; }
}

.only-m { display: none; }
@media (max-width: 700px) { .only-m { display: inline; } }

/* Versandboxen */
.boxgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 12px; }
.boxtile { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 0; overflow: hidden; }
.boxtile.full { border-color: var(--warn-line); }
.boxhead { display: grid; gap: 6px; width: 100%; text-align: left; padding: 14px; background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
div.boxhead { cursor: default; }
.boxcount strong { font-size: 1.6rem; }
.boxparcels { display: grid; gap: 6px; padding: 0 14px 14px; max-height: 280px; overflow: auto; }
.parcel { display: grid; gap: 1px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2, rgba(127,127,127,.08)); }
.notice.warn { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn); }

/* Auftragsprüfung im Drawer */
.finding { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 8px; }
.finding.stopp { border-color: var(--bad-line); background: var(--bad-soft); }
.finding.pruefen { border-color: var(--warn-line); background: var(--warn-soft); }
.finding .ftop { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.plan { margin: 6px 0 0; }
details.plan summary { cursor: pointer; font-weight: 600; }

/* Produktion (Büro) */
.prod-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.prod-card { display: grid; gap: 12px; align-content: start; }
.prod-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.prod-props { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.prod-prop { display: grid; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.prod-prop.wide { grid-column: 1 / -1; }

/* ===== Team & Zugänge ===== */
.otp { font-family: var(--mono); font-size: 1.7rem; font-weight: 700; letter-spacing: .06em; padding: 18px 16px; text-align: center; border-radius: var(--r-md); background: var(--surface-2); border: 1px dashed var(--line-strong); user-select: all; word-break: break-all; }
.role-legend { display: grid; gap: 6px; margin: 0 0 14px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); }
.role-legend > div { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: baseline; }
.team-notes { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 2px; }
/* Zeilen für Konten und Mitarbeiter: laufen bei schmaler Breite um, statt eine Tabelle zu quetschen */
.team-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.team-row:first-child { border-top: 0; }
.team-row .who { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.team-row .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.team-row .meta select { width: auto; min-width: 110px; }
.team-row .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.team-row.is-off .who { opacity: .65; }
@media (max-width: 640px) { .role-legend > div { grid-template-columns: 1fr; gap: 2px; } .otp { font-size: 1.25rem; } }

/* Passwortfeld mit Auge-Schalter (lib.js passwordField): Der Knopf sitzt im Feld, der Fokus ist sichtbar (globales :focus-visible) */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 46px; }
.pw-eye { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: var(--r-sm); cursor: pointer; padding: 0; }
.pw-eye:hover { color: var(--ink); background: var(--surface-2); }
.pw-eye[aria-pressed="true"] { color: var(--accent); }
