:root {
  --p: #173f43; --a: #f2b705; --a-ink: #1d1d1b;
  --bg: #f4f4f1; --card: #fff; --line: #e3e2dc; --muted: #6b6a64; --text: #1d1d1b;
  --ok: #1b7f3b; --ok-bg: #e5f4ea; --warn: #9a6500; --warn-bg: #fff3d6; --bad: #b00020; --bad-bg: #fde8eb; --info: #1f5fa8; --info-bg: #e6effa;
  --r: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: inherit; }
img { max-width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--p); color: #fff; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.app-logo { display: block; padding: 2px 8px 16px; }
.app-logo img { height: 38px; width: auto; display: block; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 10px; }
.brand img { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: #fff; }
.brand .logo-ph { width: 40px; height: 40px; border-radius: 6px; background: var(--a); color: var(--a-ink); display: grid; place-items: center; font-weight: 800; }
.brand b { display: block; font-size: 16px; }
.brand small { opacity: .7; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: rgba(255,255,255,.85); margin: 2px 0; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: var(--a); color: var(--a-ink); font-weight: 600; }
.nav .badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.side .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.side .foot button { margin-top: 8px; }
.layout > div { min-width: 0; }
.main { padding: 22px 26px 60px; min-width: 0; }
.topbar { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--p); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 40; }
  .topbar-logo { height: 28px; width: auto; }
  .topbar-band { margin-left: auto; font-weight: 600; font-size: 14px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
  .topbar button { background: transparent; color: #fff; border: 0; font-size: 22px; padding: 2px 6px; }
  .main { padding: 16px 14px 60px; }
}

/* Karten, Tabellen */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: 1fr; } }
.kpi { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--a); border-radius: var(--r); padding: 12px 14px; }
.kpi span { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.kpi b { display: block; font-size: 22px; margin-top: 2px; }
.kpi small { color: var(--muted); }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600; background: #fafaf7; }
td.n, th.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafaf4; }
tr.sum td { font-weight: 700; border-top: 2px solid var(--p); }
td input.qty { width: 74px; text-align: right; }
.neg { color: var(--bad); } .pos { color: var(--ok); }

