/* =========================================================================
   FleetBook — Windows 11 Fluent Design System
   Solo asset locali, niente CDN, niente Google Fonts esterni.
   ========================================================================= */

:root {
    /* SURFACES */
    --bg:               #f3f3f3;
    --bg-mica:          linear-gradient(180deg, #fbfbfb 0%, #f3f3f3 100%);
    --surface:          #ffffff;
    --surface-2:        #fafafa;
    --surface-hover:    #f5f5f5;
    --surface-active:   #ebebeb;

    /* BORDERS */
    --border:           rgba(0,0,0,0.0578);
    --border-strong:    rgba(0,0,0,0.10);
    --divider:          rgba(0,0,0,0.058);

    /* TEXT */
    --fg:               #1f1f1f;
    --fg-secondary:     #5e5e5e;
    --fg-tertiary:      #8a8a8a;
    --fg-disabled:      #a8a8a8;
    --fg-on-accent:     #ffffff;

    /* ACCENT (Windows 11 default blue) */
    --accent:           #005fb8;
    --accent-hover:     #0074d4;
    --accent-pressed:   #00478c;
    --accent-soft:      #eef4fb;
    --accent-fg:        #003a78;

    /* STATES */
    --success:          #107c10;
    --success-soft:     #e6f4e6;
    --success-fg:       #054b16;
    --success-border:   #b6e0b6;

    --warning:          #c47306;
    --warning-soft:     #fff4ce;
    --warning-fg:       #8a4d00;
    --warning-border:   #f7d57a;

    --danger:           #c42b1c;
    --danger-soft:      #fde7e9;
    --danger-fg:        #8b0e0e;
    --danger-border:    #f2c1c5;

    --info:             #0078d4;
    --info-soft:        #f0f6fc;
    --info-fg:          #003a78;
    --info-border:      #c7dff5;

    /* SHAPE */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;

    /* ELEVATION */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow:    0 2px 4px rgba(0,0,0,0.04), 0 1px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);

    /* TYPOGRAPHY (font nativi Windows 11 — niente CDN) */
    --font: "Segoe UI Variable Display", "Segoe UI Variable", "Segoe UI",
            -apple-system, BlinkMacSystemFont, system-ui, "Helvetica Neue", Arial, sans-serif;
    --font-text: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI",
                 -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono: "Cascadia Mono", "Consolas", ui-monospace, "SF Mono", Menlo, monospace;

    /* LAYOUT */
    --sidebar-w: 240px;
    --topbar-h:  52px;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font-text);
    font-size: 14px;
    line-height: 1.45;
    background: var(--bg);
    background-image: var(--bg-mica);
    background-attachment: fixed;
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img, svg { display: block; max-width: 100%; }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.32); }

/* ---------- ICONS ---------- */
.icon { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.75; }
.icon-sm { width: 14px; height: 14px; stroke-width: 2; }
.icon-lg { width: 22px; height: 22px; stroke-width: 1.5; }
.icon-xl { width: 32px; height: 32px; stroke-width: 1.5; }

/* ---------- LAYOUT ---------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--divider);
}
.sidebar-brand-mark {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent) 0%, #0078d4 50%, #50e6ff 100%);
    color: #fff;
    display: grid; place-items: center;
    box-shadow: 0 1px 4px rgba(0, 95, 184, 0.30);
}
.sidebar-brand-mark .icon { width: 17px; height: 17px; stroke-width: 2; }
.sidebar-brand-name {
    font-family: var(--font);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.005em;
    color: var(--fg);
}
.sidebar-brand-sub {
    font-size: 11px;
    color: var(--fg-tertiary);
    margin-top: -1px;
}

.sidebar-nav {
    padding: 8px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sidebar-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--fg-tertiary);
    padding: 14px 12px 6px;
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 400;
    color: var(--fg);
    transition: background .12s ease;
    position: relative;
}
.nav-item:hover { background: var(--surface-hover); }
.nav-item:active { background: var(--surface-active); }
.nav-item.active {
    background: var(--surface-hover);
    font-weight: 600;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 8px; bottom: 8px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.nav-item .icon {
    width: 18px; height: 18px;
    color: var(--fg-secondary);
    stroke-width: 1.75;
}
.nav-item.active .icon { color: var(--accent); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid var(--divider);
}
.sidebar-user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, #0078d4 100%);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-email {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-user-sub {
    font-size: 10px;
    color: var(--fg-tertiary);
    margin-top: 1px;
}
.sidebar-user-logout { flex-shrink: 0; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--divider);
    font-size: 11px;
    color: var(--fg-tertiary);
}

/* MAIN */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    height: var(--topbar-h);
    background: rgba(255,255,255,0.78);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-mobile-btn {
    display: none;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px;
    color: var(--fg-secondary);
}
.topbar-mobile-btn:hover { background: var(--surface-hover); }
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--fg-secondary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}
.breadcrumb a { color: var(--fg-secondary); transition: color .12s; }
.breadcrumb a:hover { color: var(--fg); }
.breadcrumb .crumb-sep { color: var(--fg-tertiary); width: 12px; height: 12px; }
.breadcrumb .crumb-current { color: var(--fg); font-weight: 600; }

