/* ── Marken-Tokens (identisch zum Orga-Dashboard) ── */
:root {
  --gruen:     #3a7d44;
  --gruen-d:   #2a5c32;
  --gruen-l:   #5aab67;
  --gruen-xl:  #e8f5ea;
  --gruen-xxl: #f3faf4;
  --gelb:      #f4a435;
  --gelb-xl:   #fdf0dc;
  --rot:       #d9534f;
  --rot-xl:    #fbeaea;
  --blau:      #3a7db0;
  --bg:        #f7f9f7;
  --card:      #ffffff;
  --border:    #ddeedd;
  --text:      #1e2e20;
  --muted:     #5f7a62;
  --grau-xl:   #eef1ee;
  --fn: 'Nunito', system-ui, sans-serif;
  --fl: 'Lora', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--fn); background: var(--bg); color: var(--text);
  font-size: 17px; line-height: 1.5; min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

/* ── Topbar ── */
.topbar {
  background: var(--gruen-d); color: #fff; padding: 0 1.25rem; min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.topbar-brand { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; }
.topbar-icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--rot);
  display: grid; place-items: center; font-weight: 900; font-size: 1.2rem;
}
.topbar-title { font-family: var(--fl); font-size: 1.2rem; font-weight: 600; line-height: 1.2; }
.topbar-sub { font-size: .8rem; opacity: .75; }
.topbar-right { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; flex-wrap: wrap; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.1); color: #fff; font-size: 1.3rem;
}
.icon-btn:hover { background: rgba(255,255,255,.2); }

