:root {
    --sidebar-w: 250px;
}

body {
    background: #f4f6f9;
}

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
}

@media (min-width: 992px) {
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        flex-shrink: 0;
    }
}

.sidebar-logo {
    width: 100%;
    max-width: 190px;
    height: auto;
}

.topbar-logo {
    height: 26px;
    width: auto;
    flex-shrink: 0;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, .8);
    border-radius: .375rem;
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.sidebar .nav-link.active {
    background: #0d6efd;
    color: #fff;
}

.main-content {
    min-width: 0;
}

.card-stat .display-6 {
    font-weight: 600;
}

.table td, .table th {
    vertical-align: middle;
}

.login-wrap {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b, #0f172a);
}

.timeline {
    border-left: 2px solid #dee2e6;
    padding-left: 1rem;
}

.timeline .item {
    position: relative;
    margin-bottom: 1rem;
}

.timeline .item::before {
    content: "";
    position: absolute;
    left: -1.4rem;
    top: .35rem;
    width: .7rem;
    height: .7rem;
    border-radius: 50%;
    background: #0d6efd;
}

/* ===================================================================
   Smartphone e tablet (sotto i 992px): barra in basso, tocchi più ampi
   =================================================================== */
.topbar .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topbar {
    flex-wrap: nowrap;
    gap: .75rem;
}

.topbar .navbar-brand {
    flex: 1;
    min-width: 0;
    margin-right: 0;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    background: #fff;
    border-top: 1px solid #dee2e6;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .05);
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0 4px;
    font-size: .7rem;
    color: #6c757d;
    text-decoration: none;
}

.bottom-nav a i {
    font-size: 1.35rem;
    line-height: 1.2;
}

.bottom-nav a.active {
    color: #0d6efd;
    font-weight: 600;
}

@media (max-width: 991.98px) {
    body.has-bottom-nav .main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }

    /* 16px evita lo zoom automatico dei campi su iPhone e rende i campi più comodi */
    .form-control, .form-select, .form-control-sm, .form-select-sm {
        font-size: 16px;
    }

    .form-control-sm, .form-select-sm {
        min-height: 40px;
    }

    .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: 36px;
    }

    h1.h3 {
        font-size: 1.3rem;
    }

    .card-stat .display-6 {
        font-size: 1.6rem;
    }
}

/* Elenchi a schede per smartphone (al posto delle tabelle) */
.lista-card .item {
    display: block;
    background: #fff;
    border-radius: .6rem;
    padding: .8rem .9rem;
    margin-bottom: .6rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    color: inherit;
    text-decoration: none;
    border-left: 4px solid transparent;
}


.lista-card .item .titolo {
    font-weight: 600;
    line-height: 1.25;
}

.lista-card .item .meta {
    font-size: .8rem;
    color: #6c757d;
}

/* Pulsanti azione grandi (chiama, naviga, intervento) */
.azioni-rapide {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .5rem;
}

.azioni-rapide .btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: .55rem .25rem;
    font-size: .75rem;
    line-height: 1.1;
}

.azioni-rapide .btn i {
    font-size: 1.35rem;
    margin-bottom: .2rem;
}

.sezione-titolo {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c757d;
    font-weight: 600;
    margin: 1rem 0 .5rem;
}

/* Codice fornitore accanto al codice articolo (sempre visibile: è il codice che conoscono i tecnici) */
.cod-forn {
    display: inline-block;
    padding: 0 .35em;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    background: #f8f9fa;
    color: #212529;
    font-size: .85em;
    font-weight: 600;
    white-space: nowrap;
}

/* Sotto scorta minima: riga gialla ben visibile, quantità arancione, etichetta "mancano N" */
.table > tbody > tr.sotto-scorta > * {
    --bs-table-bg: #ffe69c;
    --bs-table-bg-state: #ffe69c;
    --bs-table-hover-bg: #ffda6a;
}

.table > tbody > tr.sotto-scorta > td:first-child {
    box-shadow: inset 4px 0 0 #fd7e14;
}

.qta-sottoscorta {
    color: #c35a00;
    font-weight: 700;
}

.badge-sottoscorta {
    display: inline-block;
    padding: .1em .45em;
    border-radius: .25rem;
    background: #fd7e14;
    color: #fff;
    font-size: .75em;
    font-weight: 600;
    white-space: nowrap;
}

.lista-card .item.sotto-scorta {
    border-left-color: #fd7e14;
    background: #fff8e1;
}

/* Scorta minima modificabile nella tabella giacenze */
.input-scorta {
    width: 80px;
    margin-left: auto;
}

.input-scorta.modificata {
    border-color: #0d6efd;
    background: #e7f1ff;
}
