:root {
  --accent: #c62828;
  --accent-dark: #8e1c1c;
  --green: #2e7d32;
  --bg: #f2f0ec;
  --card: #ffffff;
  --ink: #1c1c1c;
  --muted: #78716c;
  --line: #e5e1da;
  --radius: 12px;
}

:root[data-theme="dark"] {
  --accent: #e05353;
  --accent-dark: #c62828;
  --green: #43a047;
  --bg: #17171b;
  --card: #202027;
  --ink: #ececf0;
  --muted: #a0a0a8;
  --line: #34343d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 40px; height: 40px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.badge-demo {
  background: #fff3cd;
  color: #7a5c00;
  border: 1px solid #ffe08a;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
[data-theme="dark"] .badge-demo {
  background: #3a3313;
  color: #ffd75e;
  border-color: #57501f;
}
.lang-select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}

/* ---------- Produkte ---------- */
.products-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px;
  gap: 12px;
}
.cats { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-chip {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.cat-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  overflow-y: auto;
  align-content: start;
  padding-bottom: 10px;
}
.product-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 92px;
  transition: transform .06s ease, box-shadow .06s ease;
  user-select: none;
}
.product-card:active { transform: scale(.97); }
.product-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.product-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.product-price { margin-top: auto; color: var(--accent); font-weight: 700; }
.product-vat { font-size: 11px; color: var(--muted); }

/* ---------- Warenkorb ---------- */
.cart-pane {
  background: var(--card);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.cart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.cart-head h2 { font-size: 16px; }
.cart-items { flex: 1; overflow-y: auto; padding: 8px 14px; }
.cart-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 14px;
}
.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.cart-row-name { font-size: 14px; font-weight: 600; }
.cart-row-sum { font-weight: 700; text-align: right; }
.cart-row-qty {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
}
.qty-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.qty-val { min-width: 26px; text-align: center; font-weight: 600; }
.cart-foot { border-top: 1px solid var(--line); padding: 12px 14px; }
.vat-lines { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.vat-lines div { display: flex; justify-content: space-between; }
.total-line {
  display: flex; justify-content: space-between;
  font-size: 20px; font-weight: 800;
  margin-bottom: 10px;
}
.pay-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: var(--bg); border: 1px solid var(--line); color: var(--ink); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-pay { padding: 16px 0; font-size: 16px; }
.btn-danger { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.btn-cash { background: var(--green); color: #fff; }
.btn-card { background: #1565c0; color: #fff; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: grid; place-items: center;
  z-index: 50;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  width: min(420px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-wide { width: min(680px, 96vw); }
.modal h3 { margin-bottom: 12px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 16px;
}

/* Barzahlung */
.cash-due { font-size: 18px; margin-bottom: 12px; }
.cash-quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cash-input-label { display: block; font-size: 14px; font-weight: 600; }
.cash-input-label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  font-size: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
}
.cash-change { margin-top: 10px; font-size: 16px; font-weight: 700; min-height: 24px; }
.cash-change.neg { color: var(--accent); }
.cash-change.ok { color: var(--green); }

/* Beleg */
.modal-receipt { width: min(380px, 94vw); }
.receipt {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12.5px;
  background: #fffef8;
  color: #1c1c1c; /* Beleg bleibt auch im Dark Mode "Papier" */
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 14px;
  white-space: pre-wrap;
}
.receipt .r-center { text-align: center; }
.receipt .r-title { font-size: 15px; font-weight: 700; }
.receipt hr { border: none; border-top: 1px dashed #bbb; margin: 8px 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: 1px 0; vertical-align: top; }
.receipt td.num { text-align: right; white-space: nowrap; }
.receipt .r-total td { font-weight: 700; font-size: 14px; padding-top: 4px; }
.receipt .r-qr { display: grid; place-items: center; margin-top: 8px; }
.receipt .r-small { font-size: 11px; color: #555; }
.receipt .r-storno { color: var(--accent); font-weight: 700; }

/* Journal */
.report {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.report-tile {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.report-tile .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.report-tile .v { font-size: 17px; font-weight: 800; margin-top: 2px; }
.journal-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.journal-row {
  display: grid;
  grid-template-columns: 70px 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.journal-row:last-child { border-bottom: none; }
.journal-row .jnr { font-weight: 700; }
.journal-row .jtype { color: var(--muted); }
.journal-row .jsum { font-weight: 700; text-align: right; }
.journal-row .storno-flag { color: var(--accent); font-size: 11px; font-weight: 700; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .cart-pane { border-left: none; border-top: 1px solid var(--line); max-height: 45vh; }
}

@media print {
  body > *:not(#receiptModal) { display: none !important; }
  .modal-backdrop { position: static; background: none; display: block; }
  .modal { width: auto; box-shadow: none; padding: 0; }
  .modal-actions { display: none; }
  .receipt { border: none; }
}
