/* RS Voltec – eigenes Design nach Logo/Webseite: Schwarz + Blitz-Gelb */
:root {
  --ink: #111111;        /* Schwarz (Logo)   */
  --volt: #f5e11a;       /* Blitz-Gelb (Logo) – Schwarz darauf ≈ 15:1 */
  --volt-d: #d9c400;     /* Gelb dunkler (Hover/Rand) */
  --bg: #f4f4f1; --card: #ffffff; --line: #e1e1da; --field: #8c8c84;
  --t: #111111; --m: #55554f;                      /* Nebentext 7:1 */
  --ok: #1a7f37; --warn: #9a5b00; --warn-bg: #fff4cc; --err: #b42318; --err-bg: #fdecea;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--t); font-size: 16px; line-height: 1.4; }
.ic { width: 20px; height: 20px; flex: none; vertical-align: middle; }

/* ---------- Kopf ---------- */
.top { background: var(--card); display: flex; align-items: center; gap: 12px; padding: 8px 16px; position: sticky; top: 0; z-index: 10; border-bottom: 4px solid var(--volt); }
.logo { height: 30px; width: auto; display: block; }
.nav { display: flex; gap: 2px; margin-left: 12px; }
.nav a { color: var(--t); text-decoration: none; padding: 8px 12px; border-radius: 8px; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.nav a:hover { background: #f0f0ea; }
.nav a.active { background: var(--ink); color: var(--volt); }
.undo { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.sync { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 4px 10px; font: inherit; font-size: .82rem; color: var(--m); cursor: pointer; white-space: nowrap; }
.sync::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #9a9a92; }
.sync[data-s="ok"]::before { background: var(--ok); }
.sync[data-s="sync"]::before, .sync[data-s="pending"]::before { background: var(--volt-d); }
.sync[data-s="offline"]::before, .sync[data-s="signedout"]::before, .sync[data-s="nosheet"]::before { background: var(--warn); }
.sync[data-s="error"]::before { background: var(--err); }
.sync[data-s="signedout"], .sync[data-s="error"] { border-color: var(--ink); color: var(--ink); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
main > * { min-width: 0; }          /* nichts darf die Seite seitlich verbreitern */
td { overflow-wrap: anywhere; hyphens: auto; }
td.r, td:has(.stock), td:has(input.num) { overflow-wrap: normal; white-space: nowrap; }
section.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.hint { color: var(--m); font-size: .88rem; }
.err { color: var(--err); font-size: .88rem; margin: 4px 0 0; }
.err:empty { display: none; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.grow { flex: 1 1 180px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

label { display: block; font-size: .85rem; color: var(--m); margin-top: 10px; }
input, select, textarea { width: 100%; padding: 9px; border: 1px solid var(--field); border-radius: 8px; font: inherit; font-size: 16px; color: var(--t); background: #fff; margin-top: 3px; }
input[aria-invalid="true"] { border-color: var(--err); }
input.num { width: 76px; text-align: right; }
input:focus, select:focus { outline: 3px solid var(--volt); outline-offset: 0; border-color: var(--ink); }

/* ---------- Buttons ---------- */
.btn { background: var(--volt); color: var(--ink); border: 1px solid var(--volt-d); border-radius: 8px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 42px; }
.btn:hover { background: #ffe94a; }
.btn.dark { background: var(--ink); color: var(--volt); border-color: var(--ink); }
.btn.dark:hover { background: #2a2a2a; }
.btn.sec { background: #fff; color: var(--ink); border-color: var(--ink); font-weight: 500; }
.btn.sec:hover { background: #f4f4ef; }
.btn.ghost { background: none; border-color: transparent; font-weight: 500; }
.btn.ghost:hover { background: #f0f0ea; }
.btn.danger { color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: .9rem; min-height: 36px; }
.btn.icon { padding: 0; min-width: 40px; min-height: 40px; justify-content: center; }
.btn:disabled { opacity: .35; cursor: default; }
.btn:focus-visible, a:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- Tabellen / Listen ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: middle; }
th { font-size: .75rem; color: var(--m); text-transform: uppercase; letter-spacing: .04em; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover { background: #fafaf5; }
tr.group td { background: var(--ink); color: var(--volt); font-weight: 600; font-size: .85rem; padding: 6px 8px; border: 0; }
tr.sub td { background: #f0f0ea; font-weight: 600; font-size: .85rem; padding: 5px 8px; }
.ean { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; color: var(--m); }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 10px; font-size: .78rem; font-weight: 600; background: var(--warn-bg); color: var(--warn); white-space: nowrap; }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.ok { background: #e6f4ea; color: var(--ok); }
.badge .ic { width: 13px; height: 13px; }
.neg { color: var(--err); font-weight: 700; }
.stock { display: inline-flex; align-items: center; gap: 8px; }
.stock b { min-width: 34px; text-align: center; cursor: pointer; }
.empty { text-align: center; color: var(--m); padding: 24px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { border: 1px solid var(--ink); background: #fff; border-radius: 16px; padding: 4px 12px; font: inherit; font-size: .88rem; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--volt); }

/* ---------- Vorlagen-Fenster ---------- */
.total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; background: var(--ink); color: #fff; border-radius: var(--r); padding: 12px 16px; }
.total b { color: var(--volt); font-size: 1.5rem; }
.preview { white-space: pre-wrap; font-family: inherit; background: #fafaf5; border: 1px dashed var(--field); border-radius: 8px; padding: 10px 12px; margin: 0; font-size: .95rem; }
.changed { background: var(--warn-bg); }

/* ---------- Dialoge ---------- */
dialog { border: 0; border-radius: 12px; padding: 20px; width: min(540px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.35); border-top: 6px solid var(--volt); }
dialog::backdrop { background: rgba(0,0,0,.55); }
.videoBox { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; }
.videoBox video { width: 100%; height: 100%; object-fit: cover; }
.aim { position: absolute; left: 10%; right: 10%; top: 38%; bottom: 38%; border: 3px solid var(--volt); border-radius: 6px; }

.fab { display: none; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 14px 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; max-width: 92vw; display: flex; gap: 12px; align-items: center; border-left: 5px solid var(--volt); }
#toast.show { opacity: 1; pointer-events: auto; }
#toast button { background: none; border: 0; color: var(--volt); font: inherit; font-weight: 700; cursor: pointer; padding: 4px; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ---------- Handy ---------- */
@media (max-width: 760px) {
  .top { padding: 8px 12px; }
  .logo { height: 24px; }
  .sync .lbl { display: none; }
  .sync { padding: 8px 10px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; margin: 0; background: var(--ink); justify-content: space-around; padding: 4px 0 calc(4px + env(safe-area-inset-bottom)); z-index: 15; }
  .nav a { color: #cfcfc8; flex-direction: column; gap: 2px; font-size: .75rem; padding: 4px 8px; min-width: 64px; min-height: 50px; justify-content: center; }
  .nav a .ic { width: 24px; height: 24px; }
  .nav a.active { background: none; color: var(--volt); }
  main { padding: 10px 10px 160px; }
  section.card { padding: 12px; }
  .hide-sm { display: none !important; }
  .grid2 { grid-template-columns: 1fr; }
  th, td { padding: 7px 4px; }
  .stock { gap: 4px; }
  .stock b { min-width: 28px; }
  input.num { width: 58px; }
  .btn, .btn.icon { min-height: 44px; }
  .btn.icon { min-width: 44px; }
  .fab { display: flex; align-items: center; justify-content: center; position: fixed; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); width: 62px; height: 62px; border-radius: 50%; background: var(--ink); color: var(--volt); border: 3px solid var(--volt); box-shadow: 0 4px 14px rgba(0,0,0,.35); z-index: 20; cursor: pointer; }
  .fab .ic { width: 28px; height: 28px; }
  #toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
}
@media print { .top, .nav, .fab, .btn { display: none !important; } }
