/* ==========================================================================
   POS Tabacchi Mirage — Design System
   Basato su Material Design 3 (MD3)
   ========================================================================== */

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

button, a, [onclick] {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    overflow-x: hidden;
    width: 100%;
    height: 100%;
}

/* ===== DESIGN TOKENS (CSS Custom Properties) ===== */
/*
    Palette MD3. Per personalizzare il tema cambia solo --md-primary
    (la sua variante container viene calcolata proporzionalmente).
    Il colore principale è anche configurabile da Settings > Aspetto.
*/
:root {
    /* Primary — viola (brand Mirage) */
    --md-primary:               #6750A4;
    --md-on-primary:            #FFFFFF;
    --md-primary-container:     #EADDFF;
    --md-on-primary-container:  #21005D;

    /* Secondary */
    --md-secondary:             #625B71;
    --md-on-secondary:          #FFFFFF;
    --md-secondary-container:   #E8DEF8;
    --md-on-secondary-container:#1D192B;

    /* Tertiary */
    --md-tertiary:              #7D5260;
    --md-on-tertiary:           #FFFFFF;
    --md-tertiary-container:    #FFD8E4;

    /* Surface / Background */
    --md-surface:               #FEF7FF;
    --md-on-surface:            #1D1B20;
    --md-surface-variant:       #E7E0EB;
    --md-on-surface-variant:    #49454F;
    --md-bg:                    #F3F3F3;

    /* Outline */
    --md-outline:               #79747E;
    --md-outline-variant:       #CAC4D0;

    /* Utility */
    --md-navy:                  #1C1B1F;   /* sidebar e testo heading */
    --md-sidebar-text:          #FFFFFF;

    /* Semantic */
    --md-error:                 #B3261E;
    --md-error-container:       #F9DEDC;
    --md-success:               #386A20;
    --md-success-container:     #C4ECAF;
    --md-warning:               #7D5700;
    --md-warning-container:     #FFDEA7;

    /* Border Radius */
    --radius-sm:  8px;
    --radius:     12px;
    --radius-lg:  16px;
    --radius-xl:  28px;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, .05);
    --shadow:     0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, .1);

    /* Layout */
    --bottom-bar: 80px;
    --safe-bottom: constant(safe-area-inset-bottom);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== BODY ===== */
body {
    font-family: 'Roboto', sans-serif;
    background: var(--md-bg);
    color: var(--md-on-surface);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    width: 100%;
    -webkit-font-smoothing: antialiased;
}

/* ===== MATERIAL SYMBOLS ===== */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

/* Icona filled (per nav item attivo, ecc.) */
.mso-fill {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--md-outline-variant);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }


/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */

#login-screen {
    position: fixed;
    inset: 0;
    background: var(--md-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-box {
    width: 100%;
    max-width: 440px;
    margin: 1rem;
    padding: 0;
}

.login-logo {
    text-align: center;
    margin-bottom: 2.5rem;
}

/* Icona default se nessun logo è caricato */
.login-logo-icon {
    width: 64px;
    height: 64px;
    background: var(--md-primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(103, 80, 164, .25);
}

.login-logo-icon .material-symbols-outlined { font-size: 36px; }

/* Logo caricato via Settings */
.login-logo img {
    max-width: 280px;
    max-height: 120px;
    margin: 0 auto 1rem;
    display: block;
}

.login-logo h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--md-on-surface);
    letter-spacing: -.5px;
}

.login-logo p {
    color: var(--md-on-surface-variant);
    margin-top: .25rem;
    font-weight: 500;
    font-size: .875rem;
}

.login-card {
    background: var(--md-surface);
    border: 1px solid var(--md-surface-variant);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.login-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: .25rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--md-on-surface-variant);
    font-size: .875rem;
    margin-bottom: 2rem;
}

.login-error {
    background: var(--md-error-container);
    color: var(--md-error);
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .875rem;
    display: none;
}

.login-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.login-footer p {
    font-size: .75rem;
    color: var(--md-on-surface-variant);
    display: flex;
    align-items: center;
    gap: .375rem;
}

/* Pallino verde "online" nel footer login */
.login-footer .dot {
    width: 6px;
    height: 6px;
    background: #386A20;
    border-radius: 50%;
}


/* ==========================================================================
   FORM — MD3 Style
   ========================================================================== */

/* Campo con icona a sinistra (usato nel login) */
.m3-field { margin-bottom: 1.25rem; }

.m3-field label {
    display: block;
    font-size: .75rem;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    margin-bottom: .375rem;
    margin-left: .25rem;
}

.m3-input-wrap {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
    background: rgba(231, 224, 235, .3);
    border: 1px solid var(--md-outline);
    border-radius: var(--radius);
    transition: all .2s;
    height: 52px;
}