/* Segment-Schalter */
.seg { display: inline-flex; background: rgba(0,0,0,.2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  border: 0; background: transparent; color: #fff; padding: .45rem .9rem; border-radius: 9px;
  font-weight: 700; font-size: .92rem;
}
.seg button[aria-checked="true"] { background: #fff; color: var(--gruen-d); }
.seg-small { background: var(--grau-xl); }
.seg-small button { color: var(--text); padding: .4rem .8rem; }
.seg-small button[aria-checked="true"] { background: var(--gruen); color: #fff; }

/* ── Layout ── */
.wrap { max-width: 860px; margin: 0 auto; padding: 1.25rem 1rem 3rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.1rem 1.25rem; box-shadow: 0 1px 3px rgba(30,46,32,.04);
}
.step { display: grid; grid-template-columns: 40px 1fr; gap: 1rem; }
.step-no {
  width: 40px; height: 40px; border-radius: 50%; background: var(--gruen-xl); color: var(--gruen-d);
  display: grid; place-items: center; font-weight: 900; font-size: 1.15rem;
}
.step-body { min-width: 0; }
.step-title { font-weight: 800; font-size: 1.1rem; margin-bottom: .5rem; display: block; }

/* 1 · Scannen */
.scan-row { display: flex; align-items: center; gap: .75rem; }
.ean-input {
  flex: 1; min-width: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: .06em;
  padding: .55rem .8rem; border: 2px solid var(--border); border-radius: 12px; background: var(--gruen-xxl);
  font-variant-numeric: tabular-nums;
}
.ean-input:focus { outline: none; border-color: var(--gruen); background: #fff; }
.ean-input.bad { border-color: var(--rot); background: var(--rot-xl); }
.led { width: 16px; height: 16px; border-radius: 50%; background: var(--grau-xl); border: 2px solid var(--border); flex: none; }
.led.on { background: var(--gruen-l); border-color: var(--gruen); box-shadow: 0 0 0 6px rgba(90,171,103,.25); }
.led.err { background: var(--rot); border-color: var(--rot); box-shadow: 0 0 0 6px rgba(217,83,79,.25); }
.artikel { margin-top: .6rem; font-size: 1.15rem; font-weight: 700; }
.artikel .src { font-size: .82rem; font-weight: 600; color: var(--muted); margin-left: .35rem; }
.artikel.warn { color: #9a5b00; }
.artikel.err { color: var(--rot); }

/* 2 · Preis */
.price-row { display: flex; gap: 1.25rem; align-items: end; flex-wrap: wrap; }
.price-field { display: grid; gap: .2rem; font-size: .85rem; color: var(--muted); font-weight: 700; }
.price-wrap { display: inline-flex; align-items: center; gap: .4rem; }
.price-wrap input {
  width: 9ch; font-size: 1.9rem; font-weight: 800; text-align: right; color: var(--text);
  padding: .3rem .6rem; border: 2px solid var(--border); border-radius: 12px; font-variant-numeric: tabular-nums;
}
.price-wrap input:focus { outline: none; border-color: var(--gruen); }
.price-wrap b { font-size: 1.5rem; color: var(--text); }
.vat { display: grid; gap: .2rem; font-size: .85rem; color: var(--muted); font-weight: 700; }
.hint { min-height: 1.3em; font-size: .88rem; color: var(--muted); margin: .3rem 0 .6rem; }
.pct-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .6rem; }
.pct-grid button {
  border: 2px solid var(--border); background: #fff; border-radius: 14px; padding: .9rem .2rem;
  font-size: 1.45rem; font-weight: 900; color: var(--rot); font-variant-numeric: tabular-nums;
  transition: transform .06s, background .1s;
}
.pct-grid button:hover { border-color: var(--rot); }
.pct-grid button:active { transform: scale(.97); }
.pct-grid button[aria-checked="true"] { background: var(--rot); border-color: var(--rot); color: #fff; }
.result {
  margin-top: .9rem; display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.result .old { text-decoration: line-through; color: var(--muted); font-size: 1.3rem; }
.result .arrow { color: var(--muted); }
.result .new { font-size: 2.2rem; font-weight: 900; color: var(--gruen-d); }
.result .save { font-size: .95rem; color: var(--muted); }

/* 3 · Vorschau */
.preview-stage {
  background: repeating-linear-gradient(45deg, var(--grau-xl) 0 10px, #f6f8f6 10px 20px);
  border-radius: 12px; padding: 1.25rem; display: grid; place-items: center; overflow: hidden;
}
.preview { transform-origin: center; }
.preview .label { box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.preview .placeholder { color: var(--muted); font-weight: 700; padding: 1.5rem; text-align: center; }
.msg { min-height: 1.4em; margin: .6rem 0; font-weight: 700; font-size: .95rem; }
.msg.ok { color: var(--gruen); }
.msg.err { color: var(--rot); }
.print-row { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.count { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--muted); }
.count button {
  width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--border); background: #fff;
  font-size: 1.3rem; font-weight: 800; color: var(--text);
}
.count output { min-width: 1.6ch; text-align: center; font-size: 1.3rem; color: var(--text); font-weight: 900; }
.btn-print {
  border: 0; background: var(--gruen); color: #fff; font-size: 1.3rem; font-weight: 900;
  padding: .85rem 1.6rem; border-radius: 14px; display: inline-flex; align-items: center; gap: .7rem;
}
.btn-print:hover:not(:disabled) { background: var(--gruen-d); }
.btn-print:disabled { background: var(--grau-xl); color: var(--muted); cursor: not-allowed; }
kbd {
  font-family: inherit; font-size: .75rem; font-weight: 800; padding: .1rem .45rem;
  border-radius: 6px; background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.35);
}
.btn-print:disabled kbd { background: transparent; border-color: var(--border); }

/* Protokoll */
.log-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.log-head .step-title { margin: 0; }
.log-actions { display: flex; gap: .5rem; }
.pill { display: inline-block; background: var(--gruen-xl); color: var(--gruen-d); border-radius: 99px; padding: 0 .55rem; font-size: .85rem; }
.btn-ghost {
  border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: .45rem .8rem;
  font-weight: 700; font-size: .9rem; color: var(--gruen-d); display: inline-block;
}
.btn-ghost:hover { background: var(--gruen-xxl); }
.btn-ghost.danger { color: var(--rot); }
.btn-primary { border: 0; background: var(--gruen); color: #fff; border-radius: 10px; padding: .5rem 1.1rem; font-weight: 800; }
.table-wrap { overflow-x: auto; }
.log { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.log th { text-align: left; color: var(--muted); font-weight: 700; border-bottom: 2px solid var(--border); padding: .35rem .4rem; white-space: nowrap; }
.log td { border-bottom: 1px solid var(--grau-xl); padding: .35rem .4rem; white-space: nowrap; }
.log td:nth-child(2) { white-space: normal; min-width: 12ch; }
.log .r { text-align: right; }
.log .empty td { color: var(--muted); text-align: center; padding: 1rem; }
.foot { text-align: center; }

/* Einstellungen */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(30,46,32,.45); }
.settings { padding: 1.25rem 1.4rem; display: grid; gap: 1rem; }
.settings h2 { font-family: var(--fl); font-weight: 600; }
.settings fieldset { border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem 1rem; display: grid; gap: .6rem; }
.settings legend { font-weight: 800; padding: 0 .35rem; }
.settings legend small { font-weight: 600; color: var(--muted); }
.settings label { display: grid; gap: .2rem; font-size: .85rem; font-weight: 700; color: var(--muted); }
.settings input, .settings select {
  border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; color: var(--text);
  font-size: 1rem; background: #fff; min-width: 0;
}
.settings label.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--text); }
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.settings-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.settings-actions .spacer { flex: 1; }
.btn-ghost.file { cursor: pointer; }

@media (max-width: 620px) {
  .step { grid-template-columns: 1fr; }
  .step-no { display: none; }
  .pct-grid { grid-template-columns: repeat(3, 1fr); }
  .grid5 { grid-template-columns: repeat(3, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .seg button { padding: .4rem .6rem; font-size: .82rem; }
}

/* ═════════════ ETIKETT (Bildschirm-Vorschau und Druck, Maße in mm) ═════════════ */
.label {
  background: #fff; color: #000; overflow: hidden; position: relative;
  font-family: 'Nunito', 'Arial Narrow', Arial, sans-serif; line-height: 1.05;
  /* Breite/Höhe setzt app.js inline aus den Einstellungen */
  padding: 1mm 2mm;
}
.label .bc { display: block; }

/* Preis-Barcode: links Rabatt + Preis, rechts der neue Code */
.label-b { display: grid; grid-template-columns: 1fr auto; grid-template-rows: 1fr auto; column-gap: 1mm; }
.label-b .lb-left { display: flex; flex-direction: column; justify-content: center; gap: .6mm; min-width: 0; }
.label-b .badge {
  align-self: flex-start; background: #000; color: #fff; font-weight: 900; font-size: 4.2mm;
  padding: .5mm 1.4mm; border-radius: 1.2mm; white-space: nowrap;
}
.label-b .statt { font-size: 2.6mm; font-weight: 700; }
.label-b .statt s { text-decoration-thickness: .3mm; }
.label-b .neu { font-size: 6mm; font-weight: 900; white-space: nowrap; letter-spacing: -.02em; }
.label-b .lb-code { align-self: center; justify-self: end; }
.label-b .lb-foot {
  grid-column: 1 / -1; font-size: 2mm; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-top: .2mm solid #000; padding-top: .4mm;
}

/* Artikel + Rabatt-Code: zwei Codes übereinander, klar getrennt */
.label-a { display: flex; flex-direction: column; gap: 1mm; }
.label-a .la-name { font-size: 3mm; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-a .la-block { display: grid; grid-template-columns: 7mm 1fr; align-items: center; }
.label-a .la-no {
  width: 5.5mm; height: 5.5mm; border-radius: 50%; border: .4mm solid #000; display: grid; place-items: center;
  font-weight: 900; font-size: 3.2mm;
}
.label-a .la-cap { font-size: 2.5mm; font-weight: 800; margin-bottom: .4mm; }
.label-a .la-cap.big { font-size: 3.6mm; }
.label-a .la-sep { border-top: .3mm dashed #000; }
.label-a .la-hint { font-size: 2mm; font-weight: 600; margin-top: auto; }
.label-a .la-price { float: right; font-weight: 900; }

/* ── Druck: nur die Etiketten, randlos, je Etikett eine Seite ── */
#print-area { display: none; }
@media print {
  html, body { background: #fff !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .label { break-after: page; page-break-after: always; box-shadow: none; }
  #print-area .label:last-child { break-after: auto; page-break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
