/* Thekenkasse – klarer, ruhiger Stil (angelehnt an apple.com).
   Die Vereinsfarben setzt brand_css() in app/bootstrap.php über die Variablen --green, --green-dark, --green-soft, --lime und --on-accent. */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --hairline: rgba(0, 0, 0, .1);
  --fill: rgba(0, 0, 0, .05);
  --fill-strong: rgba(0, 0, 0, .09);

  --green: #12763c;        /* Vereinsgrün */
  --green-dark: #0d572c;   /* Vereinsgrün dunkel */
  --green-soft: #e8f5e9;   /* Vereinsgrün hell */
  --lime: #b4d965;         /* Akzent */
  --on-accent: #ffffff;    /* Schrift auf Akzentfarbe */
  --danger: #d70015;

  --nav: rgba(245, 245, 247, .78);
  --seg-on: #ffffff;
  --shadow: 0 2px 10px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-lift: 0 10px 30px rgba(0, 0, 0, .08);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}

/* Dunkel: automatisch nach Geräteeinstellung – außer "Hell" ist gewählt –
   oder fest, wenn "Dunkel" gewählt ist (Schalter oben rechts). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --hairline: rgba(255, 255, 255, .14);
    --fill: rgba(255, 255, 255, .07);
    --fill-strong: rgba(255, 255, 255, .13);
    --green: #2a9d58;
    --green-dark: #34b468;
    --green-soft: rgba(42, 157, 88, .2);
    --danger: #ff453a;
    --nav: rgba(22, 22, 23, .78);
    --seg-on: #48484a;
    --shadow: 0 0 0 transparent;
    --shadow-lift: 0 0 0 transparent;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --hairline: rgba(255, 255, 255, .14);
  --fill: rgba(255, 255, 255, .07);
  --fill-strong: rgba(255, 255, 255, .13);
  --green: #2a9d58;
  --green-dark: #34b468;
  --green-soft: rgba(42, 157, 88, .2);
  --danger: #ff453a;
  --nav: rgba(22, 22, 23, .78);
  --seg-on: #48484a;
  --shadow: 0 0 0 transparent;
  --shadow-lift: 0 0 0 transparent;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.47 var(--font);
  letter-spacing: -.022em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.03em; line-height: 1.1; margin: 0 0 .5em; }
h1 { font-size: 40px; }
h2 { font-size: 24px; }
.muted { color: var(--muted); }

/* ---------- Navigationsleiste (Milchglas) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 52px;
  padding: 0 max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
  background: var(--nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); font-weight: 600; font-size: 17px; white-space: nowrap;
}
.brand img { width: 38px; height: auto; display: block; }
.brand { gap: 10px; font-size: 18px; }
.auth-logo { display: block; width: 130px; height: auto; margin: 0 auto 24px; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  color: var(--muted); font-size: 14px; padding: 6px 12px; border-radius: 980px; white-space: nowrap;
  transition: color .2s, background .2s;
}
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--fill); }
.topbar nav a.logout { margin-left: 8px; }

/* ---------- Grundbausteine ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 48px 22px 80px; }
main.narrow { max-width: 440px; padding-top: 6vh; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 19px; }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 32px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 24px; }
.card h2 { margin-bottom: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 980px; padding: 9px 20px;
  font: inherit; font-size: 15px; font-weight: 500; letter-spacing: -.01em;
  cursor: pointer; transition: background .2s, transform .1s;
  background: var(--fill); color: var(--text);
}
.btn:hover { background: var(--fill-strong); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn.primary { background: var(--green); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--green-dark); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--fill); }
.btn.small { padding: 6px 14px; font-size: 14px; }
.btn.big { width: 100%; padding: 16px 28px; font-size: 17px; }
.link {
  border: 0; background: none; padding: 0; font: inherit; font-size: 15px;
  color: var(--green); cursor: pointer;
}
.link:disabled { color: var(--muted); opacity: .5; cursor: default; }

label { display: block; margin-bottom: 18px; font-size: 14px; color: var(--muted); }
label > input, label > select { margin-top: 6px; }
input, select {
  display: block; width: 100%;
  font: inherit; font-size: 17px; color: var(--text);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 12px 14px; outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236e6e73' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
input[type=checkbox] {
  display: inline-block; width: 22px; height: 22px; padding: 0; margin: 0; vertical-align: middle;
  border-radius: 7px; cursor: pointer; position: relative;
}
input[type=checkbox]:checked { background: var(--green); border-color: var(--green); }
input[type=checkbox]:checked::after {
  content: ""; position: absolute; left: 7px; top: 3px; width: 5px; height: 10px;
  border: solid var(--on-accent); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

.flash {
  max-width: 1080px; margin: 16px auto 0; padding: 12px 18px; border-radius: 12px;
  font-size: 15px; background: var(--green-soft); color: var(--green-dark);
}
.flash.err { background: rgba(215, 0, 21, .08); color: var(--danger); }
main .flash { margin: 0 0 18px; }
body > .flash { margin: 16px 22px 0; }
@media (min-width: 1124px) { body > .flash { margin: 16px auto 0; } }

/* ---------- Tabellen (Admin) ---------- */
.table-wrap { overflow-x: auto; margin: 0 -8px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  text-align: left; font-weight: 500; font-size: 13px; color: var(--muted);
  padding: 8px; border-bottom: 1px solid var(--hairline);
}
td { padding: 12px 8px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td input, td select { padding: 8px 10px; font-size: 15px; border-radius: 10px; }
.icon-cell { font-size: 26px; width: 44px; text-align: center; }
tr.inactive td { opacity: .45; }

/* ---------- Kasse ---------- */
.pos-page { overscroll-behavior: none; }
.pos {
  max-width: none; padding: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 380px;
  min-height: calc(100dvh - 52px);
}
.catalog { padding: 28px 28px 48px; }
.section-title { font-size: 28px; margin: 12px 4px 16px; }
.section-title:not(:first-child) { margin-top: 36px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }

.tile {
  position: relative; -webkit-touch-callout: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 150px; padding: 18px 10px 16px;
  background: var(--surface); color: var(--text);
  border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  font: inherit; cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform .12s ease, box-shadow .2s ease;
}
@media (hover: hover) { .tile:hover { box-shadow: var(--shadow-lift); } }
.tile:active { transform: scale(.96); }
.tile.selected { box-shadow: inset 0 0 0 2.5px var(--green), var(--shadow-lift); }
.tile.bump { animation: bump .22s ease; }
@keyframes bump { 50% { transform: scale(1.04); } }
.tile-icon { font-size: 48px; line-height: 1.15; margin-bottom: 6px; }
.tile-name { font-size: 17px; font-weight: 600; text-align: center; }
.tile-price { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile-badge {
  position: absolute; top: 10px; right: 10px;
  min-width: 30px; height: 30px; padding: 0 9px; border-radius: 15px;
  background: var(--green); color: var(--on-accent); font-size: 16px; font-weight: 600; line-height: 30px;
  font-variant-numeric: tabular-nums;
}
.tile-minus {
  position: absolute; top: 10px; left: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--fill-strong); color: var(--text); font-size: 22px; line-height: 28px; font-weight: 500;
}
.tile-badge[hidden], .tile-minus[hidden] { display: none; }

.ticket {
  position: sticky; top: 52px; height: calc(100dvh - 52px);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--hairline);
}
.ticket-head { display: flex; align-items: baseline; justify-content: space-between; padding: 28px 24px 12px; }
.ticket-head h2 { margin: 0; font-size: 24px; }
.ticket-lines { list-style: none; margin: 0; padding: 0 24px; flex: 1; overflow-y: auto; }
.ticket-lines li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--hairline); font-size: 16px;
}
.ticket-lines li.ticket-empty { display: block; border: 0; color: var(--muted); padding-top: 24px; }
.line-qty {
  display: flex; align-items: center; gap: 6px;
}
.line-qty button {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--fill); color: var(--text); font-size: 18px; line-height: 1;
}
.line-qty button:hover { background: var(--fill-strong); }
.line-qty span { min-width: 22px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.line-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-sum { font-variant-numeric: tabular-nums; }
.ticket-foot { padding: 18px 24px max(24px, env(safe-area-inset-bottom)); border-top: 1px solid var(--hairline); }
.total { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.total span { color: var(--muted); font-size: 17px; }
.total strong { font-size: 40px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 19px; padding: 40px 4px; }

/* Smartphone / Tablet hochkant: Bestellung als Leiste unten */
@media (max-width: 860px) {
  .pos { display: block; }
  .catalog { padding: 16px 16px 240px; }
  .section-title { font-size: 22px; margin: 8px 2px 12px; }
  .section-title:not(:first-child) { margin-top: 26px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
  .tile { min-height: 118px; padding: 14px 6px 12px; border-radius: 16px; }
  .tile-icon { font-size: 38px; margin-bottom: 2px; }
  .tile-name { font-size: 15px; }
  .tile-price { font-size: 13px; }
  .tile-badge { top: 6px; right: 6px; min-width: 26px; height: 26px; line-height: 26px; font-size: 14px; padding: 0 7px; }
  .tile-minus { top: 6px; left: 6px; width: 26px; height: 26px; line-height: 24px; font-size: 19px; }
  .ticket {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; max-height: 48dvh; z-index: 40;
    border-left: 0; border-top: 1px solid var(--hairline);
    background: var(--nav); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  }
  .ticket-head { padding: 12px 18px 0; }
  .ticket-head h2 { font-size: 17px; }
  .ticket-lines { padding: 0 18px; }
  .ticket-lines li { padding: 8px 0; font-size: 15px; }
  .ticket-lines li.ticket-empty { padding: 6px 0; }
  .ticket-foot { display: flex; align-items: center; gap: 16px; padding: 12px 18px max(12px, env(safe-area-inset-bottom)); }
  .total { flex: 1; margin: 0; flex-direction: column; align-items: flex-start; }
  .total span { font-size: 13px; }
  .total strong { font-size: 30px; line-height: 1.1; }
  .ticket-foot .btn.big { width: auto; padding: 15px 30px; }
}

/* ---------- Bezahl-Dialog ---------- */
dialog.sheet {
  width: min(460px, calc(100vw - 32px)); padding: 32px;
  border: 0; border-radius: 24px; background: var(--surface); color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog.sheet[open] { animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.sheet-label { margin: 0; color: var(--muted); font-size: 15px; text-align: center; }
.sheet-total {
  margin: 2px 0 26px; text-align: center;
  font-size: 56px; font-weight: 600; letter-spacing: -.035em; font-variant-numeric: tabular-nums;
}
.given { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 8px; }
.given-custom { margin-bottom: 18px; text-align: center; border-radius: 14px; }
.given button {
  border: 0; border-radius: 14px; padding: 14px 0; cursor: pointer;
  background: var(--fill); color: var(--text); font: inherit; font-size: 17px; font-weight: 500;
  font-variant-numeric: tabular-nums; transition: background .2s;
}
.given button:hover { background: var(--fill-strong); }
.given button.on { background: var(--green); color: var(--on-accent); }
.change {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 20px; margin-bottom: 18px; border-radius: 16px;
  background: var(--green-soft); color: var(--green-dark);
}
.change strong { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.change.short { background: rgba(215, 0, 21, .08); color: var(--danger); }
.change[hidden] { display: none; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast {
  position: fixed; left: 50%; top: 68px; transform: translateX(-50%); z-index: 100;
  padding: 10px 20px; border-radius: 980px; font-size: 15px; font-weight: 500;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lift);
  animation: rise .25s ease;
}
.toast[hidden] { display: none; }

/* ---------- Auswertung ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 24px; }
.filters label { margin: 0; }
.filters input { width: auto; padding: 8px 12px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips a { padding: 7px 14px; border-radius: 980px; background: var(--fill); color: var(--text); font-size: 14px; }
.chips a:hover { background: var(--fill-strong); text-decoration: none; }
.chips a.on { background: var(--text); color: var(--bg); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: 14px; }
.stat strong { display: block; font-size: 34px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--fill); min-width: 80px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--green), var(--lime)); }

/* ---------- Artikel-Formular ---------- */
.form-grid { display: grid; grid-template-columns: 90px 2fr 1fr 1fr 90px; gap: 12px; align-items: end; }
.form-grid label { margin: 0; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.emoji-picker button {
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--fill);
  font-size: 22px; cursor: pointer;
}
.emoji-picker button:hover { background: var(--fill-strong); }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.inline-form { display: inline; }

@media (max-width: 720px) {
  h1 { font-size: 32px; }
  main { padding: 28px 16px 60px; }
  .card { padding: 22px 18px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .wide { grid-column: 1 / -1; }
  .topbar { padding: 0 12px; }
  .topbar nav a { padding: 6px 9px; font-size: 13px; }
  .brand { font-size: 15px; }
}

/* Segment-Umschalter (Kategorie beim Anlegen) */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 20px;
  background: var(--fill); border-radius: 12px;
}
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; padding: 8px 18px; border-radius: 9px; cursor: pointer;
  font-size: 15px; font-weight: 500; color: var(--text); transition: background .2s, box-shadow .2s;
}
.segmented input:checked + span { background: var(--seg-on); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--green-soft); }
.emoji-picker[hidden] { display: none; }
.form-grid.new-grid { grid-template-columns: 90px 2fr 1fr; }
@media (max-width: 720px) { .form-grid.new-grid { grid-template-columns: 1fr 1fr; } }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.card-head h2 { margin: 0; }
.card-head p { margin: 0; font-size: 15px; font-variant-numeric: tabular-nums; }
tr[id] { scroll-margin-top: 140px; }
tr:target td { background: var(--green-soft); }

/* ================================================================
   Handy & Tablet – Hauptnutzung an der Theke
   ================================================================ */

button, a, input, select, label { touch-action: manipulation; }

.menu-toggle { display: none; }
.icon-input { width: 58px; text-align: center; font-size: 22px !important; padding: 4px !important; }
.price-input { width: 90px; text-align: right; }
.pw-form { display: flex; gap: 6px; align-items: center; }
.pw-form input { min-width: 150px; }
.user-grid { grid-template-columns: 2fr 1fr 2fr; }
.bar-inline, .c-who-inline { display: none; }
.date-range { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.c-time { white-space: nowrap; }

/* Finger statt Maus: größere Tippflächen, keine Zoom-auslösenden Mini-Schriften */
@media (pointer: coarse) {
  .btn.small { min-height: 40px; padding: 8px 16px; }
  .line-qty button { width: 38px; height: 38px; font-size: 20px; }
  .line-qty { gap: 8px; }
  .tile-minus::after { content: ""; position: absolute; inset: -10px; }
  input, select, td input, td select { font-size: 16px; }
  .emoji-picker button { width: 46px; height: 46px; font-size: 24px; }
  .segmented span { padding: 10px 18px; }
  .chips a { padding: 10px 16px; }
  input[type=checkbox] { width: 28px; height: 28px; border-radius: 8px; }
  input[type=checkbox]:checked::after { left: 9px; top: 4px; width: 7px; height: 13px; }
}

/* ---------- Tablet hochkant: größere Kacheln ---------- */
@media (min-width: 600px) and (max-width: 860px) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
  .tile { min-height: 140px; }
  .tile-icon { font-size: 46px; }
  .tile-name { font-size: 17px; }
  .tile-price { font-size: 14px; }
  .catalog { padding: 24px 24px 260px; }
  .ticket { max-height: 42dvh; }
  .ticket-head { padding: 16px 24px 0; }
  .ticket-lines { padding: 0 24px; }
  .ticket-foot { padding: 14px 24px max(14px, env(safe-area-inset-bottom)); }
  .total strong { font-size: 36px; }
  .ticket-foot .btn.big { padding: 18px 44px; font-size: 19px; }
}

/* ---------- Handy quer: Bestellung rechts statt unten ---------- */
@media (orientation: landscape) and (max-height: 540px) and (min-width: 560px) {
  .pos { display: grid; grid-template-columns: minmax(0, 1fr) 290px; }
  .catalog { padding: 12px 16px 24px; }
  .ticket {
    position: sticky; top: 52px; bottom: auto; height: calc(100dvh - 52px); max-height: none;
    border-top: 0; border-left: 1px solid var(--hairline); background: var(--surface);
  }
  .ticket-foot { display: block; }
  .total { flex-direction: row; align-items: baseline; margin-bottom: 10px; }
  .total strong { font-size: 28px; }
  .ticket-foot .btn.big { width: 100%; padding: 12px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .tile { min-height: 100px; }
  .tile-icon { font-size: 32px; }
}

/* ---------- Handy (und schmale Tablets) ---------- */
@media (max-width: 700px) {
  main { padding: 20px 16px 48px; }
  h1 { font-size: 30px; }
  .page-head { margin-bottom: 18px; }
  .page-head p { font-size: 16px; }
  .page-head .btn { width: 100%; }
  .card { padding: 20px 16px; border-radius: 16px; }
  .card + .card { margin-top: 16px; }
  .card h2 { font-size: 21px; margin-bottom: 14px; }
  .card-head { margin-bottom: 12px; }
  .card > p > .btn.primary { width: 100%; padding: 14px; font-size: 17px; }
  main.narrow { padding-top: 24px; }
  .auth-logo { width: 110px; margin-bottom: 18px; }

  /* Tabellen werden zu gestapelten Karten */
  .table-wrap { margin: 0; overflow: visible; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: grid; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--hairline); }
  table.stack tr:last-child { border-bottom: 0; padding-bottom: 0; }
  table.stack tr:first-child { padding-top: 4px; }
  table.stack td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
  table.stack td input:not([type=checkbox]), table.stack td select { width: 100%; padding: 10px 12px; }
  table.stack tr.empty-row { display: block; }

  /* Artikel */
  table.stack:not(.users):not(.orders) tr {
    grid-template-columns: 58px minmax(0, 1fr) 100px;
    grid-template-areas: "icon name active" "cat cat price" "move actions actions";
    align-items: center;
  }
  .c-icon { grid-area: icon; } .c-name { grid-area: name; } .c-cat { grid-area: cat; }
  .c-price { grid-area: price; } .c-move { grid-area: move; } .c-active { grid-area: active; }
  .c-actions { grid-area: actions; }
  table.stack .icon-pick { width: 58px; height: 50px; }
  table.stack .price-input { text-align: right; }
  .c-active { padding-left: 4px !important; justify-content: flex-end; }
  .c-active { display: flex !important; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); }
  .c-active::before { content: attr(data-label); }
  .c-actions .actions { flex-wrap: nowrap; gap: 4px; justify-content: flex-end; }
  .c-actions .actions { justify-content: flex-end; }
  .c-actions .btn.danger { padding-left: 10px; padding-right: 10px; }
  tr.inactive td { opacity: 1; }
  tr.inactive .c-icon, tr.inactive .c-name, tr.inactive .c-cat, tr.inactive .c-price { opacity: .45; }

  /* Benutzer */
  table.users tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "user del" "role role" "pw pw"; align-items: center; }
  .c-user { grid-area: user; font-size: 18px; } .c-del { grid-area: del; }
  .c-role { grid-area: role; } .c-pw { grid-area: pw; }
  .c-role::before, .c-pw::before { content: attr(data-label); display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
  .pw-form input { min-width: 0; flex: 1; }
  .user-grid { grid-template-columns: 1fr; }

  /* Letzte Bestellungen */
  table.orders tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "time sum" "items del"; gap: 4px 12px; align-items: center; }
  .c-time { grid-area: time; font-weight: 600; } .c-sum { grid-area: sum; font-weight: 600; text-align: right !important; }
  .c-items { grid-area: items; font-size: 15px; color: var(--muted); }
  table.orders .c-del { grid-area: del; }
  .c-who { display: none !important; }
  .c-who-inline { display: inline; font-weight: 400; }

  /* Auswertung */
  .c-bar { display: none; }
  .bar-inline { display: block; width: 64px; margin: 6px 0 0 auto; height: 6px; min-width: 0; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat { padding: 14px 16px; border-radius: 16px; }
  .stat strong { font-size: 24px; }
  .stat span { font-size: 13px; }
  .filters { display: block; margin-bottom: 16px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips a { white-space: nowrap; }
  .date-range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .date-range input { width: 100%; }
  .date-range .btn { grid-column: 1 / -1; padding: 12px; }

  /* Neuer Artikel */
  .form-grid.new-grid { grid-template-columns: 90px 1fr; grid-template-areas: "icon price" "name name"; }
  .new-grid > label:nth-child(1) { grid-area: icon; }
  .new-grid > label:nth-child(2) { grid-area: name; }
  .new-grid > label:nth-child(3) { grid-area: price; }
  .segmented { display: flex; }
  .segmented label { flex: 1; text-align: center; }
  .segmented span { padding-left: 8px; padding-right: 8px; }

  /* Bezahl-Dialog als Blatt von unten */
  dialog.sheet {
    width: 100%; max-width: 100%; margin: auto 0 0; padding: 24px 18px max(18px, env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0; max-height: 92dvh; overflow-y: auto;
  }
  dialog.sheet[open] { animation: slideup .28s cubic-bezier(.2, .8, .2, 1); }
  .sheet-total { font-size: 48px; margin-bottom: 18px; }
  .given button { padding: 16px 0; font-size: 18px; }
  .toast { top: auto; bottom: 120px; }
}
@keyframes slideup { from { transform: translateY(100%); } }

/* ---------- Hell/Dunkel-Schalter oben rechts ---------- */
.brand { margin-right: auto; }
.topbar nav { order: 1; }
.theme-toggle {
  order: 2; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--fill); color: var(--text); transition: background .2s;
}
.theme-toggle:hover { background: var(--fill-strong); }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
.menu-toggle { order: 3; }
@media (pointer: coarse) { .theme-toggle { width: 42px; height: 42px; } }
@media (max-width: 700px) { .topbar { gap: 8px; } }

/* ---------- Artikel-Symbole (eigene SVGs oder Emoji) ---------- */
img.ico { display: block; width: 1.25em; height: 1.25em; -webkit-user-drag: none; }
.ico-emoji { display: inline-block; line-height: 1; }
.tile-icon { display: flex; align-items: center; justify-content: center; height: 1.3em; }
.tile-icon img.ico { width: 1.5em; height: 1.5em; }
.tile-icon { margin-bottom: 8px; }
.icon-cell { font-size: 30px; }
.icon-cell .ico { margin: 0 auto; }
.line-name { display: flex; align-items: center; gap: 6px; }
img.line-ico { width: 28px; height: 28px; flex: none; }
span.line-ico { flex: none; width: 26px; text-align: center; font-size: 20px; }

.field { display: block; margin: 0; }
.field-label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.icon-pick {
  display: inline-flex; align-items: center; justify-content: center;
  width: 58px; height: 46px; padding: 0; cursor: pointer;
  border: 1px solid var(--hairline); border-radius: 12px; background: var(--surface);
  font-size: 26px; color: var(--muted); transition: border-color .2s, box-shadow .2s;
}
.icon-pick:hover { border-color: var(--green); }
.icon-pick:focus-visible { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.icon-pick-empty { font-size: 22px; font-weight: 300; }
.new-grid .icon-pick { width: 100%; max-width: 90px; height: 48px; }

dialog.icon-sheet { width: min(620px, calc(100vw - 32px)); max-height: 86dvh; overflow-y: auto; padding: 0 24px 24px; }
.icon-sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 10px; background: var(--surface);
}
.icon-sheet-head h2 { margin: 0; font-size: 22px; }
.icon-group-title { margin: 14px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.icon-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--fill); color: var(--text); font: inherit; font-size: 40px; line-height: 1;
  transition: background .2s, box-shadow .2s;
}
.icon-grid button span:not(.ico) { font-size: 12px; line-height: 1.25; letter-spacing: 0; text-align: center; color: var(--muted); }
.icon-grid button:hover { background: var(--fill-strong); }
.icon-grid button.on { box-shadow: inset 0 0 0 2.5px var(--green); background: var(--green-soft); }
.icon-grid.emoji { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.icon-grid.emoji button { font-size: 28px; padding: 10px 0; }
.icon-own { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.icon-own input { width: auto; flex: 1; min-width: 140px; }
@media (max-width: 700px) {
  dialog.icon-sheet { width: 100%; padding: 0 16px max(16px, env(safe-area-inset-bottom)); }
  .icon-grid { grid-template-columns: repeat(3, 1fr); }
  .icon-grid.emoji { grid-template-columns: repeat(6, 1fr); }
}

/* ---------- Reihenfolge per Drag & Drop ---------- */
.c-move { width: 52px; }
.drag-handle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: 12px; padding: 0;
  background: transparent; color: var(--muted); cursor: grab;
  touch-action: none; -webkit-user-select: none; user-select: none;
  transition: background .15s, color .15s;
}
.drag-handle:hover, .drag-handle:focus-visible { background: var(--fill); color: var(--text); outline: none; }
tr.dragging { position: relative; z-index: 5; }
tr.dragging td { background: var(--surface); }
tr.dragging .drag-handle { cursor: grabbing; background: var(--green-soft); color: var(--green); }
tr.dragging { box-shadow: 0 12px 30px rgba(0, 0, 0, .14); outline: 2px solid var(--green); outline-offset: -2px; border-radius: 12px; }
body.is-dragging, body.is-dragging * { -webkit-user-select: none; user-select: none; cursor: grabbing; }
@media (max-width: 700px) {
  table.stack tr.dragging { background: var(--surface); padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
  .c-move { width: auto; }
}

/* ---------- Rückfrage-Dialog (z. B. Abmelden) ---------- */
dialog.confirm { width: min(380px, calc(100vw - 32px)); text-align: center; padding: 28px 24px 22px; }
.confirm-title { margin: 0 0 8px; font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.confirm-text { margin: 0 0 22px; font-size: 15px; color: var(--muted); }
.btn.danger-fill { background: var(--danger); color: #fff; }
.btn.danger-fill:hover { background: var(--danger); filter: brightness(.92); text-decoration: none; }
@media (max-width: 700px) { dialog.confirm { width: 100%; } }

/* ---------- Anmeldung: Benutzerwahl + PIN-Ziffernfeld ---------- */
.login h1 { font-size: 28px; text-align: center; margin-bottom: 20px; }
.login-step[hidden] { display: none; }
.user-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.user-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px 14px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--fill); color: var(--text); font: inherit;
  transition: background .2s, transform .1s;
}
.user-tile:hover { background: var(--fill-strong); }
.user-tile:active { transform: scale(.97); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--lime), var(--green)); color: var(--on-accent);
  font-size: 24px; font-weight: 600;
}
.avatar.vorstand { background: linear-gradient(135deg, #8e8e93, #3a3a3c); color: #fff; }
.user-name { font-size: 17px; font-weight: 600; }
.user-role { font-size: 13px; color: var(--muted); margin-top: -4px; }

.back { display: block; margin: -6px 0 8px; font-size: 15px; }
.login-who { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-who h1 { margin: 0; }
.login-who .avatar { width: 64px; height: 64px; font-size: 28px; }
.login-error { margin: 8px 0 0; text-align: center; font-size: 15px; color: var(--danger); }
.login-error[hidden], #pin-area[hidden], #pw-area[hidden] { display: none; }
#pw-area { margin-top: 18px; }

.pin-hint { margin: 16px 0 10px; text-align: center; color: var(--muted); font-size: 15px; }
.pin-dots { display: flex; justify-content: center; gap: 18px; margin-bottom: 26px; }
.pin-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.6px solid var(--text); transition: background .12s;
}
.pin-dots i.on { background: var(--text); }
.pin-dots.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

.keypad { display: grid; grid-template-columns: repeat(3, 76px); justify-content: center; gap: 14px 22px; }
.keypad button {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--fill); color: var(--text); font: inherit; font-size: 30px; font-weight: 400;
  transition: background .12s;
  -webkit-user-select: none; user-select: none;
}
.keypad button:active { background: var(--fill-strong); }
@media (hover: hover) { .keypad button:hover { background: var(--fill-strong); } }
.keypad .key-del { background: transparent; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 380px) {
  .keypad { grid-template-columns: repeat(3, 68px); gap: 12px 18px; }
  .keypad button { width: 68px; height: 68px; font-size: 26px; }
}
.badge-locked { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 980px; font-size: 12px; font-weight: 600; background: rgba(215, 0, 21, .1); color: var(--danger); vertical-align: middle; }

/* ---------- Kompakte Navigation (Menü-Knopf) ----------
   Wird per Skript aktiviert, sobald die Einträge nicht nebeneinander passen –
   unabhängig von Bildschirmbreite und eingestellter Schriftgröße. */
.topbar.compact .menu-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 980px; padding: 8px 14px; min-height: 40px;
  background: var(--fill); color: var(--text); font: inherit; font-size: 15px; font-weight: 500; cursor: pointer;
}
.topbar.compact nav {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  flex-direction: column; gap: 0; padding: 6px 0 10px;
  background: var(--surface); border-bottom: 1px solid var(--hairline);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .12);
}
.topbar.compact.open nav { display: flex; animation: rise .2s ease; }
.topbar.compact nav a {
  font-size: 19px; color: var(--text); padding: 14px 22px; border-radius: 0; margin: 0;
}
.topbar.compact nav a.active { background: transparent; color: var(--green); font-weight: 600; }
.topbar.compact nav a.logout { margin: 6px 0 0; border-top: 1px solid var(--hairline); color: var(--danger); padding-top: 16px; }
.topbar.compact nav a.logout .who { color: var(--muted); }
.topbar.compact nav a { white-space: nowrap; }

/* ---------- Keine Zeilenumbrüche in Bedienelementen ---------- */
.topbar, .topbar nav a, .brand, .menu-toggle, .btn, .link, .chips a, .segmented span,
th, .field-label, label, .user-name, .user-role, .stat span, .stat strong,
.total, .sheet-label, .card-head p, .section-title, .page-head h1, .card h2,
.given button, .icon-grid button span:not(.ico), .tile-price, .c-time, .c-sum {
  white-space: nowrap;
}
.page-head p { white-space: normal; }
.stat { min-width: 0; overflow: hidden; }
.stat span, .user-name { overflow: hidden; text-overflow: ellipsis; }
.tile-name { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.icon-grid button span:not(.ico) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
td.c-pname { width: 100%; max-width: 0; }
.fit { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) {
  .bar-inline { display: none; }
  table.orders .c-items { min-width: 0; }
}
/* Schmale Handys: zwei Kacheln pro Reihe, damit lange Namen in eine Zeile passen */
@media (max-width: 599px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { min-height: 112px; }
  .tile-name { font-size: 16px; }
}
/* Symbol-Auswahl: breitere Felder, damit Namen vollständig in eine Zeile passen */
.icon-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
@media (max-width: 700px) { .icon-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