.topbar-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.content {
    padding: 24px 28px 40px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

.page-header { margin-bottom: 20px; }
.page-header h1 {
    font-family: var(--font);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--fg);
    margin-bottom: 2px;
}
.page-header p {
    font-size: 13.5px;
    color: var(--fg-secondary);
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--fg);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    min-height: 32px;
    transition: background .12s ease, border-color .12s ease;
    white-space: nowrap;
    user-select: none;
    text-decoration: none;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { background: var(--surface-active); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; stroke-width: 1.75; }

.btn-icon { padding: 6px; min-height: 32px; min-width: 32px; }
.btn-icon .icon { width: 16px; height: 16px; }

.btn-primary {
    background: var(--accent);
    color: var(--fg-on-accent);
    border-color: var(--accent);
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-pressed); border-color: var(--accent-pressed); }

.btn-danger {
    color: var(--danger-fg);
    border-color: var(--danger-border);
    background: var(--surface);
}
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger:active { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }

.btn-sm { padding: 4px 10px; font-size: 12px; min-height: 26px; gap: 5px; }
.btn-sm .icon { width: 13px; height: 13px; }
.btn-sm.btn-icon { padding: 4px; min-width: 26px; }

.btn-lg { padding: 8px 18px; font-size: 14px; min-height: 36px; }

/* ---------- CARDS ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-body { padding: 18px 20px; }
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title {
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--fg);
}
.card-title .icon { color: var(--fg-secondary); }
.card-sub { font-size: 12px; color: var(--fg-tertiary); margin-top: 2px; }

/* ---------- BADGE ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--fg-secondary);
    border: 1px solid var(--border);
    line-height: 1.4;
}
.badge .icon { width: 12px; height: 12px; stroke-width: 2; }
.badge-success { background: var(--success-soft); color: var(--success-fg); border-color: var(--success-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning-fg); border-color: var(--warning-border); }
.badge-danger  { background: var(--danger-soft); color: var(--danger-fg); border-color: var(--danger-border); }
.badge-info    { background: var(--info-soft); color: var(--info-fg); border-color: var(--info-border); }

/* ---------- FLASH ---------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--success-soft);
    color: var(--success-fg);
    border: 1px solid var(--success-border);
    font-size: 13px;
    font-weight: 500;
}
.flash .icon { color: var(--success); margin-top: 1px; }

/* ---------- FORMS ---------- */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.form-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
}
.form-hint {
    font-size: 11.5px;
    color: var(--fg-tertiary);
    margin-top: 2px;
}
.input, .select, .textarea {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid var(--border-strong);
    border-bottom: 1.5px solid var(--fg-tertiary);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--fg);
    font-size: 14px;
    font-family: var(--font-text);
    min-height: 32px;
    transition: border-color .12s ease;
}
.input:hover, .select:hover, .textarea:hover { border-bottom-color: var(--fg-secondary); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-bottom: 1.5px solid var(--accent);
    padding-bottom: 6.5px;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--fg-tertiary); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) {
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ---------- STAT CARDS ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
}
.stat-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.stat-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--fg-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
}
.stat-icon .icon { width: 16px; height: 16px; }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-soft); color: var(--danger); }

