/* =========================================================
   GESTIONALE INVENTARIO – STYLESHEET (Material-inspired)
   Indice:
    1. Design tokens
    2. Reset & base
    3. Layout, header, navigazione
    4. Breadcrumb & page header
    5. Card
    6. Tabelle
    7. Form
    8. Bottoni
    9. Badge, stati e messaggi
   10. Autocomplete
   11. Modali
   12. Toast
   13. Login
   14. Inventario / magazzino
   15. Dettaglio variante & movimenti
   16. Acquisti (lista, form, dettaglio)
   17. Ordini
   18. Categorie
   19. Utility
   20. Responsive
   ========================================================= */

/* =========================================================
   1. DESIGN TOKENS
   ========================================================= */
:root {
    /* Brand */
    --brand-primary: #00065c;
    --brand-secondary: #001080;
    --brand-accent: #0284c7;
    --brand-accent-hover: #0369a1;
    --brand-accent-soft: #e0f2fe;

    /* Semantici */
    --color-success: #15803d;
    --color-success-soft: #dcfce7;
    --color-warning: #a16207;
    --color-warning-soft: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-dark: #b91c1c;
    --color-danger-soft: #fee2e2;
    --color-info: #0284c7;
    --color-info-soft: #e0f2fe;

    /* Superfici */
    --bg-app: #f4f6fa;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f8fafc;
    --bg-hover: #f1f5f9;
    --bg-header: var(--brand-primary);
    --bg-overlay: rgb(15 23 42 / .55);

    /* Tabelle */
    --table-head-bg: #e9eef8;
    --table-head-text: var(--brand-primary);
    --table-stripe: #f7f9fc;
    --table-hover: #e8f3fc;
    --table-border: #dfe5ee;

    /* Bordi */
    --border-color: #d5dbe5;
    --border-color-light: #e8ecf2;

    /* Testo */
    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #5b6678;
    --text-light: #94a3b8;
    --text-inverse: #ffffff;

    /* Forma */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    /* Dimensioni */
    --header-height: 64px;
    --breadcrumb-height: 44px;
    --control-height: 40px;
    --icon-btn-size: 32px;

    /* Elevazioni */
    --elevation-1: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .08);
    --elevation-2: 0 2px 4px rgb(15 23 42 / .06), 0 4px 12px rgb(15 23 42 / .10);
    --elevation-3: 0 8px 24px rgb(15 23 42 / .14);
    --elevation-4: 0 20px 60px rgb(15 23 42 / .22);

    /* Transizioni */
    --transition: .18s ease;

    /* Alias di compatibilità (usati in vecchie regole/HTML) */
    --colore-primario: var(--brand-primary);
    --colore-accento: var(--brand-accent);
    --input-bg: var(--bg-surface);
}

/* =========================================================
   2. RESET & BASE
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-app);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand-accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--brand-accent-hover);
    text-decoration: underline;
}

[hidden] {
    display: none !important;
}

svg.mdi {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    vertical-align: middle;
    fill: currentColor;
    color: inherit;
}

.icon-small {
    width: 1rem;
    height: 1rem;
}

.icon-medium {
    width: 1.35rem;
    height: 1.35rem;
}

:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* =========================================================
   3. LAYOUT, HEADER, NAVIGAZIONE
   ========================================================= */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

main.main-wrap {
    padding: 1rem 4rem;
}

.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 2rem;
    color: var(--text-inverse);
    background-color: var(--bg-header);
    box-shadow: var(--elevation-2);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .5px;
    color: var(--text-inverse);
    white-space: nowrap;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin: 0 auto 0 2rem;
}

.nav-item,
.dropbtn {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .85rem;
    font: inherit;
    font-size: .9rem;
    font-weight: 500;
    color: var(--text-inverse);
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition);
}

.nav-item:hover,
.dropbtn:hover,
.nav-item.active,
.dropbtn.active {
    color: var(--text-inverse);
    background-color: rgb(255 255 255 / .14);
    text-decoration: none;
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1001;
    min-width: 210px;
    padding: .4rem 0;
    background-color: var(--bg-surface);
    border-radius: var(--radius);
    box-shadow: var(--elevation-3);
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content {
    display: block;
}

.dropdown-content a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem 1rem;
    font-size: .9rem;
    color: var(--text-main);
    text-decoration: none;
}

.dropdown-content a:hover {
    color: var(--brand-accent);
    background-color: var(--bg-hover);
}

/* Menu utente */
.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 1rem;
    border-left: 1px solid rgb(255 255 255 / .2);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: .85rem;
    line-height: 1.2;
}

.user-badge {
    margin-top: 2px;
    padding: .1rem .45rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #fff;
    border-radius: var(--radius-pill);
}

.user-badge.admin {
    background-color: var(--color-danger);
}

.user-badge.user {
    background-color: var(--brand-accent);
}

.btn-logout {
    display: flex;
    align-items: center;
    padding: .45rem .6rem;
    color: var(--text-inverse);
    background: rgb(220 38 38 / .25);
    border-radius: var(--radius);
    transition: background var(--transition);
}

.btn-logout:hover {
    background: rgb(220 38 38 / .5);
}

.mobile-menu-toggle {
    display: none;
    font-size: 1.5rem;
    color: var(--text-inverse);
    background: transparent;
    border: none;
    cursor: pointer;
}

/* =========================================================
   4. BREADCRUMB & PAGE HEADER
   ========================================================= */