.m3-input-wrap:focus-within {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 1px var(--md-primary);
}

.m3-input-wrap .material-symbols-outlined {
    color: var(--md-on-surface-variant);
    font-size: 20px;
    flex-shrink: 0;
}

.m3-input-wrap input,
.m3-input-wrap select {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: .9375rem;
    font-family: inherit;
    color: var(--md-on-surface);
    padding: 0;
    min-width: 0;
}

.m3-input-wrap input::placeholder { color: rgba(73, 69, 79, .5); }

.m3-input-wrap .toggle-pw {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-on-surface-variant);
    padding: 0;
    display: flex;
}

/* Campo form generico (usato nelle pagine interni) */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    margin-bottom: .375rem;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    font-size: .75rem;
    margin-left: .25rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .75rem 1rem;
    border: 1px solid var(--md-outline);
    border-radius: var(--radius);
    font-size: .9375rem;
    transition: all .2s;
    font-family: inherit;
    background: rgba(231, 224, 235, .15);
    color: var(--md-on-surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: 0 0 0 1px var(--md-primary);
}

/* Due colonne */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}


/* ==========================================================================
   BUTTONS — MD3 Style
   Tutti i pulsanti usano classe base `.btn` + variante colore
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .625rem 1.5rem;
    border: none;
    border-radius: 9999px;   /* pill shape, MD3 standard */
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    font-family: inherit;
    touch-action: manipulation;
    height: 40px;
}

/* Varianti colore */
.btn-primary   { background: var(--md-primary); color: var(--md-on-primary); }
.btn-primary:hover { box-shadow: 0 1px 3px rgba(103, 80, 164, .4); }

.btn-secondary { background: var(--md-surface-variant); color: var(--md-on-surface-variant); }
.btn-secondary:hover { background: var(--md-outline-variant); }

.btn-success   { background: var(--md-success-container); color: var(--md-success); }
.btn-success:hover { filter: brightness(.95); }

.btn-danger    { background: var(--md-error-container); color: var(--md-error); }
.btn-danger:hover  { filter: brightness(.95); }

.btn-filled-tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn-filled-tonal:hover { filter: brightness(.95); }

.btn-text      { background: none; color: var(--md-primary); }
.btn-text:hover { background: rgba(103, 80, 164, .08); }

.btn-outline   { background: none; border: 1px solid var(--md-outline); color: var(--md-on-surface-variant); }
.btn-outline:hover { background: var(--md-surface-variant); }

/* Dimensioni */
.btn-sm  { padding: .375rem .875rem; font-size: .75rem;  height: 32px; }
.btn-lg  { padding: .875rem 2rem;    font-size: 1rem;    height: 52px; }

/* Stati */
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block    { width: 100%; }


/* ==========================================================================
   APP LAYOUT
   Desktop: sidebar fissa sinistra + main-content
   Mobile:  bottom nav + pagine full-width
   ========================================================================== */

#app {
    display: none;         /* mostrato via JS dopo autenticazione */
    min-height: 100vh;
    min-height: 100dvh;
}

.app-layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}


/* ==========================================================================
   SIDEBAR (desktop ≥ 1200px)
   Collassata a 72px su tablet, espansa a 260px su desktop
   ========================================================================== */

.mobile-only-logo { display: none !important; }

