/**
 * Colors come from the theme (public/themes/*.json → --c-*). Neutral accent; color only for meaning
 * (ok/warn/danger, the wine-type dots). line = decoration; field = borders of inputs (≥ 3:1).
 * Desktop (≥ 900px): sidebar and centered overlays. Phone: bottom bar and full-screen pages.
 *
 * @author    Janosch Skrobek
 * @copyright 2026 bworx
 */
:root {
  --c-background: #15171c; --c-surface: #1e2128; --c-text: #e8eaee; --c-muted: #a3a9b5;
  --c-line: #323744; --c-field: #70778a; --c-accent: #e8eaee; --c-on-accent: #15171c; --c-danger: #ff9a9a;
  --c-ok: #8fd19e; --c-warn: #f0c674; --c-wine-red: #c2566b; --c-wine-white: #e3d48c; --c-wine-rose: #e9a3b4;
  --c-wine-sparkling: #cfd6e0; --c-wine-sweet: #e0b060;
  --radius: 12px;
  --tabbar: 72px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--c-background); color: var(--c-text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, p { margin: 0; }
h1 { font-size: 1.4rem; font-weight: 650; }
h2 { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--c-muted); }
.small { font-size: .85rem; }
.grow { flex: 1; min-width: 0; }
.ok { color: var(--c-ok); } .warn { color: var(--c-warn); } .danger { color: var(--c-danger); }

/* controls */
button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 44px; padding: 0 1rem; border-radius: var(--radius); cursor: pointer;
  background: transparent; border: 1px solid var(--c-field);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; white-space: nowrap;
}
button.primary { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); font-weight: 600; }
button.wide { width: 100%; }
button:disabled { opacity: .45; cursor: default; }
button.link { border: 0; min-height: 36px; padding: 0 .4rem; text-decoration: underline; text-underline-offset: 3px; }
button.danger-text, .danger-text { color: var(--c-danger); border-color: transparent; }
.icon-btn { width: 44px; padding: 0; border-color: transparent; flex: none; }
.icon-btn.tiny { width: 28px; min-height: 28px; }
input, select, textarea {
  min-height: 44px; padding: 0 .8rem; border-radius: var(--radius); width: 100%;
  background: var(--c-background); border: 1px solid var(--c-field);
}
textarea { min-height: 96px; padding: .6rem .8rem; resize: vertical; }
input[type=radio] { width: 22px; min-height: 22px; accent-color: var(--c-accent); }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.icon { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; }
.icon.small { width: 1em; height: 1em; }
.icon.big { width: 3rem; height: 3rem; color: var(--c-muted); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login {
  width: min(100%, 22rem); display: grid; gap: .6rem;
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius); padding: 1.5rem;
}
.login label { color: var(--c-muted); font-size: .9rem; }
.error { color: var(--c-danger); }

/* frame */
.app { min-height: 100vh; }
.sidebar { display: none; }
.content { padding: .75rem 1rem calc(var(--tabbar) + 1.5rem); max-width: 1100px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: flex; align-items: flex-start;
  background: var(--c-surface); border-top: 1px solid var(--c-line); z-index: 10;
}
.tab { flex: 1; flex-direction: column; gap: 2px; border: 0; border-radius: 0; height: var(--tabbar); font-size: .75rem; color: var(--c-muted); }
.tab .icon { width: 26px; height: 26px; }
.tab.sel { color: var(--c-text); }
.tab-center { flex: 1.2; display: flex; justify-content: center; }
.fab {
  width: 64px; height: 64px; border-radius: 32px; margin-top: -20px; padding: 0;
  background: var(--c-accent); color: var(--c-on-accent); border: 0; box-shadow: 0 6px 18px rgb(0 0 0 / .35);
}
.fab .icon { width: 30px; height: 30px; }
.desk-only { display: none !important; }
.app.has-page > .content { display: none; }
.desk-title { display: none; }