.stat-value {
    font-family: var(--font);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--fg);
    line-height: 1.1;
}
.stat-value.sm { font-size: 18px; }
.stat-meta {
    font-size: 12px;
    color: var(--fg-tertiary);
    margin-top: 4px;
}
.stat-meta.danger  { color: var(--danger); }
.stat-meta.warning { color: var(--warning); }
.stat-meta.success { color: var(--success); }

/* ---------- VEHICLE GRID ---------- */
.vehicle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.vehicle-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 18px 16px 22px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
    display: flex;
    flex-direction: column;
    gap: 14px;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
    overflow: hidden;
}
.vehicle-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--success);
    transition: background .15s ease;
}
.vehicle-card.status-warning::before { background: var(--warning); }
.vehicle-card.status-danger::before  { background: var(--danger); }
.vehicle-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.vehicle-card-arrow {
    position: absolute;
    right: 14px; top: 22px;
    width: 16px; height: 16px;
    color: var(--fg-tertiary);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity .18s ease, transform .18s ease, color .18s ease;
}
.vehicle-card:hover .vehicle-card-arrow {
    opacity: 1;
    transform: translateX(0);
    color: var(--accent);
}
.vehicle-card-head {
    display: flex;
    align-items: center;
    gap: 13px;
}
.vehicle-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    background: linear-gradient(135deg, #eaf3fc 0%, #f5f9fd 100%);
    border: 1px solid var(--border);
    color: var(--accent);
    display: grid; place-items: center;
    flex-shrink: 0;
    transition: background .15s ease, color .15s ease;
}
.vehicle-icon .icon { width: 26px; height: 26px; stroke-width: 1.6; }
.vehicle-card.status-warning .vehicle-icon {
    background: linear-gradient(135deg, #fff4ce 0%, #fef9e0 100%);
    color: var(--warning-fg);
    border-color: var(--warning-border);
}
.vehicle-card.status-danger .vehicle-icon {
    background: linear-gradient(135deg, #fde7e9 0%, #fdf3f4 100%);
    color: var(--danger-fg);
    border-color: var(--danger-border);
}

.vehicle-name {
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    color: var(--fg);
    letter-spacing: -0.01em;
    line-height: 1.25;
}

/* Targa stile italiana: strip blu "I" sulla sinistra */
.vehicle-plate {
    display: inline-flex;
    align-items: stretch;
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    background: #ffffff;
    border: 1.5px solid #1a1a1a;
    border-radius: 4px;
    margin-top: 6px;
    line-height: 1;
    padding: 0;
    color: #1a1a1a;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
    user-select: none;
}
.vehicle-plate:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.vehicle-plate:active { transform: translateY(0); }
.vehicle-plate.copied {
    border-color: var(--success);
}
.vehicle-plate.copied::after {
    content: '✓';
    color: var(--success);
    padding-right: 6px;
    align-self: center;
    font-weight: 700;
}
.vehicle-plate::before {
    content: 'I';
    background: #003399;
    color: #fcc917;
    font-family: var(--font);
    font-size: 9px;
    font-weight: 700;
    padding: 0 4px;
    display: flex;
    align-items: center;
    margin-right: 6px;
    letter-spacing: 0;
}
.vehicle-plate-text {
    padding: 2px 6px 2px 0;
    align-self: center;
}

.vehicle-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 22px;
}
.vehicle-meta {
    display: flex;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--divider);
    font-size: 12.5px;
    color: var(--fg-secondary);
    flex-wrap: wrap;
}
.vehicle-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}
.vehicle-meta-item .icon { width: 13px; height: 13px; color: var(--fg-tertiary); }
.vehicle-meta-sep {
    width: 3px; height: 3px;
    border-radius: 50%;
    background: var(--border-strong);
    margin: 0 10px;
}

/* ---------- HERO (VEHICLE DETAIL) ---------- */
.hero {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 22px;
    align-items: flex-start;
    overflow: hidden;
}
.hero > * { position: relative; z-index: 1; }
.hero-watermark {
    position: absolute;
    right: -40px;
    bottom: -50px;
    width: 280px;
    height: 280px;
    color: var(--accent);
    opacity: 0.045;
    pointer-events: none;
    z-index: 0;
    stroke-width: 1;
}
.hero-icon {
    width: 76px; height: 76px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent-soft) 0%, #f5f9fd 60%, #ffffff 100%);
    border: 1px solid var(--accent-soft);
    color: var(--accent);
    display: grid; place-items: center;
    box-shadow: 0 4px 14px rgba(0, 95, 184, 0.10);
}
.hero-icon .icon { width: 38px; height: 38px; stroke-width: 1.5; }
.hero-info { min-width: 0; }
.hero-info h2 {
    font-family: var(--font);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--fg);
    margin-bottom: 4px;
}
.hero-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--fg-secondary);
    margin-bottom: 10px;
}
.hero-meta .sep { color: var(--fg-tertiary); }