.sidebar {
    width: 72px;
    background: var(--md-navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: width .2s;
}

@media (min-width: 1200px) {
    .sidebar { width: 260px; }
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 72px;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: var(--md-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon .material-symbols-outlined { color: var(--md-sidebar-text); font-size: 24px; }

.sidebar-logo { max-width: 140px; max-height: 40px; object-fit: contain; }

.sidebar-header-text { display: none; }

@media (min-width: 1200px) {
    .sidebar-header-text {
        display: flex;
        flex-direction: column;
    }
}

.sidebar-header-text h1 { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.sidebar-header-text p  { font-size: .7rem; color: var(--md-outline); }

.sidebar-nav {
    flex: 1;
    padding: .5rem;
    overflow-y: auto;
}

/* Nav item — pill shape attivo con secondary-container */
.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1rem;
    color: var(--md-sidebar-text);
    opacity: .7;
    cursor: pointer;
    transition: all .2s;
    border-radius: 9999px;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.nav-item:hover  { opacity: 1; background: rgba(255, 255, 255, .08); }
.nav-item.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); opacity: 1; }

.nav-item .material-symbols-outlined { font-size: 22px; flex-shrink: 0; }

.nav-item-label { display: none; }

@media (min-width: 1200px) {
    .nav-item-label { display: block; }
}

.sidebar-footer {
    padding: .75rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem;
}

/* Avatar con iniziali utente */
.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--md-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .875rem;
    flex-shrink: 0;
    color: #fff;
}

.user-details { flex: 1; min-width: 0; display: none; }

@media (min-width: 1200px) {
    .user-details { display: flex; flex-direction: column; }
}

.user-name {
    font-weight: 700;
    font-size: .8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: .625rem;
    color: var(--md-sidebar-text);
    opacity: .7;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .05em;
}

.sidebar-actions { display: none; gap: .25rem; }

@media (min-width: 1200px) {
    .sidebar-actions { display: flex; }
}

.sidebar-action-btn {
    background: none;
    border: none;
    color: var(--md-sidebar-text);
    opacity: .7;
    cursor: pointer;
    padding: .5rem;
    border-radius: 50%;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-action-btn:hover { background: rgba(255, 255, 255, .1); opacity: 1; }

.suspend-btn,
.logout-btn {
    background: none;
    border: none;
    color: var(--md-outline);
    cursor: pointer;
    padding: .5rem;
    border-radius: 50%;
    transition: all .2s;
    font-size: 1rem;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.suspend-btn:hover { color: var(--md-warning-container); background: rgba(255, 255, 255, .1); }
.logout-btn:hover  { color: var(--md-error-container);   background: rgba(255, 255, 255, .1); }


/* ==========================================================================
   BOTTOM NAVIGATION (mobile / tablet ≤ 1024px)
   ========================================================================== */

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--md-surface-variant);
    z-index: 50;
    padding-bottom: var(--safe-bottom);
    border-top: 1px solid var(--md-outline-variant);
}

.bottom-nav-inner {
    display: flex;
    height: var(--bottom-bar);
    align-items: center;
    justify-content: space-around;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--md-on-surface-variant);
    font-size: .625rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    border: none;
    background: none;
    font-family: inherit;
    touch-action: manipulation;
    padding: .5rem 0;
}

.bottom-nav-item .material-symbols-outlined { font-size: 22px; transition: all .2s; }

.bottom-nav-item.active { color: var(--md-on-surface); }

/* Pill indicator sull'icona attiva */
.bottom-nav-item.active .nav-pill {
    background: var(--md-secondary-container);
    border-radius: 9999px;
    padding: .25rem 1.25rem;
    margin-bottom: 2px;
}

.bottom-nav-item.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.bottom-nav-item .nav-pill { padding: .25rem; transition: all .2s; }


/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */

.main-content {
    flex: 1;
    margin-left: 72px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    max-width: 100vw;
}

@media (min-width: 1200px) {
    .main-content { margin-left: 260px; }
}

.page-header {
    background: var(--md-bg);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-shrink: 0;
    height: 64px;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--md-navy);
}

.page-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.page {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.page.hidden { display: none !important; }


/* ==========================================================================
   CARDS — MD3
   ========================================================================== */

.card {
    background: var(--md-surface);
    border: 1px solid var(--md-surface-variant);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--md-surface-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.card-title {
    font-size: .875rem;
    font-weight: 500;
    color: var(--md-on-surface);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-body { padding: 1.25rem; }


/* ==========================================================================
   TABLES — MD3
   ========================================================================== */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: collapse; }

th, td {
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--md-surface-variant);
    white-space: nowrap;
    font-size: .8125rem;
}

th {
    background: var(--md-surface);
    font-weight: 500;
    font-size: .6875rem;
    text-transform: uppercase;
    color: var(--md-on-surface-variant);
    position: sticky;
    top: 0;
    letter-spacing: .05em;
}

tr:hover { background: rgba(231, 224, 235, .3); }


/* ==========================================================================
   BADGES — MD3 (usati per stato scontrino, ruolo utente, ecc.)
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .25rem .625rem;
    border-radius: 9999px;
    font-size: .6875rem;
    font-weight: 500;
}

.badge-success { background: var(--md-success-container); color: var(--md-success); }
.badge-warning { background: var(--md-warning-container); color: var(--md-warning); }
.badge-danger  { background: var(--md-error-container);   color: var(--md-error);   }
.badge-primary { background: var(--md-primary-container); color: var(--md-on-primary-container); }


/* ==========================================================================
   TABS — contenuto a schede (usato in Settings, Scontrini, ecc.)
   ========================================================================== */

.tabs {
    display: flex;
    gap: .25rem;
    background: var(--md-surface-variant);
    padding: .25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    flex: none;
    padding: .5rem 1rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    font-size: .8125rem;
    font-family: inherit;
    white-space: nowrap;
    color: var(--md-on-surface-variant);
}

.tab:hover  { background: rgba(255, 255, 255, .5); }
.tab.active { background: var(--md-surface); box-shadow: var(--shadow-sm); color: var(--md-on-surface); }


/* ==========================================================================
   STAT CARDS — Dashboard KPI
   ========================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--md-surface);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--md-surface-variant);
}

.stat-label {
    font-size: .6875rem;
    color: var(--md-on-surface-variant);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: .03em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--md-on-surface);
    margin-top: .125rem;
}


/* ==========================================================================
   FILTER BAR — barra filtri nelle liste (prodotti, scontrini)
   ========================================================================== */

.filter-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
    padding: .75rem;
    background: var(--md-surface);
    border-radius: var(--radius);
    border: 1px solid var(--md-surface-variant);
}

