:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e2e6ec;
  --accent: #b4321f;
  --accent-text: #ffffff;
  --ok-bg: #e7f6ec;
  --ok-text: #14602f;
  --err-bg: #fdecea;
  --err-text: #9b1c12;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --surface: #1c222c;
    --text: #e8ecf2;
    --muted: #98a2b3;
    --line: #2d3644;
    --accent: #e0553f;
    --accent-text: #ffffff;
    --ok-bg: #143323;
    --ok-text: #8fe0ad;
    --err-bg: #3a1a17;
    --err-text: #ffb4aa;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 1.25rem 0 1rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }
.wrap { max-width: 1600px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; padding-bottom: 4px; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.tenant { color: var(--muted); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; padding-bottom: 8px; }
.nav a { padding: 6px 12px; border-radius: var(--radius); text-decoration: none; color: var(--text); }
.nav a:hover { background: var(--bg); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
main.wrap { padding-bottom: 48px; }

.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.head h1 { margin-bottom: 0.5rem; }

.btn {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.icon { padding: 8px 12px; line-height: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: 0.85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; border: 1px solid var(--line); background: var(--bg); }
.badge.s-placed { background: #fff4d6; border-color: #f0d98a; color: #6b4e00; }
.badge.s-confirmed { background: #e3efff; border-color: #b7d3ff; color: #17408b; }
.badge.s-shipped { background: #efe6ff; border-color: #d3bfff; color: #4a2a91; }
.badge.s-delivered { background: var(--ok-bg); border-color: transparent; color: var(--ok-text); }
.badge.s-cancelled { background: var(--err-bg); border-color: transparent; color: var(--err-text); }
@media (prefers-color-scheme: dark) {
  .badge.s-placed { background: #3b3113; border-color: #5c4d1d; color: #ffe08a; }
  .badge.s-confirmed { background: #172a4a; border-color: #28477c; color: #a9c8ff; }
  .badge.s-shipped { background: #2b1f4a; border-color: #46367a; color: #cdb8ff; }
}

.notice { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 1rem; }
.notice.ok { background: var(--ok-bg); color: var(--ok-text); }
.notice.error { background: var(--err-bg); color: var(--err-text); }
.empty { padding: 24px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

.cards { list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { display: block; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); font-weight: 600; }
.card:hover { border-color: var(--accent); }

.receipt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 20px 20px; }
.receipt h1 { margin-top: 0; }
.receipt > header p { margin: 12px 0 0; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.totals { width: auto; margin: 16px 0 0 auto; }
.totals th { font-weight: 400; text-align: left; padding-right: 32px; }
.totals .grand th, .totals .grand td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.form { display: grid; gap: 16px; max-width: 680px; }
.form label { display: grid; gap: 4px; font-weight: 600; }
select, input, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); width: 100%; font-weight: 400;
}
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; background: var(--surface); }
legend { font-weight: 600; padding: 0 6px; }
.item-row { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; margin-bottom: 8px; }
.preview { margin: 8px 0 0; color: var(--muted); }

@media print {
  body { background: #fff; color: #000; }
  .top, .no-print { display: none !important; }
  .receipt { border: 0; padding: 0; }
  .table-wrap { border: 0; }
}

.tenant { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.logout { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.form.narrow { max-width: 360px; }

/* ---------- Allgemeine Ergänzungen ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn.small { padding: 4px 10px; font-size: 0.9rem; }
.btn.danger { color: var(--err-text); border-color: var(--err-text); }
.btn.huge { padding: 18px 28px; font-size: 1.3rem; font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; }
.check input { width: auto; }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.logo { height: 48px; width: auto; max-width: 240px; object-fit: contain; vertical-align: middle; margin-right: 10px; border-radius: 6px; }
.logo.big { height: clamp(64px, 12vh, 120px); max-width: min(380px, 42vw); margin-right: 0; border-radius: 8px; }
.thumb { height: 40px; width: 56px; object-fit: cover; border-radius: 6px; display: block; }
.thumb-cell { width: 68px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }
.secret { background: var(--ok-bg); color: var(--ok-text); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 1rem; }
.secret p { margin: 4px 0; }
.secret-value code { font-size: 1.4rem; letter-spacing: 0.05em; user-select: all; }
.badge.s-preparing { background: #e3efff; border-color: #b7d3ff; color: #17408b; }
.badge.s-ready { background: var(--ok-bg); border-color: transparent; color: var(--ok-text); }
.empty.big { font-size: 1.4rem; padding: 48px 24px; }

/* Bild-Upload */
.uploader { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; max-width: 680px; }
.uploader-preview { width: 160px; height: 120px; display: grid; place-items: center; background: var(--bg); border-radius: 6px; overflow: hidden; }
.uploader-preview img { width: 100%; height: 100%; object-fit: contain; }
.uploader-actions { display: grid; gap: 8px; justify-items: start; }
.uploader-actions p { margin: 0; font-size: 0.9rem; }

/* ---------- Schlanke Ansicht für Tablets (Kiosk, Küche) ---------- */
body.bare { min-height: 100vh; display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.bare-top { display: flex; align-items: center; gap: 20px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.bare-name { font-size: clamp(1.6rem, 3vw, 2.6rem); font-weight: 700; line-height: 1.1; }
.spacer { flex: 1; }
.bare-main { flex: 1; padding: 12px 20px; }
.bare-foot { padding: 6px 20px; text-align: right; font-size: 0.8rem; color: var(--muted); }

/* Kiosk */
.kiosk { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) clamp(340px, 30vw, 460px); align-items: start; }
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 11vw, 240px), 1fr)); }
.tile { display: grid; grid-template-rows: auto auto auto; align-content: start; gap: 4px; padding: 0 0 12px; text-align: center; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; }
.tile:active { transform: scale(0.97); border-color: var(--accent); }
.tile-img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
.tile-ph { display: grid; place-items: center; width: 100%; aspect-ratio: 3 / 2; font-size: 3.2rem; font-weight: 700; background: var(--bg); color: var(--muted); }
.tile-name { font-size: clamp(1rem, 1.3vw, 1.3rem); font-weight: 600; padding: 4px 10px 0; }
.tile-price { color: var(--muted); font-size: 1.05rem; }
.kiosk-cart { position: sticky; top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.kiosk-cart h2 { margin-top: 0; }
label.big { display: grid; gap: 6px; font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; }
label.big input { font-size: 1.4rem; padding: 12px 14px; }
.cart { list-style: none; margin: 0 0 8px; padding: 0; }
.cart-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cart-name { font-weight: 600; }
.cart-controls { display: flex; align-items: center; gap: 8px; }
.cart-controls .btn.icon { min-width: 44px; min-height: 44px; font-size: 1.4rem; }
.cart-qty { min-width: 1.5em; text-align: center; font-size: 1.2rem; font-weight: 600; }
.cart-line { min-width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
.cart-total { font-size: 1.3rem; margin: 12px 0; display: flex; justify-content: space-between; }
.kiosk-cart .btn.primary { width: 100%; }
.done { max-width: 720px; margin: 3vh auto 0; text-align: center; }
.done h1 { font-size: 2.4rem; }
.done-check { font-size: 6.5rem; margin: 0; color: var(--ok-text); line-height: 1; }
.done-nr { font-size: 1.6rem; }
.done-eta { font-size: 1.4rem; }
@media (max-width: 900px) and (orientation: portrait), (max-width: 760px) {
  .kiosk { grid-template-columns: 1fr; }
  .kiosk-cart { position: static; order: -1; }
}

/* Küche */
.ktools { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ktools .bad { color: var(--err-text); font-weight: 600; }
.ksummary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { display: grid; justify-items: center; align-content: center; min-width: 110px; padding: 10px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.stat-num { font-size: 2.4rem; font-weight: 700; line-height: 1.1; }
.stat.wide { flex: 1; min-width: 260px; }
.stat-big { font-size: 2rem; }
.kcards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(clamp(340px, 22vw, 470px), 100%), 1fr)); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-left: 10px solid var(--muted); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.kcard.s-placed { border-left-color: #e0a800; }
.kcard.s-preparing { border-left-color: #2b6cdf; }
.kcard.s-ready { border-left-color: #2e9e5b; }
.kcard header { display: flex; align-items: baseline; gap: 10px; }
.knr { font-size: clamp(1.8rem, 2vw, 2.5rem); font-weight: 700; }
.kname { font-size: clamp(1.3rem, 1.5vw, 1.9rem); font-weight: 600; flex: 1; overflow-wrap: anywhere; }
.kage { font-variant-numeric: tabular-nums; color: var(--muted); }
.kage.warn { color: #b26a00; font-weight: 700; }
.kage.late { color: var(--err-text); font-weight: 700; }
.kcard p { margin: 0; }
.kitems { list-style: none; margin: 4px 0; padding: 0; font-size: clamp(1.2rem, 1.35vw, 1.7rem); }
.kitems li { padding: 2px 0; }
.kqty { font-weight: 700; display: inline-block; min-width: 2.2em; }
.knote { background: var(--err-bg); color: var(--err-text); border-radius: 6px; padding: 4px 8px; }
.kcard footer { margin-top: auto; display: grid; gap: 8px; }
.keta { color: var(--muted); }
.kbuttons { display: flex; gap: 8px; flex-wrap: wrap; }
.kbtn { flex: 1; min-height: 56px; min-width: 90px; font: inherit; font-size: 1.15rem; font-weight: 600; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.kbtn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); flex: 2; }
.kbtn.danger { color: var(--err-text); flex: 0 0 auto; min-height: 56px; font-size: 0.95rem; }
.kbtn:disabled { opacity: 0.5; }
.kbtn:active { transform: scale(0.97); }

@media print { .bare-top, .bare-foot, .ktools { display: none; } }

/* ---------- Bessere Platznutzung: Formular und Bild nebeneinander ---------- */
.split { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1000px) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); }
}
.split > * > h2:first-child { margin-top: 0.5rem; }
.uploader.stack { flex-direction: column; align-items: stretch; max-width: none; }
.uploader.stack .uploader-preview { width: 100%; height: 240px; }
.uploader.stack .uploader-preview img { object-fit: contain; }
.form { max-width: 760px; }
.form.narrow { max-width: 420px; }

/* ---------- Freier Wunsch und WhatsApp ---------- */
.fine-print { font-size: 0.85rem; margin: -6px 0 12px; }
.kiosk-cart textarea { font-size: 1.1rem; min-height: 4.5em; resize: vertical; }
.kiosk-cart { max-height: calc(100vh - 24px); overflow-y: auto; }
.done-wish { font-size: 1.3rem; }
.knote { white-space: pre-wrap; overflow-wrap: anywhere; }
.kwish { margin: 6px 0; padding: 10px 12px; border-radius: 8px; background: #fff7d6; border: 1px solid #f0d98a; color: #3d3000; font-size: clamp(1.3rem, 1.6vw, 2rem); line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.kwish-label { display: block; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: #8a6a00; margin-bottom: 2px; }
.kwa { display: grid; gap: 6px; margin: 6px 0; padding: 8px; border-radius: 8px; background: var(--bg); }
.kphone { font-size: 0.9rem; color: var(--muted); }
.wa-select { font-size: 1rem; }
.kbtn.wa-send { background: #1faa59; border-color: #1faa59; color: #ffffff; flex: none; width: 100%; min-height: 52px; }
@media (prefers-color-scheme: dark) {
  .kwish { background: #3b3113; border-color: #5c4d1d; color: #ffe9a3; }
  .kwish-label { color: #e0c060; }
}
