/* ============================================================
   FLANGO CAFÉ - MOBILE & TABLET RESPONSIVE STYLES
   FORCEFUL OVERRIDES - Sikrer mobil layout altid virker
   ============================================================ */

/* ============================================================
   DESKTOP - over 767px
   ============================================================ */
@media (min-width: 768px) {
    /* Skjul selected-user-info når vi er på login-skærme */
    body:has(#screen-club-login:not([style*="display: none"])) #selected-user-info,
    body:has(#screen-admin-login:not([style*="display: none"])) #selected-user-info,
    #main-app[style*="display: none"] #selected-user-info,
    #main-app[style*="display:none"] #selected-user-info {
        display: none !important;
    }
}

/* ============================================================
   TABLET (iPAD) - 768px til 1024px
   ============================================================ */
@media (max-width: 1024px) and (min-width: 768px) {
    /* Main App Layout - Reducer gap og padding */
    #main-app {
        gap: 12px !important;
        padding: 12px !important;
    }

    /* Product Grid - 2 kolonner på tablet */
    #products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding: 15px !important;
    }

    /* Alle dynamiske grid rules til 2 kolonner */
    #products:has(> .product-btn:nth-child(2):last-child),
    #products:has(> .product-btn:nth-child(3):last-child),
    #products:has(> .product-btn:nth-child(4):last-child),
    #products:has(> .product-btn:nth-child(5):last-child) {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    #products:has(> .product-btn:nth-child(5):last-child) > .product-btn:first-child {
        grid-column: span 1 !important;
    }

    /* Product buttons - større */
    .product-btn {
        min-height: 140px !important;
        padding: 14px !important;
    }

    /* Modals - mindre på tablet */
    .modal-content {
        max-width: 90vw !important;
        max-height: 90vh !important;
        margin: 20px auto !important;
    }
}

/* ============================================================
   MOBILE (SMARTPHONE) - under 768px
   KRITISK: Alle styles med !important for at override desktop
   ============================================================ */