.filter-bar input,
.filter-bar select {
    padding: .5rem .75rem;
    border: 1px solid var(--md-outline);
    border-radius: var(--radius-sm);
    font-size: .8125rem;
    font-family: inherit;
    background: rgba(231, 224, 235, .15);
}

.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--md-primary);
}

.filter-bar label {
    font-size: .6875rem;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.filter-group { display: flex; flex-direction: column; gap: .25rem; }


/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */

.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--md-navy);
    color: #fff;
    padding: .875rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    z-index: 300;
    transition: transform .3s ease, opacity .3s ease;
    font-size: .875rem;
    max-width: calc(100vw - 32px);
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
}

.toast.active { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error   { background: var(--md-error);   }
.toast.success { background: var(--md-success);  }


/* ==========================================================================
   POS LAYOUT — pagina cassa (checkout)
   Griglia: prodotti | pannello carrello
   ========================================================================== */

/* Grid principale desktop */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    height: calc(100vh - 120px);
}

.pos-products {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Search bar (campo ricerca prodotti, con barcode scan) */
.search-bar {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin-bottom: 1rem;
}

.search-bar .material-symbols-outlined {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-on-surface-variant);
    font-size: 20px;
}

.search-bar input {
    width: 100%;
    height: 48px;
    padding-left: 3rem;
    padding-right: 1rem;
    background: var(--md-surface);
    border: none;
    border-radius: 9999px;
    font-size: .875rem;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
    color: var(--md-on-surface);
}

.search-bar input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(103, 80, 164, .2);
}

.search-bar input::placeholder { color: var(--md-on-surface-variant); }

/* Categorie — Segmented Button (scrollabile su mobile) */
.categories-bar {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}

.categories-bar::-webkit-scrollbar { display: none; }

.category-btn {
    display: flex;
    align-items: center;
    gap: .375rem;
    padding: .5rem 1rem;
    background: transparent;
    border: 1px solid var(--md-outline);
    font-size: .8125rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
    font-family: inherit;
    touch-action: manipulation;
    color: var(--md-on-surface);
    margin-left: -1px;  /* overlap borders */
}

/* Forma pill: solo gli estremi arrotondati */
.category-btn:first-child { border-radius: 9999px 0 0 9999px; margin-left: 0; }
.category-btn:last-child  { border-radius: 0 9999px 9999px 0; }
.category-btn:hover       { background: rgba(231, 224, 235, .3); }
.category-btn.active      { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: var(--md-secondary); }

/* Grid prodotti — auto-fit responsive */
.products-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: .75rem;
    overflow-y: auto;
    padding: .25rem;
    align-content: start;
    -webkit-overflow-scrolling: touch;
}

.products-grid::-webkit-scrollbar { display: none; }

.product-card {
    background: var(--md-surface);
    border: 1px solid var(--md-surface-variant);
    border-radius: var(--radius);
    padding: 1rem .75rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    width: 100%;
    font-family: inherit;
    color: inherit;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    min-height: 100px;
    -webkit-transform: translateZ(0);  /* GPU layer per performance scroll */
    transform: translateZ(0);
}

.product-card:hover  { background: rgba(231, 224, 235, .4); }
.product-card:active { background: rgba(231, 224, 235, .6); }

/* Prodotto nel carrello: bordo primario */
.product-card.in-cart {
    border-color: var(--md-primary);
    border-width: 2px;
}

/* Prodotto generico/prezzo libero */
.product-card.generic {
    background: var(--md-primary-container);
    border-color: var(--md-primary);
    border-width: 2px;
}

.product-card.generic:hover { background: rgba(234, 221, 255, .8); }

.product-icon { font-size: 1.75rem; line-height: 1; }
.product-card .material-symbols-outlined { font-size: 2rem; color: var(--md-primary); }
.product-card.generic .material-symbols-outlined { color: var(--md-on-primary-container); }