.breadcrumb-bar {
    display: flex;
    align-items: center;
    height: var(--breadcrumb-height);
    padding: 0 2rem;
    font-size: .85rem;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color-light);
}

.breadcrumb-container,
.purchase-detail-page .page-breadcrumb {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.purchase-detail-page .page-breadcrumb {
    margin-bottom: .5rem;
    font-size: .8rem;
    color: var(--text-muted);
}

.breadcrumb-container a,
.purchase-detail-page .page-breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb-container a:hover,
.purchase-detail-page .page-breadcrumb a:hover {
    color: var(--brand-accent);
}

.breadcrumb-separator {
    color: var(--text-light);
}

.breadcrumb-current {
    font-weight: 600;
    color: var(--text-main);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border-color);
}

/* =========================================================
   5. CARD
   ========================================================= */
.card,
.content-card,
.purchase-section,
.order-header {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-1);
}

.card,
.content-card {
    margin-bottom: 1.5rem;
}

.card {
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    font-weight: 600;
    background-color: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border-color-light);
}

.card-body {
    padding: 1.25rem;
}

.content-card {
    padding: 1.5rem;
}

.content-card .card-header {
    margin-bottom: 1.25rem;
    padding: 0 0 1rem;
    background: none;
}

.content-card .card-header h2 {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.1rem;
}

/* Card riepilogo (KPI) */
.summary-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-1);
    transition: box-shadow var(--transition);
}

.summary-card:hover {
    box-shadow: var(--elevation-2);
}

.summary-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    font-size: 24px;
    color: var(--brand-primary);
    background: var(--brand-accent-soft);
    border-radius: var(--radius);
}

.summary-card div:last-child {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.summary-card span,
.variant-info-item span {
    font-size: .85rem;
    color: var(--text-muted);
}

.summary-card strong {
    font-size: 1.35rem;
    color: var(--text-main);
}

/* =========================================================
   6. TABELLE
   ========================================================= */

/* Contenitore: la tabella "galleggia" come un pannello */
.table-responsive,
.purchases-table-wrapper {
    width: 100%;
    overflow-x: auto;
    background: var(--bg-surface);
    border: 1px solid var(--table-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-1);
}

.table,
.movement-table,
.data-table,
.purchases-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.purchases-table {
    min-width: 850px;
}

/* Celle */
.table th,
.table td,
.movement-table th,
.movement-table td,
.data-table th,
.data-table td,
.purchases-table th,
.purchases-table td {
    padding: .9rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--table-border);
}

/* Intestazione: fondo tinta brand, testo scuro, filetto marcato */
.table th,
.movement-table th,
.data-table th,
.purchases-table th {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--table-head-text);
    background-color: var(--table-head-bg);
    border-bottom: 2px solid #c9d3e6;
    white-space: nowrap;
}

/* Contenuto: testo pieno, più leggibile */
.table td,
.movement-table td,
.data-table td,
.purchases-table td {
    font-size: .93rem;
    color: var(--text-main);
}

/* Prima colonna = identificativo della riga */
.table td:first-child,
.data-table td:first-child,
.purchases-table td:first-child {
    font-weight: 600;
}

/* Righe alternate */
.table tbody tr:nth-child(even),
.movement-table tbody tr:nth-child(even),
.data-table tbody tr:nth-child(even),
.purchases-table tbody tr:nth-child(even) {
    background-color: var(--table-stripe);
}

/* Hover: sfondo azzurro + barra laterale d'accento */
.table tbody tr,
.movement-table tbody tr,
.data-table tbody tr,
.purchases-table tbody tr {
    transition: background-color var(--transition);
}

.table tbody tr:hover,
.movement-table tbody tr:hover,
.data-table tbody tr:hover,
.purchases-table tbody tr:hover {
    background-color: var(--table-hover);
}

.table tbody tr:hover>td:first-child,
.movement-table tbody tr:hover>td:first-child,
.data-table tbody tr:hover>td:first-child,
.purchases-table tbody tr:hover>td:first-child {
    box-shadow: inset 3px 0 0 var(--brand-accent);
}

.table tbody tr:last-child td,
.movement-table tbody tr:last-child td,
.data-table tbody tr:last-child td,
.purchases-table tbody tr:last-child td {
    border-bottom: 0;
}

