/* =========================================================
   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; }

/* ---------- 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: 50;
    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(8, minmax(0,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);
}
.admin-tabs a.active i { color: var(--brand-primary); }

/* ---------- 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; }

.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; }
    .admin-tabs {
        display:flex;
        overflow-x:auto;
        gap:5px;
        padding:5px;
        border-radius:13px;
        scrollbar-width:none;
        position: sticky;
        top: 70px;
        z-index: 35;
    }
    .admin-tabs::-webkit-scrollbar { display:none; }
    .admin-tabs a { min-width:85px; min-height:47px; padding:7px 8px; font-size:.66rem; }
    .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,.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; padding:0 !important; overflow:hidden; min-height:620px; }
#kmaster-map { 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; }

@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 Italtrans */
.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;
    padding: .35rem .75rem;
    border-radius: 10px;
    background: rgba(255,255,255,.10);
    line-height: 1.05;
}

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

    .header-user small {
        font-size: .7rem;
        opacity: .75;
        margin-top: 3px;
    }

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

.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;
}