/* =====================================================================
   Getränke-Service-App – mobiles Stylesheet
   ===================================================================== */

:root {
  --c-bg: #f2f4f3;
  --c-surface: #ffffff;
  --c-text: #1c2422;
  --c-muted: #5f6d69;
  --c-border: #dde3e0;
  --c-primary: #1f6f54;
  --c-primary-dark: #175843;
  --c-primary-soft: #e2f1ea;
  --c-accent: #b7791f;
  --c-danger: #b3352c;
  --c-danger-soft: #fbe9e7;
  --c-warn: #8a6d1a;
  --c-warn-soft: #fdf3d5;
  --c-ok-soft: #e2f1ea;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 40, 34, 0.10), 0 4px 14px rgba(20, 40, 34, 0.06);
  --footer-h: calc(64px + env(safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 16px;
  line-height: 1.45;
}

button { font: inherit; }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }

/* ------------------------------------------------------------------ */
/* Login                                                                */
/* ------------------------------------------------------------------ */
.login-page { display: flex; min-height: 100dvh; align-items: center; justify-content: center; padding: 1rem; }
.login-wrap { width: 100%; max-width: 420px; text-align: center; }
.login-logo { font-size: 3.2rem; margin-bottom: .25rem; }
.login-wrap h1 { font-size: 1.6rem; }
.login-sub { color: var(--c-muted); margin: 0 0 1.25rem; }
.login-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.25rem; }
.login-name-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 1rem 1.1rem;
  background: var(--c-surface); border: 2px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 1.15rem; font-weight: 600; cursor: pointer; text-align: left;
}
.login-name-btn:active { transform: scale(.985); }
.login-name-btn.is-last-used { border-color: var(--c-primary); background: var(--c-primary-soft); }
.login-divider { display: flex; align-items: center; gap: .75rem; color: var(--c-muted); font-size: .85rem; margin: 1rem 0; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--c-border); }
.login-new { display: flex; flex-direction: column; gap: .6rem; }

/* ------------------------------------------------------------------ */
/* Grundelemente                                                        */
/* ------------------------------------------------------------------ */
.input, select.input, textarea.input {
  width: 100%; padding: .85rem 1rem; font-size: 1.05rem;
  border: 1.5px solid var(--c-border); border-radius: 12px;
  background: var(--c-surface); color: var(--c-text);
}
.input:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .9rem 1.2rem; min-height: 52px;
  border: none; border-radius: 12px; font-size: 1.05rem; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: transform .06s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:not(:disabled):active { background: var(--c-primary-dark); }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border: 1.5px solid var(--c-border); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-ghost-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 42px; padding: .5rem .9rem; font-size: .95rem; }

.alert { padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 600; }
.alert-error { background: var(--c-danger-soft); color: var(--c-danger); }

