/* Plattenkiste: hell und kontrastreich für draußen am Stand, Preise als runde Preisaufkleber. */
:root {
  --bg: #E9ECE6;        /* graugrüne Plattenladen-Wand */
  --surface: #F7F8F5;   /* Innenhülle */
  --ink: #1B2420;       /* Schrift */
  --muted: #5D6A63;
  --line: #CBD2CA;
  --action: #0E5A57;    /* Petrol für Aktionen */
  --action-ink: #FFFFFF;
  --sticker: #FFD23F;   /* Preisaufkleber */
  --sticker-ink: #2A2200;
  --sold: #9AA59F;
  --danger: #A3261B;
  --ok: #2F6B2F;
  --radius-s: 6px;
  --radius-m: 12px;
  --font: "Archivo", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141917; --surface: #1D2421; --ink: #E7ECE8; --muted: #9AA8A0; --line: #34403A;
    --action: #3FA39C; --action-ink: #06201E; --sticker: #F2C53A; --sticker-ink: #231C00;
    --sold: #5E6B64; --danger: #E2715F; --ok: #7FC17F; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141917; --surface: #1D2421; --ink: #E7ECE8; --muted: #9AA8A0; --line: #34403A;
  --action: #3FA39C; --action-ink: #06201E; --sticker: #F2C53A; --sticker-ink: #231C00;
  --sold: #5E6B64; --danger: #E2715F; --ok: #7FC17F; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
.boot { padding: 2rem 1rem; color: var(--muted); }

/* ---------- Grundgerüst ---------- */
.shell { max-width: 760px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.topbar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}
.wordmark { font-weight: 800; font-stretch: 75%; font-size: 1.6rem; letter-spacing: -0.01em; margin: 0; }
.net { font-size: .85rem; color: var(--muted); }
.net.off { color: var(--danger); font-weight: 600; }

h2 { font-stretch: 75%; font-weight: 800; font-size: 1.9rem; line-height: 1.05; margin: 18px 0 12px; }
h3 { font-stretch: 85%; font-weight: 700; font-size: 1.15rem; margin: 22px 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Untere Navigation im Stil von Kisten-Trennkarten */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 8px env(safe-area-inset-bottom);
}
.tabs button {
  border: 0; background: none; padding: 12px 4px 14px; cursor: pointer;
  font-stretch: 75%; font-weight: 700; font-size: 1.05rem; color: var(--muted);
  border-top: 4px solid transparent;
}
.tabs button[aria-current="page"] { color: var(--ink); border-top-color: var(--ink); }

/* ---------- Bedienelemente ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: var(--radius-s);
  border: 2px solid var(--action); background: var(--action); color: var(--action-ink);
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--action); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: 12px; }

label.field { display: block; }
label.field > span { display: block; font-size: .875rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: var(--radius-s);
  border: 2px solid var(--line); background: var(--surface);
}
input:focus { border-color: var(--action); outline: none; }
.search { font-size: 1.15rem; min-height: 56px; }

.panel { background: var(--surface); border-radius: var(--radius-m); padding: 16px; border: 1px solid var(--line); }
.notice { border-left: 4px solid var(--action); background: var(--surface); padding: 12px 14px; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.notice.err { border-left-color: var(--danger); }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 10px 16px; min-height: 44px; cursor: pointer; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- Plattenliste ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.rec {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.rec.tap { cursor: pointer; }
.rec.tap:active { background: var(--surface); }
.cover { width: 56px; height: 56px; border-radius: 3px; object-fit: cover; background: var(--line); display: block; }
.cover.ph { display: grid; place-items: center; }
.cover.ph::after { content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); box-shadow: inset 0 0 0 9px var(--ink), inset 0 0 0 10px var(--muted); opacity: .6; }
.rec .t { font-weight: 700; line-height: 1.2; }
.rec .a { line-height: 1.2; }
.rec .m { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.rec.sold .t, .rec.sold .a { color: var(--sold); text-decoration: line-through; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 6px; border-radius: 3px; background: var(--ink); color: var(--bg); vertical-align: 1px; }

/* Der Preisaufkleber */
.sticker {
  display: grid; place-items: center; text-align: center;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--sticker); color: var(--sticker-ink);
  font-weight: 800; font-stretch: 75%; font-size: 1.05rem; line-height: 1;
  transform: rotate(-8deg); box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.sticker small { display: block; font-size: .62rem; font-weight: 600; font-stretch: 100%; }
.sticker.none { background: transparent; border: 2px dashed var(--line); color: var(--muted); font-size: .7rem; font-weight: 600; transform: none; box-shadow: none; }
.sticker.big { width: 96px; height: 96px; font-size: 1.7rem; }

/* ---------- Flohmarkt ---------- */
.till {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; margin: 8px 0 14px;
}
.till div { background: var(--surface); padding: 10px 12px; }
.till b { display: block; font-size: 1.5rem; font-stretch: 75%; font-weight: 800; line-height: 1.1; }
.till span { font-size: .8rem; color: var(--muted); }
.market-card { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.market-card b { font-stretch: 85%; font-size: 1.1rem; }

/* Verkaufsdialog von unten */
.sheet-back { position: fixed; inset: 0; background: rgba(10, 15, 13, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto;
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; min-width: 56px; padding: 8px 12px; border-radius: 22px; border: 2px solid var(--line); background: transparent; font-weight: 700; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.price-input { font-size: 2rem; font-weight: 800; font-stretch: 75%; text-align: center; min-height: 64px; }

/* ---------- Auswertung ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; }
.kpi b { display: block; font-size: 1.6rem; font-weight: 800; font-stretch: 75%; line-height: 1.1; }
.kpi span { font-size: .85rem; color: var(--muted); }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: 8.5rem 1fr 3rem; gap: 10px; align-items: center; padding: 4px 0; font-size: .92rem; }
.bars .bar { height: 14px; background: var(--action); border-radius: 0 3px 3px 0; min-width: 2px; }
.bars .n { text-align: right; color: var(--muted); }
.bars .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t th { font-weight: 600; color: var(--muted); font-size: .8rem; }
.scroll-x { overflow-x: auto; }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--action); transition: width .3s; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: var(--radius-s); max-width: calc(100% - 32px); font-weight: 600; }
.toast button { margin-left: 12px; background: none; border: 0; color: var(--sticker); font-weight: 800; cursor: pointer; }

.login { max-width: 420px; margin: 0 auto; padding: 12vh 16px 40px; }
.login .wordmark { font-size: 3.2rem; line-height: .95; }
@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Gruppen nach Kategorie ---------- */
details.group { border-bottom: 1px solid var(--line); }
details.group > summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 0 10px; font-stretch: 75%; font-weight: 800; font-size: 1.35rem;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: "▸"; font-stretch: 100%; font-size: .9rem; margin-right: 8px; color: var(--muted); }
details.group[open] > summary::before { content: "▾"; }
details.group > summary > span:first-child { flex: 1; }
details.group > summary .muted { font-weight: 600; font-size: .95rem; font-stretch: 100%; }
details.group .list { margin-bottom: 8px; }

/* Auswahl-Liste mit Häkchen */
.rec.pick { grid-template-columns: 44px 1fr auto; }
.rec.pick label { display: grid; place-items: center; height: 44px; cursor: pointer; }
.rec.pick input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--action); }
.chip .muted { font-weight: 500; margin-left: 4px; }
.chip[aria-pressed="true"] .muted { color: inherit; opacity: .75; }

/* Preis älter als 6 Stunden: blasser Aufkleber */
.sticker.stale { background: transparent; border: 2px solid var(--sticker); color: var(--ink); box-shadow: none; }
.rec .m a, .credits a { color: var(--action); font-weight: 600; }
.credits { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.topbar .wordmark { font-size: 1.35rem; }
.closeout { border: 2px solid var(--ink); margin: 12px 0; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.small-btn { min-height: 40px; padding: 6px 14px; font-size: .95rem; }

/* ---------- Vereinfachte Oberfläche ---------- */
.rec { grid-template-columns: 1fr auto; padding: 12px 0; }
.rec .t { font-size: 1.05rem; }
.sticker { width: 52px; height: 52px; font-size: 1.1rem; }
.sticker.none { font-size: 1rem; }
.sold-tag { color: var(--danger); font-weight: 600; }
.rec.sold .sold-tag { text-decoration: none; }
.label { font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.label .muted { font-size: .85rem; }
.till-line { font-size: 1.15rem; margin: 0 0 14px; }
.till-line b { font-size: 2rem; font-stretch: 75%; font-weight: 800; }
.sale-right { display: flex; align-items: center; gap: 10px; }
.x { background: none; border: 0; color: var(--muted); font-size: 1.6rem; line-height: 1; padding: 4px 8px; cursor: pointer; min-height: 44px; }
.x:hover { color: var(--danger); }
.offline { background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: var(--radius-s); font-size: .9rem; margin: 12px 0 0; }
.shell { padding-top: calc(8px + env(safe-area-inset-top)); }
.tabs { grid-template-columns: repeat(3, 1fr); }
.rec.sold .a { text-decoration: none; }

/* ---------- Flohmarkt: Dabei / Verkauft ---------- */
.seg-wide { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin: 4px 0 12px; }
.seg-wide button { min-height: 52px; font-size: 1.05rem; font-weight: 700; }
.seg .count { font-weight: 500; opacity: .7; margin-left: 4px; }

/* ---------- Filter ---------- */
.filters { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 select { min-height: 44px; }

/* ---------- Analyse ---------- */
.chart { margin: 18px 0 8px; }
.chart figcaption { font-weight: 700; margin-bottom: 8px; }
.hbars { list-style: none; margin: 0; padding: 0; }
.hbars li { display: grid; grid-template-columns: 7.5rem 1fr 4.2rem; gap: 10px; align-items: center; padding: 3px 0; font-size: .92rem; }
.hbars .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars .track { height: 14px; }
.hbars .bar { display: block; height: 100%; background: var(--action); border-radius: 0 4px 4px 0; }
.hbars .val, .cols .val { color: var(--ink); font-variant-numeric: tabular-nums; }
.hbars .val { text-align: right; }
.cols { display: flex; align-items: flex-end; gap: 6px; height: 170px; border-bottom: 1px solid var(--line); padding-top: 4px; }
.cols .col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.cols .bar { width: 70%; max-width: 44px; background: var(--action); border-radius: 4px 4px 0 0; }
.cols .val { font-size: .75rem; margin-bottom: 3px; white-space: nowrap; }
.cols .lbl { position: absolute; bottom: -20px; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.chart:has(.cols) { padding-bottom: 22px; }
.kpis { margin-bottom: 4px; }
.tabs { grid-template-columns: repeat(4, 1fr); }
.tabs button { font-size: .98rem; }
