/* GSA — tema condiviso */
:root {
    --gsa-primary: #1a56db;
    --gsa-primary-dark: #1240a8;
    --gsa-accent: #0ea5e9;
    --gsa-bg: #f1f5f9;
    --gsa-card-border: #e2e8f0;
    --gsa-text: #1e293b;
    --gsa-muted: #64748b;
    --gsa-radius: 12px;
    --gsa-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
    --gsa-shadow-hover: 0 4px 8px rgba(15, 23, 42, .10), 0 8px 24px rgba(15, 23, 42, .10);
}

body {
    background-color: var(--gsa-bg);
    color: var(--gsa-text);
    font-family: var(--bs-body-font-family, system-ui, -apple-system, "Segoe UI", sans-serif);
}

/* Navbar — sticky in cima, sfondo leggermente traslucido */
.gsa-navbar {
    background: linear-gradient(120deg,
        rgba(9, 42, 107, .96) 0%,
        rgba(13, 71, 161, .96) 55%,
        rgba(25, 118, 210, .96) 130%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(18, 64, 168, .35), 0 8px 24px rgba(15, 23, 42, .12);
    padding-top: .45rem;
    padding-bottom: .45rem;
    z-index: 1040;
}
.gsa-navbar .navbar-brand {
    letter-spacing: .5px;
    font-size: 1.25rem;
}
.gsa-navbar .nav-link {
    border-radius: 8px;
    margin: 0 2px;
    padding: .45rem .8rem;
    transition: background .15s ease;
}
.gsa-navbar .nav-link:hover {
    background: rgba(255, 255, 255, .12);
}
.gsa-navbar .nav-link.active {
    background: rgba(255, 255, 255, .2);
    font-weight: 600;
}
.gsa-navbar .btn-outline-light {
    border-color: rgba(255, 255, 255, .55);
}
.gsa-navbar .btn-outline-light:hover {
    color: var(--gsa-primary-dark);
}

/* Card */
.card.gsa-card, .gsa-card {
    border: 1px solid var(--gsa-card-border);
    border-radius: var(--gsa-radius);
    box-shadow: var(--gsa-shadow);
    transition: box-shadow .2s ease, transform .2s ease;
}
.gsa-card:hover {
    box-shadow: var(--gsa-shadow-hover);
}
.card-header-gsa {
    background: #fff;
    border-bottom: 1px solid var(--gsa-card-border);
    border-radius: var(--gsa-radius) var(--gsa-radius) 0 0 !important;
    padding: .9rem 1.1rem;
}

/* Dashboard tiles */
.dash-tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    border-radius: var(--gsa-radius);
    border: 1px solid var(--gsa-card-border);
    background: #fff;
    padding: 1.25rem;
    box-shadow: var(--gsa-shadow);
    transition: transform .18s ease, box-shadow .18s ease;
}
.dash-tile:hover {
    transform: translateY(-4px);
    box-shadow: var(--gsa-shadow-hover);
    text-decoration: none;
}
.dash-tile .tile-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: .75rem;
}
.dash-tile .tile-num {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
}
.tile-blue   { background: #e0ecff; color: #1a56db; }
.tile-green  { background: #dcf5e3; color: #15803d; }
.tile-amber  { background: #fef3c7; color: #b45309; }
.tile-purple { background: #ede9fe; color: #6d28d9; }
.tile-red    { background: #fee2e2; color: #b91c1c; }
.tile-cyan   { background: #cffafe; color: #0e7490; }

/* Separatori mese */
.month-separator td, .gsa-month-sep {
    background: #fff7e0 !important;
    color: #92400e !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-size: .82rem;
}

/* Badge km */
.km-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
    white-space: nowrap;
}
.km-badge.km-loading {
    background: #f1f5f9;
    color: var(--gsa-muted);
    border-color: #e2e8f0;
    font-weight: 400;
}
.km-badge.km-error {
    background: #f8fafc;
    color: #94a3b8;
    border-color: #e2e8f0;
    font-weight: 400;
}
.km-badge .fa-road { font-size: .75rem; }

/* Pill ruoli */
.role-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: .85rem;
}
.role-pill.ok   { background: #d4edda; border-color: #c3e6cb; color: #155724; }
.role-pill.warn { background: #fff3cd; border-color: #ffeeba; color: #856404; }
.role-pill.over { background: #dc3545; border-color: #dc3545; color: #fff; }
.role-pill.none { background: #e9ecef; border-color: #dee2e6; color: #495057; }

/* Tabelle */
.gsa-table thead th {
    background: #f8fafc;
    color: var(--gsa-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 600;
    border-bottom: 2px solid var(--gsa-card-border);
    white-space: nowrap;
}
.gsa-table tbody td { vertical-align: middle; }
.gsa-table tbody tr:hover { background: #f8fafc; }

/* Bottoni azione compatti */
.btn-action { padding: .25rem .5rem; font-size: .85rem; }

/* Toolbar pagina */
.gsa-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1rem;
}
.gsa-toolbar .page-title { margin: 0; font-size: 1.35rem; font-weight: 700; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1240a8 0%, #1a56db 50%, #0ea5e9 100%);
}
.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(2, 20, 60, .35);
    padding: 2.25rem;
    width: 100%;
    max-width: 400px;
}
.login-logo {
    width: 60px; height: 60px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--gsa-primary), var(--gsa-accent));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto 1rem;
}

/* Dual range slider km (min/max) */
.km-range-wrap {
    min-width: 220px;
    flex: 1 1 220px;
    max-width: 340px;
}
.dual-range {
    position: relative;
    height: 26px;
}
.dual-range .dr-track {
    position: absolute;
    top: 11px;
    left: 0; right: 0;
    height: 6px;
    border-radius: 3px;
    background: #cbd5e1;
}
.dual-range .dr-fill {
    position: absolute;
    top: 11px;
    height: 6px;
    border-radius: 3px;
    background: var(--gsa-primary);
}
.dual-range input[type="range"] {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 26px;
    margin: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}
.dual-range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--gsa-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    pointer-events: auto;
    cursor: pointer;
    margin-top: -1px;
}
.dual-range input[type="range"]::-moz-range-thumb {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--gsa-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    pointer-events: auto;
    cursor: pointer;
}
.dual-range input[type="range"]::-moz-range-track {
    background: transparent;
}

/* Spinner piccolo */
.spin-sm {
    display: inline-block;
    width: .75rem; height: .75rem;
    border: 2px solid #cbd5e1;
    border-top-color: var(--gsa-primary);
    border-radius: 50%;
    animation: gsa-spin .7s linear infinite;
    vertical-align: -1px;
}
@keyframes gsa-spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
    .gsa-toolbar .page-title { font-size: 1.15rem; }
}