/* Numeri: allineati a destra, cifre a larghezza fissa */
.table th.text-right,
.data-table th.text-right,
.purchases-table th.text-right,
.table td.text-right,
.data-table td.text-right,
.purchases-table td.text-right {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.table td.text-right,
.data-table td.text-right,
.purchases-table td.text-right {
    font-weight: 500;
}

/* Piè di tabella / totali */
.table tfoot td,
.data-table tfoot td,
.purchases-table tfoot td {
    font-weight: 700;
    background: var(--table-head-bg);
    border-top: 2px solid #c9d3e6;
    border-bottom: 0;
}

.movement-table td {
    white-space: nowrap;
}

.movement-table td:nth-child(3) {
    min-width: 220px;
    white-space: normal;
}

.actions-cell {
    white-space: nowrap;
}

/* =========================================================
   7. FORM
   ========================================================= */
.form-group {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.form-group label,
.purchase-form-grid label,
.purchase-modal-form label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control,
.purchase-form-grid input,
.purchase-form-grid select,
.purchase-filters input,
.purchase-filters select,
.purchase-modal-form input,
.purchase-modal-form select,
.purchase-modal-form textarea {
    width: 100%;
    min-height: var(--control-height);
    padding: .5rem .75rem;
    font: inherit;
    color: var(--text-main);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control {
    height: var(--control-height);
    padding-block: 0;
}

.purchase-modal-form textarea,
textarea.form-control {
    height: auto;
    padding-block: .6rem;
    resize: vertical;
}

.form-control:hover,
.purchase-form-grid input:hover,
.purchase-form-grid select:hover,
.purchase-modal-form input:hover,
.purchase-modal-form select:hover,
.purchase-modal-form textarea:hover {
    border-color: var(--text-light);
}

.form-control:focus,
.purchase-form-grid input:focus,
.purchase-form-grid select:focus,
.purchase-filters input:focus,
.purchase-filters select:focus,
.purchase-modal-form input:focus,
.purchase-modal-form select:focus,
.purchase-modal-form textarea:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgb(2 132 199 / .18);
}

.form-actions {
    display: flex;
    gap: .6rem;
    margin-top: 1.4rem;
}

.input-compact {
    width: 100px;
    min-width: 80px;
    text-align: right;
}

/* =========================================================
   8. BOTTONI
   ========================================================= */
.btn-submit,
.inventory-filter-submit,
.btn-secondary,
.btn-danger,
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    height: var(--control-height);
    padding: 0 1.4rem;
    font: inherit;
    font-weight: 600;
    color: var(--text-inverse);
    background-color: var(--brand-primary);
    border: 1px solid transparent;
    border-radius: var(--radius);
    box-shadow: var(--elevation-1);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition), box-shadow var(--transition);
}

.btn-submit {
    width: 100%;
    margin-top: .5rem;
}

.form-actions .btn-submit,
.purchase-modal-footer .btn-submit,
.page-header .btn-submit {
    width: auto;
    margin-top: 0;
}

.btn-submit:hover,
.inventory-filter-submit:hover {
    color: var(--text-inverse);
    background-color: var(--brand-secondary);
    box-shadow: var(--elevation-2);
    text-decoration: none;
}

.btn-submit:disabled {
    opacity: .6;
    cursor: not-allowed;
    box-shadow: none;
}

/* Varianti opzionali */
.btn-secondary {
    color: var(--text-secondary);
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    box-shadow: none;
}

.btn-secondary:hover {
    color: var(--text-main);
    background-color: var(--bg-hover);
    text-decoration: none;
}

.btn-danger {
    background-color: var(--color-danger);
}

.btn-danger:hover {
    color: var(--text-inverse);
    background-color: var(--color-danger-dark);
    text-decoration: none;
}

.inventory-filter-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    height: var(--control-height);
    padding: 0 1rem;
    font-weight: 500;
    color: var(--text-muted);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    text-decoration: none;
    transition: background-color var(--transition), color var(--transition);
}

.inventory-filter-reset:hover {
    color: var(--text-main);
    background-color: var(--bg-hover);
    text-decoration: none;
}

/* Azioni di riga */
.table-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--brand-accent);
    background-color: transparent;
    border-radius: 50%;
    transition: background-color var(--transition), color var(--transition);
}

.table-action-btn:hover {
    color: var(--brand-accent-hover);
    background-color: var(--brand-accent-soft);
    text-decoration: none;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--icon-btn-size);
    height: var(--icon-btn-size);
    padding: 0;
    font-size: 17px;
    line-height: 1;
    color: var(--text-muted);
    background: var(--bg-surface);
    border: 1px solid var(--border-color-light);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.btn-icon:hover {
    color: var(--text-main);
    background: var(--bg-hover);
    border-color: var(--border-color);
    text-decoration: none;
}

.btn-icon.edit-icon:hover {
    color: var(--brand-accent-hover);
    background: var(--color-info-soft);
    border-color: #bae6fd;
}

.btn-icon.delete-icon:hover {
    color: var(--color-danger);
    background: var(--color-danger-soft);
    border-color: #fecaca;
}

.purchase-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .4rem;
    white-space: nowrap;
}

/* =========================================================
   9. BADGE, STATI E MESSAGGI
   ========================================================= */
.status-label {
    display: inline-block;
    padding: .2rem .6rem;
    font-size: .8rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
}

.status-label.is-active {
    color: var(--color-success);
    background: var(--color-success-soft);
}

.status-label.is-inactive {
    color: var(--text-muted);
    background: var(--bg-hover);
}

.auth-message {
    display: none;
    margin-top: 1rem;
    padding: .75rem;
    font-size: .9rem;
    text-align: center;
    border-radius: var(--radius);
}

.auth-message.info {
    display: block;
    color: var(--brand-accent-hover);
    background: var(--color-info-soft);
}

.auth-message.success {
    display: block;
    color: #166534;
    background: var(--color-success-soft);
}

.auth-message.error {
    display: block;
    color: #991b1b;
    background: var(--color-danger-soft);
}

.empty-inventory-cell,
.empty-state,
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    color: var(--text-muted);
    text-align: center;
}

.empty-inventory-cell {
    padding: 3rem 1rem;
}

.empty-state {
    padding: 2.5rem 1.25rem;
}

.loading-state {
    flex-direction: row;
    padding: 3rem 1.25rem;
}

.empty-inventory-cell p,
.empty-state p {
    font-size: .95rem;
}

#purchases-empty,
#orders-empty {
    padding: 2.5rem 1.25rem;
    color: var(--text-muted);
    text-align: center;
}

#orders-empty p {
    margin-top: .6rem;
}

/* =========================================================
   10. AUTOCOMPLETE
   ========================================================= */
.autocomplete-group {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 280px;
    margin-top: 4px;
    overflow-y: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--elevation-3);
}

