/* =========================================================
   VITRANSLOGI UI - CMU inspired
   Cambia SOLO queste variabili quando avrai i colori del logo.
   ========================================================= */
:root {
    --brand-primary: #1769e0;
    --brand-primary-rgb: 23, 105, 224;
    --brand-accent: #e83b4f;
    --brand-accent-rgb: 232, 59, 79;
    --brand-dark: #11151b;
    --brand-dark-2: #1a2028;
    --brand-soft: #eaf2ff;
    --page-bg: #f3f5f8;
    --surface: #ffffff;
    --surface-soft: #f8f9fb;
    --text: #1c2430;
    --muted: #6f7b8a;
    --border: #e3e7ed;
    --success: #169b62;
    --warning: #e89a19;
    --danger: #d9364e;
    --info: #2477d4;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 2px 8px rgba(17, 24, 39, .05);
    --shadow-md: 0 12px 32px rgba(17, 24, 39, .08);
    --shadow-lg: 0 24px 64px rgba(17, 24, 39, .14);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page-bg); }
body {
    min-height: 100vh;
    margin: 0;
    background: var(--page-bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-primary); }
a:hover { color: color-mix(in srgb, var(--brand-primary) 78%, #000); }

/* ---------- Bootstrap override ---------- */
.btn {
    min-height: 42px;
    border-radius: 11px;
    font-weight: 700;
    border-width: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    box-shadow: 0 6px 16px rgba(var(--brand-primary-rgb), .18);
}
.btn-primary:hover,
.btn-primary:focus {
    background: color-mix(in srgb, var(--brand-primary) 88%, #000);
    border-color: color-mix(in srgb, var(--brand-primary) 88%, #000);
}
.btn-light { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline-primary { color: var(--brand-primary); border-color: rgba(var(--brand-primary-rgb), .35); }
.btn-outline-primary:hover { background: var(--brand-primary); border-color: var(--brand-primary); }
.btn-outline-danger { color: var(--danger); border-color: rgba(217,54,78,.28); }
.btn-outline-warning { color: #9a6700; border-color: #efd18e; }
.btn-sm { min-height: 34px; border-radius: 9px; font-size: .82rem; }

.form-control,
.form-select {
    min-height: 46px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background-color: #fff;
    color: var(--text);
    box-shadow: none;
}
textarea.form-control { min-height: auto; }
.form-control:focus,
.form-select:focus {
    border-color: rgba(var(--brand-primary-rgb), .7);
    box-shadow: 0 0 0 .22rem rgba(var(--brand-primary-rgb), .11);
}
.form-control::placeholder { color: #a0a9b5; }
.form-check-input:checked { background-color: var(--brand-primary); border-color: var(--brand-primary); }
label { color: #465161; font-weight: 700; font-size: .86rem; margin-bottom: .4rem; }

.table { --bs-table-bg: transparent; color: var(--text); }
.table thead th {
    border-bottom: 1px solid var(--border);
    background: #f7f8fa;
    color: #707b89;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
    padding: 13px 14px;
}
.table tbody td { border-color: #edf0f3; padding: 14px; vertical-align: middle; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: rgba(var(--brand-primary-rgb), .035); }

.modal-content { border: 0; border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { border-bottom: 1px solid var(--border); padding: 20px 22px; }
.modal-header h5 { margin: 0; font-weight: 800; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 22px; }
/* Modali anagrafiche: devono stare sopra header/menu sticky, non dietro di essi. */
.modal { z-index: 2600 !important; }
.modal-backdrop { z-index: 2500 !important; }
.modal-dialog { margin-top: 88px; }
@media (max-width: 576px) { .modal-dialog { margin-top: 74px; } }


/* ---------- Brand / top bar ---------- */
.brand-icon,
.brand-mark {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, var(--brand-primary), color-mix(in srgb, var(--brand-primary) 72%, #000));
    box-shadow: 0 8px 20px rgba(var(--brand-primary-rgb), .25);
}
.brand-icon { width: 64px; height: 64px; border-radius: 18px; font-size: 29px; }
.brand-icon.small { width: 44px; height: 44px; border-radius: 12px; font-size: 19px; }
.brand-mark { width: 46px; height: 46px; border-radius: 13px; font-weight: 900; letter-spacing: -.04em; font-size: 18px; }
.brand-copy strong { display: block; color: #fff; font-size: 1rem; line-height: 1.05; }
.brand-copy span { display: block; margin-top: 4px; color: rgba(255,255,255,.58); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }

.admin-header {
    position: sticky;
    top: 0;
    z-index: 2000;
    background: rgba(17,21,27,.97);
    border-bottom: 1px solid rgba(255,255,255,.07);
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
    backdrop-filter: blur(12px);
}
.admin-header .container-xl { min-height: 70px; }
.admin-header .header-title h1 { color: #fff; font-size: 1.03rem; font-weight: 800; margin: 0; }
.admin-header .header-title div { color: rgba(255,255,255,.52) !important; }
.admin-header .btn-header {
    color: #fff;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.07);
    min-height: 38px;
}
.admin-header .btn-header:hover { background: rgba(255,255,255,.13); }

.admin-main { padding-top: 24px; padding-bottom: 40px; }
.admin-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(86px,1fr));
    gap: 5px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}
.admin-tabs a {
    min-height: 50px;
    padding: 8px 7px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #687483;
    text-decoration: none;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1.1;
    transition: all .16s ease;
}
.admin-tabs a i { font-size: 1.05rem; }
.admin-tabs a:hover { background: var(--surface-soft); color: var(--text); }
.admin-tabs a.active {
    background: var(--brand-dark);
    color: #fff;
    box-shadow: 0 6px 14px rgba(17,21,27,.18);
}
/* Stesso effetto per TUTTE le icone della voce di menu attiva.
   !important evita override da Bootstrap/pagine specifiche. */
.admin-tabs > a.active > i.bi:first-child {
    color: #111 !important;
    background: #fff !important;
    border: 2px solid #111 !important;
    border-radius: 9px;
    padding: 5px;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(255,255,255,.22);
}
.admin-tabs a.locked { background: #f7f8fa; color: #7e8997; }
.admin-tabs a.locked:hover { background: var(--brand-soft); color: var(--brand-primary); }
.mobile-admin-menu-toggle { display:none; }
.module-lock { font-size: .68rem !important; margin-left: 2px; color: #a37400; }

/* ---------- Moduli opzionali ---------- */
.feature-locked {
    max-width: 780px;
    margin: 5vh auto 0;
    padding: clamp(30px, 6vw, 64px);
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 26px;
    background: radial-gradient(circle at 50% 0, var(--brand-soft), #fff 52%);
    box-shadow: var(--shadow-md);
}
.feature-locked-icon {
    width: 86px; height: 86px; margin: 0 auto 18px; display: grid; place-items: center;
    border-radius: 25px; background: var(--brand-primary); color: #fff; font-size: 38px;
    box-shadow: 0 16px 35px rgba(var(--brand-primary-rgb), .25);
}
.feature-badge { display: inline-flex; gap: 6px; align-items: center; padding: 7px 11px; border-radius: 999px; background: #fff4d6; color: #8a6000; font-size: .75rem; font-weight: 800; }
.feature-locked h1 { margin: 16px 0 8px; font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 900; }
.feature-locked > p { max-width: 600px; margin: 0 auto; color: var(--muted); font-size: 1.03rem; }
.feature-benefits { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 26px 0; }
.feature-benefits span { padding: 10px 13px; border: 1px solid var(--border); border-radius: 11px; background: #fff; font-weight: 750; font-size: .86rem; }
.feature-benefits i { color: var(--success); }
.feature-locked > .btn { margin: 4px; }

/* ---------- Fatturazione ---------- */
.invoice-trip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.invoice-trip-option { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px; margin: 0; border: 1px solid var(--border); border-radius: 13px; background: #fff; cursor: pointer; }
.invoice-trip-option:has(input:checked) { border-color: var(--brand-primary); background: var(--brand-soft); box-shadow: 0 0 0 2px rgba(var(--brand-primary-rgb), .08); }
.invoice-trip-option input { width: 19px; height: 19px; accent-color: var(--brand-primary); }
.invoice-trip-option span { min-width: 0; flex: 1; }
.invoice-trip-option strong, .invoice-trip-option small, .invoice-trip-option b { display: block; }
.invoice-trip-option small { color: var(--muted); margin: 2px 0 5px; }
.invoice-trip-option b { color: var(--brand-primary); }
.invoice-trip-option.not-ready { background: #f7f8fa; cursor: default; opacity: .78; }
.invoice-trip-option > a { font-size: .75rem; font-weight: 800; }
.invoice-status-bozza { background: #edf0f4; color: #566170; }
.invoice-status-emessa { background: #e8f2ff; color: #1769e0; }
.invoice-status-inviatasdi { background: #fff2ce; color: #805900; }
.invoice-status-consegnata { background: #dcf6e9; color: #087345; }
.invoice-status-scartata { background: #ffe1e5; color: #a51e34; }
.invoice-mobile-list { display:grid; gap:11px; }
.invoice-mobile-card { overflow:hidden; border:1px solid var(--border); border-radius:15px; background:#fff; box-shadow:var(--shadow-sm); }
.invoice-mobile-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; padding:15px; border-top:3px solid var(--brand-primary); }
.invoice-mobile-head > div,.invoice-mobile-customer { display:grid; gap:2px; }
.invoice-mobile-card small { display:block; color:var(--brand-primary); font-size:.62rem; font-weight:900; letter-spacing:.08em; }
.invoice-mobile-head strong { font-size:1rem; }
.invoice-mobile-head div span,.invoice-mobile-customer span { color:var(--muted); font-size:.72rem; }
.invoice-mobile-customer { margin:0 15px; padding:12px 0; border-top:1px solid var(--border); }
.invoice-mobile-customer strong { overflow-wrap:anywhere; font-size:.88rem; }
.invoice-mobile-total { display:flex; justify-content:space-between; align-items:end; gap:15px; padding:12px 15px; background:var(--surface-soft); color:var(--muted); font-size:.8rem; }
.invoice-mobile-total strong { color:var(--text); font-size:1.13rem; text-align:right; }
.invoice-mobile-total small { margin-bottom:3px; }
.invoice-mobile-actions { display:flex; flex-wrap:wrap; gap:7px; padding:12px 15px 15px; }
.invoice-mobile-actions form { display:inline-flex; }

/* ---------- Common pages ---------- */
.page-shell { max-width: 1320px; margin: 0 auto; padding: 28px 20px 42px; }
.page-heading,
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.page-heading h1,
.section-title h1,
.section-title h2 { margin: 0; font-size: clamp(1.25rem, 1.8vw, 1.65rem); font-weight: 850; letter-spacing: -.025em; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: .9rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.panel > h2,
.panel-heading,
.stops-block h2 {
    font-size: .95rem;
    font-weight: 850;
    margin: 0 0 16px;
}
.panel:not(.table-responsive) { padding: 20px; }
.panel.table-responsive { padding: 0; }

/* ---------- Dashboard ---------- */
.stat-card {
    height: 100%;
    min-height: 94px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 17px;
    display: flex;
    align-items: center;
    gap: 13px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: "";
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    right: -22px;
    top: -22px;
    background: rgba(var(--brand-primary-rgb), .08);
}
.stat-card > i {
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand-primary);
    font-size: 19px;
}
.stat-card.danger > i { color: var(--danger); background: #fff0f2; }
.stat-card strong { display: block; font-size: 1.55rem; line-height: 1; letter-spacing: -.035em; }
.stat-card span { display: block; margin-top: 5px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.stat-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.stat-card-link:hover {
    color: inherit;
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(15, 23, 42, .10);
    border-color: rgba(15, 23, 42, .22);
}

.alert-row {
    margin-top: 9px;
    padding: 13px 14px;
    border: 1px solid;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.alert-row.expired { background: #fff2f4; border-color: #ffd2d9; }
.alert-row.expiring { background: #fff9ec; border-color: #f6dda1; }
.alert-row strong { font-size: .88rem; }
.alert-row small { display: block; margin-top: 3px; color: var(--muted); font-size: .76rem; }
.alert-row > span { flex: 0 0 auto; font-size: .68rem; font-weight: 850; text-transform: uppercase; }

.kanban { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.kanban-col {
    min-height: 180px;
    padding: 12px;
    border: 1px solid var(--border);
    border-top: 3px solid #939eab;
    border-radius: 12px;
    background: #f7f8fa;
}
.kanban-col.status-incorso { border-top-color: var(--info); }
.kanban-col.status-inritardo { border-top-color: var(--warning); }
.kanban-col.status-arrivato { border-top-color: var(--success); }
.kanban-col h3 { margin: 0; color: #7b8592; font-size: .68rem; font-weight: 900; letter-spacing: .045em; text-transform: uppercase; }
.kanban-item {
    margin-top: 9px;
    padding: 11px;
    background: #fff;
    border: 1px solid #e9edf2;
    border-radius: 10px;
    box-shadow: 0 2px 7px rgba(17,24,39,.04);
}
.kanban-item b,.kanban-item span,.kanban-item small { display: block; }
.kanban-item b { color: var(--brand-primary); font-size: .74rem; }
.kanban-item span { margin-top: 4px; font-size: .79rem; font-weight: 750; }
.kanban-item small { margin-top: 4px; color: var(--muted); font-size: .73rem; }

/* ---------- Cards / entities ---------- */
.entity-card {
    height: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 17px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: transform .16s ease, box-shadow .16s ease;
}
.entity-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.entity-card h3 { margin: 0 0 7px; font-size: 1rem; font-weight: 850; letter-spacing: -.01em; }
.entity-card p { margin: 0 0 8px; color: var(--muted); font-size: .84rem; line-height: 1.55; }
.entity-card small { color: #717c89; }
.status-pill { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: #eef2f6; color: #53606f; font-size: .69rem; font-weight: 800; white-space: nowrap; }

.tracking-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.tracking-grid > div { padding: 14px; border: 1px solid var(--border); border-radius: 12px; display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; background: var(--surface-soft); }
.tracking-grid i { grid-row: span 2; color: var(--brand-accent); font-size: 1.15rem; }
.tracking-grid strong { font-size: .86rem; }
.tracking-grid span { color: var(--muted); font-size: .75rem; }

.metric-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px 0; border-top: 1px solid #edf0f3; }
.stops-block { padding: 15px; background: #f7f8fa; border: 1px solid var(--border); border-radius: 13px; }
.stop-row { display: grid; grid-template-columns: 2fr 1.6fr 110px 42px; gap: 8px; margin-top: 8px; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(300px, 1.05fr) minmax(420px, .95fr);
    background: #fff;
}
.login-brand {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    padding: clamp(40px,6vw,86px);
    color: #fff;
    background: var(--brand-dark);
}
.login-brand::before,
.login-brand::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.login-brand::before { width: 420px; height: 420px; top: -150px; right: -150px; border: 80px solid rgba(var(--brand-primary-rgb),.16); }
.login-brand::after { width: 260px; height: 260px; bottom: -120px; left: -90px; background: rgba(var(--brand-accent-rgb),.12); }
.login-brand-content { position: relative; z-index: 1; max-width: 560px; }
.login-brand .login-logo { width: 74px; height: 74px; border-radius: 21px; display: grid; place-items: center; margin-bottom: 28px; background: var(--brand-primary); font-size: 1.6rem; font-weight: 900; box-shadow: 0 16px 36px rgba(var(--brand-primary-rgb),.26); }
.login-brand h1 { margin: 0; font-size: clamp(2rem,4vw,3.4rem); font-weight: 900; letter-spacing: -.055em; }
.login-brand p { max-width: 470px; margin: 16px 0 0; color: rgba(255,255,255,.65); font-size: 1rem; line-height: 1.6; }
.login-form-side { display: grid; place-items: center; padding: 32px; background: #f7f8fa; }
.login-card { width: min(430px,100%); padding: 34px; background: #fff; border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-md); }
.login-card .mobile-logo { display: none; }
.login-card h2 { margin: 0; font-size: 1.55rem; font-weight: 900; letter-spacing: -.035em; }
.login-card .login-subtitle { margin: 7px 0 26px; color: var(--muted); font-size: .88rem; }
.login-card .btn-primary { min-height: 50px; }

/* ---------- Driver / employee mobile app ---------- */
.driver-header {
    position: sticky;
    top: 0;
    z-index: 60;
    color: #fff;
    background: var(--brand-dark);
    border-bottom: 1px solid rgba(255,255,255,.07);
    box-shadow: 0 7px 22px rgba(0,0,0,.16);
}
.driver-header-inner { max-width: 540px; min-height: 68px; margin: 0 auto; padding: 9px 14px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.driver-header-inner > div { text-align: center; }
.driver-header small,.driver-header strong { display: block; }
.driver-header small { color: rgba(255,255,255,.52); font-size: .67rem; text-transform: uppercase; letter-spacing: .07em; }
.driver-header strong { margin-top: 2px; font-size: .93rem; }
.back { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; text-decoration: none; border-radius: 11px; background: rgba(255,255,255,.06); }
.back:hover { color: #fff; background: rgba(255,255,255,.12); }
.driver-main { max-width: 540px; margin: 0 auto; padding: 18px 14px 42px; }

.docs-button {
    margin-bottom: 20px;
    padding: 17px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(135deg, var(--brand-primary), color-mix(in srgb,var(--brand-primary) 72%,#000));
    box-shadow: 0 10px 24px rgba(var(--brand-primary-rgb),.22);
}
.docs-button:hover { color:#fff; }
.docs-button span { display:flex; align-items:center; gap:12px; }
.docs-button span > i { width: 45px; height:45px; display:grid; place-items:center; border-radius:12px; background:rgba(255,255,255,.14); font-size:1.25rem; }
.docs-button b { font-size: .84rem; letter-spacing: .025em; }
.driver-section { margin-bottom: 22px; }
.driver-section h2 { margin: 0 0 11px; display:flex; align-items:center; gap:8px; color:#374252; font-size:.8rem; font-weight:900; text-transform:uppercase; letter-spacing:.055em; }
.driver-section h2 i { color: var(--brand-primary); }
.empty-card { padding: 22px; border: 1px dashed #cbd2db; border-radius: 14px; text-align: center; color: #929da9; background:#fff; font-size:.84rem; }
.trip-card,.trip-detail-card,.route-card,.delivery-card,.doc-row { background:#fff; border:1px solid var(--border); border-radius:16px; box-shadow:var(--shadow-sm); }
.trip-card { display:block; margin-bottom:10px; padding:15px; color:inherit; text-decoration:none; transition:transform .15s ease, box-shadow .15s ease; }
.trip-card:hover { color:inherit; transform:translateY(-1px); box-shadow:var(--shadow-md); }
.trip-top { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:9px; }
.trip-top code { color: var(--brand-primary); font-size:.76rem; font-weight:900; }
.driver-status { padding:5px 8px; border-radius:999px; background:#e9edf2; color:#5d6875; font-size:.64rem; font-weight:900; text-transform:uppercase; }
.s-incorso { background:#e4efff; color:#155fc0; }
.s-inritardo { background:#fff0d9; color:#a86700; }
.s-arrivato { background:#dcf7e9; color:#0c7a49; }
.s-completato { background:#edf0f3; color:#687381; }
.trip-card > div:not(.trip-top) { display:flex; gap:8px; margin-top:6px; color:#687482; font-size:.79rem; }
.trip-card .dest { color:#2c3540; }
.trip-card > small { display:block; margin-top:8px; color:#9aa4af; font-size:.72rem; }
.trip-detail-card { padding:16px; margin-bottom:12px; }
.vehicle-line { display:flex; align-items:center; gap:11px; }
.vehicle-line > i { width:42px; height:42px; flex:0 0 42px; display:grid; place-items:center; border-radius:11px; background:var(--brand-soft); color:var(--brand-primary); font-size:1.1rem; }
.vehicle-line small { display:block; margin-top:2px; color:var(--muted); font-size:.72rem; }
.route-card { padding:15px; margin-bottom:12px; }
.route-card h3,.delivery-card h3 { margin:0 0 7px; color:#677281; font-size:.69rem; font-weight:900; text-transform:uppercase; letter-spacing:.055em; }
.route-stop { display:grid; grid-template-columns:31px 1fr 38px; gap:10px; align-items:center; padding:11px 0; border-top:1px solid #edf0f3; }
.route-stop > span { width:29px; height:29px; border-radius:50%; display:grid; place-items:center; background:#eef2f6; color:#566271; font-size:.74rem; font-weight:900; }
.route-stop b { font-size:.83rem; }
.route-stop small { display:block; margin-top:2px; color:var(--muted); font-size:.71rem; }
.route-stop > a { width:38px; height:38px; display:grid; place-items:center; border-radius:10px; color:var(--brand-primary); background:var(--brand-soft); text-decoration:none; }
.driver-action { width:100%; min-height:58px; margin-bottom:10px; padding:15px 14px; border:0; border-radius:15px; display:flex; align-items:center; justify-content:center; gap:9px; font-size:.94rem; font-weight:900; letter-spacing:.01em; box-shadow:0 8px 20px rgba(17,24,39,.10); }
.driver-action.start { background:var(--success); color:#fff; }
.driver-action.issue { min-height:50px; background:#fff4e2; color:#9a6200; border:1px solid #f2d49c; box-shadow:none; }
.driver-action.arrive { background:var(--brand-primary); color:#fff; }
.driver-action.complete { background:var(--success); color:#fff; }
.issue-note { display:flex; gap:10px; padding:13px; border-radius:13px; background:#fff5e7; border:1px solid #f2d5a5; color:#8c5a0a; font-size:.8rem; }
.issue-note span { display:block; margin-top:2px; }
.delivery-card { padding:15px; margin-bottom:12px; }
.delivery-row { padding:12px 0; border-top:1px solid #edf0f3; }
.delivery-row small,.delivery-row label { display:block; margin-bottom:6px; color:var(--muted); font-size:.72rem; }
.big-number { min-height:54px; text-align:center; font-size:1.25rem; font-weight:850; }
.photo-upload { min-height:90px; display:flex; align-items:center; justify-content:center; gap:9px; padding:18px; border:1px dashed #cbd3dd; border-radius:13px; background:#f6f8fa; color:#586473; font-size:.8rem; font-weight:850; cursor:pointer; }
.photo-upload input { display:none; }
.photo-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:10px; }
.photo-grid img { width:100%; aspect-ratio:1; object-fit:cover; border-radius:9px; }
.doc-group { margin:17px 0 8px; color:#85909c; font-size:.65rem; font-weight:900; letter-spacing:.06em; text-transform:uppercase; }
.doc-row { margin-bottom:8px; padding:12px; display:flex; align-items:center; gap:9px; }
.doc-row > div { flex:1; min-width:0; }
.doc-row b { font-size:.8rem; }
.doc-row small { display:block; margin-top:2px; color:var(--muted); font-size:.69rem; }
.doc-status { padding:5px 7px; border-radius:999px; background:#dcf7e9; color:#0b7748; font-size:.61rem; font-weight:900; text-transform:uppercase; }
.doc-status.inscadenza { background:#fff0d7; color:#8a5b0b; }
.doc-status.scaduto { background:#ffe1e6; color:#aa2439; }

/* ---------- Edit pages / document sections ---------- */
.edit-page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 44px; }
.form-card { background:#fff; border:1px solid var(--border); border-radius:18px; box-shadow:var(--shadow-sm); padding:22px; }
.form-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.form-section:first-child { margin-top:0; padding-top:0; border-top:0; }
.form-section-title { display:flex; align-items:center; gap:10px; margin:0 0 16px; color:#36414f; font-size:.95rem; font-weight:900; }
.form-section-title i { width:34px; height:34px; display:grid; place-items:center; border-radius:9px; background:var(--brand-soft); color:var(--brand-primary); }

/* ---------- Responsive ---------- */
@media (max-width: 1050px) {
    .admin-tabs { grid-template-columns: repeat(4,1fr); }
    .kanban { grid-template-columns: repeat(2,1fr); }
    .tracking-grid { grid-template-columns:1fr; }
}
@media (max-width: 760px) {
    .admin-header .container-xl { min-height:62px; padding-left:14px; padding-right:14px; }
    .admin-header .header-title div { display:none; }
    .brand-icon.small { width:38px; height:38px; font-size:17px; }
    .admin-main { padding: 14px 12px 32px; }
    .mobile-admin-menu-toggle { width:100%; min-height:48px; margin-bottom:7px; padding:0 14px; display:flex; align-items:center; gap:9px; border:1px solid var(--border); border-radius:13px; background:#fff; color:var(--text); box-shadow:var(--shadow-sm); font-size:.8rem; font-weight:850; }
    .mobile-admin-menu-toggle > i:first-child { width:29px; height:29px; display:grid; place-items:center; border-radius:8px; background:var(--brand-primary); color:#fff; }
    .mobile-admin-menu-toggle > i:last-child { transition:transform .18s ease; }
    .mobile-admin-menu-toggle.open > i:last-child { transform:rotate(180deg); }
    .admin-tabs { display:none; grid-template-columns:repeat(3,minmax(0,1fr)); overflow:visible; gap:5px; padding:5px; border-radius:13px; position:static; }
    .admin-tabs.mobile-open { display:grid; }
    .admin-tabs a { min-width:0; min-height:58px; padding:7px 5px; font-size:.64rem; text-align:center; }
    .shared-admin-nav { margin-top:12px; margin-bottom:-3px; }
    .section-title { align-items:flex-start; }
    .section-title .btn { flex:0 0 auto; }
    .kanban { grid-template-columns:1fr; }
    .stop-row { grid-template-columns:1fr 88px 42px; }
    .stop-row input:nth-child(2) { grid-column:1/-1; grid-row:2; }
    .panel:not(.table-responsive) { padding:15px; }
    .stat-card { min-height:86px; padding:14px; }
    .stat-card > i { width:38px; height:38px; flex-basis:38px; }
    .stat-card strong { font-size:1.3rem; }
    .entity-card { padding:15px; }
    .table { font-size:.78rem; }
    .table thead th,.table tbody td { padding:11px 10px; }

    .login-page { grid-template-columns:1fr; background:#f5f6f8; }
    .login-brand { display:none; }
    .login-form-side { min-height:100vh; padding:20px; }
    .login-card { padding:28px 22px; border-radius:18px; }
    .login-card .mobile-logo { width:56px; height:56px; margin-bottom:22px; display:grid; place-items:center; border-radius:16px; background:var(--brand-dark); color:#fff; font-weight:900; }

    .edit-page { padding:20px 12px 34px; }
    .form-card { padding:16px; border-radius:15px; }
}
@media (max-width: 520px) {
    .section-title h1,.section-title h2 { font-size:1.2rem; }
    .section-title .btn { min-height:38px; padding:.45rem .65rem; font-size:.78rem; }
    .alert-row { align-items:flex-start; }
    .entity-card { flex-direction:column; }
    .entity-card > .d-flex { width:100%; justify-content:flex-end; }
    .driver-main { padding-left:11px; padding-right:11px; }
}

@media print {
    .admin-header,.admin-tabs,.mobile-admin-menu-toggle,.btn { display:none !important; }
    body { background:#fff; }
    .panel,.entity-card { box-shadow:none; }
}

/* ---------- KMaster ---------- */
.kmaster-page { padding-bottom: 40px; }
.kmaster-layout { display:grid; grid-template-columns:minmax(0,1fr) 340px; gap:16px; align-items:start; }
.kmaster-map-panel { position:relative; z-index:0; isolation:isolate; padding:0 !important; overflow:hidden; min-height:620px; }
#kmaster-map { position:relative; z-index:0; width:100%; height:620px; background:#e9edf2; }
.kmaster-map-empty { position:absolute; inset:0; display:grid; place-items:center; pointer-events:none; color:var(--muted); font-weight:700; }
.kmaster-list { overflow:hidden; background:#fff; border:1px solid var(--border); border-radius:18px; box-shadow:var(--shadow-sm); }
.kmaster-list-head { min-height:58px; padding:14px 16px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border); }
.kmaster-list-head strong { font-size:.9rem; }
.kmaster-list-head span { min-width:28px; height:28px; padding:0 8px; display:grid; place-items:center; border-radius:999px; background:var(--brand-soft); color:var(--brand-primary); font-size:.73rem; font-weight:900; }
.kmaster-driver { width:100%; border:0; border-bottom:1px solid #edf0f3; background:#fff; padding:13px 14px; display:grid; grid-template-columns:40px 1fr 24px; gap:10px; align-items:center; text-align:left; color:inherit; transition:background .15s ease; }
.kmaster-driver:last-child { border-bottom:0; }
.kmaster-driver:hover { background:#f7f9fb; }
.kmaster-driver-icon { width:40px; height:40px; display:grid; place-items:center; border-radius:12px; background:var(--brand-soft); color:var(--brand-primary); font-size:1.05rem; }
.kmaster-driver-data { min-width:0; }
.kmaster-driver-data strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:.82rem; }
.kmaster-driver-data small { display:block; margin-top:3px; color:var(--muted); font-size:.69rem; }
.kmaster-address { display:block; margin-top:3px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#7a8592; font-size:.67rem; }
.kmaster-driver > i { color:#a0a9b4; }
.leaflet-popup-content { font-family:inherit; }
/* Leaflet usa z-index elevati per pane e controlli: li teniamo confinati sotto header/menu admin. */
.kmaster-map-panel .leaflet-pane { z-index: 20; }
.kmaster-map-panel .leaflet-tile-pane { z-index: 10; }
.kmaster-map-panel .leaflet-overlay-pane { z-index: 20; }
.kmaster-map-panel .leaflet-shadow-pane { z-index: 30; }
.kmaster-map-panel .leaflet-marker-pane { z-index: 40; }
.kmaster-map-panel .leaflet-tooltip-pane { z-index: 50; }
.kmaster-map-panel .leaflet-popup-pane { z-index: 60; }
.kmaster-map-panel .leaflet-top,
.kmaster-map-panel .leaflet-bottom { z-index: 70; }

@media (max-width: 900px) {
    .kmaster-layout { grid-template-columns:1fr; }
    .kmaster-list { order:-1; max-height:290px; overflow:auto; }
    .kmaster-map-panel,#kmaster-map { min-height:520px; height:520px; }
}
@media (max-width: 520px) {
    .kmaster-map-panel,#kmaster-map { min-height:440px; height:440px; }
}

/* KMaster - stato flotta */
.kmaster-status-panel{display:flex;align-items:stretch;gap:12px;margin-bottom:16px;padding:12px;background:#fff;border:1px solid var(--border);border-radius:18px;box-shadow:var(--shadow-sm)}
.kmaster-status-card{min-width:150px;flex:0 0 auto;border:1px solid #edf0f3;background:#fff;border-radius:14px;padding:11px 14px;display:grid;grid-template-columns:42px 1fr;grid-template-rows:auto auto;column-gap:10px;text-align:left;transition:.15s ease}
.kmaster-status-card:hover,.kmaster-status-card.active{transform:translateY(-1px);box-shadow:0 7px 20px rgba(0,0,0,.07)}
.kmaster-status-icon{grid-row:1/3;width:42px;height:42px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:1.15rem}
.kmaster-status-card.stopped .kmaster-status-icon{background:#ff5b57}.kmaster-status-card.idle .kmaster-status-icon{background:#ffb000}.kmaster-status-card.moving .kmaster-status-icon{background:#55b900}
.kmaster-status-number{font-size:1rem;font-weight:900;line-height:1.1}.kmaster-status-label{font-size:.72rem;font-weight:700;color:var(--muted);margin-top:3px}
.kmaster-status-reset{margin-left:auto;border:0;background:transparent;color:var(--brand-primary);font-weight:800;font-size:.76rem;padding:0 10px}.kmaster-status-reset.active{text-decoration:underline}
.kmaster-driver-icon.stopped{background:#fff0ef;color:#ff5b57}.kmaster-driver-icon.idle{background:#fff6dd;color:#e99c00}.kmaster-driver-icon.moving{background:#eef9e7;color:#55a900}.kmaster-driver-icon.unknown{background:#eff2f5;color:#84909c}
.kmaster-inline-status.stopped{color:#e44c49}.kmaster-inline-status.idle{color:#d08a00}.kmaster-inline-status.moving{color:#479b00}.kmaster-inline-status.unknown{color:#77818c}
.kmaster-driver-extra{display:flex;gap:12px;flex-wrap:wrap;margin-top:5px;color:#647180;font-size:.68rem}.kmaster-driver-extra i,.kmaster-address i{margin-right:3px}
.kmaster-map-marker-wrap{background:transparent!important;border:0!important}.kmaster-map-marker{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:var(--marker-color);border:3px solid #fff;color:#fff;font-size:1rem;box-shadow:0 4px 12px rgba(0,0,0,.25)}
.km-popup{min-width:190px}.km-popup>strong{font-size:.88rem}.km-popup-plate{font-weight:800;color:#47515d;margin-top:2px}.km-popup-status{display:flex;align-items:center;gap:6px;margin:8px 0 7px;font-size:.75rem;font-weight:800}.km-popup-status span{width:9px;height:9px;border-radius:50%}.km-popup-status.stopped{color:#e44c49}.km-popup-status.stopped span{background:#ff5b57}.km-popup-status.idle{color:#d08a00}.km-popup-status.idle span{background:#ffb000}.km-popup-status.moving{color:#479b00}.km-popup-status.moving span{background:#55b900}.km-popup-status.unknown{color:#77818c}.km-popup-status.unknown span{background:#8d98a5}.km-popup-details{display:grid;gap:4px;color:#65717e;font-size:.7rem}.km-popup-details i{width:14px;margin-right:4px;color:#8793a0}
@media(max-width:700px){.kmaster-status-panel{overflow-x:auto}.kmaster-status-card{min-width:138px}.kmaster-status-reset{min-width:100px}}

/* Viaggi - modello a tappe */
.trip-stops { display:grid; gap:14px; }
.trip-stop-card { padding:16px; border:1px solid var(--border); border-radius:13px; background:#f7f8fa; }
.trip-stop-head { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:12px; }
.trip-stop-card label { display:block; margin-bottom:5px; font-size:.78rem; font-weight:700; color:#596574; }
.trip-route-stop small i { margin-right:4px; }
@media (max-width:767.98px) {
  .trip-stop-card { padding:12px; }
}


.company-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.company-header-logo {
    width: 58px;
    height: 46px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    padding: 5px;
}

.header-user {
    display: flex;
    gap: .6rem;
    padding: .42rem .8rem .42rem .48rem;
    border: 1px solid rgba(var(--brand-primary-rgb),.75);
    border-radius: 12px;
    background: rgba(var(--brand-primary-rgb),.18);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), 0 5px 14px rgba(0,0,0,.15);
    line-height: 1.05;
}

    .header-user-avatar { width:32px; height:32px; display:grid; place-items:center; flex:0 0 32px; border-radius:9px; background:var(--brand-primary); color:#fff; }

    .header-user strong {
        display: block;
        font-size: .85rem;
        color: #fff;
        white-space: nowrap;
    }

    .header-user small {
        font-size: .7rem;
        color: rgba(255,255,255,.78);
        margin-top: 3px;
    }

    .header-user i {
        font-size: 1rem;
    }

.shared-admin-nav { margin-top:18px; margin-bottom:-5px; position:relative; z-index:1500; }

.header-title h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.header-title .small {
    font-size: .75rem;
    opacity: .8;
}

.company-logo-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.company-actions-column { min-width: 285px; }
.company-actions { display: flex; flex-direction: column; gap: .7rem; min-width: 275px; }
.company-logo-upload { display: grid; grid-template-columns: auto minmax(70px,1fr) auto; align-items: center; gap: .55rem; padding-top: .65rem; border-top: 1px solid var(--border); }
.company-logo-file { min-width: 0; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .72rem; }

.geo-field {
    position: relative;
}

.geo-suggestions {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    z-index: 3000;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
    max-height: 300px;
    overflow-y: auto;
}

    .geo-suggestions.show {
        display: block;
    }

.geo-suggestion-item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #edf0f2;
    background: #fff;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    text-align: left;
    cursor: pointer;
}

    .geo-suggestion-item:first-child {
        border-radius: 10px 10px 0 0;
    }

    .geo-suggestion-item:last-child {
        border-bottom: 0;
        border-radius: 0 0 10px 10px;
    }

    .geo-suggestion-item:hover {
        background: #f5f8fb;
    }

.geo-suggestion-icon {
    margin-top: 2px;
    font-size: 1.1rem;
    color: #0d6efd;
}

.geo-suggestion-text {
    min-width: 0;
}

    .geo-suggestion-text strong {
        display: block;
        font-size: .88rem;
        font-weight: 600;
    }

    .geo-suggestion-text small {
        display: block;
        margin-top: 2px;
        color: #6c757d;
        font-size: .75rem;
    }

.geo-suggestion-empty {
    padding: 12px;
    font-size: .85rem;
    color: #6c757d;
}


.photo-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.photo-upload {
    cursor: pointer;
}

    .photo-upload input {
        display: none;
    }

    .photo-upload.secondary {
        background: #f3f5f7;
        color: #333;
    }

.photo-preview-grid {
    margin-top: 14px;
}

.photo-preview-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    background: #eee;
}

    .photo-preview-item img {
        display: block;
        width: 100%;
        height: 120px;
        object-fit: cover;
    }

.photo-preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,.65);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Billing customer cards */
.customer-heading { border-bottom: 2px solid var(--brand-primary); padding-bottom: 1rem; }
.customer-eyebrow, .customer-card-label, .customer-form-title small, .customer-data-grid small, .customer-list-heading { color: var(--brand-primary); font-size: .7rem; font-weight: 800; letter-spacing: .1em; }
.customer-heading h1 { margin-top: .15rem; }
.customer-form-card { border-top: 3px solid var(--brand-primary); }
.customer-form-title { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.35rem; }
.customer-form-title h2 { font-size: 1.2rem; margin: .1rem 0 0; }
.customer-icon { width: 42px; height: 42px; border-radius: 12px; background: color-mix(in srgb, var(--brand-primary) 13%, white); color: var(--brand-primary); display: grid; place-items: center; font-size: 1.15rem; }
.customer-list { display: grid; gap: .85rem; }
.customer-list-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 .25rem; }
.customer-count { background: color-mix(in srgb, var(--brand-primary) 13%, white); border-radius: 999px; min-width: 27px; padding: .2rem .55rem; text-align: center; }
.customer-card { position: relative; overflow: hidden; display: grid; grid-template-columns: 5px 1fr auto; background: #fff; border: 1px solid #e2e8ed; border-radius: 14px; box-shadow: 0 8px 24px rgba(39,49,59,.06); }
.customer-card-accent { background: var(--brand-primary); }
.customer-card-main { padding: 1.15rem 1.2rem; min-width: 0; }
.customer-card h3 { font-size: 1.12rem; margin: .15rem 0 .3rem; color: #27313b; }
.customer-address { color: #6c737a; font-size: .85rem; margin: 0; }
.customer-state { border-radius: 999px; padding: .3rem .65rem; background: #eceff1; color: #6c737a; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.customer-state.active { background: #e4f7ee; color: #168553; }
.customer-data-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .85rem 1rem; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid #edf0f2; }
.customer-data-grid div { min-width: 0; }
.customer-data-grid small, .customer-data-grid strong { display: block; }
.customer-data-grid strong { margin-top: .16rem; font-size: .83rem; overflow-wrap: anywhere; color: #3c4650; }
.customer-payment { grid-column: 1 / -1; }
.customer-card-actions { border-left: 1px solid #edf0f2; padding: 1rem; display: flex; flex-direction: column; justify-content: center; gap: .5rem; }
.customer-card.is-disabled { opacity: .72; }
@media (max-width: 767.98px) {
  .customer-card { grid-template-columns: 5px 1fr; }
  .customer-card-actions { grid-column: 2; border-left: 0; border-top: 1px solid #edf0f2; flex-direction: row; justify-content: flex-end; }
  .customer-data-grid { grid-template-columns: 1fr; }
  .customer-payment { grid-column: auto; }
}
.brand-preview { border: 1px solid #e3e7ed; border-top: 4px solid var(--preview-primary); border-radius: 12px; padding: 1.25rem; color: var(--preview-secondary); background: #fff; }
.brand-preview small { color: var(--preview-primary); font-weight: 800; letter-spacing: .12em; }
.brand-preview h3 { margin: .35rem 0 1rem; }
.brand-preview button { border: 0; border-radius: 9px; padding: .55rem 1rem; background: var(--preview-primary); color: #fff; font-weight: 700; }
.fuel-estimator {
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand-primary, #36aee3) 8%, white), #fff 55%);
    border: 1px solid color-mix(in srgb, var(--brand-primary, #36aee3) 24%, #dfe5ec);
    border-radius: 16px;
}

.fuel-result {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: .45rem .75rem;
    background: #fff;
    border: 1px solid #dfe5ec;
    border-radius: .5rem;
}

.fuel-result-total {
    color: var(--brand-primary, #087cac);
    font-size: 1.25rem;
    font-weight: 800;
}


/* DEMO: mini telefono con la vista dell'autista, visibile solo su desktop larghi. */
.demo-driver-phone{position:fixed;left:12px;top:138px;width:205px;z-index:20;display:none}
.demo-driver-phone-label{margin:0 0 7px 5px;color:#5e6875;font-size:.69rem;font-weight:800;text-transform:uppercase;letter-spacing:.055em}
.demo-driver-phone-label i{margin-right:4px}
.demo-driver-phone-shell{position:relative;height:560px;padding:14px 7px 9px;background:#151922;border:2px solid #2c323c;border-radius:28px;box-shadow:0 18px 44px rgba(17,24,39,.20)}
.demo-driver-phone-speaker{position:absolute;top:6px;left:50%;width:45px;height:4px;transform:translateX(-50%);border-radius:999px;background:#3c444f}
.demo-driver-phone iframe{width:100%;height:100%;border:0;border-radius:18px;background:#eef1f5;pointer-events:auto}
@media (min-width:1450px){.demo-driver-phone{display:block}}
@media (min-width:1700px){.demo-driver-phone{left:30px;width:270px;height:auto}.demo-driver-phone-shell{height:620px}}


/* ---------- Creator / Aziende ---------- */
.companies-page { max-width: 1540px; }
.companies-page .row > [class*="col-"] { min-width: 0; }
.companies-page .panel.table-responsive { overflow-x: auto; }
.companies-page table { width: 100%; min-width: 880px; table-layout: auto; }
.companies-page th,
.companies-page td { vertical-align: middle; }
.companies-page th:first-child,
.companies-page td:first-child { min-width: 175px; }
.companies-page .company-actions-column { min-width: 245px; width: 245px; }
.companies-page .company-actions { min-width: 0; width: 100%; }
.companies-page .company-actions > .d-flex { gap: .45rem !important; }
.companies-page .company-logo-upload { grid-template-columns: auto minmax(0, 1fr) auto; width: 100%; }
.companies-page .company-logo-file { max-width: 105px; }
.companies-page .demo-feature-on { cursor: default; pointer-events: none; }

@media (max-width: 1199.98px) {
    .companies-page { max-width: 100%; }
    .companies-page .company-actions-column { min-width: 225px; width: 225px; }
    .companies-page table { min-width: 840px; }
}

@media (max-width: 991.98px) {
    .companies-page .panel.table-responsive { margin-top: 0; }
    .companies-page table { min-width: 820px; }
}

/* ---------- Statistiche avanzate ---------- */
.stats-heading { align-items: flex-end; }
.stats-heading p { margin-top: 4px; font-size: .86rem; }
.stats-period-form { display: flex; align-items: center; gap: 9px; }
.stats-period-form .form-select { min-width: 165px; }

.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.stats-kpi-card {
    min-height: 112px;
    padding: 17px;
    display: flex;
    align-items: center;
    gap: 13px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 15px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stats-kpi-card::after {
    content: "";
    position: absolute;
    width: 70px;
    height: 70px;
    right: -30px;
    top: -30px;
    border-radius: 50%;
    background: rgba(var(--brand-primary-rgb), .07);
}
.stats-kpi-icon {
    width: 45px;
    height: 45px;
    flex: 0 0 45px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--brand-soft);
    color: var(--brand-primary);
    font-size: 1.15rem;
}
.stats-kpi-card > div:last-child { min-width: 0; }
.stats-kpi-card span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.stats-kpi-card strong { display: block; margin-top: 4px; font-size: 1.45rem; line-height: 1.1; letter-spacing: -.035em; }
.stats-kpi-card small { display: block; margin-top: 4px; color: var(--muted); font-size: .68rem; line-height: 1.25; }
.stats-kpi-warning .stats-kpi-icon { background: #fff6df; color: #a97000; }

.stats-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.stats-chart-card { min-height: 360px; }
.stats-chart-wide { grid-column: span 2; }
.stats-chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.stats-chart-head h3 { margin: 2px 0 0; font-size: 1rem; font-weight: 900; letter-spacing: -.02em; }
.stats-chart-head > i { color: var(--brand-primary); font-size: 1.2rem; }
.stats-chart-eyebrow { display: block; color: var(--muted); font-size: .64rem; line-height: 1; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.stats-chart-wrap { position: relative; height: 270px; margin-top: 16px; }
.stats-chart-wrap-wide { height: 300px; }
.stats-chart-note { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: .7rem; }

.stats-ranking { display: grid; gap: 15px; }
.stats-ranking-row { display: grid; grid-template-columns: 30px 1fr; gap: 11px; align-items: start; }
.stats-rank { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--brand-soft); color: var(--brand-primary); font-size: .75rem; font-weight: 900; }
.stats-ranking-main { min-width: 0; }
.stats-ranking-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .83rem; }
.stats-ranking-main b { white-space: nowrap; font-size: .82rem; }
.stats-ranking-main small { display: block; margin-top: 4px; color: var(--muted); font-size: .68rem; }
.stats-ranking-bar { height: 6px; margin-top: 7px; overflow: hidden; border-radius: 999px; background: #edf1f4; }
.stats-ranking-bar span { display: block; height: 100%; border-radius: inherit; background: var(--brand-primary); }

.stats-table th { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }
.stats-table td { font-size: .82rem; }
.stats-inline-pct { display: grid; grid-template-columns: 45px minmax(90px, 1fr); gap: 8px; align-items: center; }
.stats-inline-pct > span { font-weight: 850; }
.stats-inline-pct > div { height: 6px; overflow: hidden; border-radius: 999px; background: #edf1f4; }
.stats-inline-pct i { display: block; height: 100%; border-radius: inherit; background: #f3ad36; }

@media (max-width: 1199.98px) {
    .stats-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
    .stats-heading { align-items: stretch; flex-direction: column; }
    .stats-period-form { justify-content: space-between; }
    .stats-period-form .form-select { min-width: 0; width: 170px; }
    .stats-kpi-grid { grid-template-columns: 1fr; }
    .stats-chart-grid { grid-template-columns: 1fr; }
    .stats-chart-wide { grid-column: auto; }
    .stats-chart-card { min-height: 330px; }
    .stats-chart-wrap, .stats-chart-wrap-wide { height: 245px; }
}

/* Pacchetti avanzati */
.packages-page { padding-bottom: 48px; }
.packages-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:24px; }
.packages-eyebrow { display:inline-flex; align-items:center; gap:7px; margin-bottom:6px; font-size:.78rem; font-weight:900; text-transform:uppercase; letter-spacing:.08em; color:var(--brand-primary); }
.packages-counter { min-width:130px; padding:12px 16px; border:1px solid var(--border); border-radius:16px; background:#fff; text-align:center; box-shadow:var(--shadow-sm); }
.packages-counter strong { display:block; font-size:1.6rem; line-height:1; }
.packages-counter span { display:block; margin-top:5px; color:var(--muted); font-size:.75rem; }
.packages-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; margin-top:22px; }
.package-card { min-width:0; display:flex; flex-direction:column; min-height:310px; padding:22px; border:1px solid var(--border); border-radius:20px; background:#fff; color:var(--text); text-decoration:none; box-shadow:var(--shadow-sm); transition:.18s ease; }
.package-card:hover { transform:translateY(-3px); box-shadow:0 15px 35px rgba(24,47,70,.11); border-color:rgba(54,174,227,.45); color:var(--text); }
.package-card.locked { background:linear-gradient(180deg,#fff,#fafbfc); }
.package-card-top { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.package-icon { width:48px; height:48px; display:grid; place-items:center; border-radius:14px; background:var(--brand-soft); color:var(--brand-primary); font-size:1.25rem; }
.package-card.enabled .package-icon { background:#e9f8ef; color:#16864c; }
.package-status { display:inline-flex; align-items:center; gap:5px; padding:5px 9px; border-radius:999px; font-size:.69rem; font-weight:800; }
.package-status.on { background:#e9f8ef; color:#16864c; }
.package-status.off { background:#f0f2f5; color:#7b8490; }
.package-group { margin-top:20px; color:var(--brand-primary); font-size:.68rem; font-weight:900; text-transform:uppercase; letter-spacing:.08em; }
.package-card h2 { margin:6px 0 8px; font-size:1.15rem; font-weight:900; }
.package-card p { color:var(--muted); font-size:.88rem; line-height:1.5; }
.package-benefits { display:grid; gap:5px; margin-top:auto; padding-top:12px; }
.package-benefits span { display:flex; gap:7px; align-items:flex-start; font-size:.78rem; color:#596471; }
.package-benefits i { color:var(--brand-primary); }
.package-open { display:flex; align-items:center; gap:7px; margin-top:16px; padding-top:13px; border-top:1px solid var(--border); font-size:.8rem; font-weight:900; color:var(--brand-primary); }
.feature-badge-on { background:#e9f8ef !important; color:#16864c !important; }
.module-active-demo { max-width:650px; margin:22px auto; padding:15px 18px; display:flex; gap:13px; text-align:left; border:1px solid #ccebd8; border-radius:15px; background:#f3fbf6; color:#21603c; }
.module-active-demo > i { font-size:1.4rem; color:#19a25c; }
.module-active-demo strong,.module-active-demo span { display:block; }
.module-active-demo span { margin-top:2px; font-size:.84rem; opacity:.83; }
.company-feature-list { display:flex; flex-wrap:wrap; gap:5px; min-width:270px; max-width:520px; }
.company-feature-pill { border:1px solid #d9dee5; border-radius:999px; background:#fff; color:#687383; padding:4px 8px; font-size:.65rem; font-weight:800; line-height:1.1; white-space:nowrap; }
button.company-feature-pill { cursor:pointer; }
.company-feature-pill.enabled { border-color:#a9dfbf; background:#eaf8ef; color:#167744; }
.company-feature-pill.disabled:hover { border-color:var(--brand-primary); color:var(--brand-primary); background:var(--brand-soft); }
.company-feature-pill i { margin-right:3px; }
.companies-page table { min-width: 1080px; }

@media (max-width: 1100px) {
    .packages-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 700px) {
    .packages-heading { align-items:flex-start; flex-direction:column; }
    .packages-counter { width:100%; }
    .packages-grid { grid-template-columns:1fr; }
    .package-card { min-height:0; }
}

/* ---------- Pacchetti avanzati operativi ---------- */
.advanced-module-page { padding-bottom:48px; }
.advanced-centered { max-width:720px; margin:0 auto; }
.advanced-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px; align-items:center; padding:13px 0; border-bottom:1px solid var(--border); }
.advanced-row:last-child { border-bottom:0; }
.advanced-row strong,.advanced-row small,.advanced-row p { display:block; }
.advanced-row small { margin-top:3px; color:var(--muted); font-size:.72rem; }
.advanced-row p { margin:5px 0 0; font-size:.82rem; color:#56616d; }
.advanced-row .form-control { grid-column:1/-1; }
.ai-answer { display:flex; gap:14px; padding:20px; border:1px solid #cfe9d9; border-radius:18px; background:#f3fbf6; }
.ai-answer>i { font-size:1.5rem; color:#16864c; }
.ai-answer p { margin:.4rem 0 0; line-height:1.55; }
.driver-advanced-card { border-left:4px solid var(--brand-primary,#36aee3); }
.driver-flash { margin:10px 0 16px; }
.driver-chat-list { display:grid; gap:7px; max-height:240px; overflow:auto; }
.driver-chat-msg { display:grid; grid-template-columns:1fr auto; gap:2px 8px; padding:9px 11px; border-radius:12px; background:#f1f4f7; font-size:.78rem; }
.driver-chat-msg.mine { background:#e7f7fd; }
.driver-chat-msg span { grid-column:1/-1; }
.driver-chat-msg small { color:#7a8490; }
.driver-check-row { display:flex; align-items:center; gap:12px; padding:13px 0; border-bottom:1px solid #e8edf1; font-weight:750; }
.driver-check-row input { width:23px; height:23px; }
.signature-canvas { display:block; width:100%; height:150px; border:1px dashed #9ca8b3; border-radius:12px; background:#fff; touch-action:none; }
.epod-card { border:2px solid color-mix(in srgb,var(--brand-primary,#36aee3) 35%,#dfe5ec); }
@media(max-width:700px){.advanced-row{grid-template-columns:1fr}.advanced-row .btn{width:100%}}

/* Centro notifiche ufficio */
.notification-bell-wrap { position: relative; }
.notification-bell { position: relative; min-width: 38px; justify-content:center; }
.notification-badge { position:absolute; top:-7px; right:-7px; min-width:19px; height:19px; padding:0 5px; border-radius:999px; background:#dc3545; color:#fff; font-size:.68rem; font-weight:800; line-height:19px; text-align:center; box-shadow:0 0 0 2px var(--brand-accent,#27313B); }
.notification-dropdown { width:min(390px,calc(100vw - 20px)); border:0; border-radius:16px; overflow:hidden; box-shadow:0 16px 40px rgba(20,33,48,.18); }
.notification-dropdown-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; border-bottom:1px solid #e9edf1; background:#fff; }
.notification-dropdown-head div { display:flex; flex-direction:column; min-width:0; }
.notification-dropdown-head strong { font-size:.95rem; }
.notification-dropdown-head small { color:#7b8794; font-size:.72rem; }
.notification-dropdown-head a { font-size:.78rem; font-weight:700; text-decoration:none; white-space:nowrap; }
.notification-dropdown-list { max-height:430px; overflow:auto; background:#fff; }
.notification-dropdown-item { display:flex; gap:11px; align-items:flex-start; padding:12px 14px; color:#24313d; text-decoration:none; border-bottom:1px solid #eef1f4; transition:background .15s ease; }
.notification-dropdown-item:hover { background:#f7fafc; color:#24313d; }
.notification-dropdown-copy { min-width:0; flex:1; display:flex; flex-direction:column; gap:2px; }
.notification-dropdown-copy strong { font-size:.82rem; line-height:1.25; }
.notification-dropdown-copy span { color:#56616d; font-size:.76rem; line-height:1.3; overflow:hidden; text-overflow:ellipsis; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.notification-dropdown-copy small { color:#8a949f; font-size:.68rem; }
.notification-type-icon { width:34px; height:34px; flex:0 0 34px; border-radius:10px; display:inline-flex; align-items:center; justify-content:center; background:#eef4f7; color:#34495e; }
.notification-type-icon.type-chat { background:#e8f5fd; color:#1387bd; }
.notification-type-icon.type-delay { background:#fff0ed; color:#cf4d34; }
.notification-type-icon.type-arrival { background:#e9f8ef; color:#25844b; }
.notification-type-icon.type-checklist { background:#fff7df; color:#9b7412; }
.notification-type-icon.type-epod { background:#f0ecff; color:#6952b8; }
.notification-type-icon.type-document { background:#edf2ff; color:#4968b6; }
.notification-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; padding:30px 16px; color:#87929c; font-size:.82rem; }
.notification-empty i { font-size:1.45rem; }
.office-notification-toast { position:fixed; top:88px; right:18px; z-index:1085; width:min(430px,calc(100vw - 36px)); display:grid; grid-template-columns:auto minmax(0,1fr) auto auto; align-items:center; gap:11px; padding:13px 14px; border:1px solid #dfe6eb; border-radius:15px; background:#fff; box-shadow:0 18px 45px rgba(25,39,52,.22); opacity:0; pointer-events:none; transform:translateY(-8px); transition:opacity .2s ease,transform .2s ease; }
.office-notification-toast.show { opacity:1; pointer-events:auto; transform:translateY(0); }
.office-notification-toast > div { min-width:0; display:flex; flex-direction:column; }
.office-notification-toast strong { font-size:.86rem; }
.office-notification-toast span:not(.notification-type-icon) { font-size:.75rem; color:#5e6974; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.office-notification-toast .btn-close { font-size:.65rem; }
.notification-list-page { display:grid; gap:9px; }
.notification-page-item { display:flex; align-items:center; gap:12px; padding:14px 16px; border:1px solid #e3e8ed; border-radius:14px; background:#fff; color:#27313b; text-decoration:none; }
.notification-page-item.unread { border-color:rgba(var(--brand-primary-rgb),.32); background:rgba(var(--brand-primary-rgb),.035); }
.notification-page-item:hover { color:#27313b; border-color:rgba(var(--brand-primary-rgb),.5); }
.notification-page-item > span:nth-child(2) { display:flex; flex-direction:column; gap:2px; }
.notification-page-item strong { font-size:.9rem; }
.notification-message { font-size:.79rem; color:#596571; }
.notification-page-item small { color:#8b949e; font-size:.7rem; }
.notification-unread-dot { width:9px; height:9px; flex:0 0 9px; border-radius:50%; background:#dc3545; }
.min-w-0 { min-width:0!important; }
@media(max-width:700px){
  .office-notification-toast { top:70px; right:10px; width:calc(100vw - 20px); grid-template-columns:auto minmax(0,1fr) auto; }
  .office-notification-toast .btn-primary { display:none; }
  .notification-dropdown { width:calc(100vw - 20px); }
}

/* Notifiche area autista / mini smartphone */
.driver-header-inner { grid-template-columns:44px 1fr 78px; }
.driver-header-actions { display:flex; align-items:center; justify-content:flex-end; gap:2px; text-align:right!important; }
.driver-notification-wrap { position:relative; }
.driver-notification-button { position:relative; border:0; background:transparent; padding:0; }
.driver-notification-badge { position:absolute; top:1px; right:0; min-width:16px; height:16px; padding:0 4px; border-radius:999px; background:#dc3545; color:#fff; font-size:.58rem; line-height:16px; font-weight:800; text-align:center; box-shadow:0 0 0 2px var(--brand-primary,#36AEE3); }
.driver-notification-menu { width:min(300px,calc(100vw - 24px)); border:0; border-radius:13px; overflow:hidden; box-shadow:0 14px 35px rgba(18,30,42,.22); }
.driver-notification-head { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:10px 12px; border-bottom:1px solid #e8edf1; color:#27313b; background:#fff; }
.driver-notification-head strong { font-size:.78rem; }
.driver-notification-head small { color:#87929d; font-size:.64rem; }
.driver-notification-item { display:flex; flex-direction:column; gap:2px; padding:10px 12px; text-decoration:none; color:#27313b; border-bottom:1px solid #edf1f4; background:#fff; text-align:left; }
.driver-notification-item:hover { background:#f6fafc; color:#27313b; }
.driver-notification-item strong { font-size:.75rem; line-height:1.2; }
.driver-notification-item span { font-size:.7rem; line-height:1.25; color:#5c6873; white-space:normal; }
.driver-notification-item small { font-size:.62rem; color:#929ba4; }
.driver-notification-empty { padding:22px 12px; text-align:center; color:#87929d; background:#fff; font-size:.72rem; }

/* Clickable dashboard cards */
.kanban-item-link,.alert-row-link{color:inherit;text-decoration:none;display:block}.kanban-item-link:hover .kanban-item{transform:translateY(-2px);box-shadow:0 8px 18px rgba(20,28,38,.10)}.alert-row-link:hover .alert-row{box-shadow:0 5px 14px rgba(20,28,38,.08)}

.driver-login-row > div > label:first-child{min-height:24px;display:flex;align-items:end}.driver-login-row .form-control{min-height:38px}
