/* Produkt Katalog – gemeinsames Design fuer alle Seiten.
   Mobile first: Navigation unten (Handy), oben ab 860px (PC). */

:root {
    --bg: #eef0f3;
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --ink: #14161b;
    --ink-2: #565c6b;
    --ink-3: #8a90a0;
    --line: #e0e3e9;
    --line-2: #cfd3dc;
    --accent: #3347ff;
    --accent-ink: #ffffff;
    --accent-soft: #e7eaff;
    --money: #0b9a56;
    --money-soft: #e1f5ea;
    --warn: #b97800;
    --warn-soft: #fff2d6;
    --danger: #dc3b3b;
    --danger-soft: #fdeaea;
    --plate: #e9ebef;
    --plate-dot: rgba(20, 22, 27, 0.09);
    --shadow: 0 1px 2px rgba(20, 22, 27, 0.05), 0 4px 14px -6px rgba(20, 22, 27, 0.12);
    --shadow-lg: 0 24px 60px -20px rgba(20, 22, 27, 0.35);

    --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

    --r-sm: 10px;
    --r: 16px;
    --r-lg: 22px;
    --appbar-h: 60px;
    --sticky-top: 0px; /* Handy: Kopfleiste scrollt weg, Suche klebt ganz oben */
    --tabbar-h: 66px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    color-scheme: light;
}

