:root {
  --bg: #f2f4f3; --surface: #fff; --ink: #18211e; --muted: #67736e; --line: #dde3e0;
  --accent: #1d7a4f; --accent-ink: #fff; --soft: #e1f1e8; --danger: #b3372f; --warn: #9a6a00; --warn-bg: #fdf1d3;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111715; --surface: #1b2320; --ink: #e8eeeb; --muted: #94a19b; --line: #2a3531;
    --accent: #3fae7a; --accent-ink: #08140f; --soft: #1d3228; --danger: #ef8a82; --warn: #f0c35a; --warn-bg: #3a2f10; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
#app { max-width: 640px; margin: 0 auto; padding: 0 14px 90px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 2px 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Kopfzeile */
.top { display: flex; align-items: center; gap: 6px; padding: 14px 0 10px; position: sticky; top: env(safe-area-inset-top); background: var(--bg); z-index: 5; }
.top h1 { font-size: 22px; flex: 1; }
.back { font-size: 30px; line-height: 1; padding: 0 10px 4px 2px; color: var(--accent); text-decoration: none; }
.top.home { padding-top: 22px; }
.top.home h1 { font-size: 28px; }

/* Startseite */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 14px 14px; color: inherit; text-decoration: none; min-height: 118px; }
.tile:active { background: var(--soft); }
.tile .ti { font-size: 32px; line-height: 1.1; }
.tile b { font-size: 17px; margin-top: auto; }
.tile small { color: var(--muted); }
.tile .badge { position: absolute; top: 12px; right: 12px; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 1px 9px; font-size: 14px; font-weight: 600; }

