/* ===== Farbrollen (helles & dunkles Theme) ===== */
:root {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --muted:          #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --series-1:       #2a78d6;
  --good:           #0ca30c;
  --good-text:      #006300;
  --critical:       #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:           #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --muted:          #898781;
    --grid:           #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255, 255, 255, 0.10);
    --series-1:       #3987e5;
    --good:           #0ca30c;
    --good-text:      #0ca30c;
    --critical:       #d03b3b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 0.5rem; }

/* ===== Login ===== */
.screen { min-height: 100dvh; }
#screen-login { display: flex; align-items: center; justify-content: center; padding: 1rem; }
#screen-login.hidden { display: none; }
.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 22rem;
  width: 100%;
}
.login-emoji { font-size: 3.5rem; }

/* ===== Kopfzeile ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  padding-top: calc(0.7rem + env(safe-area-inset-top));
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.chip {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-primary);
}
.chip.negative { color: var(--critical); }
.btn-icon { background: none; border: none; font-size: 1.1rem; color: var(--muted); cursor: pointer; padding: 0.2rem; }

/* ===== Layout ===== */
#main { padding: 1rem; padding-bottom: calc(5rem + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.hint { margin: 0.2rem 0 0.8rem; font-size: 0.9rem; }
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem 1rem;
  margin: 0.9rem 0;
}
.card h2 { margin-top: 0; }

/* ===== Getränke-Buttons ===== */
.drink-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.7rem; }
.drink-btn {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 0.6rem 0.8rem;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-primary);
  transition: transform 0.06s ease;
}
.drink-btn:active { transform: scale(0.95); }
.drink-btn .emoji { font-size: 2.2rem; display: block; }
.drink-btn .name { font-weight: 600; display: block; margin-top: 0.3rem; }
.drink-btn .price { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* ===== Kacheln (Stat-Tiles) ===== */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.7rem; margin: 0.3rem 0 0.5rem; }
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
}
.tile .label { font-size: 0.78rem; color: var(--muted); }
.tile .value { font-size: 1.5rem; font-weight: 700; margin-top: 0.15rem; }
.tile .value.negative { color: var(--critical); }
.tile .value.positive { color: var(--good-text); }

/* ===== Listen & Tabellen ===== */
.list { display: flex; flex-direction: column; gap: 0.4rem; }
.list-row {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  font-size: 0.92rem;
}
.list-row .grow { flex: 1; min-width: 0; }
.list-row .when { color: var(--muted); font-size: 0.8rem; }
.list-row .amount { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.list-row .undo { background: none; border: none; color: var(--series-1); cursor: pointer; font-size: 0.85rem; padding: 0.2rem; }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table td, .table th { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--grid); text-align: left; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: none; }
.table .negative { color: var(--critical); }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  margin-top: 0.5rem;
}
.btn-primary { background: var(--series-1); color: #fff; border-color: transparent; }
.btn-secondary { background: var(--surface-1); color: var(--text-primary); }
.btn-big { font-size: 1.05rem; padding: 0.8rem 1.4rem; width: 100%; }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.82rem; margin: 0; white-space: nowrap; }

/* ===== Tab-Leiste ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  background: none; border: none;
  font-family: inherit;
  font-size: 1.2rem;
  padding: 0.5rem 0 0.45rem;
  color: var(--muted);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
}
.tab span { font-size: 0.68rem; }
.tab.active { color: var(--series-1); font-weight: 600; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(4.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text-primary); color: var(--page);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  display: flex; align-items: center; gap: 0.9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 20;
  max-width: min(92vw, 26rem);
}
.toast-btn { background: none; border: none; color: var(--series-1); font-weight: 700; cursor: pointer; font-size: 0.95rem; }

/* ===== Admin-Getränkeliste ===== */
.admin-drink {
  display: flex; flex-wrap: wrap;
  gap: 0.4rem; align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--grid);
}
.admin-drink input[type="text"], .admin-drink input[type="number"] {
  font-family: inherit; font-size: 0.9rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--page); color: var(--text-primary);
}
.admin-drink .f-emoji { width: 3.2rem; text-align: center; }
.admin-drink .f-name { flex: 1 1 8rem; min-width: 6rem; }
.admin-drink .f-price { width: 5rem; }
.admin-drink label { white-space: nowrap; }

/* ===== Dialog ===== */
dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 1.2rem;
  width: min(92vw, 22rem);
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog label { display: block; margin: 0.6rem 0; font-size: 0.9rem; color: var(--text-secondary); }
dialog input, dialog select {
  width: 100%; margin-top: 0.25rem;
  font-family: inherit; font-size: 1rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--page); color: var(--text-primary);
}
.dlg-buttons { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.8rem; }

/* ===== Diagramme ===== */
.viz-root svg { display: block; width: 100%; height: auto; }
.viz-root .bar-label { font-size: 12px; fill: var(--text-secondary); }
.viz-root .bar-value { font-size: 12px; font-weight: 600; fill: var(--text-primary); font-variant-numeric: tabular-nums; }
.viz-root .axis-label { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.viz-root .gridline { stroke: var(--grid); stroke-width: 1; }
.viz-root .baseline { stroke: var(--baseline); stroke-width: 1; }
.viz-tooltip {
  position: fixed; z-index: 30; pointer-events: none;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.3rem 0.55rem; font-size: 0.8rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