.autocomplete-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    width: 100%;
    padding: .7rem .85rem;
    color: inherit;
    text-align: left;
    background: var(--bg-surface);
    border: 0;
    border-bottom: 1px solid var(--border-color-light);
    cursor: pointer;
    transition: background-color var(--transition);
}

.autocomplete-option:last-child {
    border-bottom: 0;
}

.autocomplete-option:hover {
    background: var(--bg-hover);
}

.autocomplete-option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.autocomplete-option-info strong {
    font-size: .9rem;
    font-weight: 600;
}

.autocomplete-option-info small {
    font-size: .78rem;
    color: var(--text-muted);
}

.autocomplete-option-stock {
    flex-shrink: 0;
    font-size: .85rem;
    font-weight: 600;
    color: var(--brand-primary);
}

.autocomplete-status {
    padding: .85rem;
    font-size: .85rem;
    color: var(--text-muted);
}

/* =========================================================
   11. MODALI
   ========================================================= */
.purchase-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    overflow-y: auto;
    background: var(--bg-overlay);
}

.purchase-modal {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-4);
}

.purchase-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color-light);
}

.purchase-modal-header h2 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.purchase-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--icon-btn-size);
    height: var(--icon-btn-size);
    font-size: 25px;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition);
}

.purchase-modal-close:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

.purchase-modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
}

.purchase-modal-form label {
    color: var(--text-secondary);
}

.purchase-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    margin-top: .3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color-light);
}

/* =========================================================
   12. TOAST
   ========================================================= */
.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    width: calc(100% - 40px);
    max-width: 380px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    font-size: .95rem;
    line-height: 1.4;
    color: var(--text-main);
    background: var(--bg-surface);
    border-left: 4px solid var(--color-info);
    border-radius: var(--radius);
    box-shadow: var(--elevation-3);
    pointer-events: auto;
    animation: toastSlideIn .3s cubic-bezier(.16, 1, .3, 1) forwards;
}

.toast-success {
    border-left-color: #2e7d32;
}

.toast-error {
    border-left-color: #d32f2f;
}

.toast-warning {
    border-left-color: #ed6c02;
}

.toast-info {
    border-left-color: #0288d1;
}

.toast-success .toast-icon svg {
    fill: #2e7d32;
}

.toast-error .toast-icon svg {
    fill: #d32f2f;
}

.toast-warning .toast-icon svg {
    fill: #ed6c02;
}

.toast-info .toast-icon svg {
    fill: #0288d1;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.toast-icon svg {
    width: 22px;
    height: 22px;
}

.toast-message {
    flex-grow: 1;
    word-break: break-word;
}

.toast-close {
    margin-left: .5rem;
    padding: 0 4px;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-light);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--transition);
}

.toast-close:hover {
    color: var(--text-main);
}

.toast-fade-out {
    animation: toastFadeOut .3s ease-in forwards;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* =========================================================
   13. LOGIN
   ========================================================= */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height) - 4rem);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem 2rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-3);
}

.login-header {
    margin-bottom: 2rem;
    text-align: center;
}

.login-header h1 {
    margin-top: .5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-primary);
}

/* =========================================================
   14. INVENTARIO / MAGAZZINO
   ========================================================= */
.inventory-section-heading,
.warehouse-summary-heading {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1rem;
}

.inventory-section-heading h2,
.warehouse-summary-heading h2 {
    font-size: 1rem;
    font-weight: 600;
}

/* Filtri */
.inventory-filters,
.warehouse-summary-card {
    margin-bottom: 1.25rem;
}

.inventory-filters {
    padding: 1rem 1.25rem;
}

.inventory-filters-form,
.inventory-filters-form-auto {
    display: grid;
    gap: 1rem;
    align-items: end;
}

.inventory-filters-form {
    grid-template-columns: repeat(5, 1fr);
}