/* Eingabe / Vorschläge */
.addbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
input[type=text], input[type=search], input[type=date], input[type=time], input[type=number], input[type=password], select {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px; min-height: 46px; }
.addbar input { flex: 1; width: auto; }
#sugg { width: 100%; display: flex; flex-direction: column; gap: 6px; }
#sugg:empty { display: none; }
.sg { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.sg.info { color: var(--muted); }
.sg.new { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sg.new span { flex: 1 1 100%; }
.sg.new select { flex: 1; width: auto; }
.primary { background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 0 16px; min-height: 46px; font-weight: 600; }
.primary.sm { min-height: 40px; padding: 0 14px; }
.primary.wide { width: 100%; margin: 4px 0 10px; }
.ghost { display: flex; align-items: center; justify-content: center; text-align: center; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 6px 14px; min-height: 44px; line-height: 1.25; }
.ghost.danger, .danger { color: var(--danger); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.actions > * { flex: 1; }

/* Gruppen & Zeilen */
.grp { margin: 18px 0 6px; }
.grp > h2 { font-size: 15px; font-weight: 600; color: var(--muted); padding: 0 2px 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; overflow: hidden; }
.row .main { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 12px; text-align: left; min-height: 52px; min-width: 0; }
.row .main > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.row .main.on { background: var(--soft); }
.row em { font-style: normal; color: var(--muted); font-size: 14px; margin-left: 6px; }
.row .price { color: var(--muted); font-size: 13px; margin-left: auto; padding-left: 8px; white-space: nowrap; }
.row .count { color: var(--accent); font-weight: 600; font-size: 14px; padding-right: 12px; white-space: nowrap; }
.circle { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--accent); display: grid; place-items: center; }
.circle.full { background: var(--accent); }
.circle.full::after { content: "✓"; color: var(--accent-ink); font-size: 14px; font-weight: 700; }
.mini { width: 44px; align-self: stretch; color: var(--muted); font-size: 18px; }
.mini.fav { color: #d9a400; }
.mini:active { background: var(--soft); }
.total { margin: 14px 2px 0; color: var(--muted); }
.total b { color: var(--ink); }

/* Tabs / Chips */
.tabs, .chips { display: flex; gap: 8px; overflow-x: auto; margin: 4px 0 14px; padding-bottom: 2px; }
.tabs button, .chips button { flex: none; padding: 9px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); }
.tabs button.act, .chips button.act { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.card { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.card > div:first-child { flex: 1; min-width: 0; }
.card small { display: block; color: var(--muted); }

/* Kassenbon */
.drop { display: grid; place-items: center; text-align: center; min-height: 150px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); padding: 20px; cursor: pointer; font-weight: 600; }
.drop:active { background: var(--soft); }
.status { display: flex; align-items: center; gap: 10px; padding: 18px 4px; color: var(--muted); }
.spin { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }
.rhead { display: grid; gap: 8px; margin-bottom: 10px; }
.rhead .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rrow { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 6px; }
.rrow.off { opacity: .45; }
.rrow > input[type=checkbox] { width: 22px; height: 22px; margin-top: 12px; accent-color: var(--accent); flex: none; }
.rf { flex: 1; min-width: 0; display: grid; gap: 6px; }
.r2 { display: grid; grid-template-columns: 1fr 64px 92px; gap: 6px; }
.r2 input, .r2 select, .rf > input { min-height: 40px; padding: 8px 10px; }
.r3 { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.tag { border-radius: 99px; padding: 0 8px; background: var(--soft); color: var(--accent); }
.tag.new { background: var(--warn-bg); color: var(--warn); }
.rsum { border-radius: 12px; padding: 10px 12px; margin: 4px 0 8px; background: var(--soft); font-size: 14px; }
.rsum.bad { background: var(--warn-bg); color: var(--warn); }
.cb { display: flex; gap: 10px; align-items: center; padding: 8px 2px; }
.cb input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Statistik */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.kpi b { display: block; font-size: 22px; }
.kpi small { color: var(--muted); }
.stat h2 { font-size: 17px; margin: 22px 2px 10px; }
.brow { margin-bottom: 10px; }
.bl { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.bar { height: 8px; border-radius: 99px; background: var(--line); margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* Sheet */
.sheetbg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { position: relative; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.sheet h2 { font-size: 20px; padding-right: 40px; }
.sheet h3 { font-size: 14px; color: var(--muted); margin-top: 8px; }
.sheet .x { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; font-size: 18px; color: var(--muted); }
.sheet .scroll { max-height: 46vh; overflow-y: auto; }
.sheet .actions { margin: 6px 0 0; }
.sheet label.l { font-size: 14px; color: var(--muted); display: grid; gap: 4px; }

/* Toast */
#toast { position: fixed; left: 14px; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom)); max-width: 612px; margin: 0 auto; background: var(--ink); color: var(--bg);
  border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; transform: translateY(calc(100% + 60px)); transition: transform .2s; z-index: 30; white-space: pre-line; pointer-events: none; }
#toast.show { transform: none; pointer-events: auto; }
#toast button { color: var(--accent); font-weight: 700; filter: brightness(1.4); }

/* Login */
#login { position: fixed; inset: 0; background: var(--bg); z-index: 40; display: grid; place-items: center; padding: 20px; overflow-y: auto; }
#login[hidden] { display: none; }
.lbox { width: 100%; max-width: 320px; text-align: center; }
.lbox .logo { width: 72px; height: 72px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); font-size: 36px; display: grid; place-items: center; margin: 0 auto 14px; }
.lbox p { color: var(--muted); margin: 6px 0 18px; }
.dots { display: flex; gap: 14px; justify-content: center; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent); }
.dots i.f { background: var(--accent); }
.perr { min-height: 24px; color: var(--danger); margin: 12px 0 4px; font-size: 14px; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad button { height: 64px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); font-size: 24px; }
.pad button:active { background: var(--soft); }

textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }

/* Manager: Abschnitte, Listen-Modul */
.sec { font-size: 15px; font-weight: 600; color: var(--muted); margin: 20px 2px 8px; }
.top + .sec { margin-top: 6px; }
.linkcard { color: inherit; text-decoration: none; }
.linkcard:active { background: var(--soft); }
.bigemoji { font-size: 28px; line-height: 1; }
.row.entry { flex-wrap: wrap; }
.row.entry .sub { flex: 1 1 100%; padding: 0 14px 12px 50px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.row.entry .sub a { color: var(--accent); }
.row.entry.done .t { text-decoration: line-through; color: var(--muted); }
.row.entry .time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }
.stars { color: #d9a400; letter-spacing: 1px; }
.langrow { justify-content: center; margin: 22px 0 0; }

.links { display: grid; gap: 8px; }
.links:empty { display: none; }
.lrow { display: grid; grid-template-columns: 1fr 44px; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.lrow .ll { grid-column: 1; min-height: 40px; padding: 8px 10px; }
.lrow .lu { grid-column: 1; min-height: 40px; padding: 8px 10px; }
.lrow .mini { grid-column: 2; grid-row: 1 / span 2; width: 44px; }

/* ===== Desktop & Tablet ===== */
.cols .grp { margin: 0 0 18px; break-inside: avoid; }
.cols { margin-top: 14px; }
.cardgrid { display: grid; gap: 8px; }
.cardgrid .card { margin-bottom: 0; }

@media (hover: hover) {
  .row .main:hover { background: var(--soft); }
  .tile:hover, .linkcard:hover { border-color: var(--accent); }
  .mini:hover { background: var(--soft); color: var(--ink); }
  .ghost:hover { border-color: var(--accent); }
  .primary:hover { filter: brightness(1.08); }
  .tabs button:hover, .chips button:hover, .sg:hover, .pad button:hover { border-color: var(--accent); }
  button, .tile, .linkcard { transition: background-color .12s, border-color .12s; }
}
@media (min-width: 760px) {
  body { font-size: 17px; }
  #app { max-width: 760px; padding: 0 24px 90px; }
  #app.r-home { max-width: 920px; }
  #app.r-home .tiles { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  #app.r-home .tile { min-height: 140px; }
  .top { padding-top: 22px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .cardgrid { grid-template-columns: 1fr 1fr; }
  .sheetbg { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; max-width: 560px; max-height: 86vh; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
  .sheet .scroll { max-height: 50vh; }
  #toast { left: 50%; right: auto; width: 560px; margin-left: -280px; }
  .actions > * { flex: 0 1 auto; min-width: 180px; }
  .primary.wide { width: auto; padding: 0 28px; }
}
@media (min-width: 1000px) {
  #app.r-list, #app.r-stock { max-width: 1080px; }
  #app.r-list .cols, #app.r-stock .cols { column-count: 2; column-gap: 24px; }
}

/* Einkaufsliste: Bestand und Liste nebeneinander (Desktop) bzw. per Reiter (Handy) */
.shop .pane { display: none; }
.shop .pane.act { display: block; }
.tabs2 { display: flex; gap: 8px; margin: 0 0 14px; }
.tabs2 button { flex: 1; padding: 11px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.tabs2 button.act { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ph { font-size: 17px; margin: 4px 2px 10px; display: flex; align-items: center; gap: 8px; }
.cnt { background: var(--soft); color: var(--accent); border-radius: 99px; padding: 0 8px; font-size: 13px; font-weight: 700; }
.chips .act .cnt { background: rgba(255,255,255,.25); color: inherit; }
.addbtn { width: 48px; align-self: stretch; font-size: 22px; font-weight: 700; color: var(--accent); background: var(--soft); }
.addbtn.on { background: var(--accent); color: var(--accent-ink); }
.addbtn:active { filter: brightness(.9); }
.shop .addbar input { width: 100%; }
@media (min-width: 1000px) {
  #app.r-list { max-width: 1180px; }
  .tabs2 { display: none; }
  .shop { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
  .shop .pane, .shop .pane.act { display: block; }
  .shop .pane:last-child { position: sticky; top: 70px; }
  #app.r-list .cols { column-count: 1; }
}
