:root {
    --bg-app: #f0f4f8;
    --bg-panel: #ffffff;
    --text-main: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --border-color-card: #edf2f7; 
    --primary: #0d6efd; 
    --primary-hover: #0b5ed7;
    --success: #198754;
    --success-hover: #157347;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    font-size: 14px;
    overflow-x: hidden;
    
    /* ========================================================================= */
    /* HINTERGRUND-DESIGN */
    background-image: 
        radial-gradient(circle at 50% 0%, #ffffff 0%, transparent 70%),
        radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 100% 100%, 20px 20px;
    background-attachment: fixed;
    /* ========================================================================= */
}

h1, h2, h3 { color: #1a202c; margin-top: 0; }

/* Seiten-Layout mit Sidebar */
.app-layout { 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh; 
    width: 100%;
    box-sizing: border-box;
}

.sidebar {
    background: var(--bg-panel);
    padding: 12px 15px 30px 15px; 
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 10;
    box-sizing: border-box;
}
.sidebar img#mainLogo { width: 100%; max-width: 150px; height: auto; display: block; margin: 0 auto 10px auto; object-fit: contain; }
.sidebar-adresse { text-align: center; margin-bottom: 5px; font-size: 0.8em; color: var(--text-muted); line-height: 1.35; }
.sidebar .form-group { margin-bottom: 8px; }
.sidebar .form-group label { display: block; font-weight: 600; margin-bottom: 3px; font-size: 0.82em; color: var(--text-muted); }
.sidebar .form-group input, .sidebar .form-group select, .sidebar .form-group textarea { 
    width: 100%; padding: 6px 8px; box-sizing: border-box; 
    border: 1px solid var(--border-color); border-radius: 4px; 
    font-size: 13px; outline: none; transition: border-color 0.2s;
}
.sidebar .form-group input:focus, .sidebar .form-group select:focus, .sidebar .form-group textarea:focus { border-color: var(--primary); }
.sidebar .btn { width: 100%; margin-bottom: 4px; padding: 8px 10px; font-weight: 600; font-size: 13px; box-sizing: border-box; }
.sidebar-divider { margin: 10px 0; border: 0; border-top: 1px solid var(--border-color); }

.sidebar-cart { 
    background: #f0fff4; 
    border: 1px solid var(--success); 
    border-radius: var(--radius); 
    padding: 10px 12px; 
    margin-bottom: 10px; 
    text-align: center; 
}
.sidebar-cart .cart-info { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.sidebar-cart strong { color: var(--success); font-size: 1.1em;}

.main-content {
    flex: 1; 
    min-width: 0; /* Verhindert, dass breite Elemente (wie der Ticker) die Seite nach rechts aufblähen */
    padding: 10px; 
    max-width: 100%; 
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (min-width: 900px) {
    .app-layout { flex-direction: row; align-items: flex-start; }
    .main-content { padding: 15px 20px; }
    .sidebar { 
        width: 260px; 
        flex-shrink: 0; 
        position: sticky; 
        top: 0; 
        height: 100vh; 
        max-height: 100vh;
        overflow-y: auto; 
        padding-bottom: 45px; /* Genug Luft am unteren Rand für den letzten Button */
        border-right: 1px solid var(--border-color); 
        border-bottom: none; 
        box-sizing: border-box;
    }
}

/* Panels */
.panel { background: var(--bg-panel); padding: 15px; border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 15px; border: 1px solid #edf2f7; box-sizing: border-box; max-width: 100%; }

/* Buttons */
.btn { background-color: var(--primary); color: white; border: none; padding: 8px 12px; cursor: pointer; border-radius: 4px; font-size: 12px; font-weight: 500; transition: all 0.2s; }
.btn:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: #a0aec0; color: white;}
.btn-secondary:hover { background-color: #718096; }
.btn-success { background-color: var(--success); color: white;}
.btn-success:hover { background-color: var(--success-hover); }
.btn-outline { background-color: transparent; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-outline:hover { background-color: #f7fafc; border-color: #cbd5e0; }
.btn:disabled { background-color: #e2e8f0; cursor: not-allowed; color: #a0aec0; border: none;}

/* KARTEN & GRID - MOBILE FIRST & ZWEISPALTIG */
#produktGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 100%; box-sizing: border-box; }
.product-card { background: #fff; padding: 10px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); display: flex; flex-direction: column; border: 1px solid var(--border-color-card); transition: box-shadow 0.2s; box-sizing: border-box; min-width: 0; }
.product-card:hover { box-shadow: 0 4px 8px rgba(0,0,0,0.1); border-color: #e2e8f0; }

@keyframes highlight-green {
    0% { box-shadow: 0 0 0 2px var(--success); border-color: var(--success); background-color: #f0fff4; }
    100% { box-shadow: 0 2px 5px rgba(0,0,0,0.05); border-color: var(--border-color-card); background-color: #fff; }
}
.item-added { animation: highlight-green 0.6s ease; }

.product-card img { width: 100%; height: 130px; object-fit: contain; margin-bottom: 8px; background: #fff;}
.card-info { flex: 1; display: flex; flex-direction: column; }
.card-info strong { display: block; font-size: 0.9em; color: #000; margin-bottom: 4px; line-height: 1.2;}
.card-info p { margin: 0 0 4px 0; font-size: 0.8em; color: #333; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;}
.product-preis-absatz { color: #555; font-size: 0.85em; margin-top: 4px; margin-bottom: 6px;}

.barcode-wrapper { width: 100%; text-align: center; margin-top: auto; padding-top: 4px; }
.barcode-wrapper svg { width: 100% !important; height: auto !important; max-height: 40px; display: block; margin: 0 auto; }

/* Flexibles Card Footer Layout mit +/- Buttons */
.card-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px; margin-top: 8px; border-top: 1px solid #edf2f7; padding-top: 8px;}
.menge-wrapper { display: flex; align-items: center; border: 1px solid #ccc; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.menge-btn { background: #f0f4f8; border: none; padding: 0; width: 28px; height: 28px; font-size: 16px; cursor: pointer; color: var(--text-main); font-weight: normal; display:flex; align-items:center; justify-content:center; transition: background 0.2s;}
.menge-btn:hover { background: #e2e8f0; }
.menge-wrapper input { width: 36px; height: 28px; border: none; border-left: 1px solid #ccc; border-right: 1px solid #ccc; text-align: center; font-size: 13px; outline: none; border-radius: 0; padding: 0; -moz-appearance: textfield;}
.menge-wrapper input::-webkit-outer-spin-button, .menge-wrapper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ve-label { color: #888; font-size: 0.75em; margin: 0 2px; white-space: nowrap; flex-grow: 1; text-align: center;}
.card-footer .btn { padding: 6px 10px; font-size: 11px; flex-shrink: 0;}

/* ANPASSUNGEN FÜR DESKTOP/TABLET */
@media (min-width: 550px) {
    #produktGrid { grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); gap: 14px; }
    .product-card { padding: 14px; }
    .product-card img { height: 180px; margin-bottom: 10px;}
    .card-info strong { font-size: 1.05em; margin-bottom: 5px;}
    .card-info p { font-size: 0.85em; margin-bottom: 5px; line-height: 1.3; }
    .product-preis-absatz { font-size: 0.9em; margin-top: 5px; margin-bottom: 10px;}
    .barcode-wrapper { padding-top: 5px; }
    .barcode-wrapper svg { max-height: 55px; }
    .card-footer { margin-top: 12px; padding-top: 12px;}
    .menge-wrapper input { width: 38px; }
    .menge-btn { width: 28px; }
    .card-footer .btn { padding: 6px 10px; font-size: 12px; }
    .ve-label { font-size: 0.8em; margin: 0 3px; }
}

/* Modals & Fenster Scroll-Fix */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(2px); align-items: center; justify-content: center; }
.modal-content { background-color: var(--bg-panel); padding: 25px; border-radius: 8px; width: 90%; max-width: 700px; max-height: 90vh; display: flex; flex-direction: column; margin: 5vh auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); border: none; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; margin-bottom: 15px; flex-shrink: 0; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); transition: color 0.2s;}
.modal-close:hover { color: #e53e3e; }

/* Flexibles Scrollen im Body des Modals */
.modal-body { flex: 1; overflow-y: auto; min-height: 0; padding-right: 5px; }
.modal-footer { flex-shrink: 0; margin-top: 15px; display: flex; justify-content: flex-end; gap: 10px; padding-top: 15px; border-top: 1px solid var(--border-color); }

/* Scanner */
#scannerContainer { background: var(--bg-panel); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 20px; text-align: center; }
#scannerVideo { width: 100%; max-width: 400px; border: 1px solid var(--border-color); background: #000; border-radius: var(--radius); }
#scannerControls { margin-top: 10px; display: flex; justify-content: center; gap: 10px; align-items: center; flex-wrap: wrap;}
#scannerResult { margin-top: 10px; font-weight: bold; color: var(--success); }

/* Tabelle Warenkorb */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #edf2f7; font-size: 0.9em; background: #fff; }
th { background-color: #f7fafc; font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 0.8em; letter-spacing: 0.05em;}
td input { width: 55px; border: 1px solid var(--border-color); padding: 6px; border-radius: 4px; text-align: center; }
.menge-display { font-weight: bold; text-align: center; }
.summary-gratis-row td { color: var(--success); background-color: #f0fff4; }
.gratis-text { font-weight: bold; }
.summary-actions { margin-top: 20px; text-align: right; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;}

#scrollToTopBtn { display: none; position: fixed; bottom: 20px; right: 20px; z-index: 99; border: none; background-color: var(--text-main); color: white; cursor: pointer; padding: 12px 15px; border-radius: 50%; font-size: 16px; box-shadow: var(--shadow-md); transition: transform 0.2s;}
#scrollToTopBtn:hover { transform: translateY(-3px); }

/* Mobile Cart Bar (Sticky Footer) */
.mobile-cart-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--success);
    color: white;
    padding: 12px 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
    cursor: pointer;
}
.mobile-cart-bar .cart-info { display: flex; flex-direction: column; }
.mobile-cart-bar .cart-info span { font-size: 12px; opacity: 0.9; }
.mobile-cart-bar .cart-info span:last-child { font-weight: bold; font-size: 16px; opacity: 1; }
.mobile-cart-bar .cart-action { font-weight: bold; font-size: 14px; background: rgba(255,255,255,0.2); padding: 8px 12px; border-radius: var(--radius); }

@media (min-width: 900px) {
    .mobile-cart-bar { display: none !important; }
}
@media (max-width: 899px) {
    body { padding-bottom: 80px; } 
}

/* Aktionen (Mix&Match) */
#aktionsListe { display: flex; flex-direction: column; gap: 10px; }
.aktions-item { display: flex; align-items: center; gap: 15px; padding: 10px; border: 1px solid var(--border-color); border-radius: var(--radius); background: #f8fafc; }
.aktions-item img { width: 45px; height: 45px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border-color);}
.aktions-item .info { flex: 1; display: flex; flex-direction: column; }
.aktions-item .info strong { font-size: 1em; color: var(--text-main); }
.aktions-item .info span { font-size: 0.85em; color: var(--text-muted); margin-top: 2px;}
.aktions-item input.menge-input { width: 55px; padding: 6px; border: 1px solid var(--border-color); border-radius: 4px; text-align: center;}

.auswahl-sektion { border: 1px solid var(--border-color); padding: 12px; margin-bottom: 12px; border-radius: var(--radius); background: #f8fafc;}
.artikel-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-top: 10px; padding-right: 5px;}
.artikel-item-modal { text-align: center; font-size: 0.8em; background: var(--bg-panel); padding: 8px; border-radius: 6px; border: 1px solid var(--border-color); box-shadow: var(--shadow-sm);}
.artikel-item-modal img { width: 100%; height: 60px; object-fit: contain; margin-bottom: 6px; }
.artikel-item-modal input { width: 100%; padding: 6px; margin-top: 6px; text-align: center; box-sizing: border-box; border: 1px solid var(--border-color); border-radius: 4px;}

/* =========================================================================
   ENDLOS NEUHEITEN TICKER (SANFTER EINZEL-VORSCHUB OHNE LEERLAUF)
   ========================================================================= */
.ticker-wrap {
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 12px 5px;
    background: var(--bg-panel);
    position: relative;
}

.ticker-move {
    display: flex;
    gap: 15px;
    width: max-content;
    will-change: transform;
}

.ticker-item {
    flex: 0 0 140px;
    width: 140px;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    white-space: normal;
}

.ticker-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-color: var(--primary, #3182ce);
}

.ticker-item img {
    max-width: 100%;
    height: 90px;
    object-fit: contain;
    margin-bottom: 8px;
}

.ticker-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e53e3e;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 12px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}