html.dark {
    --bg: #0d0f13;
    --surface: #171a21;
    --surface-2: #1d2129;
    --ink: #f0f2f6;
    --ink-2: #a6acba;
    --ink-3: #6d7485;
    --line: #272c36;
    --line-2: #343a46;
    --accent: #7b88ff;
    --accent-ink: #0d0f13;
    --accent-soft: #1d2250;
    --money: #3fd68d;
    --money-soft: #0f2c1e;
    --warn: #f0b43c;
    --warn-soft: #33270c;
    --danger: #ff6b6b;
    --danger-soft: #3a1717;
    --plate: #12151b;
    --plate-dot: rgba(255, 255, 255, 0.07);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px);
}
body.no-scroll { overflow: hidden; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.mono { font-family: var(--mono); font-feature-settings: "zero" 0; letter-spacing: -0.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App-Leiste oben ---------- */
.appbar {
    position: relative; z-index: 40;
    background: var(--bg);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--line);
}
.appbar-in {
    margin: 0 auto; height: var(--appbar-h);
    padding: 0 16px; display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand-mark { display: grid; gap: 2px; width: 26px; justify-items: center; }
.brand-mark i { display: block; height: 4px; border-radius: 2px; background: var(--accent); }
.brand-mark i:nth-child(1) { width: 40%; opacity: 0.55; }
.brand-mark i:nth-child(2) { width: 62%; opacity: 0.7; }
.brand-mark i:nth-child(3) { width: 82%; opacity: 0.85; }
.brand-mark i:nth-child(4) { width: 100%; background: var(--ink); }
.brand-name {
    font-weight: 800; font-stretch: 125%; font-size: 0.95rem; line-height: 0.95;
    letter-spacing: -0.01em; text-transform: uppercase;
}

.icon-btn {
    width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
    background: var(--surface); display: inline-grid; place-items: center; color: var(--ink-2);
    transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.is-on { color: var(--money); }
.appbar-actions { display: flex; align-items: center; gap: 8px; }

/* Wartende Aenderungen (ohne Internet) */
.pending-pill {
    display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 999px;
    border: 1px solid var(--warn); background: var(--warn-soft); color: var(--warn); font-weight: 800; font-size: .88rem;
}
.pending-pill svg { width: 18px; height: 18px; }
.pending-pill .pending-txt { display: none; font-weight: 700; }
.pending-pill.is-busy svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (min-width: 480px) { .pending-pill .pending-txt { display: inline; } }

/* Anmeldefenster */
.login { max-width: 440px; margin: 0 auto; }
.login-body { padding: 22px 20px 6px; text-align: center; }
.login-ico { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.login-ico svg { width: 26px; height: 26px; }
.login-body h2 { margin: 0 0 6px; font-size: 1.3rem; font-weight: 800; font-stretch: 112%; }
.login-body p { margin: 0 0 16px; color: var(--ink-2); font-size: .92rem; }
.pw-field { position: relative; display: block; text-align: left; }
.pw-field .field { padding-right: 52px; font-size: 1.05rem; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-3); display: grid; place-items: center; }
.pw-eye svg { width: 20px; height: 20px; }
.login-body .login-error { color: var(--danger); font-weight: 700; margin: 10px 0 0; }

/* Desktop-Navigation */
.tabs { display: none; }
.tabs a {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
    border-radius: 12px; text-decoration: none; font-weight: 600; font-size: 0.95rem; color: var(--ink-2);
    transition: background .15s, color .15s;
}
.tabs a svg { width: 18px; height: 18px; }
.tabs a:hover { color: var(--ink); background: var(--surface); }
.tabs a[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }

/* Handy-Navigation unten */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(var(--tabbar-h) + var(--safe-b)); padding: 6px 8px calc(6px + var(--safe-b));
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border-radius: 14px; text-decoration: none; color: var(--ink-3);
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.01em;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a .tab-ico { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 999px; transition: background .2s; }
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"] .tab-ico { background: var(--accent-soft); color: var(--accent); }

@media (min-width: 860px) {
    :root { --sticky-top: var(--appbar-h); }
    .appbar { position: sticky; top: 0; background: rgba(238, 240, 243, 0.92); }
    html.dark .appbar { background: rgba(13, 15, 19, 0.92); }
    .appbar-in { padding: 0 32px; }
    .tabs { display: flex; gap: 4px; }
    .tabbar { display: none; }
    body { padding-bottom: 48px; }
    .brand { margin-right: 24px; }
    .tabs { margin-right: auto; }
}

/* ---------- Seitenaufbau ---------- */
.page { margin: 0 auto; padding: 20px 16px 0; }
@media (min-width: 860px) { .page { padding: 28px 32px 0; } }
.page-head { margin: 4px 0 20px; }
.page-head h1 {
    margin: 0; font-weight: 800; font-stretch: 125%;
    font-size: clamp(1.9rem, 7.5vw, 2.9rem); line-height: 0.95; letter-spacing: -0.03em;
}
.page-head .lede { margin: 10px 0 0; color: var(--ink-2); font-size: 0.98rem; max-width: 52ch; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.section-label {
    font-family: var(--mono); font-size: 0.72rem; font-weight: 500; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--ink-3);
}

/* ---------- Formularfelder ---------- */
.field, .select, .textarea {
    width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-sm);
    border: 1px solid var(--line-2); background: var(--surface); outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; }
.field:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field::placeholder, .textarea::placeholder { color: var(--ink-3); }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a90a0' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.hint { font-size: 0.8rem; color: var(--ink-3); margin-top: 6px; }

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-3); pointer-events: none; }
.search .field { padding-left: 44px; border-radius: 14px; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid transparent;
    font-weight: 700; font-size: 0.98rem; text-decoration: none; white-space: nowrap;
    touch-action: manipulation; user-select: none; transition: transform .08s, background .15s, border-color .15s, opacity .15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-dark { background: var(--ink); color: var(--bg); }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-3); }
.btn-money { background: var(--money); color: #fff; }
html.dark .btn-money { color: #06170e; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 0.9rem; border-radius: 12px; }

/* ---------- Chips (Tags) ---------- */
.chips {
    display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px; padding: 2px 16px 4px; scroll-padding: 16px;
    /* weicher Rand rechts zeigt: hier kann man weiterwischen */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
    font-weight: 600; font-size: 0.92rem; color: var(--ink-2); white-space: nowrap; touch-action: manipulation;
}
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .chip-n { font-family: var(--mono); font-size: 0.75rem; opacity: 0.6; }
@media (min-width: 860px) { .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; -webkit-mask-image: none; mask-image: none; } }

/* Filamentfarbe je Tag */
.swatch {
    flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--sw, var(--ink-3));
    box-shadow: inset 0 0 0 2.5px rgba(255, 255, 255, 0.45);
}