@media (min-width: 900px) {
  .app { display: flex; height: 100vh; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; width: 250px; flex: none; padding: 1.25rem .9rem;
    border-right: 1px solid var(--c-line); background: var(--c-surface); overflow-y: auto;
  }
  .sidebar .sec { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); padding: 1.1rem .7rem .4rem; }
  .nav { justify-content: flex-start; text-align: left; border: 0; min-height: 42px; padding: 0 .7rem; color: var(--c-muted); gap: .75rem; }
  .nav.sel { background: var(--c-background); color: var(--c-text); }
  .sync-line { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; }
  .content { flex: 1; overflow-y: auto; padding: 1.5rem 2rem 2rem; max-width: none; }
  .tabbar, .phone-only { display: none !important; }
  .desk-only { display: inline-flex !important; }
  .app.has-page > .content { display: block; }
  .desk-title { display: block; }
  .area-pick { display: none !important; }
}

.sync-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--c-ok); flex: none; }
.sync-syncing { background: var(--c-muted); }
.sync-offline { background: transparent; border: 2px solid var(--c-muted); }
.sync-error { background: var(--c-danger); }

/* stock list */
.stock { display: flex; flex-direction: column; gap: .75rem; }
.stock-head { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
.area-pick { position: relative; display: inline-flex; align-items: center; gap: .4rem; font-size: 1.4rem; font-weight: 700; flex: 1; }
.area-pick select { border: 0; background: transparent; font-size: 1.4rem; font-weight: 700; padding: 0 1.6rem 0 0; width: auto; appearance: none; margin-right: -1.6rem; }
.search { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--c-field); border-radius: var(--radius); padding-left: .8rem; background: var(--c-background); }
.search input { border: 0; padding-left: 0; background: transparent; }
.search .icon { color: var(--c-muted); }
.chips { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.chip {
  min-height: 38px; padding: 0 .9rem; border-radius: 19px; border: 1px solid var(--c-line); color: var(--c-text);
  font-size: .92rem; gap: .4rem; display: inline-flex; align-items: center; background: transparent;
}
.chip.on { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
.chip.static { cursor: default; }
.chip.select { padding-right: .4rem; }
.chip.select select { border: 0; background: transparent; min-height: 34px; padding: 0 .3rem; width: auto; }
.chip.on select { color: var(--c-on-accent); }
.vintage-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.field.inline { display: flex; align-items: center; gap: .4rem; }
.field.inline select { width: auto; }
.summary { font-size: .9rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-red { background: var(--c-wine-red); } .dot-white { background: var(--c-wine-white); } .dot-rose { background: var(--c-wine-rose); }
.dot-sparkling { background: var(--c-wine-sparkling); } .dot-sweet { background: var(--c-wine-sweet); }

.rows { list-style: none; margin: 0; padding: 0; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 16px; overflow: hidden; }
.row { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--c-line); padding-right: .75rem; }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; justify-content: flex-start; text-align: left; border: 0; border-radius: 0; padding: .6rem .5rem .6rem .9rem; gap: .8rem; min-height: 68px; white-space: normal; }
.thumb { width: 40px; height: 52px; border-radius: 7px; background: var(--c-background); border: 1px solid var(--c-line); display: grid; place-items: center; color: var(--c-muted); flex: none; }
.row-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.row-title { display: flex; align-items: center; gap: .45rem; font-weight: 600; min-width: 0; }
.row-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; }
.status, .loc { display: inline-flex; align-items: center; gap: .3rem; }
.row-count { display: flex; align-items: center; gap: .25rem; }
.row-count .icon-btn { border: 1px solid var(--c-line); width: 38px; min-height: 38px; }
.count { min-width: 2.2rem; text-align: center; font-size: 1.2rem; font-weight: 700; }
.empty { display: grid; justify-items: center; gap: 1rem; padding: 3rem 1rem; text-align: center; color: var(--c-muted); }

