:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1f1a14;
  --muted: #6b645a;
  --line: #ddd6c8;
  --accent: #7a1f1f;
  --accent-ink: #ffffff;
  --ok: #2e7d32;
  --warn: #b26a00;
  --bad: #c62828;
  --input: #fffbe6;
  --input-line: #cfc3a6;
  --calc: #f0ebe0;
  --radius: 10px;
  --tap: 46px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
  padding-bottom: 90px;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.ok { color: var(--ok); }

header.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
header.top a { color: var(--accent-ink); text-decoration: none; font-weight: 600; }
header.top .title { flex: 1; min-width: 200px; }
header.top .title small { display: block; opacity: .85; font-weight: 400; font-size: .85rem; }
.badge {
  padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: rgba(255,255,255,.18); color: var(--accent-ink);
}
.badge.ok { background: #2e7d32; }
.badge.warn { background: #b26a00; }
.badge.bad { background: #8e0000; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stand-btn {
  display: block; text-align: left; width: 100%;
  padding: 18px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); font-size: 1.1rem; font-weight: 600; color: var(--ink);
  min-height: 72px; cursor: pointer;
}
.stand-btn small { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.stand-btn.active { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }

input[type=text], input[type=date], input[type=password], textarea, select {
  font: inherit; min-height: var(--tap); padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--input-line); background: var(--input); color: var(--ink); width: 100%;
}
textarea { min-height: 70px; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
input:read-only { background: var(--calc); color: var(--muted); }

/* Erfassungstabelle */
.tabelle-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.erfassung { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 720px; }
table.erfassung th, table.erfassung td { padding: 2px 3px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.erfassung th { position: sticky; top: 0; background: var(--calc); font-size: .8rem; text-align: right; z-index: 2; font-weight: 600; }
table.erfassung th:first-child, table.erfassung td:first-child {
  position: sticky; left: 0; background: var(--card); text-align: left; z-index: 3; min-width: 140px; white-space: normal;
}
table.erfassung th:first-child { background: var(--calc); z-index: 4; }
table.erfassung td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.erfassung td input.num { width: 64px; min-height: 42px; padding: 6px 5px; }
table.erfassung td.calc { background: var(--calc); color: var(--muted); }
table.erfassung td.soll { font-weight: 600; color: var(--ink); }
table.erfassung tr.gruppe th { position: static; background: var(--calc); font-weight: 700; font-size: .8rem; color: var(--muted); padding-top: 12px; border-bottom: 2px solid var(--line); }
table.erfassung tr.gruppe th:first-child { position: sticky; left: 0; background: var(--calc); color: var(--ink); font-size: .9rem; text-transform: uppercase; letter-spacing: .02em; z-index: 3; }
table.erfassung tr.summe td { font-weight: 700; background: var(--calc); }
table.erfassung .einheit { color: var(--muted); font-size: .75rem; margin-left: 4px; }
table.erfassung .plus { min-height: 42px; min-width: 36px; padding: 0; margin-left: 2px; font-size: 1.2rem; line-height: 1; }
tr.neg td.calc.soll { color: var(--bad); }

/* Kassenabgleich */
.kasse { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .kasse { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.kv .v input { width: 150px; }
.kv .gesamt { font-size: 1.4rem; font-weight: 700; }
.diff { font-size: 1.6rem; font-weight: 800; }
.zaehlhilfe { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.zaehlhilfe label { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.zaehlhilfe label span { width: 56px; text-align: right; color: var(--muted); }
.zaehlhilfe input { width: 70px; }
details summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }

/* Aktionsleiste unten */
.aktionen {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.aktionen .status { flex: 1; min-width: 160px; font-size: .9rem; color: var(--muted); }

/* Listen */
table.liste { width: 100%; border-collapse: collapse; background: var(--card); }
table.liste th, table.liste td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.liste td.num, table.liste th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.liste tr.summe td { font-weight: 700; background: var(--calc); }
table.liste a.btn { min-height: 36px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--calc); }
.pill.offen { background: #fff3cd; color: #7a5200; }
.pill.abgeschlossen { background: #e3f2e5; color: #1f5a24; }

body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
body.login .card { width: min(380px, 100%); display: grid; gap: 12px; }
body.readonly input, body.readonly textarea { pointer-events: none; opacity: .75; }

/* Nur in der Buchhaltungsansicht (nach Buchhaltungs-PIN) sichtbar */
.nur-buch { display: none; }
body.buchhaltung th.nur-buch, body.buchhaltung td.nur-buch { display: table-cell; }
body.buchhaltung div.nur-buch, body.buchhaltung p.nur-buch, body.buchhaltung section.nur-buch { display: block; }
table.gutscheine input { width: 120px; }
table.gutscheine td, table.gutscheine th { padding: 6px 4px; }
body.buchhaltung .btn.nur-buch { display: inline-flex; }
body.buchhaltung table.erfassung { min-width: 980px; }

/* Inhalt verdecken, wenn die App im Hintergrund ist (Vorschau im App-Umschalter) */
body.verdeckt main, body.verdeckt .aktionen { filter: blur(18px); pointer-events: none; }
body.verdeckt::after { content: "Standabrechnung"; position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 2rem; font-weight: 700; z-index: 999; }
/* Text am Stand nicht markier-/kopierbar (kein echter Schutz, nur weniger Beiläufiges) */
body:not(.buchhaltung) table.erfassung td:first-child { -webkit-user-select: none; user-select: none; }

/* Hinweise (Buchhaltung) */
ul.hinweise { margin: 0; padding-left: 20px; }
ul.hinweise li { margin: 4px 0; }
ul.hinweise li.bad { color: var(--bad); font-weight: 600; }
ul.hinweise li.warn { color: var(--warn); }
ul.hinweise li.ok { color: var(--ok); }
.hinweise-zelle { max-width: 360px; white-space: normal; }
.hinweis { display: block; font-size: .8rem; line-height: 1.3; }
.hinweis.bad { color: var(--bad); font-weight: 600; }
.hinweis.warn { color: var(--warn); }
table.zaehler input { width: 110px; }
table.zaehler td, table.zaehler th { padding: 6px 6px; white-space: nowrap; }

/* Flaschen: ganze Flaschen + Rest der angebrochenen Flasche */
table.erfassung td.fl { white-space: nowrap; }
table.erfassung td.fl input.ganz { width: 48px; }
table.erfassung td.fl select.rest { font: inherit; font-size: .85rem; min-height: 42px; padding: 4px 2px; margin-left: 2px;
  border-radius: 8px; border: 1px solid var(--input-line); background: var(--input); color: var(--ink); width: 112px; }
table.erfassung td.fl input.kg { width: 58px; margin-left: 4px; }

/* Eingabefelder einer Spalte stehen linksbündig in einer Linie, auch wenn eine Zelle breiter ist (Flaschen + Rest) */
table.erfassung td.eingabe { text-align: left; }
table.erfassung tr.gruppe th { text-align: left; }
table.erfassung tr.gruppe th:first-child { text-align: left; }

/* Eigenes Dialogfenster */
.dialog-hintergrund { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: grid; place-items: center; padding: 16px; }
.dialog-hintergrund[hidden] { display: none; }
.dialog { background: var(--card); border-radius: var(--radius); padding: 20px; width: min(440px, 100%); box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.dialog h3 { margin: 0 0 8px; }
.dialog p { margin: 0 0 16px; }

/* Startseite Standansicht */
.card.angemeldet { border-left: 6px solid var(--accent); }
.stand-name { font-size: 2rem; font-weight: 800; line-height: 1.1; margin: 4px 0; }
.btn.gross { min-height: 64px; font-size: 1.2rem; padding: 0 28px; }
a.stand-btn { text-decoration: none; }

.pill.geschlossen { background: #e3e8f2; color: #2b3f6b; }
table.tresor td, table.tresor th { padding: 6px 6px; }

/* Hinweise in der Übersicht: nur Marken, aufklappbar */
.pill.bad-pill { background: #fde2e2; color: #8e0000; }
.pill.warn-pill { background: #fff3cd; color: #7a5200; }
.hinweise-details summary { list-style: none; cursor: pointer; min-height: 0; display: inline-flex; gap: 4px; }
.hinweise-details summary::-webkit-details-marker { display: none; }
.hinweise-details[open] > div { margin-top: 6px; max-width: 420px; }
table.liste td { vertical-align: top; }