/* KM form */
.km-form {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin-top: 10px;
}
.km-form .input {
    width: 140px;
    padding: 5px 10px;
    font-size: 13px;
    min-height: 28px;
}
.km-form .btn-sm { min-height: 28px; }

/* Cal box */
.cal-box {
    background: var(--info-soft);
    border: 1px solid var(--info-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-top: 12px;
}
.cal-box-title {
    font-size: 12px;
    color: var(--info-fg);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}
.cal-box-title .icon { width: 14px; height: 14px; }
.cal-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cal-row .select { padding: 4px 8px; font-size: 12.5px; flex: 1; min-width: 140px; min-height: 28px; }
.cal-row .btn-sm { min-height: 28px; }
.cal-current {
    font-size: 12px;
    color: var(--info-fg);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.cal-current .icon { width: 13px; height: 13px; color: var(--success); }

/* ---------- POLICY CARD (Assicurazione / Bollo) ---------- */
.policy-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.policy-company {
    font-family: var(--font);
    font-size: 17px;
    font-weight: 600;
    color: var(--fg);
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.policy-subtitle {
    font-size: 12px;
    color: var(--fg-tertiary);
    margin-top: 3px;
}
.policy-amount {
    font-family: var(--font);
    font-size: 24px;
    font-weight: 700;
    color: var(--fg);
    letter-spacing: -0.025em;
    line-height: 1;
    text-align: right;
    white-space: nowrap;
}
.policy-amount-sub {
    font-size: 11px;
    color: var(--fg-tertiary);
    font-weight: 400;
    margin-left: 3px;
}

/* Timeline visual */
.policy-timeline {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 6px 0 2px;
}
.pt-point {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.pt-point.end { align-items: flex-end; text-align: right; }
.pt-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--fg-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.pt-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
}
.pt-sub {
    font-size: 11px;
    color: var(--fg-secondary);
    font-weight: 400;
    margin-top: 1px;
}
.pt-sub.danger  { color: var(--danger); font-weight: 500; }
.pt-sub.warning { color: var(--warning); font-weight: 500; }
.pt-sub.success { color: var(--success); font-weight: 500; }
.pt-bar {
    position: relative;
    height: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.pt-bar-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: var(--success);
    border-radius: 999px;
    transition: width .3s ease;
}
.pt-bar-fill.warning { background: var(--warning); }
.pt-bar-fill.danger  { background: var(--danger); }

/* Countdown style (Bollo) */
.countdown {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 4px 0 8px;
}
.countdown-num {
    font-family: var(--font);
    font-size: 56px;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--success);
    line-height: 0.9;
}
.countdown-num.warning { color: var(--warning); }
.countdown-num.danger { color: var(--danger); font-size: 32px; line-height: 1.1; }
.countdown-info { display: flex; flex-direction: column; gap: 2px; }
.countdown-label {
    font-size: 13px;
    color: var(--fg-secondary);
    font-weight: 500;
}
.countdown-date {
    font-size: 12px;
    color: var(--fg-tertiary);
    font-weight: 500;
}

/* Extras row (link, note) */
.policy-extras {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.policy-extras-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12.5px;
    color: var(--fg-secondary);
    min-width: 0;
}
.policy-extras-item .icon {
    width: 14px; height: 14px;
    color: var(--fg-tertiary);
    flex-shrink: 0;
    margin-top: 2px;
}
.policy-extras-item a {
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.policy-extras-item a:hover { text-decoration: underline; }

/* ---------- INFO / WARN BOX ---------- */
.info-box, .warn-box {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-radius: var(--radius);
    padding: 11px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}
.info-box {
    background: var(--info-soft);
    border: 1px solid var(--info-border);
    color: var(--info-fg);
}
.info-box .icon { color: var(--info); margin-top: 1px; }
.warn-box {
    background: var(--warning-soft);
    border: 1px solid var(--warning-border);
    color: var(--warning-fg);
}
.warn-box .icon { color: var(--warning); margin-top: 1px; }

/* ---------- KEY/VALUE TABLE ---------- */
.kv-table {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    border-top: 1px solid var(--divider);
}
.kv {
    padding: 12px 18px;
    border-right: 1px solid var(--divider);
    border-bottom: 1px solid var(--divider);
}
.kv:last-child { border-right: none; }
.kv-label {
    font-size: 11px;
    color: var(--fg-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
    font-weight: 600;
}
.kv-value { font-size: 14px; font-weight: 500; color: var(--fg); }
.kv-value.ok      { color: var(--success); }
.kv-value.warning { color: var(--warning); }
.kv-value.danger  { color: var(--danger); }
.kv-value a { color: var(--accent); }
.kv-value a:hover { text-decoration: underline; }

/* ---------- TIMELINE ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item {
    display: flex;
    gap: 14px;
    padding: 4px 8px 22px;
    position: relative;
    border-radius: var(--radius);
    transition: background .15s ease;
    margin: 0 -8px;
}
.tl-item:hover { background: var(--bg-mica); background: var(--surface-2); }
.tl-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 25px;
    top: 42px; bottom: 4px;
    width: 1px;
    background: var(--divider);
}
.tl-actions {
    display: flex;
    gap: 4px;
    transition: opacity .15s ease;
}
@media (hover: hover) and (min-width: 700px) {
    .tl-actions { opacity: 0; }
    .tl-item:hover .tl-actions { opacity: 1; }
}

/* Timeline footer (totale spese) */
.timeline-footer {
    margin-top: 6px;
    padding: 12px 8px 4px;
    border-top: 1px dashed var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--fg-secondary);
}
.timeline-footer-total {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.timeline-footer-total-label { font-size: 11px; color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.timeline-footer-total-value { font-family: var(--font); font-size: 17px; font-weight: 700; color: var(--fg); letter-spacing: -0.02em; }
.tl-dot {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--fg-secondary);
    display: grid; place-items: center;
    flex-shrink: 0;
    z-index: 1;
}
.tl-dot .icon { width: 17px; height: 17px; }
.tl-dot.tagliando { background: #eaf3fc; color: #005fb8; border-color: #c7dff5; }
.tl-dot.olio      { background: #fff4ce; color: #8a4d00; border-color: #f7d57a; }
.tl-dot.gomme     { background: #f0f9ff; color: #075985; border-color: #c4e7fa; }
.tl-dot.freni     { background: #fde7e9; color: #8b0e0e; border-color: #f2c1c5; }
.tl-dot.filtri    { background: #f3eafd; color: #6b21a8; border-color: #ddc4f5; }
.tl-dot.revisione { background: #faf3ff; color: #6b21a8; border-color: #e0c4f5; }
.tl-dot.carrozzeria { background: #e6f4e6; color: #054b16; border-color: #b6e0b6; }
.tl-body { flex: 1; padding-top: 4px; min-width: 0; }
.tl-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.tl-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: capitalize;
}
.tl-date { font-size: 12px; color: var(--fg-tertiary); }
.tl-detail { font-size: 13px; color: var(--fg-secondary); margin-bottom: 8px; }
.tl-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.tl-actions { display: flex; gap: 5px; }

/* ---------- ALERT ITEMS ---------- */
.alert-item {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface);
}
.alert-item-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: grid; place-items: center;
    flex-shrink: 0;
    background: var(--surface-2);
    color: var(--fg-secondary);
}
.alert-item-icon .icon { width: 15px; height: 15px; }
.alert-item-body { flex: 1; min-width: 0; }
.alert-item-title { font-size: 13.5px; font-weight: 600; text-transform: capitalize; }
.alert-item-detail { font-size: 12.5px; color: var(--fg-secondary); margin-top: 2px; }
.alert-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.alert-item.danger { border-color: var(--danger-border); background: var(--danger-soft); }
.alert-item.danger .alert-item-icon { background: var(--danger); color: #fff; }
.alert-item.warn   { border-color: var(--warning-border); background: var(--warning-soft); }
.alert-item.warn   .alert-item-icon { background: var(--warning); color: #fff; }
.alert-item.ok     { border-color: var(--success-border); background: var(--success-soft); }
.alert-item.ok     .alert-item-icon { background: var(--success); color: #fff; }

/* ---------- DOCUMENTS ---------- */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.doc-card {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
    overflow: hidden;
}
.doc-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Stylized file thumbnail */
.doc-thumb {
    width: 48px; height: 56px;
    border-radius: 6px;
    background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
    border: 1px solid var(--border-strong);
    display: grid; place-items: end center;
    padding: 0 0 8px;
    position: relative;
    flex-shrink: 0;
    margin-bottom: 4px;
}
.doc-thumb::before {
    /* corner fold */
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 11px; height: 11px;
    background: linear-gradient(225deg, var(--surface) 0%, var(--surface) 49%, var(--border-strong) 50%, var(--surface-2) 51%, var(--surface-2) 100%);
    border-left: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
    border-bottom-left-radius: 3px;
}
.doc-thumb-ext {
    font-family: var(--font);
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    padding: 2px 5px;
    border-radius: 3px;
    letter-spacing: 0.04em;
    background: var(--fg-secondary);
    line-height: 1.2;
}
.doc-thumb.pdf   { background: linear-gradient(180deg, #fef2f3 0%, #fde7e9 100%); border-color: var(--danger-border); }
.doc-thumb.pdf   .doc-thumb-ext { background: var(--danger); }
.doc-thumb.image { background: linear-gradient(180deg, #f3faf3 0%, #e6f4e6 100%); border-color: var(--success-border); }
.doc-thumb.image .doc-thumb-ext { background: var(--success); }
.doc-thumb.word  { background: linear-gradient(180deg, #f5f9fd 0%, #eaf3fc 100%); border-color: var(--info-border); }
.doc-thumb.word  .doc-thumb-ext { background: var(--info); }
.doc-thumb.excel { background: linear-gradient(180deg, #f3faf3 0%, #e6f4e6 100%); border-color: var(--success-border); }
.doc-thumb.excel .doc-thumb-ext { background: var(--success); }

.doc-nome {
    font-size: 13px;
    font-weight: 600;
    word-break: break-word;
    color: var(--fg);
    line-height: 1.35;
}
.doc-cat {
    font-size: 11px;
    color: var(--fg-tertiary);
    text-transform: capitalize;
    font-weight: 500;
}
.doc-actions {
    display: flex;
    gap: 5px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--divider);
}

/* ---------- NOTE / LINK refined ---------- */
.list-item-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    transition: border-color .12s, box-shadow .12s;
}
.list-item-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-actions { display: flex; gap: 3px; flex-shrink: 0; transition: opacity .15s ease; }
@media (hover: hover) and (min-width: 700px) {
    .list-item-actions { opacity: 0; }
    .list-item-row:hover .list-item-actions { opacity: 1; }
}

/* ---------- ALERT FORM COMPACT ---------- */
.alert-add {
    margin-top: 8px;
    padding: 14px 14px 12px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.alert-add-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--fg-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.alert-add-title .icon { width: 13px; height: 13px; }
.alert-add-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: end;
}
.alert-add-row .form-row { margin-bottom: 0; }
@media (max-width: 640px) {
    .alert-add-row { grid-template-columns: 1fr; }
}

.upload-area {
    display: block;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 22px;
    text-align: center;
    background: var(--surface-2);
    transition: all .12s;
    cursor: pointer;
}
.upload-area:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-area input[type=file] { display: none; }
.upload-area-icon {
    width: 44px; height: 44px;
    margin: 0 auto 8px;
    border-radius: 11px;
    background: var(--surface);
    display: grid; place-items: center;
    color: var(--fg-secondary);
    box-shadow: var(--shadow-sm);
}
.upload-area-icon .icon { width: 22px; height: 22px; }
.upload-area-title { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.upload-area-sub { font-size: 12px; color: var(--fg-tertiary); }
.upload-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ---------- NOTE / LINK ---------- */
.note-item {
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.note-text { font-size: 13.5px; line-height: 1.55; margin-bottom: 8px; color: var(--fg); }
.note-edit { display: none; }
.note-edit textarea { width: 100%; margin-bottom: 6px; }

.link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--surface);
}
.link-item .icon-link { color: var(--fg-tertiary); width: 14px; height: 14px; flex-shrink: 0; }
.link-item a {
    font-size: 13px;
    color: var(--accent);
    flex: 1;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.link-item a:hover { text-decoration: underline; }
.link-edit {
    display: none;
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}
.link-edit input, .link-edit select { margin-bottom: 6px; }

/* ---------- SECTION GRIDS ---------- */
.section { margin-bottom: 18px; }
.section-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}
@media (max-width: 900px) {
    .section-grid-2 { grid-template-columns: 1fr; }
}

/* ---------- EMPTY ---------- */
.empty {
    text-align: center;
    padding: 60px 20px;
}
.empty-icon {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    border-radius: 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--fg-tertiary);
}
.empty-icon .icon { width: 30px; height: 30px; }
.empty h2 {
    font-family: var(--font);
    font-size: 17px;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 4px;
}
.empty p { font-size: 13.5px; color: var(--fg-secondary); margin-bottom: 20px; }
.empty-state {
    text-align: center;
    padding: 26px 20px;
    color: var(--fg-tertiary);
    font-size: 13px;
}
.empty-state a { color: var(--accent); }

/* ---------- TIPO PICKER (INTERVENTI) ---------- */
.tipo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
@media (max-width: 640px) { .tipo-grid { grid-template-columns: repeat(2, 1fr); } }
.tipo-btn {
    padding: 12px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    font-family: var(--font-text);
    color: var(--fg-secondary);
    transition: all .12s;
    font-weight: 500;
}
.tipo-btn:hover { background: var(--surface-hover); color: var(--fg); }
.tipo-btn.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-fg);
    box-shadow: 0 0 0 1px var(--accent) inset;
}
.tipo-btn .icon-wrap {
    width: 34px; height: 34px;
    margin: 0 auto 6px;
    border-radius: 8px;
    background: var(--surface-2);
    display: grid; place-items: center;
    color: var(--fg-secondary);
    transition: all .12s;
}
.tipo-btn .icon-wrap .icon { width: 17px; height: 17px; }
.tipo-btn.selected .icon-wrap { background: var(--accent); color: #fff; }

/* ---------- REVISIONE BOX ---------- */
.revisione-box {
    background: var(--info-soft);
    border: 1px solid var(--info-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    display: none;
}
.revisione-box.visible { display: block; }
.revisione-box .titolo {
    font-size: 13px;
    font-weight: 600;
    color: var(--info-fg);
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
}
.revisione-opzioni { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.rev-btn {
    padding: 5px 12px;
    border: 1px solid var(--info-border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    cursor: pointer;
    font-size: 12.5px;
    font-family: var(--font-text);
    color: var(--info-fg);
    font-weight: 500;
    min-height: 28px;
}
.rev-btn:hover { background: var(--info-soft); }
.rev-btn.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- CALENDAR ---------- */
.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}
.cal-month-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cal-month-nav h2 {
    font-family: var(--font);
    font-size: 18px;
    font-weight: 600;
    min-width: 180px;
    text-align: center;
    letter-spacing: -0.01em;
}
.cal-grid {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.cal-header div {
    padding: 10px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--fg-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cal-body { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day {
    min-height: 110px;
    border-right: 1px solid var(--divider);
    border-bottom: 1px solid var(--divider);
    padding: 6px;
    background: var(--surface);
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.vuoto { background: var(--surface-2); }
.day-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-secondary);
    margin-bottom: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
}
.cal-day.oggi .day-num {
    color: #fff;
    background: var(--accent);
    border-radius: 50%;
}
.evento {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-bottom: 2px;
    line-height: 1.3;
    border-left: 3px solid;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.evento.tagliando    { background: #eaf3fc; color: #003a78; border-color: #005fb8; }
.evento.olio         { background: #fff4ce; color: #6b3a00; border-color: #c47306; }
.evento.revisione    { background: #f3eafd; color: #4c1d95; border-color: #7c3aed; }
.evento.assicurazione{ background: #e6f4e6; color: #054b16; border-color: #107c10; }
.evento.bollo        { background: #fde7e9; color: #8b0e0e; border-color: #c42b1c; }
.evento.gomme        { background: #f0f9ff; color: #075985; border-color: #0078d4; }
.evento.freni        { background: #fde7e9; color: #8b0e0e; border-color: #c42b1c; }
.evento.filtri       { background: #faf3ff; color: #6b21a8; border-color: #a855f7; }
.evento.carrozzeria  { background: #e6f4e6; color: #054b16; border-color: #107c10; }
.evento.altro        { background: var(--surface-2); color: var(--fg-secondary); border-color: var(--border-strong); }
.evento .ev-veicolo { display: block; font-weight: 400; opacity: 0.75; font-size: 10px; }

.legenda { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.leg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-secondary); }
.leg-dot { width: 12px; height: 12px; border-radius: 3px; }

/* ---------- ACCOUNT / BACKUP ---------- */
.account-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--surface);
}
.account-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0078d4, #00b294);
    display: grid; place-items: center;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}
.account-info { flex: 1; min-width: 0; }
.account-email {
    font-size: 13.5px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-sub {
    font-size: 12px;
    color: var(--fg-tertiary);
    display: flex; align-items: center; gap: 4px;
    margin-top: 2px;
}
.account-sub .icon { width: 12px; height: 12px; color: var(--success); }

.backup-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    background: var(--surface);
    gap: 10px;
}
.backup-nome {
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
}
.backup-size { font-size: 11px; color: var(--fg-tertiary); margin-top: 1px; }

.path-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--fg-secondary);
    word-break: break-all;
}

/* ---------- STATS TABLE ---------- */
.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--divider);
}
.stat-row:last-child { border-bottom: none; }
.stat-row-name { font-size: 13.5px; color: var(--fg); }
.stat-row-name .muted { font-size: 12px; color: var(--fg-tertiary); margin-left: 4px; }
.stat-row-val { font-size: 14px; font-weight: 600; }
.stat-row-link {
    text-decoration: none;
    color: inherit;
    padding: 10px 12px;
    margin: 0 -12px;
    border-radius: var(--radius-sm);
    transition: background .12s ease, transform .12s ease;
}
.stat-row-link:hover {
    background: var(--surface-2);
    border-bottom-color: transparent;
}
.stat-row-link:hover .stat-row-name { color: var(--accent); }

/* ---------- TOAST ---------- */
.toast {
    position: fixed;
    bottom: 22px;
    right: 22px;
    background: var(--fg);
    color: var(--surface);
    padding: 10px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    z-index: 100;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
.toast .icon { width: 16px; height: 16px; color: var(--success); }
.toast.error .icon { color: #fff; }

/* ---------- DIVIDER & UTIL ---------- */
.divider {
    border: none;
    border-top: 1px solid var(--divider);
    margin: 14px 0;
}
.chart-wrap { position: relative; height: 240px; }
.text-muted { color: var(--fg-secondary); }
.text-subtle { color: var(--fg-tertiary); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 16px; }
.mt-2 { margin-top: 16px; }

/* ---------- MOBILE SIDEBAR ---------- */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 40;
}
.nav-spacer { flex: 1; }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        z-index: 50;
        width: 280px;
        height: 100vh;
        height: 100dvh; /* gestisce la chrome dinamica dei browser mobile */
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-lg);
        /* Lascia ~0.5cm di respiro in basso (+ safe-area per iPhone con notch) */
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }

    /* Compatta la sidebar: Impostazioni e utente subito sotto i nav items
       invece di essere spinti in fondo (più facile da raggiungere col pollice). */
    .nav-spacer { display: none; }

    /* Footer "FleetBook 1.0 · …" non serve a nulla sul telefono e ruba spazio */
    .sidebar-footer { display: none; }

    /* Topbar a 2 righe: hamburger+breadcrumb sopra, azioni sotto con divisore */
    .topbar {
        height: auto;
        min-height: var(--topbar-h);
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .topbar-mobile-btn { display: inline-flex; order: 0; }
    .breadcrumb { order: 1; flex: 1 1 0; }
    .topbar-actions {
        order: 2;
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px solid var(--divider);
    }

    .content { padding: 16px; }
    .hero { grid-template-columns: 1fr; }
}

/* Sui telefoni stretti (≤480px) compatta ulteriormente i bottoni della topbar */
@media (max-width: 480px) {
    .topbar-actions .btn {
        padding: 6px 10px;
        font-size: 12.5px;
    }
}