.inventory-filters-form-auto {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.inventory-filter-group {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    min-width: 0;
}

.inventory-filter-group label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.inventory-filter-footer {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.inventory-filter-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Checkbox personalizzata */
.inventory-filter-checkbox,
.inventory-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    min-height: var(--control-height);
    font-size: .9rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.inventory-filter-checkbox {
    padding: 0 .85rem;
    background-color: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color var(--transition);
}

.inventory-filter-checkbox:hover {
    border-color: var(--brand-accent);
}

.inventory-filter-checkbox input {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: transparent;
    border: 2px solid var(--text-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition);
}

.inventory-filter-checkbox input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.inventory-filter-checkbox input:checked::after {
    content: "";
    position: absolute;
    top: 0;
    left: 4px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Riepilogo magazzino */
.warehouse-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    color: var(--text-inverse);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-2);
}

.warehouse-summary-content {
    display: flex;
    align-items: center;
    gap: 1.75rem;
}

.warehouse-summary-item {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.warehouse-summary-title {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .85;
}

.warehouse-summary-value {
    font-size: 1.3rem;
    font-weight: 700;
}

.warehouse-summary-divider {
    width: 1px;
    height: 42px;
    background: rgb(255 255 255 / .3);
}

.warehouse-summary-badge {
    margin-bottom: 1rem;
    font-size: .95rem;
    font-weight: 500;
}

/* Celle tabella */
.inventory-product-name {
    font-weight: 600;
    color: var(--text-main);
}

.inventory-variant-name {
    font-size: .85rem;
    color: var(--text-muted);
}

.inventory-category-name {
    font-size: .9rem;
}

.inventory-family-name {
    font-size: .8rem;
    color: var(--text-muted);
}

.inventory-empty-value {
    color: var(--text-light);
}

.inventory-total-value {
    font-weight: 600;
}

.inventory-actions-cell {
    text-align: center;
}

.article-code-badge {
    padding: .15rem .5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    color: var(--text-muted);
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.text-normal-stock {
    font-weight: 600;
    color: var(--text-main);
}

.text-danger-stock {
    display: inline-block;
    padding: .15rem .55rem;
    font-weight: 700;
    color: var(--color-danger);
    background-color: var(--color-danger-soft);
    border-radius: var(--radius-pill);
}

/* =========================================================
   15. DETTAGLIO VARIANTE & MOVIMENTI
   ========================================================= */
.inventory-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.variant-info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
}

.variant-info-item {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.variant-info-item strong {
    font-weight: 600;
    color: var(--text-main);
}

.movement-count {
    font-size: .85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.movement-badge {
    display: inline-flex;
    align-items: center;
    padding: .25rem .6rem;
    font-size: .76rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
}

.movement-badge.purchase {
    color: var(--color-success);
    background: rgb(34 160 100 / .13);
}

.movement-badge.credit-note {
    color: var(--color-danger-dark);
    background: rgb(220 70 70 / .12);
}

.movement-badge.withdrawal {
    color: var(--color-warning);
    background: rgb(220 150 40 / .16);
}

.movement-badge.adjustment {
    color: #1d4ed8;
    background: rgb(80 130 220 / .12);
}

.movement-positive {
    font-weight: 600;
    color: var(--color-success) !important;
}

.movement-negative {
    font-weight: 600;
    color: var(--color-danger-dark) !important;
}

/* Info riga stock (usata in ordini/acquisti) */
.variant-stock-info {
    display: flex;
    justify-content: space-between;
    margin: -5px 0 15px;
    padding: .65rem .8rem;
    font-size: .9rem;
    background: var(--bg-hover);
    border-radius: var(--radius);
}

.variant-stock-info strong {
    font-weight: 700;
}

/* =========================================================
   16. ACQUISTI
   ========================================================= */
.purchase-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.purchase-summary-grid .summary-card {
    min-height: 100px;
}

.purchase-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.1rem;
}

.purchase-notes-field {
    grid-column: span 2;
}

.purchase-list-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.purchase-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}

.purchase-filters select {
    width: auto;
}

.purchase-filters input {
    width: 190px;
}

#purchases-body td:first-child {
    font-weight: 600;
    white-space: nowrap;
}

#purchases-body td:nth-child(6) {
    font-weight: 700;
    color: var(--text-main);
}

#purchases-body .text-center {
    padding: 2rem;
    color: var(--text-light);
    text-align: center;
}

/* Dettaglio acquisto */
.purchase-detail-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.purchase-section {
    padding: 1.4rem;
    border: 1px solid var(--border-color-light);
}

.purchase-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.purchase-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.purchase-section .section-header p {
    margin-top: 4px;
    font-size: .85rem;
    color: var(--text-muted);
}

.purchase-info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    min-width: 0;
}

.info-label {
    font-size: .75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.info-item strong {
    font-size: .95rem;
    color: var(--text-main);
    overflow-wrap: anywhere;
}

.purchase-detail-page .data-table {
    min-width: 750px;
}

/* Riepilogo economico */
.purchase-totals-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.purchase-totals-section h2 {
    align-self: flex-start;
    margin-bottom: 1.25rem;
}

.purchase-totals {
    width: 100%;
    max-width: 420px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    gap: 1.25rem;
    padding: .75rem 0;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color-light);
}

.total-row strong {
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.total-row.credit-total strong {
    color: var(--color-danger);
}

.total-row.total-net {
    margin-top: .3rem;
    padding-top: 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    border-top: 2px solid var(--border-color);
    border-bottom: none;
}

.total-row.total-net strong {
    font-size: 1.2rem;
}

/* =========================================================
   17. ORDINI
   ========================================================= */
.order-filters {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-left: auto;
}

.order-filters select {
    width: auto;
    min-width: 100px;
}

.order-filters .input-with-icon {
    min-width: 220px;
}

#order-cancel {
    margin-top: .6rem;
}

#orders-body .row-highlight {
    background: var(--brand-accent-soft);
}

.order-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
}

.order-info h3 {
    margin-bottom: .5rem;
    color: var(--brand-primary);
}

.order-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: .9rem;
    color: var(--text-muted);
}

.order-meta span {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.order-total {
    text-align: right;
}

.order-total-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.order-total-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-accent);
}

/* =========================================================
   18. CATEGORIE
   ========================================================= */
.category-list-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
}

.category-search {
    min-width: 220px;
    margin-left: auto;
}

/* =========================================================
   19. UTILITY
   ========================================================= */
.text-right {
    text-align: right !important;
}

.text-center {
    text-align: center;
}

.nothing {
    margin: 0;
    padding: 0;
}