.status-badge {
  display: inline-block; padding: .15rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.status-service { background: var(--c-ok-soft); color: var(--c-primary); }
.status-kitchen { background: #e8eaf6; color: #3f51a5; }
.status-pause { background: var(--c-warn-soft); color: var(--c-warn); }
.status-unavailable { background: #eceff1; color: #607d8b; }

/* ------------------------------------------------------------------ */
/* App-Shell                                                            */
/* ------------------------------------------------------------------ */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--c-primary); color: #fff;
  padding: calc(.6rem + env(safe-area-inset-top, 0px)) .9rem .6rem;
  display: flex; align-items: center; gap: .6rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.app-header .hdr-info { flex: 1; min-width: 0; }
.app-header .hdr-title { font-size: 1.02rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .hdr-sub { font-size: .8rem; opacity: .92; display: flex; align-items: center; gap: .4rem; white-space: nowrap; overflow: hidden; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #7ee2b1; flex: none; }
.conn-dot.is-connecting { background: #ffd75e; }
.conn-dot.is-offline { background: #ff8a80; }

.hdr-btn {
  flex: none; width: 46px; height: 46px; border-radius: 12px;
  background: rgba(255,255,255,.14); color: #fff; border: none;
  font-size: 1.35rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.hdr-pause {
  flex: none; border: none; border-radius: 12px; min-height: 46px;
  padding: 0 .8rem; font-weight: 800; font-size: .9rem; cursor: pointer;
  background: rgba(255,255,255,.16); color: #fff;
}
.hdr-pause.is-paused { background: var(--c-warn-soft); color: var(--c-warn); }

.app-main { padding: 1rem .9rem calc(var(--footer-h) + 1rem); max-width: 720px; margin: 0 auto; }

/* Footer-Navigation */
.footer-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(20,40,34,.08);
}
.footer-nav button {
  flex: 1; min-height: 64px; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--c-muted); font-size: .72rem; font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.footer-nav button .nav-ico { font-size: 1.45rem; line-height: 1; }
.footer-nav button.is-active { color: var(--c-primary); }
.footer-nav button.is-active::after {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px;
  background: var(--c-primary); border-radius: 0 0 3px 3px;
}
.nav-badge {
  position: absolute; top: 7px; right: calc(50% - 26px);
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--c-danger); color: #fff; font-size: .7rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

/* ------------------------------------------------------------------ */
/* Ansichten                                                            */
/* ------------------------------------------------------------------ */
.view { display: none; }
.view.is-active { display: block; }
.view-title { font-size: 1.35rem; font-weight: 800; margin-bottom: .8rem; }

.seg {
  display: flex; background: #e4e9e7; border-radius: 12px; padding: 4px; margin-bottom: 1rem;
}
.seg button {
  flex: 1; border: none; background: none; border-radius: 9px;
  min-height: 46px; font-weight: 700; font-size: .98rem; color: var(--c-muted); cursor: pointer;
}
.seg button.is-active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow); }

.card {
  background: var(--c-surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .95rem 1rem; margin-bottom: .75rem;
  border-left: 5px solid transparent;
}
.card.is-mine { border-left-color: var(--c-primary); }
.card.is-sub { border-left-color: var(--c-accent); background: #fffaf1; }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.card-title { font-size: 1.18rem; font-weight: 800; }
.card-meta { color: var(--c-muted); font-size: .88rem; margin-top: .15rem; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }

.chip {
  display: inline-block; padding: .18rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; background: #eef1f0; color: var(--c-muted);
}
.chip-mine { background: var(--c-primary-soft); color: var(--c-primary); }
.chip-sub { background: #fdf0d9; color: var(--c-accent); }
.chip-open { background: var(--c-danger-soft); color: var(--c-danger); }
.chip-zero { background: #eef1f0; color: var(--c-muted); }

.empty-hint {
  text-align: center; color: var(--c-muted); padding: 2.2rem 1rem;
  background: var(--c-surface); border-radius: var(--radius); border: 1.5px dashed var(--c-border);
}

/* Tischauswahl (Aufnehmen) */
.table-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.table-pick button {
  border: 2px solid var(--c-border); background: var(--c-surface); border-radius: 12px;
  min-height: 64px; padding: .5rem .6rem; cursor: pointer; font-weight: 700; font-size: 1rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
}
.table-pick button .tp-sub { font-size: .72rem; font-weight: 600; color: var(--c-muted); }
.table-pick button.is-selected { border-color: var(--c-primary); background: var(--c-primary-soft); }
.table-pick button.is-sub { border-color: var(--c-accent); }

/* Getränke-Stepper */
.drink-list { margin-bottom: 1rem; }
.drink-row {
  display: flex; align-items: center; justify-content: space-between; gap: .7rem;
  background: var(--c-surface); border-radius: 12px; box-shadow: var(--shadow);
  padding: .55rem .7rem .55rem 1rem; margin-bottom: .55rem;
}
.drink-row.has-qty { outline: 2px solid var(--c-primary); }
.drink-name { font-weight: 700; font-size: 1.05rem; }
.stepper { display: flex; align-items: center; gap: .15rem; }
.stepper button {
  width: 52px; height: 52px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 1.7rem; font-weight: 800; line-height: 1;
  background: #edf1ef; color: var(--c-text);
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.stepper button.plus { background: var(--c-primary-soft); color: var(--c-primary); }
.stepper button:active { transform: scale(.93); }
.stepper .qty { width: 44px; text-align: center; font-size: 1.25rem; font-weight: 800; }
.stepper .qty.is-zero { color: #b6c0bc; }

.submit-bar {
  position: fixed; left: 0; right: 0; bottom: var(--footer-h); z-index: 45;
  padding: .6rem .9rem;
  background: linear-gradient(to top, var(--c-bg) 65%, rgba(242,244,243,0));
}
.submit-bar .btn { width: 100%; max-width: 720px; margin: 0 auto; display: flex; box-shadow: 0 4px 16px rgba(23,88,67,.35); }

/* Bestellkarten (Getränke machen) */
.order-card { border-left-width: 6px; }
.order-card.age-warn { border-left-color: #e2b93b; background: #fffdf4; }
.order-card.age-late { border-left-color: var(--c-danger); background: #fff7f6; }
.order-card.is-delivered { opacity: .75; border-left-color: var(--c-primary); }
.wait-text { font-weight: 700; font-size: .88rem; color: var(--c-muted); }
.age-warn .wait-text { color: var(--c-warn); }
.age-late .wait-text { color: var(--c-danger); }

.order-items { margin: .6rem 0; padding: 0; list-style: none; }
.order-items li { display: flex; gap: .55rem; padding: .18rem 0; font-size: 1.02rem; }
.order-items .oi-qty { font-weight: 800; min-width: 2.2rem; text-align: right; }
.order-items li.is-cancelled { text-decoration: line-through; color: var(--c-muted); }
.addition-block {
  margin: .45rem 0; padding: .5rem .7rem; border-radius: 10px;
  background: #f4f7f6; border-left: 3px solid var(--c-accent);
}
.addition-label { font-size: .78rem; font-weight: 700; color: var(--c-accent); margin-bottom: .15rem; }

.order-actions { display: flex; gap: .55rem; margin-top: .6rem; flex-wrap: wrap; }
.order-actions .btn { flex: 1; min-width: 130px; }

.preparing-note {
  margin-top: .5rem; padding: .45rem .7rem; border-radius: 10px;
  background: #e8eaf6; color: #3f51a5; font-weight: 700; font-size: .9rem;
}

/* ------------------------------------------------------------------ */
/* Modale / Sheets                                                      */
/* ------------------------------------------------------------------ */
.overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(15, 25, 21, .48);
  display: none; align-items: flex-end; justify-content: center;
}
.overlay.is-open { display: flex; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  background: var(--c-surface); border-radius: 18px 18px 0 0;
  padding: 1.1rem 1rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
}
.sheet h2 { font-size: 1.2rem; margin-bottom: .9rem; }
.sheet .form-row { margin-bottom: .85rem; }
.sheet label { display: block; font-size: .85rem; font-weight: 700; color: var(--c-muted); margin-bottom: .3rem; }
.sheet-actions { display: flex; gap: .6rem; margin-top: 1rem; }
.sheet-actions .btn { flex: 1; }

.menu-list { display: flex; flex-direction: column; gap: .35rem; }
.menu-list button {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  padding: .9rem .8rem; min-height: 54px; border: none; background: none;
  border-radius: 12px; font-size: 1.05rem; font-weight: 600; cursor: pointer; text-align: left;
  color: var(--c-text);
}
.menu-list button:active { background: var(--c-bg); }
.menu-list .mi-ico { font-size: 1.3rem; width: 1.6rem; text-align: center; }
.menu-list .is-danger { color: var(--c-danger); }

/* Toast + Undo */
.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(var(--footer-h) + 10px); z-index: 90;
  display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none;
  padding: 0 1rem;
}
.toast {
  pointer-events: auto; max-width: 480px; width: 100%;
  background: #26332e; color: #fff; border-radius: 12px;
  padding: .8rem 1rem; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  animation: toast-in .2s ease;
}
.toast.is-error { background: var(--c-danger); }
.toast .toast-action {
  border: none; background: rgba(255,255,255,.18); color: #fff;
  border-radius: 9px; padding: .45rem .85rem; font-weight: 800; cursor: pointer; font-size: .95rem;
  white-space: nowrap;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ */
/* Tagesabschluss                                                       */
/* ------------------------------------------------------------------ */
.sum-table { width: 100%; border-collapse: collapse; background: var(--c-surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 1rem; }
.sum-table th, .sum-table td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--c-border); font-size: .95rem; }
.sum-table th { background: #eef1f0; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--c-muted); }
.sum-table td.num, .sum-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sum-table tr:last-child td { border-bottom: none; }
.sum-table .total-row td { font-weight: 800; background: var(--c-primary-soft); }
.sum-section { margin-bottom: 1.4rem; }
.sum-section h3 { font-size: 1.05rem; margin-bottom: .5rem; }
.table-scroll { overflow-x: auto; }

details.sum-detail { background: var(--c-surface); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: .5rem; }
details.sum-detail summary {
  padding: .8rem 1rem; font-weight: 700; cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; gap: .6rem;
}
details.sum-detail summary::-webkit-details-marker { display: none; }
details.sum-detail .detail-body { padding: 0 1rem .8rem; }
.detail-line { display: flex; justify-content: space-between; gap: .6rem; padding: .35rem 0; border-top: 1px solid var(--c-border); font-size: .92rem; flex-wrap: wrap; }
.detail-line .dl-meta { color: var(--c-muted); font-size: .82rem; width: 100%; }
.detail-line .dl-actions { display: flex; gap: .4rem; width: 100%; margin-top: .25rem; }
.detail-line .dl-actions button {
  border: 1.5px solid var(--c-border); background: var(--c-surface); border-radius: 9px;
  padding: .35rem .7rem; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.closed-banner {
  background: var(--c-warn-soft); color: var(--c-warn); border-radius: 12px;
  padding: .8rem 1rem; font-weight: 700; margin-bottom: 1rem;
}

/* ------------------------------------------------------------------ */
/* Ablauf (Tages-Checkliste)                                            */
/* ------------------------------------------------------------------ */
.sched-progress {
  background: var(--c-primary-soft); color: var(--c-primary);
  border-radius: 12px; padding: .6rem 1rem; font-weight: 800; margin-bottom: 1rem;
  text-align: center;
}
.sched-section { margin-bottom: 1.3rem; }
.sched-section h3 { font-size: 1rem; margin-bottom: .5rem; color: var(--c-muted); }
.check-row {
  display: flex; align-items: flex-start; gap: .8rem; width: 100%;
  background: var(--c-surface); border: none; border-radius: 12px;
  box-shadow: var(--shadow); padding: .8rem .9rem; margin-bottom: .5rem;
  cursor: pointer; text-align: left; font: inherit; color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
}
.check-row:active { transform: scale(.99); }
.check-box {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  border: 2.5px solid var(--c-border); background: var(--c-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: 900; color: #fff; margin-top: .05rem;
}
.check-row.is-done .check-box { background: var(--c-primary); border-color: var(--c-primary); }
.check-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.check-label { font-weight: 700; font-size: 1.02rem; }
.check-row.is-done .check-label { text-decoration: line-through; color: var(--c-muted); }
.check-sub { font-size: .82rem; color: var(--c-muted); }
.check-done-info { color: var(--c-primary); font-weight: 700; }

@media (min-width: 720px) {
  .app-main { padding-top: 1.4rem; }
  .table-pick { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
