:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1d2430;
  --muted: #6a7383;
  --line: #dfe3ea;
  --primary: #1f6feb;
  --primary-dark: #1859c0;
  --accent-bg: #eef4ff;
  --ok: #157f3b;
  --ok-bg: #e7f6ec;
  --warn: #b42318;
  --warn-bg: #fdecea;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #17202e;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: .6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .4rem 1rem;
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.session-info { font-size: .85rem; opacity: .9; }
.session-info.expired { color: #ffb4ab; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}

/* ---------- Karten ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card h2 { margin: 0 0 .75rem; font-size: 1.05rem; }

label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .85rem;
  color: var(--muted);
}

input, select {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 0;
}
input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
input.invalid { border-color: var(--warn); background: var(--warn-bg); }

.meta-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr;
  gap: .75rem;
}
.meta-grid .full { grid-column: 1 / -1; }
.stand-input { font-size: 1.1rem; font-weight: 600; }
.stand-title { font-weight: 400; opacity: .85; }
.stand-title:not(:empty)::before { content: " · "; }

.add-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}
.add-grid .grow { flex: 1 1 200px; }
.add-grid label:not(.grow) { flex: 0 1 160px; }
.add-grid label[hidden] { display: none; }

.presets {
  margin-top: .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  font-size: .85rem;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  padding: .55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f6f8fb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--warn); border-color: #f1c4bf; }
.btn.danger:hover { background: var(--warn-bg); }
.btn.small { font-size: .85rem; padding: .35rem .7rem; margin-top: .6rem; }

.chip {
  font: inherit;
  font-size: .82rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-bg);
  color: var(--primary-dark);
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--warn-bg); color: var(--warn); }
.icon-btn.small { font-size: .9rem; }

/* ---------- Getränkekarte ---------- */
.drink { border-left: 5px solid var(--primary); }
.drink.typ-fass { border-left-color: #c58a00; }

.drink-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  margin-bottom: .6rem;
}
.drink-name {
  flex: 1 1 200px;
  font-size: 1.1rem;
  font-weight: 600;
  border-color: transparent;
  background: transparent;
  padding-left: .3rem;
}
.drink-name:hover { border-color: var(--line); }
.badge {
  font-size: .75rem;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--primary-dark);
}
.typ-fass .badge { background: #fff4d6; color: #8a5f00; }
.unit-setting {
  flex-direction: row;
  align-items: center;
  gap: .4rem;
}
.unit-setting input { width: 4.5rem; text-align: right; padding: .3rem .4rem; }

.table-scroll { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; }
.protocol th, .protocol td {
  padding: .35rem .4rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.protocol thead th {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.protocol tbody th {
  font-weight: 500;
  white-space: nowrap;
  width: 30%;
}
.protocol td:last-child, .protocol th:last-child { width: 2.2rem; text-align: center; }
.num-input { display: block; width: 100%; max-width: 8rem; margin-left: auto; text-align: right; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.sum { white-space: nowrap; color: var(--muted); }

.row-gesamt { background: #f7f9fc; }
.row-gesamt th, .row-gesamt td { font-weight: 600; }
.row-gesamt .sum { color: var(--text); }

.row-verbrauch { background: var(--ok-bg); }
.row-verbrauch th, .row-verbrauch td { border-bottom: none; }
.row-verbrauch th, .row-verbrauch .sum { color: var(--ok); font-weight: 700; font-size: 1.1rem; }
.row-verbrauch .out-verbrauch-detail { color: var(--ok); font-size: .9rem; }
.row-verbrauch.pending { background: #f4f5f7; }
.row-verbrauch.pending th,
.row-verbrauch.pending td { color: var(--muted); font-weight: 500; }
.row-verbrauch.negative { background: var(--warn-bg); }
.row-verbrauch.negative th,
.row-verbrauch.negative td { color: var(--warn); }

.empty-hint {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem 0;
}

/* ---------- Übersicht ---------- */
.summary-table th, .summary-table td {
  padding: .5rem .5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.summary-table thead th { font-size: .8rem; color: var(--muted); text-transform: uppercase; }
.summary-table .strong span { font-weight: 700; color: var(--ok); }
.summary-table small { display: block; color: var(--muted); font-size: .78rem; }
.summary-table tr.negative td { color: var(--warn); }
.summary-table tr.negative .strong span { color: var(--warn); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  justify-content: flex-end;
  margin: 1rem 0 2rem;
}

/* ---------- Hinweise ---------- */
.notice {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .92rem;
}
.notice.info { background: var(--accent-bg); color: var(--primary-dark); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Mobil ---------- */
@media (max-width: 640px) {
  .container { padding: .6rem; }
  .card { padding: .75rem; }
  .meta-grid { grid-template-columns: 1fr; }
  .add-grid label:not(.grow) { flex: 1 1 45%; }
  .add-grid .btn { flex: 1 1 100%; }
  .protocol tbody th { white-space: normal; font-size: .88rem; width: auto; }
  .protocol thead th { font-size: .7rem; }
  .num-input { padding: .45rem .35rem; }
  .sum { font-size: .85rem; }
  .summary-table .hide-mobile { display: none; }
}

/* ---------- Druck ---------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 10.5pt; }
  .no-print, .topbar, .notice, .empty-hint { display: none !important; }
  .container { max-width: none; padding: 0; }
  .card { border: 1px solid #999; break-inside: avoid; padding: .5rem .7rem; margin-bottom: .6rem; }
  .drink { border-left-width: 1px; }
  input, select { border: none; padding: 0; background: transparent; }
  .drink-name { font-size: 1rem; }
  .row-verbrauch, .row-gesamt { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