.product-name {
    font-weight: 700;
    font-size: .6875rem;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.product-price {
    font-size: .75rem;
    font-weight: 500;
    color: var(--md-outline);
}

.product-card.generic .product-name  { color: var(--md-primary); }
.product-card.generic .product-price { color: var(--md-primary); opacity: .7; }


/* ==========================================================================
   CART PANEL — pannello carrello (desktop: fisso a destra; mobile: slide-up)
   ========================================================================== */

.cart-panel {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--md-surface-variant);
}

.cart-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--md-surface-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--md-surface);
}

.cart-header h2 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    font-weight: 700;
    color: var(--md-navy);
}

.cart-header h2 > * { margin-right: .5rem; }
.cart-header h2 .material-symbols-outlined { color: var(--md-on-surface-variant); font-size: 20px; }

/* Badge numero articoli */
.cart-count {
    background: var(--md-primary);
    color: var(--md-on-primary);
    padding: .125rem .5rem;
    border-radius: 9999px;
    font-size: .625rem;
    font-weight: 700;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: .75rem;
    -webkit-overflow-scrolling: touch;
}

.cart-items::-webkit-scrollbar { display: none; }

/* Stato carrello vuoto */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--md-outline);
}

.cart-empty-icon { font-size: 2.5rem; margin-bottom: .5rem; }

/* Riga articolo nel carrello */
.cart-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .625rem;
    border-radius: var(--radius-sm);
    margin-bottom: .5rem;
    transition: background .2s;
    position: relative;
}

.cart-item:hover { background: rgba(231, 224, 235, .25); }

/* Articolo inserito manualmente (senza prodotto DB) */
.cart-item.manual {
    background: var(--md-warning-container);
    border-radius: var(--radius-sm);
}

.cart-item-icon { font-size: 1rem; flex-shrink: 0; margin-top: .125rem; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name  { font-weight: 700; font-size: .8125rem; color: var(--md-navy); }
.cart-item-price { font-size: .6875rem; color: var(--md-outline); }

/* Controllo quantità */
.cart-item-qty {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-top: .5rem;
    background: rgba(231, 224, 235, .4);
    border-radius: 9999px;
    padding: .125rem;
    width: fit-content;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-primary);
    transition: all .15s;
}

.qty-btn:hover { background: rgba(103, 80, 164, .1); }
.qty-btn .material-symbols-outlined { font-size: 18px; }
.qty-value { font-weight: 700; min-width: 24px; text-align: center; font-size: .8125rem; }

.cart-item-total { font-weight: 700; color: var(--md-primary); font-size: .8125rem; flex-shrink: 0; margin-top: .125rem; }

/* Bottone rimuovi (visibile on hover) */
.cart-item-remove {
    position: absolute;
    top: .5rem;
    right: .5rem;
    opacity: 0;
    transition: opacity .2s;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-outline);
    padding: 0;
}

.cart-item:hover .cart-item-remove { opacity: 1; }

/* Footer carrello con totali */
.cart-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--md-surface-variant);
    background: var(--md-surface);
}

.cart-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: .375rem;
    font-size: .75rem;
    color: var(--md-on-surface-variant);
}

.cart-row.total {
    font-size: 1rem;
    font-weight: 700;
    padding-top: .75rem;
    border-top: 1px solid var(--md-outline-variant);
    margin-top: .5rem;
    color: var(--md-navy);
}

.cart-row.total .value {
    color: var(--md-primary);
    font-size: 1.25rem;
    font-weight: 900;
}

/* Bottoni pagamento cash / card */
.payment-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    margin: .875rem 0;
}

.btn-pay {
    height: 52px;
    padding: 0 .75rem;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: .8125rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
}

.btn-pay:active   { opacity: .7; }
.btn-pay:disabled { opacity: .5; cursor: not-allowed; }
.btn-pay.cash     { background: #A8DAB5; color: #1E4620; }
.btn-pay.card     { background: #B1B1F1; color: #2C2C6E; }

/* Preset importo attivo nel numpad pagamento */
.preset-btn.active {
    background: var(--md-primary) !important;
    color: var(--md-on-primary) !important;
    border-color: var(--md-primary) !important;
}

/* Bottone principale "Emetti scontrino" */
.btn-pay-main {
    width: 100%;
    height: 56px;
    background: var(--md-primary);
    color: var(--md-on-primary);
    border: none;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    box-shadow: 0 2px 8px rgba(103, 80, 164, .25);
    -webkit-appearance: none;
    appearance: none;
}

.btn-pay-main:active   { opacity: .7; }
.btn-pay-main:disabled { opacity: .5; cursor: not-allowed; }


/* ==========================================================================
   MOBILE CART — FAB + slide-up sheet
   ========================================================================== */

/* FAB apertura carrello (solo phone) */
.cart-fab {
    display: none;
    position: fixed;
    bottom: calc(var(--bottom-bar) + var(--safe-bottom) + 16px);
    right: 16px;
    z-index: 45;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    background: var(--md-primary-container);
    color: var(--md-on-primary-container);
    border: none;
    box-shadow: 0 6px 20px rgba(103, 80, 164, .3);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform .2s;
    align-items: center;
    justify-content: center;
}

.cart-fab .material-symbols-outlined { font-size: 26px; }
.cart-fab:active { opacity: .7; }

#scan-fab        { display: none; }
#scan-fab:active { transform: scale(.92); }

.cart-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--md-tertiary);
    color: var(--md-on-tertiary);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: .625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--md-surface);
}

