/* E-Beleg: eine Spalte, Handy zuerst, Hell und Dunkel, keine Fremdanbieter (Schrift = Systemschrift). */
:root {
  --bg: #eef0f3;
  --card: #ffffff;
  --ink: #14171c;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #0b6b4f;
  --accent-ink: #ffffff;
  --warn-bg: #fdecea;
  --warn-ink: #a1261b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .08);
  --radius: 18px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b21;
    --ink: #f2f4f7;
    --muted: #98a2b3;
    --line: #2a2f38;
    --accent: #3ccf9b;
    --accent-ink: #06231a;
    --warn-bg: #3a1714;
    --warn-ink: #ffb4a8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 30rem;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

h1, h2, p, ul, dl, table { margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* Laden und Fehler */
.status {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 40vh; color: var(--muted); text-align: center; padding: 0 12px;
}
.status.error { color: var(--warn-ink); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: dreh .8s linear infinite;
}
.status.error .spinner { display: none; }
@keyframes dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Karte */
.receipt {
  position: relative;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  padding: 28px 22px 36px;
  animation: ein .35s ease-out both;
}
@keyframes ein { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .receipt { animation: none; } }

/* Gezackter Abriss unten, wie ein Kassenbon */
.receipt::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 100%; height: 10px;
  background:
    linear-gradient(-135deg, var(--card) 5px, transparent 0) 0 0 / 14px 10px repeat-x,
    linear-gradient(135deg, var(--card) 5px, transparent 0) 0 0 / 14px 10px repeat-x;
  filter: drop-shadow(0 4px 4px rgba(16, 24, 40, .05));
}

/* Kopf */
.head { text-align: center; padding-bottom: 22px; border-bottom: 1px dashed var(--line); }
.shop { margin-bottom: 22px; }
.shop h1 { font-size: 1.15rem; font-weight: 650; letter-spacing: .01em; }
.shop p { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.total {
  font-size: clamp(2.2rem, 11vw, 2.9rem); font-weight: 700; letter-spacing: -.02em;
  margin-top: 4px; font-variant-numeric: tabular-nums;
}
.sub { color: var(--muted); font-size: .92rem; margin-top: 4px; }
.badge {
  display: inline-block; margin-top: 12px; padding: 3px 12px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; font-size: .85rem;
}

/* Positionen */
.items { list-style: none; padding: 18px 0 6px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 9px 0; }
.item .name { overflow-wrap: anywhere; }
.item .amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .detail { grid-column: 1; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.item.minus .amt { color: var(--accent); }

/* Summen */
.sums { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 14px; }
.row { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.row .v { white-space: nowrap; }
.row.sum { font-weight: 700; font-size: 1.15rem; padding-bottom: 8px; }
.row.muted { color: var(--muted); }

/* Blöcke */
.block { margin-top: 24px; }
.block h2, .tse summary {
  color: var(--muted); font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
}
.block h2 { margin-bottom: 8px; }

.tax { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.tax th { color: var(--muted); font-weight: 500; text-align: right; padding: 0 0 4px; }
.tax td { text-align: right; padding: 3px 0; }
.tax th:first-child, .tax td:first-child { text-align: left; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: .9rem; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* TSE eingeklappt */
.tse { margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 14px; }
.tse summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.tse summary::-webkit-details-marker { display: none; }
.tse summary::after { content: "+"; font-size: 1.2rem; line-height: 1; }
.tse[open] summary::after { content: "–"; }
.tse dl { margin-top: 10px; }
.tse dd.mono { font: .75rem/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: left; grid-column: 1 / -1; color: var(--muted); }
.tse dt.wide { grid-column: 1 / -1; margin-top: 6px; }

/* Aktionen */
.actions { margin-top: 28px; }
.btn {
  width: 100%; min-height: 48px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn:focus-visible, .tse summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 28px; }

@media (min-width: 40rem) {
  .page { padding-top: 48px; }
  .receipt { padding: 36px 32px 44px; }
}

@media print {
  body { background: #fff; color: #000; }
  .receipt { box-shadow: none; border-radius: 0; padding: 0; animation: none; }
  .receipt::after, .actions, .foot { display: none; }
  .tse { display: block; }
  .tse > * { display: block; }
  .tse summary::after { content: ""; }
  :root { --card: #fff; --ink: #000; --muted: #444; --line: #bbb; --accent: #000; }
}