@media (max-width: 767px) {
    /* ===== NO-SCROLL APP SHELL - 100dvh ===== */
    :root {
        --flango-mobile-header-h: 48px;   /* header ikonrække */
        --flango-mobile-banner-h: 52px;   /* "Ekspedient / Voksen ansvarlig" */
        --flango-mobile-footer-h: 240px;  /* Kompakt - knapper SKAL være synlige */
        --flango-safe-bottom: env(safe-area-inset-bottom, 0px);
    }

    html {
        overflow: hidden !important;
        width: 100% !important;
        height: 100% !important;
    }

    body {
        overflow: hidden !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100svh !important; /* iOS Safari stable viewport */
        padding: 0 !important;
        margin: 0 !important;
        position: relative !important;
        overscroll-behavior: none !important;
        -webkit-text-size-adjust: 100% !important;
    }

    /* Prefer dynamic viewport when supported */
    @supports (height: 100dvh) {
        body {
            min-height: 100dvh !important;
        }
    }

    /* ===== MAIN APP - FULL SCREEN APP SHELL ===== */
    #main-app {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto 1fr auto !important;
        grid-template-areas: none !important;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        height: 100dvh !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    /* ===== KOMPAKT HEADER (INGEN FIXED) ===== */
    .sidebar-main-header {
        position: relative !important;
        width: 100% !important;
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        padding: 6px 8px !important;
        margin: 0 !important;
        display: flex !important;
        flex-shrink: 0 !important;
        grid-area: unset !important;
    }

    /* Skjul header når main-app ikke vises */
    #main-app[style*="display: none"] .sidebar-main-header,
    #main-app[style*="display:none"] .sidebar-main-header {
        display: none !important;
    }

    .header-actions {
        display: flex !important;
        gap: 4px !important;
        width: 100% !important;
        justify-content: space-around !important;
    }

    .header-action-btn {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 4px !important;
        flex-shrink: 0 !important;
    }

    .header-action-btn img {
        width: 24px !important;
        height: 24px !important;
    }

    /* ===== KOMPAKT USER BANNER - PROFESSIONAL STYLING ===== */
    .user-session-banner {
        position: relative !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 8px 12px !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        border-bottom: none !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
        flex-shrink: 0 !important;
        grid-area: unset !important;
    }

    #logged-in-user {
        color: white !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        text-align: center !important;
        letter-spacing: 0.3px !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    }

    /* Skjul banner når main-app ikke vises */
    #main-app[style*="display: none"] .user-session-banner,
    #main-app[style*="display:none"] .user-session-banner {
        display: none !important;
    }

    /* Selected customer info (mobile): OVERLAPPING CHECKOUT BOX */
    #selected-user-info {
        position: fixed !important;
        left: 8px !important;
        right: 8px !important;
        bottom: calc(var(--flango-mobile-footer-h) + var(--flango-safe-bottom) + 5px) !important;
        top: auto !important;  /* Ingen top - kun bottom */
        z-index: 999 !important;

        /* JavaScript controls display (grid when shown, none when hidden) */
        display: grid !important;
        visibility: visible !important;
        opacity: 1 !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        padding: 12px !important;
        margin: 0 !important;

        /* Professional glassmorphism to match checkout */
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-radius: 12px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.25) !important;

        height: auto !important;
        pointer-events: auto !important;
        min-height: 48px !important;

        /* Clickable */
        cursor: pointer !important;
        transition: transform 0.2s ease, box-shadow 0.2s ease !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    /* Hover/active feedback */
    #selected-user-info:active {
        transform: scale(0.98) !important;
        box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.3) !important;
    }

    /* Skjul selected-user-info når #sidebar (checkout) er skjult */
    #main-app[style*="display: none"] #selected-user-info,
    #main-app[style*="display:none"] #selected-user-info {
        display: none !important;
    }

    /* Skjul også når vi er på andre skærme (login, admin, etc.) */
    body:has(#screen-club-login:not([style*="display: none"])) #selected-user-info,
    body:has(#screen-admin-login:not([style*="display: none"])) #selected-user-info {
        display: none !important;
    }

    /* DEBUG: if the box exists but has no children, still show a label so we can see it */
    #selected-user-info:empty::before {
        content: "VALGT BRUGER (DEBUG) — element findes men er tom" !important;
        display: block !important;
        font-size: 12px !important;
        font-weight: 800 !important;
        color: white !important;
        text-align: center !important;
        padding: 10px 8px !important;
        opacity: 0.95 !important;
    }

    /* If JS uses a class like .hidden, .is-hidden, or aria-hidden, override on mobile */
    #selected-user-info.hidden,
    #selected-user-info.is-hidden,
    #selected-user-info[hidden],
    #selected-user-info[aria-hidden="true"] {
        display: grid !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    #selected-user-info .info-box {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 2px !important;
        padding: 4px 2px !important;
        min-width: 0 !important;
    }

    #selected-user-info .info-box-label {
        font-size: 9px !important;
        font-weight: 600 !important;
        color: rgba(255, 255, 255, 0.85) !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        white-space: nowrap !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    }

    #selected-user-info .info-box-value {
        font-size: 13px !important;
        font-weight: 700 !important;
        color: white !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
    }

    #selected-user-info .info-box-value.negative {
        color: #ffcccb !important;
        font-weight: 800 !important;
    }

    /* ===== PRODUCTS AREA - FLEX GROW TO FILL ===== */
    #products-area {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        flex: 1 1 auto !important;
        background: #f5f5f5 !important;
        grid-area: unset !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        min-height: 0 !important;
    }

    /* ===== MOBILE PRODUCT GRID - FALLBACK (no pages) ===== */
    #products,
    div#products,
    #products-area #products,
    #main-app #products-area #products {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        grid-auto-rows: auto !important;
        gap: 8px !important;
        padding: 10px !important;
        background: #f0f0f0 !important;
        width: 100% !important;
        margin: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        align-content: start !important;
        align-items: start !important;
        justify-items: center !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        scroll-snap-type: none !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: auto !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    /* ===== MOBILE PAGING MODE - when .product-page wrappers exist ===== */
    #products:has(.product-page),
    div#products:has(.product-page),
    #products-area #products:has(.product-page),
    #main-app #products-area #products:has(.product-page) {
        /* Horizontal scroller for pages */
        display: flex !important;
        flex-direction: row !important;
        gap: 0 !important;
        padding: 0 !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory !important;
        scroll-behavior: smooth !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;          /* Firefox */

        /* Full width/height */
        width: 100% !important;
        height: auto !important;          /* no stretch -> no huge gaps */
        min-height: 0 !important;
    }

    #products:has(.product-page)::-webkit-scrollbar,
    div#products:has(.product-page)::-webkit-scrollbar,
    #products-area #products:has(.product-page)::-webkit-scrollbar,
    #main-app #products-area #products:has(.product-page)::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    /* Each page is a 3×2 grid of products */
    .product-page {
        flex: 0 0 100% !important;
        scroll-snap-align: start !important;
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: repeat(2, auto) !important;
        gap: 8px !important;
        padding: 10px !important;
        width: 100% !important;
        height: auto !important;
        box-sizing: border-box !important;
        align-content: start !important;
        justify-items: center !important;
        align-items: start !important;
        min-height: 0 !important;
    }

    /* Enable page dots when paging is active */
    #products:has(.product-page) ~ #products-page-dots,
    #products-area:has(.product-page) #products-page-dots {
        display: flex !important;
    }


    /* DISABLED: Dynamic grid rules konflikterer med paging - ignoreres på mobil */
    /* De originale :has() rules er kun for desktop-layoutet */

    /* Product Buttons - PRÆCIS SOM iPHONE HOMESCREEN IKONER */
    .product-btn {
        aspect-ratio: 1 / 1 !important;
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
        padding: 10px 6px !important;
        font-size: 11px !important;
        touch-action: manipulation !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        border-radius: 18px !important;
        position: relative !important;
        overflow: visible !important;  /* KRITISK: Lad badges være synlige udenfor */
        background: #ffffff !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
        border: none !important;
        margin: 0 !important;
    }

    /* ===== PAGE INDICATOR DOTS (under grid) ===== */
    #products-page-dots {
        display: none !important; /* Hidden by default */
        justify-content: center !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 8px 0 !important;
        margin: 0 !important;
        background: transparent !important;
        position: relative !important;
        z-index: 5 !important;
    }

    .page-dot {
        width: 7px !important;
        height: 7px !important;
        border-radius: 50% !important;
        background: rgba(0, 0, 0, 0.2) !important;
        transition: all 0.2s ease !important;
        cursor: pointer !important;
    }

    .page-dot.active {
        width: 9px !important;
        height: 9px !important;
        background: rgba(0, 0, 0, 0.7) !important;
    }

    .product-btn-inner {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: 100% !important;
        gap: 3px !important;
        margin: 0 !important;
    }

    /* Info box UNDER ikonet (ikke overlay) */
    .product-info-box {
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 1px !important;
        margin-top: 0 !important;   /* fjern ekstra lodret luft */
        background: transparent !important;
        padding: 0 !important;
    }

    .product-name {
        font-size: 9px !important;
        line-height: 1.1 !important;
        margin: 0 !important;
        text-align: center !important;
        color: #000 !important;
        font-weight: 500 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 100% !important;
    }

    .product-price {
        font-size: 8px !important;
        font-weight: 600 !important;
        margin: 0 !important;
        color: #666 !important;
        line-height: 1 !important;
    }

    /* Product icon/emoji - STØRRE IKONER der fylder firkanten */
    .product-icon,
    .product-btn .product-icon,
    .product-btn-inner .product-icon,
    img.product-icon {
        position: relative !important;  /* Override desktop absolute */
        inset: auto !important;  /* Override desktop inset: 0 */
        width: 68px !important;  /* Større ikon */
        height: 68px !important;
        margin: 0 auto !important;
        flex-shrink: 0 !important;
        display: block !important;
        object-fit: contain !important;
        object-position: center !important;
        opacity: 1 !important;
        border-radius: 0 !important;
        z-index: auto !important;
    }

    .product-emoji,
    .product-btn .product-emoji,
    .product-btn-inner .product-emoji {
        position: relative !important;  /* Override desktop absolute */
        inset: auto !important;  /* Override desktop inset: 0 */
        font-size: 56px !important;  /* Større emoji */
        line-height: 68px !important;
        width: 68px !important;
        height: 68px !important;
        margin: 0 auto !important;
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        z-index: auto !important;
    }

    /* Quantity badge - lille cirkel i øverste højre hjørne (som mail app) */
    .product-quantity-badge {
        position: absolute !important;
        top: 4px !important;
        right: 4px !important;
        background: #ef4444 !important;  /* Rød farve (som notification) */
        color: white !important;
        border-radius: 50% !important;  /* Cirkel */
        width: 20px !important;
        height: 20px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        display: none !important;  /* Hidden by default */
        align-items: center !important;
        justify-content: center !important;
        z-index: 20 !important;
        pointer-events: none !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
        border: 2px solid white !important;  /* Hvid kant for kontrast */
    }

    /* Vis badge når den har 'visible' class */
    .product-quantity-badge.visible {
        display: flex !important;
    }

    /* Skjul gamle badges på mobil - vi bruger quantity badge i stedet */
    .product-badge,
    .product-shortcut {
        display: none !important;
    }

    /* Sikr at parent container ikke skjuler badges */
    .product-btn,
    .product-btn-inner {
        overflow: visible !important;  /* KRITISK: Lad badges være synlige */
    }

    /* Fjern pseudo-elementer der kan skabe spacing */
    #products::before,
    #products::after,
    #products-area::before,
    #products-area::after,
    #sidebar::before,
    #sidebar::after,
    #checkout-stack::before,
    #checkout-stack::after,
    #total-price::before,
    #total-price::after,
    #user-selection-actions::before,
    #user-selection-actions::after {
        display: none !important;
        content: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ===== KOMPAKT CHECKOUT OMRÅDE - GLASSMORPHISM PRO STYLING ===== */
    #sidebar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3) !important;
        padding: 10px calc(10px + env(safe-area-inset-right, 0px)) calc(10px + var(--flango-safe-bottom)) calc(10px + env(safe-area-inset-left, 0px)) !important;
        margin: 0 !important;
        margin-top: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        grid-area: unset !important;
        flex-shrink: 0 !important;
        overflow: visible !important;
        z-index: 100 !important;
        min-height: 0 !important;
        max-height: calc(var(--flango-mobile-footer-h) + var(--flango-safe-bottom)) !important;
        height: auto !important;
    }
    /* Dræb enhver divider/linje mellem total og knapper */
    #checkout-stack hr,
    #checkout-stack .divider,
    #checkout-stack .line,
    #total-price hr,
    #total-price .divider,
    #total-price .line,
    #user-selection-actions hr,
    #user-selection-actions .divider,
    #user-selection-actions .line {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }

    #total-price {
        border-top: 0 !important;
        border-bottom: 0 !important;
        box-shadow: none !important;
    }

    #user-selection-actions {
        border-top: 0 !important;
        box-shadow: none !important;
    }

    /* Skjul kurv når main-app ikke vises */
    #main-app[style*="display: none"] #sidebar,
    #main-app[style*="display:none"] #sidebar {
        display: none !important;
    }

    /* Skjul "Indkøbskurv" header på mobil */
    #sidebar .sidebar-header {
        display: none !important;
    }

    /* VIS order-liste på mobil med scrolling - KOMPAKT STØRRELSE */
    #sidebar #current-order {
        display: block !important;
        flex: 0 0 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 8px !important;
        margin: 0 !important;
        background: rgba(255, 255, 255, 0.1) !important;
        backdrop-filter: blur(5px) !important;
        -webkit-backdrop-filter: blur(5px) !important;
        border-radius: 12px !important;
        margin-bottom: 8px !important;
        height: 120px !important;
        min-height: 120px !important;
        max-height: 120px !important;
    }

    /* Order list styling */
    #order-list {
        list-style: none !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
    }

    #order-list li {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 8px 10px !important;
        background: rgba(255, 255, 255, 0.25) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        border-radius: 10px !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        color: white !important;
        font-size: 12px !important;
        gap: 8px !important;
    }

    .cart-product-line {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    .cart-product-icon {
        width: 24px !important;
        height: 24px !important;
        flex-shrink: 0 !important;
        border-radius: 4px !important;
    }

    .cart-product-emoji {
        font-size: 20px !important;
        line-height: 1 !important;
        flex-shrink: 0 !important;
    }

    .cart-product-line span {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-weight: 600 !important;
    }

    .remove-item-btn {
        flex-shrink: 0 !important;
        width: 28px !important;
        height: 28px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(239, 68, 68, 0.3) !important;
        border-radius: 6px !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }

    .remove-item-btn:active {
        background: rgba(239, 68, 68, 0.5) !important;
        transform: scale(0.95) !important;
    }

    .cart-remove-icon {
        width: 16px !important;
        height: 16px !important;
        opacity: 0.9 !important;
    }

    /* ===== CHECKOUT STACK - PREMIUM GLASSMORPHISM BOX ===== */
    #checkout-stack {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        padding: 6px !important;
        background: rgba(255, 255, 255, 0.20) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border-radius: 16px !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
        overflow: hidden !important;
    }

    /* Hvis den mystiske bar er et input/range eller en tom divider, skjul den også */
    #checkout-stack input[type="range"],
    #checkout-stack .range,
    #checkout-stack .slider,
    #checkout-stack progress,
    #checkout-stack [role="progressbar"],
    #checkout-stack .progress,
    #checkout-stack .progress-bar,
    #checkout-stack .progress-track,
    #checkout-stack .track,
    #checkout-stack .bar,
    #checkout-stack .scroll-track,
    #checkout-stack .scrollbar,
    #checkout-stack [class*="progress"],
    #checkout-stack [class*="slider"],
    #checkout-stack [class*="track"],
    #checkout-stack [id*="progress"],
    #checkout-stack [id*="slider"],
    #checkout-stack [id*="track"],
    #checkout-stack .spacer,
    #checkout-stack .separator,
    #checkout-stack .divider,
    #checkout-stack hr,
    #checkout-stack .line {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }
    /* Extra safety: never show any thin white strip between total content and buttons */
    #checkout-stack > * {
        border-top: 0 !important;
        border-bottom: 0 !important;
        background-image: none !important;
    }

    /* Mini-kvittering container - VIS KUN TOTAL (skjul chips) */
    #total-price {
        background: transparent !important;
        border-radius: 0 !important;
        padding: 6px 10px !important;
        padding-right: calc(10px + env(safe-area-inset-right, 0px)) !important;
        margin: 0 !important;
        color: white !important;
        font-size: 18px !important;
        font-weight: 800 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
        letter-spacing: 0.5px !important;
    }

    /* Skjul chips på mobil når vi viser fuld liste */
    #mini-receipt-chips {
        display: none !important;
    }

    /* Skjul chip styling (ikke brugt når vi viser fuld liste) */
    .order-chip,
    .order-chip-qty,
    .order-chip-remove,
    .order-chip-overflow {
        display: none !important;
    }

    /* VIS total-price-value (vigtigt!) */
    #total-price-value {
        display: block !important;
        width: 100% !important;
        text-align: right !important;
    }

    /* User selection area - INGEN SPACING */
    #user-selection-area {
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
    }

    /* Mobil: VIS selected-user-info, men skjul alt andet undtagen knapper */
    #user-selection-area > *:not(#user-selection-actions):not(#selected-user-info) {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }


    /* Kill any stray form controls / progress/slider tracks inside the fixed footer */
    #sidebar input,
    #sidebar select,
    #sidebar textarea,
    #sidebar input[type="range"],
    #sidebar progress,
    #sidebar [role="progressbar"],
    #sidebar .progress,
    #sidebar .progress-bar,
    #sidebar .progress-track,
    #sidebar .slider,
    #sidebar .track {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }

    /* Mobile app-shell: no visible form controls outside modals (kills the white pill input bar) */
    #main-app input,
    #main-app select,
    #main-app textarea {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
    }

    /* Re-enable form controls inside modals */
    .modal input,
    .modal select,
    .modal textarea {
        display: block !important;
        height: auto !important;
        margin: initial !important;
        padding: initial !important;
        border: initial !important;
        background: initial !important;
        box-shadow: initial !important;
        -webkit-box-shadow: initial !important;
    }

    #main-app input,
    #main-app select,
    #main-app textarea {
        -webkit-appearance: none !important;
        appearance: none !important;
    }

    /* Also hide any pseudo scrollbars inside the footer */
    #sidebar::-webkit-scrollbar,
    #checkout-stack::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    #user-selection-actions {
        display: flex !important;
        gap: 4px !important;  /* Reduceret gap */
        margin: 0 !important;
        padding: 0 !important;            /* ingen "hvid streg" område */
        background: transparent !important;
        border: 0 !important;
        border-top: 0 !important;
        outline: none !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        background-clip: padding-box !important;
    }

    #user-selection-actions button {
        flex: 1 !important;
        padding: 14px 10px !important;
        font-size: 14px !important;
        font-weight: 700 !important;
        min-height: 48px !important;
        border-radius: 12px !important;
        border: 2px solid rgba(255, 255, 255, 0.4) !important;
        margin: 0 !important;
        outline: none !important;
        background: rgba(255, 255, 255, 0.25) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
        color: white !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
        letter-spacing: 0.5px !important;
        margin-top: 4px !important;
        transition: all 0.2s ease !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    #user-selection-actions button:active {
        transform: scale(0.98) !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    }
    /* Dræb sidste 1px "hvid streg" mellem total-indhold og knapper */
    #checkout-stack,
    #total-price,
    #user-selection-actions {
        border-top: 0 !important;
        border-bottom: 0 !important;
        outline: none !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        background-clip: padding-box !important;
    }

    /* Mobil: dræb ALLE interne border-top/bottom der kan tegne en separatorlinje */
    #checkout-stack > * {
        border-top: 0 !important;
        border-bottom: 0 !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        outline: none !important;
        background-image: none !important;
    }

    /* Og hvis et element specifikt tegner en streg, så skjul det */
    #checkout-stack .separator,
    #checkout-stack .divider,
    #checkout-stack .line,
    #checkout-stack .hr,
    #checkout-stack #divider,
    #checkout-stack #separator,
    #checkout-stack #checkout-divider {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }

    /* Vælg Kunde knap - SPECIAL STYLING */
    #select-customer-main-btn {
        padding: 14px 10px !important;
        font-size: 14px !important;
        font-weight: 700 !important;
        min-height: 48px !important;
        background: rgba(59, 130, 246, 0.4) !important;
        border: 2px solid rgba(255, 255, 255, 0.5) !important;
    }

    #select-customer-main-btn:active {
        background: rgba(59, 130, 246, 0.5) !important;
    }

    /* Gennemfør Køb knap - PREMIUM ACCENT */
    #complete-order-btn,
    #complete-purchase {
        width: 100% !important;
        padding: 14px 12px !important;
        font-size: 15px !important;
        font-weight: 800 !important;
        min-height: 50px !important;
        margin: 0 !important;
        background: linear-gradient(135deg, rgba(34, 197, 94, 0.5) 0%, rgba(16, 185, 129, 0.5) 100%) !important;
        border: 2px solid rgba(255, 255, 255, 0.6) !important;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
    }

    #complete-order-btn:active,
    #complete-purchase:active {
        background: linear-gradient(135deg, rgba(34, 197, 94, 0.6) 0%, rgba(16, 185, 129, 0.6) 100%) !important;
        transform: scale(0.97) !important;
    }

    /* Prevent horizontal clipping on mobile */
    *, *::before, *::after {
        box-sizing: border-box !important;
    }

    body {
        overflow-x: hidden !important;
    }

    /* ===== MODALS - FULL SCREEN ===== */
    .modal {
        padding: 0 !important;
        background: rgba(0, 0, 0, 0.9) !important;
        align-items: flex-start !important;
        overflow-y: auto !important;
        justify-content: flex-start !important;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: none !important;
        min-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
    }

    .modal-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
        background: white !important;
        border-bottom: 1px solid #e2e8f0 !important;
        padding: 16px 14px !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    .modal-header h2 {
        font-size: 19px !important;
        margin: 0 !important;
    }

    .close-btn {
        width: 40px !important;
        height: 40px !important;
        font-size: 30px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .modal-body {
        flex: 1 !important;
        padding: 14px !important;
        overflow-y: auto !important;
    }

    .modal-footer {
        position: sticky !important;
        bottom: 0 !important;
        background: white !important;
        border-top: 1px solid #e2e8f0 !important;
        padding: 14px !important;
        margin: 0 !important;
    }

    /* Modal lists */
    .modal-user-list {
        padding: 0 !important;
    }

    .user-item {
        padding: 14px !important;
        margin-bottom: 8px !important;
        font-size: 15px !important;
    }

    /* Modal controls */
    .modal-controls {
        padding: 12px 14px !important;
        gap: 10px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .modal-controls input {
        width: 100% !important;
        padding: 14px !important;
        font-size: 16px !important;
        min-height: 48px !important;
    }

    .modal-controls button {
        width: 100% !important;
        padding: 14px !important;
        font-size: 16px !important;
        min-height: 48px !important;
    }

    /* User list header */
    .user-list-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        background: #f8f9fa !important;
        padding: 12px 14px !important;
        gap: 10px !important;
        font-size: 14px !important;
        display: grid !important;
        grid-template-columns: 2fr 1fr 1fr 1fr !important;
    }

    .sort-header {
        padding: 10px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* ===== OPSUMMERING/HISTORIK MODALS ===== */
    .summary-view-selector {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 12px 14px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .summary-view-btn,
    .summary-role-btn {
        padding: 12px 16px !important;
        font-size: 14px !important;
        min-height: 48px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    .summary-filters {
        flex-direction: column !important;
        gap: 12px !important;
        padding: 14px !important;
    }

    .filter-group {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .filter-group input {
        width: 100% !important;
    }

    /* Report buttons - WRAP PROPERLY */
    .report-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px !important;
    }

    .report-buttons button {
        font-size: 13px !important;
        padding: 10px 12px !important;
        flex: 1 1 calc(50% - 8px) !important;
        min-width: 130px !important;
        min-height: 48px !important;
        white-space: normal !important;
        line-height: 1.3 !important;
    }

    /* History filter panel */
    .history-filter-panel {
        padding: 14px !important;
    }

    .filter-options {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .filter-column {
        width: 100% !important;
    }

    .filter-column label {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 8px 0 !important;
        min-height: 44px !important;
    }

    /* Date filter */
    .date-filter {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        padding: 14px !important;
    }

    .date-filter input {
        width: 100% !important;
        padding: 12px !important;
        font-size: 15px !important;
        min-height: 48px !important;
    }

    /* History scroll container */
    .history-scroll-container {
        max-height: calc(100vh - 400px) !important;
        overflow-y: auto !important;
    }

    /* History rows - CARD LAYOUT */
    .history-row {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        padding: 14px !important;
        gap: 10px !important;
        border-bottom: 2px solid #e2e8f0 !important;
        background: white !important;
        margin-bottom: 10px !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
    }

    .history-row > div {
        font-size: 14px !important;
    }

    .history-col-action,
    .history-col-items,
    .history-col-amount,
    .history-col-datetime,
    .history-col-staff,
    .history-col-adult,
    .history-col-edit {
        display: flex !important;
        flex-direction: column !important;
        gap: 4px !important;
    }

    .history-edit-btn {
        width: 100% !important;
        padding: 12px !important;
        min-height: 48px !important;
        font-size: 15px !important;
    }

    /* Summary layout - stack vertically */
    .summary-layout {
        flex-direction: column !important;
        gap: 20px !important;
    }

    .summary-table-container {
        border-right: none !important;
        padding-right: 0 !important;
        margin-bottom: 20px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .summary-table {
        min-width: 500px !important;
        font-size: 13px !important;
    }

    .chart-carousel {
        width: 100% !important;
    }

    .pie-chart {
        width: 200px !important;
        height: 200px !important;
        margin: 0 auto !important;
    }

    /* ===== AVATAR PICKER ===== */
    .avatar-scroller {
        gap: 14px !important;
        padding: 10px !important;
    }

    .avatar-option {
        width: 160px !important;
        height: 160px !important;
        flex-shrink: 0 !important;
    }

    .avatar-carousel-wrapper {
        flex-direction: column !important;
    }

    .avatar-scroller-viewport {
        width: 100% !important;
        overflow-x: auto !important;
    }

    .avatar-row-nav {
        width: 40px !important;
        height: 40px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 22px !important;
    }

    /* ===== GENERAL TOUCH TARGETS ===== */
    button,
    .btn,
    .action-button {
        min-height: 48px !important;
        min-width: 44px !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
        touch-action: manipulation !important;
    }

    .primary-btn {
        font-size: 16px !important;
        padding: 14px 20px !important;
        min-height: 52px !important;
    }

    /* ===== INPUTS ===== */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        min-height: 48px !important;
        padding: 12px 14px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }

    /* ===== CHECKBOXES ===== */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 22px !important;
        min-height: 22px !important;
        cursor: pointer !important;
    }
}

/* ============================================================
   SMALL MOBILE - under 480px (1 kolonne produkter)
   ============================================================ */
@media (max-width: 480px) {
    /* NOTE: On small mobile we KEEP the 2×3 paging grid from the 767px rules.
       Do NOT force 1-column layout here (it breaks paging). */
    #products {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Smaller sidebar */
    #sidebar {
        max-height: 260px !important;
    }

    /* Report buttons - FULL WIDTH */
    .report-buttons button {
        flex: 1 1 100% !important;
        min-width: auto !important;
    }

    /* Smaller avatars */
    .avatar-option {
        width: 130px !important;
        height: 130px !important;
    }

    /* Sidebar header icons smaller */
    .sidebar-header-icon {
        width: 36px !important;
        height: 36px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }
}

/* ============================================================
   LANDSCAPE MODE - Compress vertical space
   ============================================================ */
@media (max-height: 550px) and (orientation: landscape) {
    .sidebar-main-header {
        padding: 8px 12px !important;
    }

    #sidebar-logo {
        width: 50px !important;
    }

    .user-session-banner {
        top: 70px !important;
        padding: 6px 12px !important;
    }

    #main-app {
        margin-top: 120px !important;
    }

    body {
        padding-bottom: 220px !important;
    }

    #sidebar {
        max-height: 200px !important;
    }
}

/* ============================================================
   TOUCH OPTIMIZATIONS
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects */
    .product-btn:hover {
        transform: none !important;
    }

    /* Better active states */
    .product-btn:active {
        transform: scale(0.97) !important;
        transition: transform 0.1s !important;
    }

    button:active {
        opacity: 0.8 !important;
    }
}

/* ============================================================
   ACCESSIBILITY - Reduced Motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