/* Overlay scuro sotto lo sheet */
.cart-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}

.cart-overlay.active { display: block; opacity: 1; pointer-events: auto; }

/* Sheet carrello (slide dal basso) */
.cart-slideup {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--md-surface);
    z-index: 56;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
    transform: translateY(100%);
    transition: transform .35s cubic-bezier(.32, .72, 0, 1);
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-bottom);
}

.cart-slideup.active         { transform: translateY(0); }
.cart-slideup-handle         { width: 32px; height: 4px; background: var(--md-outline-variant); border-radius: 2px; margin: 12px auto 8px; }
.cart-slideup .cart-header   { border-top: none; }
.cart-slideup .cart-items    { max-height: 35vh; max-height: 35dvh; }

/* Barra totale fissa sopra la bottom nav (phone) */
.mobile-cart-bar {
    display: none;
    position: fixed;
    bottom: calc(var(--bottom-bar) + var(--safe-bottom));
    left: 0;
    right: 0;
    background: var(--md-surface);
    border-top: 1px solid var(--md-surface-variant);
    padding: .75rem 1rem;
    z-index: 44;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, .05);
}

.mobile-cart-bar-inner { display: flex; align-items: center; justify-content: space-between; }

.mobile-cart-bar .total-section { display: flex; flex-direction: column; }
.mobile-cart-bar .total-label   { font-size: .625rem; color: var(--md-on-surface-variant); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.mobile-cart-bar .total-value   { font-size: 1.25rem; font-weight: 900; color: var(--md-on-surface); }

.mobile-cart-bar .cart-btn {
    background: var(--md-primary-container);
    color: var(--md-on-primary-container);
    border: none;
    border-radius: var(--radius-lg);
    padding: .75rem 1.25rem;
    font-weight: 700;
    font-size: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    touch-action: manipulation;
    position: relative;
    box-shadow: var(--shadow);
}

.mobile-cart-bar .cart-btn .badge-count {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--md-tertiary);
    color: var(--md-on-tertiary);
    border-radius: 50%;
    font-size: .625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--md-surface);
}


/* ==========================================================================
   MODALS — Dialog MD3
   ========================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all .3s;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--md-surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    margin: 1rem;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    opacity: 0;
    transition: opacity .25s;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
    -webkit-transform: translateZ(0);
}

.modal-overlay.active .modal { opacity: 1; }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--md-surface-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--md-navy);
}

.modal-header h3 .material-symbols-outlined { color: var(--md-primary); font-size: 22px; }

.modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-on-surface-variant);
    transition: background .15s;
}

.modal-close:hover { background: var(--md-surface-variant); }
.modal-close .material-symbols-outlined { font-size: 22px; }

.modal-body   { padding: 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--md-surface-variant);
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    background: rgba(231, 224, 235, .1);
}


/* ==========================================================================
   NUMPAD — tastierino numerico (pagamento, inserimento importo)
   ========================================================================== */

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
    margin-top: .75rem;
}

.numpad-btn {
    height: 56px;
    border: 1px solid var(--md-surface-variant);
    border-radius: var(--radius);
    background: rgba(231, 224, 235, .2);
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    transition: all .15s;
    color: var(--md-on-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.numpad-btn:active        { background: var(--md-primary-container); opacity: .7; }
.numpad-btn.clear         { background: transparent; color: var(--md-error); border-color: transparent; }
.numpad-btn.clear .material-symbols-outlined { font-size: 22px; }

.amount-display {
    background: rgba(231, 224, 235, .25);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: right;
    border: 1px solid var(--md-outline-variant);
}

.amount-label { font-size: .625rem; color: var(--md-on-surface-variant); text-transform: uppercase; font-weight: 700; letter-spacing: .1em; }
.amount-value { font-size: 2rem; font-weight: 900; color: var(--md-primary); }

/* Display resto */
.change-display {
    margin-top: .75rem;
    padding: .75rem;
    background: var(--md-success-container);
    border-radius: var(--radius);
    text-align: center;
}

.change-value { font-size: 1.125rem; font-weight: 700; color: var(--md-success); }

/* Chip aliquota IVA (inserimento articolo manuale) */
.iva-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

.iva-chip {
    padding: .5rem 1rem;
    border-radius: 9999px;
    border: 1px solid var(--md-outline);
    font-size: .8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    background: transparent;
    font-family: inherit;
    color: var(--md-on-surface);
}

.iva-chip:hover  { background: rgba(234, 221, 255, .3); }
.iva-chip.active { background: var(--md-primary-container); color: var(--md-on-primary-container); border-color: var(--md-primary); }

/* Opzioni post-pagamento (stampa, email, whatsapp) */
.post-payment-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-top: 1rem;
}

.post-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 1rem;
    background: var(--md-surface);
    border: 1px solid var(--md-surface-variant);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .2s;
    touch-action: manipulation;
}