/* ---------- Segmentierte Auswahl ---------- */
.seg {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px;
    border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line);
}
.seg button {
    min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2);
    font-weight: 700; font-size: 0.92rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 0 6px; touch-action: manipulation; white-space: nowrap;
}
@media (max-width: 400px) { .seg button { font-size: .86rem; gap: 4px; } }
.seg button .seg-n { font-family: var(--mono); font-weight: 500; font-size: 0.8rem; color: var(--ink-3); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button[aria-pressed="true"] .seg-n { color: var(--accent); }

/* ---------- Karten ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }

/* Druckbett-Raster hinter Produktbildern */
.plate {
    background-color: var(--plate);
    background-image: radial-gradient(var(--plate-dot) 1px, transparent 1.2px);
    background-size: 12px 12px;
}

/* ---------- Pillen / Status ---------- */
.pill {
    display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
    font-size: 0.8rem; font-weight: 700; white-space: nowrap;
}
.pill-ok { background: var(--money-soft); color: var(--money); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--danger-soft); color: var(--danger); }
.pill-mute { background: var(--surface-2); color: var(--ink-2); }

/* ---------- Leere Zustaende, Fehler, Laden ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 1.1rem; margin-bottom: 6px; }
.empty a { color: var(--accent); font-weight: 700; }
.alert {
    padding: 14px 16px; border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger);
    font-weight: 600; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}

/* Lade-Anzeige: Schichten werden aufgebaut */
.loader { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 56px 16px; color: var(--ink-3); font-weight: 600; font-size: 0.92rem; }
.loader-stack { display: flex; flex-direction: column-reverse; gap: 3px; width: 44px; }
.loader-stack i { height: 5px; border-radius: 3px; background: var(--accent); opacity: 0; animation: layer 1.6s infinite; }
.loader-stack i:nth-child(1) { animation-delay: 0s; }
.loader-stack i:nth-child(2) { animation-delay: .2s; width: 92%; margin: 0 auto; }
.loader-stack i:nth-child(3) { animation-delay: .4s; width: 80%; margin: 0 auto; }
.loader-stack i:nth-child(4) { animation-delay: .6s; width: 64%; margin: 0 auto; }
.loader-stack i:nth-child(5) { animation-delay: .8s; width: 44%; margin: 0 auto; }
@keyframes layer { 0% { opacity: 0; transform: translateY(-6px); } 12%, 70% { opacity: 1; transform: none; } 85%, 100% { opacity: 0; } }

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; z-index: 90; transform: translateY(20px); opacity: 0; pointer-events: none;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
    max-width: min(92vw, 460px); padding: 14px 18px; border-radius: 14px;
    background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 10px; transition: opacity .2s, transform .25s cubic-bezier(.2,.9,.3,1.2);
}
.toast.show { opacity: 1; transform: none; }
.toast .toast-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--money); flex: none; }
.toast.is-error .toast-dot { background: var(--danger); }
@media (min-width: 860px) { .toast { bottom: 28px; } }

/* ---------- Sheet (Handy: von unten, PC: mittig) ---------- */
.sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 10, 14, 0.55); animation: fade .2s ease both; }
.sheet-panel {
    position: relative; width: 100%; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
    background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-lg);
    animation: up .28s cubic-bezier(.2,.9,.3,1) both; padding-bottom: var(--safe-b);
}
.sheet-panel.full { height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; font-weight: 800; font-stretch: 112%; }
.sheet-body { padding: 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex: none; }
.sheet-foot .btn { flex: 1 1 0; min-width: 0; white-space: normal; text-align: center; line-height: 1.2; padding: 0 12px; }
@media (min-width: 860px) {
    .sheet { align-items: center; padding: 24px; }
    .sheet-panel { max-width: 560px; border-radius: var(--r-lg); max-height: 88vh; }
    .sheet-panel.full { height: auto; max-height: 88vh; border-radius: var(--r-lg); }
    .sheet-panel.wide { max-width: 1200px; }
    .sheet-grab { display: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.confirm-body { text-align: center; padding: 24px 20px 8px; }
.confirm-body h2 { margin: 0 0 8px; font-size: 1.3rem; font-weight: 800; font-stretch: 112%; }
.confirm-body p { margin: 0; color: var(--ink-2); }

/* ---------- Kennzahlen ---------- */
.stat-num { font-family: var(--mono); font-weight: 700; letter-spacing: -0.04em; line-height: 1; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    .loader-stack i { opacity: 1; }
}