/* =========================================================
   20. RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
    main.main-wrap {
        padding: 2rem;
    }

    .inventory-filters-form {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1000px) {
    .purchase-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .purchase-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .mobile-menu-toggle {
        display: block;
    }

    .main-header {
        padding: 0 1rem;
    }

    .breadcrumb-bar {
        padding: 0 1rem;
    }

    .main-content,
    main.main-wrap {
        padding: 1.25rem 1rem;
    }

    /* Menu verticale a scomparsa */
    .header-nav {
        position: absolute;
        top: var(--header-height);
        left: 0;
        z-index: 2000;
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        margin: 0;
        padding: 1rem;
        background-color: var(--bg-header);
        box-shadow: var(--elevation-3);
    }

    .header-nav.open {
        display: flex;
    }

    .dropdown {
        display: block;
        width: 100%;
    }

    .dropbtn {
        width: 100%;
        justify-content: space-between;
    }

    .dropdown-content {
        position: static;
        display: block;
        min-width: 0;
        padding: 0 0 0 1rem;
        background: rgb(0 0 0 / .2);
        box-shadow: none;
    }

    .dropdown-content a {
        color: var(--text-inverse);
    }

    .dropdown-content a:hover {
        color: var(--text-inverse);
        background: rgb(255 255 255 / .1);
    }

    .user-menu {
        gap: .5rem;
        padding-left: .5rem;
    }

    .user-info {
        display: none;
    }

    .inventory-summary-grid {
        grid-template-columns: 1fr;
    }

    .variant-info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .purchase-info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {

    .purchases-table th,
    .purchases-table td,
    #purchases-body td {
        padding: .7rem .6rem;
        font-size: .85rem;
    }

    .order-filters {
        width: 100%;
        margin-left: 0;
    }

    .order-filters select {
        flex-shrink: 0;
    }

    .order-filters .input-with-icon {
        flex: 1;
        min-width: 0;
    }

    .order-header {
        align-items: flex-start;
    }

    .order-total {
        text-align: left;
    }

    .order-meta {
        flex-direction: column;
        gap: .4rem;
    }
}

@media (max-width: 700px) {
    .inventory-filters-form {
        grid-template-columns: 1fr;
    }

    .inventory-filter-footer {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .inventory-filter-actions {
        width: 100%;
    }

    .inventory-filter-actions>* {
        flex: 1;
    }

    .warehouse-summary-content {
        justify-content: space-between;
        gap: 1rem;
    }

    .movement-table th,
    .movement-table td {
        padding: .7rem .75rem;
    }
}

@media (max-width: 650px) {

    .purchase-summary-grid,
    .purchase-form-grid {
        grid-template-columns: 1fr;
    }

    .purchase-notes-field {
        grid-column: auto;
    }

    .purchase-filters {
        width: 100%;
    }

    .purchase-filters select,
    .purchase-filters input {
        flex: 1;
        min-width: 0;
        width: auto;
    }
}

@media (max-width: 600px) {
    .variant-info-grid {
        grid-template-columns: 1fr;
    }

    .purchase-section {
        padding: 1rem;
    }

    .purchase-section .section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .purchase-info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1.1rem .75rem;
    }

    .purchase-totals {
        max-width: none;
    }

    /* Modale come bottom sheet */
    .purchase-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .purchase-modal {
        max-height: 90vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .purchase-modal-form {
        padding: 1.1rem;
    }
}

/* =========================================================
   ACCORDION FILTERS & FORM GRID
   ========================================================= */

/* Intestazione Accordion */
details.inventory-filters summary.inventory-section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    border-radius: var(--radius);
    transition: background-color var(--transition);
}

details.inventory-filters summary::-webkit-details-marker {
    display: none;
}

details.inventory-filters summary:hover {
    background-color: var(--bg-hover);
}

details.inventory-filters summary h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    flex-grow: 1;
}

details.inventory-filters .heading-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-primary);
}

details.inventory-filters .accordion-arrow {
    font-size: 1.4rem;
    color: var(--text-muted);
    transition: transform var(--transition);
}

details.inventory-filters[open] .accordion-arrow {
    transform: rotate(180deg);
}

/* Form Layout Grid */
.inventory-form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
    padding: 1rem 1.25rem 1.25rem 1.25rem;
    border-top: 1px solid var(--border-color-light);
    background-color: var(--bg-surface);
}

/* Span colonne griglia */
.inventory-form-grid .col-3 {
    grid-column: span 3;
}

.inventory-form-grid .col-4 {
    grid-column: span 4;
}

.inventory-form-grid .col-6 {
    grid-column: span 6;
}

.inventory-form-grid .col-12 {
    grid-column: span 12;
}

.inventory-form-grid .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0;
}

.inventory-form-grid label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.inventory-form-grid textarea.form-control {
    resize: vertical;
    min-height: 70px;
}

/* Riga Bottoni */
.inventory-form-grid .form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color-light);
}

/* Breakpoint Responsive (sotto Sezione 20 del tuo CSS) */
@media (max-width: 992px) {

    .inventory-form-grid .col-3,
    .inventory-form-grid .col-4 {
        grid-column: span 6;
    }
}

@media (max-width: 576px) {

    .inventory-form-grid .col-3,
    .inventory-form-grid .col-4,
    .inventory-form-grid .col-6 {
        grid-column: span 12;
    }
}

/* =========================================================
   11. MODALI (MATERIAL-INSPIRED)
   ========================================================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-overlay);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    padding: 1rem;
}

.modal.is-visible {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    width: 100%;
    max-width: 540px;
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-3);
    overflow: hidden;
    transform: translateY(-20px);
    transition: transform var(--transition);
}

.modal.is-visible .modal-dialog {
    transform: translateY(0);
}

.modal-dialog.modal-lg {
    max-width: 780px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color-light);
    background-color: var(--bg-surface-alt);
}

.modal-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--color-danger);
}

.modal-body {
    padding: 1rem;
    max-height: calc(85vh - 130px);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color-light);
    background-color: var(--bg-surface-alt);
}

/* Griglia interna della Modale */
.inventory-form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
}