/* pages and overlays */
.page-wrap { position: fixed; inset: 0; z-index: 20; background: var(--c-background); }
.page { height: 100%; overflow-y: auto; outline: none; padding-bottom: 2rem; }
.page-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem .5rem .25rem; background: var(--c-background); border-bottom: 1px solid var(--c-line); }
.page-head h1 { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-body { padding: 1rem; display: flex; flex-direction: column; gap: 1.25rem; }
@media (min-width: 900px) {
  .page-wrap { background: rgb(0 0 0 / .6); display: grid; place-items: center; padding: 2rem; }
  .page { height: auto; max-height: calc(100vh - 4rem); width: min(640px, 100%); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 18px; box-shadow: 0 30px 80px rgb(0 0 0 / .45); padding-bottom: 0; }
  .page.wide { width: min(860px, 100%); }
  .page-head { background: var(--c-surface); padding: .75rem .75rem .75rem 1.5rem; border-radius: 18px 18px 0 0; }
  .page-body { padding: 1.25rem 1.5rem 1.5rem; }
}
.detail-top { display: flex; gap: 1rem; align-items: flex-start; }
.detail-top .thumb { width: 64px; height: 88px; }
.detail-top .grow { display: flex; flex-direction: column; gap: .5rem; }
.block { display: flex; flex-direction: column; gap: .6rem; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; }
.big-count { font-size: 1.3rem; }
.loc-list, .plain, .history { list-style: none; margin: 0; padding: 0; }
.loc-list li { display: flex; align-items: center; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--c-line); }
.loc-list strong { min-width: 1.5rem; text-align: right; font-size: 1.1rem; }
.drinkers { display: flex; flex-direction: column; gap: .4rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.facts dt { color: var(--c-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.history li { display: flex; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--c-line); }
.history .icon { margin-top: .2rem; color: var(--c-muted); }
.stars { display: flex; gap: 0; }
.star { width: 36px; min-height: 36px; padding: 0; border: 0; color: var(--c-line); }
.star.on { color: var(--c-warn); }
.ai-mark { display: inline-flex; align-items: center; gap: .25rem; margin-left: .5rem; }
.page-foot { display: flex; justify-content: flex-start; border-top: 1px solid var(--c-line); padding-top: 1rem; }
.notice { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; padding: .8rem 1rem; border: 1px solid var(--c-warn); border-radius: var(--radius); }
.notice > .icon { color: var(--c-warn); }

/* forms */
.form .field, .settings .field { display: flex; flex-direction: column; gap: .3rem; }
.label { font-size: .88rem; color: var(--c-muted); display: flex; gap: .5rem; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: .9rem; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } .span2 { grid-column: span 2; } }
.field.unsure input, .field.unsure textarea { border-style: dashed; border-color: var(--c-warn); }
.form-sec { margin-top: .25rem; }
.batch { display: grid; grid-template-columns: 1fr; gap: .9rem; }
@media (min-width: 600px) { .batch { grid-template-columns: 1fr 1fr; } }
.stepper { display: flex; align-items: center; gap: .25rem; }
.stepper .icon-btn { border: 1px solid var(--c-field); }
.stepper input { text-align: center; font-size: 1.2rem; font-weight: 700; max-width: 6rem; }
.more { align-self: flex-start; text-decoration: none; }
.form-foot { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; padding-top: .5rem; }

/* settings */
.settings { display: flex; flex-direction: column; gap: 1.75rem; max-width: 720px; }
.settings .block { gap: .8rem; }
.line { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; }
.add-line { display: flex; gap: .5rem; }
.add-line input { flex: 1; }
.radio { display: inline-flex; align-items: center; }
.area-block { display: flex; flex-direction: column; gap: .5rem; padding: .75rem 0; border-bottom: 1px solid var(--c-line); }
.area-name { font-weight: 600; }

/* toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 1rem + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 1rem; padding: .5rem .6rem .5rem 1rem; max-width: calc(100vw - 2rem);
  background: var(--c-text); color: var(--c-background); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .35);
}
.toast .link { color: var(--c-background); font-weight: 700; }
@media (min-width: 900px) { .toast { bottom: 1.5rem; } }
.note-input { min-height: 36px; margin-top: .3rem; font-size: .9rem; }

/* KI-Nutzung, Mehr */
.usage, .more-view { display: flex; flex-direction: column; gap: 1.5rem; max-width: 720px; }
.card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 16px; padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .5rem; }
.usage-sum strong { font-size: 2rem; }
.bar { height: 8px; border-radius: 4px; background: var(--c-line); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; background: var(--c-text); border-radius: 4px; }
.feature-line { display: flex; flex-direction: column; gap: .3rem; padding: .5rem 0; border-bottom: 1px solid var(--c-line); }
.call { align-items: flex-start; border-bottom: 1px solid var(--c-line); padding: .5rem 0; }
.small-btn { min-height: 36px; padding: 0 .8rem; font-size: .9rem; }
.big-list li { border-bottom: 1px solid var(--c-line); }
.big-link { width: 100%; justify-content: flex-start; border: 0; border-radius: 0; min-height: 56px; padding: 0 .25rem; gap: .9rem; text-align: left; }