.post-option:active       { border-color: var(--md-primary); background: var(--md-primary-container); }
.post-option-icon         { font-size: 2rem; }
.post-option-label        { font-size: .75rem; font-weight: 500; color: var(--md-on-surface-variant); }


/* ==========================================================================
   LOGO UPLOADS — sezione caricamento loghi in Settings
   ========================================================================== */

.logo-upload-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo-upload-item {
    border: 2px dashed var(--md-outline-variant);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: all .2s;
}

.logo-upload-item:hover           { border-color: var(--md-primary); background: rgba(234, 221, 255, .1); }
.logo-upload-item.has-logo        { border-style: solid; border-color: var(--md-success); }

.logo-preview {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .5rem;
}

.logo-preview img               { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview-placeholder       { color: var(--md-outline); font-size: 2.5rem; }
.logo-upload-label              { font-size: .75rem; font-weight: 500; color: var(--md-on-surface-variant); margin-bottom: .5rem; }
.logo-upload-actions            { display: flex; gap: .5rem; justify-content: center; }
.logo-upload-input              { display: none; }


/* ==========================================================================
   LOCK SCREEN — schermata blocco con PIN
   ========================================================================== */

#lock-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: var(--md-surface);
}

#lock-screen.active { display: flex; }

/* Sfondo sfumato blurred */
#lock-screen .bg-blur {
    position: absolute;
    inset: 0;
    background: var(--md-primary-container);
    opacity: .3;
    filter: blur(40px);
}

.lock-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lock-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--md-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid var(--md-surface);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
    margin-bottom: 1rem;
}

.lock-avatar .material-symbols-outlined { font-size: 56px; color: var(--md-on-primary-container); }

.lock-username { font-size: 1.25rem; font-weight: 500; color: var(--md-on-surface); margin-bottom: .25rem; }
.lock-role     { font-size: .8125rem; color: var(--md-on-surface-variant); margin-bottom: 1.5rem; }

/* Orologio grande */
.lock-time     { font-size: 4rem; font-weight: 300; color: var(--md-on-surface); letter-spacing: -.02em; margin-bottom: .5rem; }
.lock-status   { font-size: 1rem; font-weight: 500; color: var(--md-primary); margin-bottom: .25rem; }
.lock-subtitle { font-size: .8125rem; color: var(--md-on-surface-variant); margin-bottom: 2rem; }

/* Puntini PIN */
.pin-dots { display: flex; gap: 1rem; margin-bottom: 2rem; }

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--md-primary);
    transition: all .2s;
}

.pin-dot.filled { background: var(--md-primary); }

/* Numpad glassmorphism */
.lock-numpad {
    background: rgba(255, 255, 255, .7);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 24px;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .08);
    margin-bottom: 1.5rem;
}

.lock-numpad-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(231, 224, 235, .35);
    border: none;
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
    color: var(--md-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.lock-numpad-btn:active { background: var(--md-primary-container); opacity: .8; }
.lock-numpad-btn.action { background: transparent; }
.lock-numpad-btn.action .material-symbols-outlined { font-size: 24px; }

.lock-error { color: var(--md-error); font-size: .8125rem; margin-bottom: .75rem; display: none; }
.lock-box   { display: none; }
.lock-input { display: none; }

.lock-switch-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--md-primary);
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    padding: .625rem 1.25rem;
    border-radius: 9999px;
    transition: background .15s;
    font-family: inherit;
    font-size: .875rem;
}

.lock-switch-btn:hover { background: rgba(103, 80, 164, .08); }

.lock-version {
    margin-top: 2rem;
    font-size: .625rem;
    text-transform: uppercase;
    letter-spacing: .15em;
    color: rgba(73, 69, 79, .4);
    font-weight: 700;
}


/* ==========================================================================
   RESPONSIVE — Breakpoints
   ========================================================================== */