/* Badges */
.b { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eee; color: #444; white-space: nowrap; font-weight: 500; }
.b.ok { background: var(--ok-bg); color: var(--ok); }
.b.warn { background: var(--warn-bg); color: var(--warn); }
.b.bad { background: var(--bad-bg); color: var(--bad); }
.b.info { background: var(--info-bg); color: var(--info); }
.b.dark { background: var(--p); color: #fff; }

/* Formulare */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 12px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 10px; border: 1px solid #cfcdc4; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--a); outline-offset: 0; border-color: var(--a); }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 40px; }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
button, .btn { font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 8px; border: 1px solid #cfcdc4; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
button:hover, .btn:hover { background: #f6f6f2; }
button.primary, .btn.primary { background: var(--p); border-color: var(--p); color: #fff; }
button.primary:hover { filter: brightness(1.2); }
button.accent { background: var(--a); border-color: var(--a); color: var(--a-ink); }
button.danger { color: var(--bad); border-color: #f0b8c0; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.small, .btn.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 14px 0 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; font-weight: 500; }
.tabs a.active { color: var(--text); border-color: var(--a); font-weight: 700; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* Artikelkarten */
.arts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.art { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.art:hover { border-color: var(--a); }
.art .img { aspect-ratio: 4/3; background: #eeede8 center/contain no-repeat; display: grid; place-items: center; color: #aaa; font-size: 32px; }
.art .body { padding: 10px 12px; }
.art b { display: block; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #eee; }
.preview { width: 100%; max-height: 320px; object-fit: contain; background: #eeede8; border-radius: 8px; }

/* Modal, Toast */
.modal-bg { position: fixed; inset: 0; background: rgba(20,20,18,.55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 980px; }
.modal h2 { margin-top: 0; }
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--p); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
.toast.err { background: var(--bad); }

/* Login */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 20px; background: var(--p); }
.login-logo { height: 64px; width: auto; max-width: 90vw; }
.login .card { width: 100%; max-width: 380px; }

/* Charts */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column-reverse; min-width: 4px; position: relative; }
.bars .col div { width: 100%; }
.bars .col .t { background: var(--p); }
.bars .col .w { background: var(--a); }
.bars .col:hover { opacity: .8; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.hbar { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
.hbar div { height: 100%; background: var(--a); }

/* Kasse */
.pos { display: grid; grid-template-columns: 1fr 360px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .pos { grid-template-columns: 1fr; } .cart { position: sticky; bottom: 0; max-height: 48vh; overflow-y: auto; box-shadow: 0 -6px 20px rgba(0,0,0,.15); } .cart .total { font-size: 22px; margin: 6px 0; } .paybtns button { padding: 12px; } .tiles { grid-template-columns: repeat(2, 1fr); } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; text-align: left; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 6px; min-height: 120px; user-select: none; }
.tile:active { transform: scale(.98); }
.tile .img { height: 70px; background: #f1f0eb center/contain no-repeat; border-radius: 8px; }
.tile b { font-size: 14px; line-height: 1.2; }
.tile .price { font-size: 18px; font-weight: 800; }
.tile.empty { opacity: .4; }
.vbtns { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.vbtns button { padding: 18px 8px; font-size: 18px; flex-direction: column; }
.vbtns button small { font-weight: 400; font-size: 12px; color: var(--muted); }
.cart { background: #fff; border: 2px solid var(--p); border-radius: 12px; padding: 14px; }
.cart .line { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.cart .line .grow { min-width: 0; }
.cart .line button { padding: 4px 10px; }
.cart .total { font-size: 28px; font-weight: 800; text-align: right; margin: 10px 0; }
.paybtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.paybtns button { padding: 16px; font-size: 18px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.change.miss { background: var(--bad-bg); color: var(--bad); }
.change { font-size: 26px; font-weight: 800; text-align: center; padding: 10px; background: var(--ok-bg); color: var(--ok); border-radius: 10px; }

/* Unterschrift */
.sigpad { border: 2px dashed #bbb; border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 180px; display: block; }
.sigs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.sig { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.sig img { width: 100%; height: 70px; object-fit: contain; }
.sig small { display: block; color: var(--muted); }

/* Stepper Termin */
.steps { display: flex; gap: 0; margin: 10px 0 4px; overflow-x: auto; }
.steps div { flex: 1; min-width: 110px; text-align: center; font-size: 12px; color: var(--muted); padding-top: 26px; position: relative; }
.steps div::before { content: ''; position: absolute; top: 8px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #ddd; z-index: 1; }
.steps div::after { content: ''; position: absolute; top: 14px; left: -50%; width: 100%; height: 2px; background: #ddd; }
.steps div:first-child::after { display: none; }
.steps div.done { color: var(--text); }
.steps div.done::before, .steps div.done::after { background: var(--ok); }
.steps div.cur { color: var(--text); font-weight: 700; }
.steps div.cur::before { background: var(--a); box-shadow: 0 0 0 4px rgba(242,183,5,.3); }

/* Preisschilder DIN A6 */
.tags-screen { padding: 20px; }
.tags-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 16px; }
.tag { width: 105mm; height: 148mm; background: #fff; border: 1px solid #ccc; display: flex; flex-direction: column; overflow: hidden; color: #111; font-family: var(--tag-font, var(--font)); }
.tag .th { background: var(--band-p, var(--p)); color: #fff; padding: 5mm 6mm; display: flex; align-items: center; gap: 4mm; border-bottom: 2.5mm solid var(--band-a, var(--a)); }
.tag .th img { height: 12mm; max-width: 30mm; object-fit: contain; }
.tag .th b { font-size: 6mm; letter-spacing: .3mm; text-transform: uppercase; }
.tag .ti { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4mm 6mm 0; }
.tag .ti img { max-height: 100%; max-width: 100%; object-fit: contain; }
.tag .tn { padding: 2mm 6mm 0; font-size: 7mm; font-weight: 800; line-height: 1.1; text-align: center; }
.tag .tv { padding: 1mm 6mm; font-size: 4mm; text-align: center; color: #444; }
.tag .tp { font-size: 19mm; font-weight: 900; text-align: center; line-height: 1; padding: 2mm 0 1mm; }
.tag.noimg .ti { flex: .6; }
.tag.noimg .tn { font-size: 10mm; }
.tag .tf { font-size: 3.6mm; text-align: center; padding: 0 6mm 5mm; color: #444; }
@media print {
  @page { size: A6 portrait; margin: 0; }
  html, body { background: #fff; }
  body.printing #app > *:not(.tags-screen), body.printing .tags-toolbar, #modal-root, #toast-root { display: none !important; }
  body.printing .tags-screen { padding: 0; }
  body.printing .tags { display: block; }
  body.printing .tag { border: 0; page-break-after: always; break-after: page; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