.inventory-form-grid .col-4 {
    grid-column: span 4;
}

.inventory-form-grid .col-6 {
    grid-column: span 6;
}

.inventory-form-grid .col-12 {
    grid-column: span 12;
}

.inventory-form-grid .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.inventory-form-grid label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Responsive Modale */
@media (max-width: 768px) {
    .modal-dialog.modal-lg {
        max-width: 100%;
    }

    .inventory-form-grid .col-4,
    .inventory-form-grid .col-6 {
        grid-column: span 12;
    }
}

/* =========================================================
   15. DETTAGLIO VARIANTE & MOVIMENTI
   ========================================================= */

.breadcrumb-nav {
    margin-bottom: 1rem;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--brand-accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}

.btn-link:hover {
    color: var(--brand-accent-hover);
    text-decoration: underline;
}

/* Griglia Metriche / KPIs */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.metric-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
}

.metric-value.highlight {
    color: var(--brand-primary);
}

/* Info Grid Variante */
.variant-info-card {
    margin-bottom: 1.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    padding: 1.25rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.info-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
}

/* Badge Movimenti Magazzino */
.movement-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    background-color: var(--bg-surface-alt);
    color: var(--text-secondary);
}

.movement-badge.purchase {
    background-color: var(--color-success-soft);
    color: var(--color-success);
}

.movement-badge.credit-note {
    background-color: var(--color-warning-soft);
    color: var(--color-warning);
}

.movement-badge.withdrawal {
    background-color: var(--color-danger-soft);
    color: var(--color-danger);
}

.movement-badge.adjustment {
    background-color: var(--color-info-soft);
    color: var(--color-info);
}

/* Stili Celle Valori */
.movement-positive {
    color: var(--color-success);
    font-weight: 600;
}

.movement-negative {
    color: var(--color-danger);
    font-weight: 600;
}