/* Tablet / Touch (≤ 1024px o touch device) — hide sidebar, show bottom nav */
@media (max-width: 1024px), ((hover: none) and (pointer: coarse)) {
    .sidebar                { display: none !important; }
    .mobile-only-logo       { display: inline-block !important; }
    .main-content           { margin-left: 0 !important; padding-bottom: calc(var(--bottom-bar) + var(--safe-bottom)); }
    .bottom-nav             { display: block !important; }
    .mobile-cart-bar        { display: block !important; }
    .page-content           { padding: 1rem; overflow-x: hidden; }
    .page-header            { padding: 1rem; }
    .toast                  { bottom: calc(var(--bottom-bar) + var(--safe-bottom) + 12px); }
    .card                   { max-width: 100%; overflow: hidden; }
    .card-body              { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .form-row               { grid-template-columns: 1fr 1fr; }
}

/* Tablet (768px–1024px) — mostra il pannello carrello */
@media (min-width: 768px) and ((hover: none) and (pointer: coarse)),
       (min-width: 768px) and (max-width: 1024px) {
    .pos-layout             { grid-template-columns: 1fr 340px !important; height: calc(100vh - 120px - var(--bottom-bar) - var(--safe-bottom)); }
    .cart-panel             { display: flex !important; flex-direction: column; }
    .cart-fab               { display: none !important; }
    .mobile-cart-bar        { display: none !important; }
}

/* Phone (< 768px) — carrello come slide-up */
@media (max-width: 767px) {
    .pos-layout             { grid-template-columns: 1fr !important; height: calc(100dvh - 100px - var(--bottom-bar) - var(--safe-bottom)); }
    .cart-panel             { display: none !important; }
    .cart-fab               { display: flex !important; align-items: center; justify-content: center; }
    .desktop-scan-btn       { display: none !important; }
    #scan-fab               { display: flex !important; }

    .login-box              { margin: .75rem; }
    .login-card             { padding: 1.5rem; border-radius: var(--radius-lg); }
    .login-logo h1          { font-size: 1.5rem; }

    .page-header            { padding: .75rem 1rem; height: auto; }
    .page-title             { font-size: 1rem; }
    .page-content           { padding: .75rem; }

    .products-grid          { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
    .product-card           { padding: .625rem .5rem; min-height: 85px; border-radius: var(--radius-sm); }
    .product-icon           { font-size: 1.25rem; }
    .product-card .material-symbols-outlined { font-size: 1.5rem; }
    .product-name           { font-size: .5625rem; }
    .product-price          { font-size: .625rem; }

    .categories-bar         { margin-bottom: .5rem; }
    .category-btn           { padding: .375rem .75rem; font-size: .75rem; }

    .cart-slideup           { max-height: 80vh; max-height: 80dvh; }
    .cart-slideup .cart-items { max-height: 30vh; max-height: 30dvh; }

    .modal                  { margin: .5rem; max-height: 95vh; max-height: 95dvh; border-radius: var(--radius-lg); }
    .modal-body             { padding: 1rem; }
    .modal-header           { padding: .875rem 1rem; }
    .modal-footer           { padding: .875rem 1rem; flex-wrap: wrap; }
    .modal-footer .btn      { flex: 1; min-width: 0; }

    .numpad-btn             { height: 52px; font-size: 1.125rem; }
    .amount-value           { font-size: 1.5rem; }

    /* Previeni zoom su input iOS */
    .form-group input,
    .form-group select,
    .form-group textarea    { font-size: 16px; }

    .form-row               { grid-template-columns: 1fr; }
    .logo-upload-row        { grid-template-columns: 1fr; }

    #dash-grid              { grid-template-columns: 1fr !important; }

    .filter-bar             { flex-direction: column; }
    .filter-group           { flex-direction: row; align-items: center; gap: .5rem; width: 100%; }
    .filter-group input,
    .filter-group select    { flex: 1; }

    .tabs                   { margin-bottom: 1rem; }
    .tab                    { padding: .375rem .75rem; font-size: .75rem; }

    .post-payment-options   { gap: .5rem; }
    .post-option            { padding: .75rem .5rem; }
    .post-option-icon       { font-size: 1.5rem; }
    .post-option-label      { font-size: .65rem; }

    .search-bar input       { height: 44px; }
}

/* Safe area per dispositivi con notch (iOS) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
}

/* PWA Standalone mode */
@media all and (display-mode: standalone) {
    html        { -webkit-user-select: none; user-select: none; }
    body        { padding-top: env(safe-area-inset-top); }
    .login-box  { padding-top: env(safe-area-inset-top); }
    .lock-content { padding-top: env(safe-area-inset-top); }
    .page-header  { padding-top: max(1rem, env(safe-area-inset-top)); }
}