/* photos and adding by photo */
.photo-strip { display: flex; gap: .5rem; flex-wrap: wrap; }
.photo { position: relative; margin: 0; width: 72px; height: 96px; border-radius: 8px; overflow: hidden; border: 1px solid var(--c-line); background: var(--c-background); }
.photo img, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb { overflow: hidden; }
.photo-wait { display: block; width: 100%; height: 100%; }
.photo-del { position: absolute; right: 0; top: 0; width: 32px; min-height: 32px; background: rgb(0 0 0 / .55); color: #fff; border-radius: 0 0 0 8px; }
.page-body .photo-strip .photo { width: 96px; height: 128px; }
.choice { gap: .9rem; }
.file-btn, .big { min-height: 64px; width: 100%; display: flex; align-items: center; justify-content: center; gap: .6rem; border-radius: var(--radius); border: 1px solid var(--c-field); font-size: 1.05rem; cursor: pointer; }
.file-btn.primary { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); font-weight: 600; }
.file-btn:focus-within { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.center { align-items: center; text-align: center; padding-top: 3rem; padding-bottom: 3rem; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 4px solid var(--c-line); border-top-color: var(--c-text); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.modes { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.mode { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .8rem; border: 1px solid var(--c-line); border-radius: var(--radius); cursor: pointer; }
.mode.on { border-color: var(--c-field); background: var(--c-background); }
.mode input { margin-top: .15rem; }
.mode-title, .mode-hint { display: block; }
.jobs { display: flex; flex-direction: column; }
.job { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--c-line); flex-wrap: wrap; }
.page-body .job .photo-strip .photo { width: 44px; height: 58px; }

/* taking out by scan */
.side-actions { display: flex; flex-direction: column; gap: .5rem; }
.side-actions button { padding: 0 .6rem; }
.matches { display: flex; flex-direction: column; gap: .5rem; }
.match { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; gap: .75rem; padding: .5rem .75rem; min-height: 64px; border-color: var(--c-line); }
.match.on { border: 2px solid var(--c-text); }
.match .grow { display: flex; flex-direction: column; }
.match-title { font-weight: 600; }
.takeout-foot { display: flex; flex-direction: column; gap: .75rem; border-top: 1px solid var(--c-line); padding-top: 1rem; }
.big { min-height: 56px; font-size: 1.05rem; }
.source-link { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; flex: 1; min-width: 0; min-height: 44px; }
.source-link .grow { display: flex; flex-direction: column; }
.source-title { text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.found { border: 1px dashed var(--c-field); border-radius: var(--radius); padding: .5rem .75rem; }
.mhd-banner { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border: 1px solid var(--c-danger); border-radius: var(--radius); width: 100%; justify-content: flex-start; text-align: left; white-space: normal; }
.mhd-banner.soon { border-color: var(--c-warn); }

/* Einkaufsliste, Verlauf, Statistik */
.shopping, .history-view, .stats { display: flex; flex-direction: column; gap: 1rem; max-width: 760px; }
.shop-add .qty, .qty { width: 5rem; flex: none; text-align: center; }
.shop-add { flex-wrap: wrap; }
.shop-add input[type=text] { flex: 1 1 14rem; }
.shop-add button { flex: 1 0 auto; }
.suggestions { border-color: var(--c-field); }
.shop-list li { border-bottom: 1px solid var(--c-line); }
.shop-entry { display: flex; flex-direction: column; padding: .2rem 0; }
.shop-entry.done .shop-text { color: var(--c-muted); text-decoration: line-through; }
.check { width: 44px; min-height: 44px; padding: 0; border-radius: 10px; border: 2px solid var(--c-field); flex: none; margin: 4px 0; }
.check.on { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
.stock-in { display: flex; flex-direction: row; flex-wrap: wrap; gap: .5rem; align-items: center; border-color: var(--c-field); margin: 0 0 .6rem 3rem; }
.stock-in select { width: auto; }
.history-item { padding: 0; min-height: 32px; text-decoration: none; font-weight: 600; text-align: left; white-space: normal; }
.stat-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.stat-big { font-size: 1.6rem; }
.stat-row { display: flex; align-items: center; gap: .75rem; padding: .25rem 0; }
.stat-key { width: 9rem; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-n { min-width: 2.5rem; text-align: right; font-variant-numeric: tabular-nums; }