.badge-neutral {
    background-color: var(--bg-surface-alt);
    color: var(--text-muted);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 500;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Responsive */
@media (max-width: 992px) {
    .metrics-grid {
        grid-template-columns: repeat(1, 1fr);
    }

    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .info-grid {
        grid-template-columns: repeat(1, 1fr);
    }
}

/* Layout & Spaziature */
.align-start {
    align-items: flex-start;
}

.summary-metrics-group {
    display: flex;
    gap: 1.5rem;
    text-align: right;
}

.card-body-secondary {
    background-color: var(--bg-surface-secondary, #fafafa);
    border-bottom: 1px solid var(--border-color-light, #eee);
}

.inline-form-wrap {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-box-secondary {
    margin-bottom: 1rem;
    background-color: var(--bg-surface-secondary, #fafafa);
    padding: 12px;
    border-radius: 6px;
}

.section-spacer {
    margin-top: 1.5rem;
}

.form-row-spacing {
    margin-bottom: 10px;
}

/* Tipografia form */
.form-label-bold {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
}

.form-label-sm {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 2px;
    display: block;
}

/* Larghezze di colonna e griglie */
.col-grow-2 {
    flex: 2;
}

.col-min-240 {
    min-width: 240px;
}

.col-width-50 {
    width: 50px;
}

.col-width-90 {
    width: 90px;
}

.col-width-120 {
    width: 120px;
}

.col-width-130 {
    width: 130px;
}

.col-width-140 {
    width: 140px;
}

.col-width-150 {
    width: 150px;
}

.grid-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
}

/* Input di tabella */
.input-qty-table {
    width: 100px;
    display: inline-block;
}

.input-price-table {
    width: 110px;
    display: inline-block;
}

/* ==========================================================================
   Dettaglio Acquisti - Layout e utility
   ========================================================================== */

/* Allineamento header card */
.align-start {
    align-items: flex-start;
}

/* Spaziatura tra sezioni principali */
.section-spacer {
    margin-top: 1.5rem;
}

.form-row-spacing {
    margin-bottom: 0.75rem;
}

/* Layout colonna destra (sidebar card stack) */
.sidebar-cards-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Modificatori per form integrati ed extra */
.card-body-secondary {
    background-color: var(--bg-surface-secondary, #fafafa);
    border-bottom: 1px solid var(--border-color-light, #e0e0e0);
}

.inline-form-wrap {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-box-secondary {
    margin-bottom: 1rem;
    background-color: var(--bg-surface-secondary, #fafafa);
    padding: 0.85rem;
    border-radius: var(--border-radius, 6px);
    border: 1px solid var(--border-color-light, #e0e0e0);
}

/* Etichette form */
.form-label-bold {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
}

.form-label-sm {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    display: block;
}

/* Griglie e colonne */
.col-grow-2 {
    flex: 2;
}

.col-min-240 {
    min-width: 240px;
}

.col-width-50 {
    width: 50px;
}

.col-width-70 {
    width: 70px;
}

.col-width-90 {
    width: 90px;
}

.col-width-120 {
    width: 120px;
}

.col-width-130 {
    width: 130px;
}

.col-width-140 {
    width: 140px;
}

.col-width-150 {
    width: 150px;
}

.grid-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.65rem;
}

/* Input numerici compatti all'interno delle tabelle */
.input-qty-table {
    width: 90px;
    display: inline-block;
}

.input-price-table {
    width: 105px;
    display: inline-block;
}

/* Adattamento responsive per schermi piccoli */
@media (max-width: 992px) {

    .grid-1-1,
    .grid-2-1 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Dettaglio Acquisti - Layout a Due Colonne
   ========================================================================== */

/* Layout principale: 2/3 colonna sinistra, 1/3 sidebar destra */
.main-wrap .grid-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Colonna destra: stacked verticalmente per spese ed extra */
.sidebar-cards-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Form compatto in testata card merce */
.card-body-secondary {
    background-color: var(--bg-surface-secondary, #fafafa);
    border-bottom: 1px solid var(--border-color-light, #e0e0e0);
    padding: 1rem;
}

.inline-form-wrap {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-box-secondary {
    margin-bottom: 1rem;
    background-color: var(--bg-surface-secondary, #fafafa);
    padding: 0.85rem;
    border-radius: var(--border-radius, 6px);
    border: 1px solid var(--border-color-light, #e0e0e0);
}

/* Helper per etichette form */
.form-label-bold {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
}

.form-label-sm {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    display: block;
}

.form-row-spacing {
    margin-bottom: 0.75rem;
}

/* Larghezze colonne form & tabella */
.col-grow-2 {
    flex: 2;
}

.col-min-240 {
    min-width: 240px;
}

.col-width-50 {
    width: 50px;
}

.col-width-70 {
    width: 70px;
}

.col-width-90 {
    width: 90px;
}

.col-width-120 {
    width: 120px;
}

.col-width-130 {
    width: 130px;
}

.col-width-140 {
    width: 140px;
}

.grid-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.5rem;
}

/* Input compatti nelle tabelle */
.input-qty-table {
    width: 85px;
    display: inline-block;
}

.input-price-table {
    width: 100px;
    display: inline-block;
}

/* Responsive: passa a colonna singola solo su schermi piccoli/tablet */
@media (max-width: 992px) {
    .main-wrap .grid-layout {
        grid-template-columns: 1fr;
    }

    .grid-1-1,
    .grid-2-1 {
        grid-template-columns: 1fr;
    }
}

.p-4 {
    padding: 1rem !important;
}


/* ==========================================================
   BACCINFISSI - AUTENTICAZIONE E 2FA
   Login, configurazione, verifica e recupero
========================================================== */

.login-container {
    width: 100%;
    max-width: 520px;
    margin: 48px auto;
    padding: 0 16px;
}

.login-card {
    width: 100%;
    padding: 36px;
    background: var(--card-bg, #ffffff);
    color: var(--text-color, #263238);
    border: 1px solid var(--border-color, #e1e8eb);
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 45, 60, .08);
}

.login-header {
    margin-bottom: 28px;
}

.login-header h1,
.login-card h1 {
    margin: 0 0 12px;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.25;
}

.login-card p {
    margin: 0 0 18px;
    line-height: 1.6;
}

.login-card .subtitle {
    color: var(--text-muted, #647780);
    font-size: .94rem;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 22px;
}

.login-card .form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.login-card label,
.login-card .form-label-bold {
    display: block;
    font-size: .94rem;
    font-weight: 600;
}

.login-card .form-control {
    width: 100%;
    min-height: 48px;
    padding: 11px 14px;
    border: 1px solid var(--border-color, #cad8dd);
    border-radius: 10px;
    background: var(--input-bg, #fff);
    color: var(--text-color, #263238);
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}

.login-card .form-control:focus {
    outline: none;
    border-color: var(--primary, #007991);
    box-shadow: 0 0 0 3px rgba(0, 121, 145, .14);
}

.login-card .btn-primary {
    min-height: 48px;
    padding: 12px 18px;
    border: 0;
    border-radius: 10px;
    background: var(--primary, #007991);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: filter .2s, transform .2s;
}

.login-card .btn-primary:hover {
    filter: brightness(.92);
}

.login-card .btn-primary:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.login-card .btn-block {
    width: 100%;
}

/* Messaggi di errore e conferma */

.login-card .auth-message:not(:empty) {
    display: block;
    margin-top: 18px;
    padding: 13px 15px;
    border-radius: 10px;
    font-size: .92rem;
    overflow-wrap: anywhere;
}

.login-card .auth-message.error,
.login-card .alert-danger {
    color: #842029;
    background: #f8d7da;
    border: 1px solid #f5c2c7;
}

.login-card .auth-message.success {
    color: #0f5132;
    background: #d1e7dd;
    border: 1px solid #badbcc;
}

.login-card .auth-message.info {
    color: #055160;
    background: #cff4fc;
    border: 1px solid #b6effb;
}

/* Chiave Authenticator e codici di recupero */

.login-card code {
    display: inline-block;
    max-width: 100%;
    padding: 8px 11px;
    border-radius: 8px;
    background: var(--primary-light, #e0f7fa);
    color: var(--text-color, #164653);
    font-family: ui-monospace, Consolas, monospace;
    font-size: .92rem;
    overflow-wrap: anywhere;
    user-select: all;
}

.login-card details {
    margin: 16px 0;
    padding: 14px;
    border: 1px solid var(--border-color, #dce5e9);
    border-radius: 10px;
}

.login-card summary {
    cursor: pointer;
    font-weight: 600;
}

.login-card details code {
    margin-top: 12px;
}

.login-card a {
    color: var(--primary, #007991);
    text-underline-offset: 3px;
}

.login-card a:hover {
    text-decoration: underline;
}

/* Smartphone */

@media (max-width: 576px) {
    .login-container {
        margin: 24px auto;
        padding: 0 12px;
    }

    .login-card {
        padding: 24px 20px;
        border-radius: 14px;
    }

    .login-card h1 {
        font-size: 1.45rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-card .form-control,
    .login-card .btn-primary {
        transition: none;
    }
}
