/* ============================================================
   Agenda (PWA operatori) - foglio di stile mobile-first
   Tema chiaro, accenti blu notte #1f3a5f e ambra #e5a000,
   safe-area iOS, barra di navigazione inferiore fissa.
   ============================================================ */

:root {
    --kt-primary: #1f3a5f;
    --kt-primary-dark: #15294a;
    --kt-primary-soft: #e6ecf5;
    --kt-accent: #e5a000;
    --kt-accent-soft: #fff4d6;
    --kt-accent-dark: #a86f00;
    --kt-bg: #f4f6fa;
    --kt-card: #ffffff;
    --kt-text: #1b2430;
    --kt-muted: #66717f;
    --kt-border: #e1e6ee;
    --kt-success: #198754;
    --kt-success-soft: #ddf2e6;
    --kt-danger: #d83b45;
    --kt-danger-soft: #fbe2e4;
    --kt-info: #2477d4;
    --kt-info-soft: #ddeafb;
    --kt-warning-soft: #fdf0d3;
    --kt-radius: 14px;
    --kt-radius-sm: 10px;
    --kt-shadow: 0 6px 20px rgba(27, 36, 48, 0.06), 0 1px 3px rgba(27, 36, 48, 0.05);
    --kt-shadow-strong: 0 12px 30px rgba(31, 58, 95, 0.18);
    --kt-topbar-h: 56px;
    --kt-nav-h: 64px;
    --kt-sat: env(safe-area-inset-top, 0px);
    --kt-sab: env(safe-area-inset-bottom, 0px);
    --kt-sal: env(safe-area-inset-left, 0px);
    --kt-sar: env(safe-area-inset-right, 0px);
    --kt-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { -webkit-tap-highlight-color: transparent; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--kt-font);
    background: var(--kt-bg);
    color: var(--kt-text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100%;
    overscroll-behavior-y: contain;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--kt-primary); }
a:hover { color: var(--kt-primary-dark); }
h1, h2, h3, h4, h5 { letter-spacing: -0.01em; }

::selection { background: var(--kt-primary); color: #fff; }

/* ---------- Bootstrap: override colori ---------- */

.btn { border-radius: 12px; font-weight: 600; min-height: 48px; transition: transform .12s ease, box-shadow .12s ease; }
.btn-sm { min-height: 38px; border-radius: 10px; }
.btn-lg { min-height: 54px; font-size: 1.05rem; }
.btn:active { transform: scale(0.985); }

.btn-primary {
    --bs-btn-bg: var(--kt-primary);
    --bs-btn-border-color: var(--kt-primary);
    --bs-btn-hover-bg: var(--kt-primary-dark);
    --bs-btn-hover-border-color: var(--kt-primary-dark);
    --bs-btn-active-bg: var(--kt-primary-dark);
    --bs-btn-active-border-color: var(--kt-primary-dark);
    --bs-btn-disabled-bg: #7d8ea6;
    --bs-btn-disabled-border-color: #7d8ea6;
    box-shadow: 0 6px 16px rgba(31, 58, 95, 0.25);
}
.btn-outline-primary {
    --bs-btn-color: var(--kt-primary);
    --bs-btn-border-color: #b9c6d8;
    --bs-btn-hover-bg: var(--kt-primary);
    --bs-btn-hover-border-color: var(--kt-primary);
    --bs-btn-active-bg: var(--kt-primary-dark);
    --bs-btn-active-border-color: var(--kt-primary-dark);
    background: #fff;
}
.btn-warning {
    --bs-btn-bg: var(--kt-accent);
    --bs-btn-border-color: var(--kt-accent);
    --bs-btn-hover-bg: #c98c00;
    --bs-btn-hover-border-color: #c98c00;
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
}
.btn-outline-secondary { background: #fff; border-color: var(--kt-border); color: #46515e; }
.btn-danger { --bs-btn-bg: var(--kt-danger); --bs-btn-border-color: var(--kt-danger); }
.btn-outline-danger { --bs-btn-color: var(--kt-danger); --bs-btn-border-color: #f0b8bd; background: #fff; }
.btn-light { background: #fff; border-color: var(--kt-border); }

.text-primary { color: var(--kt-primary) !important; }
.bg-primary { background-color: var(--kt-primary) !important; }
.text-accent { color: var(--kt-accent-dark) !important; }

.form-control, .form-select {
    min-height: 48px;
    border-radius: 12px;
    border-color: var(--kt-border);
    font-size: 16px; /* evita lo zoom automatico su iOS */
    background-color: #fff;
}
.form-control-lg, .input-group-lg > .form-control { min-height: 54px; }
.input-group-lg > .btn { min-height: 54px; }
.form-control:focus, .form-select:focus {
    border-color: var(--kt-primary);
    box-shadow: 0 0 0 0.22rem rgba(31, 58, 95, 0.14);
}
textarea.form-control { min-height: 120px; line-height: 1.45; }
.form-label { font-weight: 600; font-size: 13.5px; color: #3c4655; margin-bottom: 4px; }
.form-text { font-size: 12.5px; }
.form-check-input { width: 1.25em; height: 1.25em; }
.form-check-input:checked { background-color: var(--kt-primary); border-color: var(--kt-primary); }
.form-switch .form-check-input { width: 3em; height: 1.6em; }
.form-switch .form-check-input:checked { background-color: var(--kt-success); border-color: var(--kt-success); }
.input-group > .btn { border-radius: 0 12px 12px 0; }
.input-group > .form-control:first-child { border-radius: 12px 0 0 12px; }

.badge { border-radius: 8px; font-weight: 600; }
.badge.text-bg-success { background: var(--kt-success-soft) !important; color: #10693f !important; }
.badge.text-bg-danger { background: var(--kt-danger-soft) !important; color: #b02a33 !important; }
.badge.text-bg-warning { background: var(--kt-warning-soft) !important; color: #9a6b00 !important; }
.badge.text-bg-info { background: var(--kt-info-soft) !important; color: #1a5da8 !important; }
.badge.text-bg-primary { background: var(--kt-primary-soft) !important; color: var(--kt-primary) !important; }
.badge.text-bg-secondary { background: #e8edf3 !important; color: #55636c !important; }

.alert { border-radius: var(--kt-radius); border: none; font-size: 14px; }
.alert-warning { background: var(--kt-warning-soft); color: #7a5500; }
.alert-danger { background: var(--kt-danger-soft); color: #9a2830; }
.alert-info { background: var(--kt-info-soft); color: #164f8f; }
.alert-success { background: var(--kt-success-soft); color: #0f5f39; }

.card {
    border: 1px solid var(--kt-border);
    border-radius: var(--kt-radius);
    box-shadow: var(--kt-shadow);
    background: var(--kt-card);
}
.card-header { background: transparent; border-bottom: 1px solid var(--kt-border); font-weight: 700; padding: 12px 16px; }
.card-body { padding: 16px; }
.card-title { font-weight: 700; font-size: 15px; }

.modal-content { border-radius: var(--kt-radius); border: none; box-shadow: var(--kt-shadow-strong); }
.modal-header { border-bottom-color: var(--kt-border); }
.modal-title { font-weight: 700; font-size: 17px; }
.modal-footer { border-top-color: var(--kt-border); gap: 8px; }
.modal-footer > .btn { flex: 1; margin: 0; }
.modal-dialog { margin: 12px; }
@media (max-width: 575.98px) {
    .modal-dialog { max-width: none; }
}

.list-group-item { border-color: var(--kt-border); padding: 12px 14px; }
.list-group-item-action:active { background: var(--kt-primary-soft); }

/* ---------- Topbar ---------- */

.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1030;
    background: linear-gradient(135deg, var(--kt-primary-dark), var(--kt-primary) 70%, #2a4a74);
    color: #fff;
    padding-top: var(--kt-sat);
    box-shadow: 0 4px 14px rgba(21, 41, 74, 0.28);
}
.topbar-inner {
    height: var(--kt-topbar-h);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 calc(12px + var(--kt-sar)) 0 calc(12px + var(--kt-sal));
}
.topbar-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    width: 40px; height: 40px;
    border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.topbar-btn:active { background: rgba(255, 255, 255, 0.25); }
.topbar-status { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sync-spinner { display: inline-flex; color: #ffd86b; }
.net-status { font-size: 18px; line-height: 1; display: inline-flex; align-items: center; }
.net-status.is-online { color: #9be7b5; }
.net-status.is-offline { color: #ffb3b8; }
.topbar-badge { text-decoration: none; }

/* ---------- Banner offline / aggiornamento ---------- */

.offline-banner {
    position: fixed;
    top: calc(var(--kt-topbar-h) + var(--kt-sat));
    left: 0; right: 0;
    z-index: 1025;
    background: #3d4756;
    color: #fff;
    font-size: 13px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}
.offline-banner i { font-size: 16px; color: #ffcf5c; }
body.is-offline .app-view { padding-top: calc(var(--kt-topbar-h) + var(--kt-sat) + 48px); }

.update-banner {
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(var(--kt-nav-h) + var(--kt-sab) + 12px);
    z-index: 1026;
    background: var(--kt-primary-dark);
    color: #fff;
    padding: 10px 14px;
    border-radius: var(--kt-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: var(--kt-shadow-strong);
    font-size: 14px;
}
.update-banner .btn { min-height: 38px; }

/* ---------- Contenuto ---------- */

.app-view {
    padding: calc(var(--kt-topbar-h) + var(--kt-sat) + 14px) calc(12px + var(--kt-sar)) calc(var(--kt-nav-h) + var(--kt-sab) + 20px) calc(12px + var(--kt-sal));
    max-width: 760px;
    margin: 0 auto;
    min-height: 100vh;
}
body.no-nav .app-view { padding-bottom: calc(var(--kt-sab) + 20px); }
body.no-nav .bottomnav { display: none; }
body.no-nav .update-banner { bottom: calc(var(--kt-sab) + 12px); }

.view-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.view-toolbar .btn { min-height: 40px; }
.section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--kt-muted);
    font-weight: 700;
    margin: 18px 0 8px;
}

.filter-tabs { display: flex; gap: 6px; background: #e9edf4; padding: 4px; border-radius: 14px; margin-bottom: 12px; }
.filter-tabs button {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--kt-muted);
    font-weight: 600;
    font-size: 14px;
    min-height: 40px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.filter-tabs button.active { background: #fff; color: var(--kt-primary); box-shadow: 0 2px 6px rgba(27, 36, 48, 0.1); }
.filter-tabs .count { font-size: 11px; background: var(--kt-primary-soft); color: var(--kt-primary); border-radius: 999px; padding: 1px 7px; }

.day-header {
    position: sticky;
    top: calc(var(--kt-topbar-h) + var(--kt-sat));
    z-index: 5;
    background: var(--kt-bg);
    padding: 10px 2px 6px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
body.is-offline .day-header { top: calc(var(--kt-topbar-h) + var(--kt-sat) + 36px); }
.day-header .day-label { font-weight: 800; font-size: 15px; color: var(--kt-primary); }
.day-header .day-label.is-today { color: var(--kt-accent-dark); }
.day-header .day-date { font-size: 12.5px; color: var(--kt-muted); }
.day-header .day-count { margin-left: auto; font-size: 12px; color: var(--kt-muted); }

/* ---------- Card servizio ---------- */

.svc-card {
    display: block;
    background: var(--kt-card);
    border: 1px solid var(--kt-border);
    border-left: 5px solid var(--kt-primary);
    border-radius: var(--kt-radius);
    padding: 12px 14px;
    margin-bottom: 10px;
    text-decoration: none;
    color: var(--kt-text);
    box-shadow: var(--kt-shadow);
    transition: transform .12s ease, box-shadow .12s ease;
}
.svc-card:active { transform: scale(0.99); box-shadow: none; }
.svc-card:hover { color: var(--kt-text); }
.svc-card.status-in_corso { border-left-color: var(--kt-accent); }
.svc-card.status-completato { border-left-color: var(--kt-success); }
.svc-card.status-annullato { border-left-color: #a5adb8; opacity: 0.75; }
.svc-card.has-pending { border-color: #f1d488; background: #fffdf7; }
.svc-card.is-now { box-shadow: 0 0 0 2px rgba(229, 160, 0, 0.35), var(--kt-shadow); }

.svc-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.svc-times { display: flex; flex-direction: column; gap: 2px; }
.svc-time { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-size: 14px; }
.svc-time i { width: 18px; text-align: center; font-size: 14px; }
.svc-time small { color: var(--kt-muted); font-size: 12px; }
.svc-time-op { font-weight: 700; color: var(--kt-primary); font-size: 16px; }
.svc-time-op i { color: var(--kt-primary); }
.svc-time-cl { color: #4b5665; }
.svc-time-cl i { color: var(--kt-accent-dark); }
.svc-date { font-size: 13px; color: var(--kt-muted); margin-bottom: 4px; }
.svc-case { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.svc-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    background: var(--kt-primary-soft);
    color: var(--kt-primary);
    padding: 2px 7px;
    border-radius: 6px;
}
.svc-case-title { font-size: 15px; }
.svc-title { font-size: 14px; color: #3c4655; margin-top: 2px; }
.svc-meta { font-size: 13px; color: var(--kt-muted); margin-top: 3px; display: flex; gap: 6px; align-items: flex-start; }
.svc-meta i { flex-shrink: 0; margin-top: 2px; }
.svc-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.flag {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600;
    background: #f1f4f8; color: #5b6774;
    padding: 3px 8px; border-radius: 999px;
}
.flag-on { background: var(--kt-success-soft); color: #10693f; }
.flag-lock { background: #eceff3; color: #6c7681; }
.flag-warn { background: var(--kt-warning-soft); color: #9a6b00; }

.svc-actions { display: flex; gap: 8px; margin-top: 10px; }
.svc-actions .btn { flex: 1; min-height: 42px; font-size: 13.5px; padding: 6px 8px; }

/* ---------- Stato servizio ---------- */

.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11.5px; font-weight: 700;
    padding: 4px 9px; border-radius: 999px;
    white-space: nowrap; flex-shrink: 0;
}
.status-badge.status-programmato { background: var(--kt-info-soft); color: #1a5da8; }
.status-badge.status-in_corso { background: var(--kt-warning-soft); color: #9a6b00; }
.status-badge.status-completato { background: var(--kt-success-soft); color: #10693f; }
.status-badge.status-annullato { background: #e8edf3; color: #55636c; }
.status-badge.status-inserita { background: var(--kt-info-soft); color: #1a5da8; }
.status-badge.status-autorizzata { background: var(--kt-success-soft); color: #10693f; }
.status-badge.status-rifiutata { background: var(--kt-danger-soft); color: #b02a33; }

/* ---------- Badge "non sincronizzato" ---------- */

.pending-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--kt-accent);
    color: #fff;
    font-size: 12px; font-weight: 700;
    padding: 3px 9px; border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(229, 160, 0, 0.4);
}
.pending-badge i { font-size: 13px; }
.pending-badge.topbar-badge { padding: 4px 9px; }
.pending-inline { color: var(--kt-accent-dark); font-size: 12px; font-weight: 700; }

/* ---------- Bottom nav ---------- */

.bottomnav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1030;
    display: flex;
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--kt-border);
    padding: 0 var(--kt-sar) var(--kt-sab) var(--kt-sal);
    box-shadow: 0 -4px 16px rgba(27, 36, 48, 0.06);
}
.bottomnav-item {
    flex: 1;
    height: var(--kt-nav-h);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--kt-muted);
    font-size: 11.5px;
    font-weight: 600;
    position: relative;
}
.bottomnav-item i { font-size: 22px; line-height: 1; transition: transform .15s ease; }
.bottomnav-item.active { color: var(--kt-primary); }
.bottomnav-item.active i { transform: translateY(-2px); }
.bottomnav-item.active::after {
    content: '';
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 28px; height: 3px; border-radius: 0 0 4px 4px;
    background: var(--kt-accent);
}
.nav-dot {
    position: absolute; top: 10px; right: calc(50% - 18px);
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--kt-accent); border: 2px solid #fff;
}

/* ---------- Toast ---------- */

.kt-toast-container {
    position: fixed;
    top: calc(var(--kt-topbar-h) + var(--kt-sat) + 8px);
    left: 12px; right: 12px;
    z-index: 1080;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.kt-toast {
    width: 100%; max-width: 480px; margin: 0 auto;
    border: none; border-radius: 12px;
    color: #fff; background: #2f3a48;
    box-shadow: var(--kt-shadow-strong);
    pointer-events: auto;
}
.kt-toast .toast-body { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.kt-toast .toast-body i { font-size: 18px; }
.kt-toast.toast-success { background: var(--kt-success); }
.kt-toast.toast-danger { background: var(--kt-danger); }
.kt-toast.toast-warning { background: var(--kt-accent); }
.kt-toast.toast-info { background: var(--kt-info); }

/* ---------- Skeleton (caricamento) ---------- */

.skeleton {
    position: relative;
    overflow: hidden;
    background: #e7ebf1;
    border-radius: 10px;
    color: transparent !important;
    min-height: 16px;
}
.skeleton::after {
    content: '';
    position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    animation: kt-shimmer 1.2s infinite;
}
.skeleton-card { height: 112px; border-radius: var(--kt-radius); margin-bottom: 10px; }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 55%; margin-bottom: 12px; }
@keyframes kt-shimmer { 100% { transform: translateX(100%); } }

/* ---------- Empty state ---------- */

.empty-state { text-align: center; padding: 40px 16px; color: var(--kt-muted); }
.empty-state-icon {
    width: 84px; height: 84px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 36px; color: var(--kt-primary);
    background: radial-gradient(circle at 35% 30%, #ffffff, var(--kt-primary-soft));
    box-shadow: inset 0 0 0 1px rgba(31, 58, 95, 0.12);
    margin-bottom: 14px;
}
.empty-state h3 { font-size: 17px; font-weight: 700; color: var(--kt-text); margin-bottom: 4px; }
.empty-state p { font-size: 14px; margin-bottom: 14px; }

/* ---------- Hero "Oggi" e KPI ---------- */

.hero {
    position: relative; overflow: hidden;
    border-radius: 18px;
    background:
        radial-gradient(420px 200px at 90% -30%, rgba(229, 160, 0, 0.35), transparent 60%),
        linear-gradient(120deg, var(--kt-primary-dark), var(--kt-primary) 60%, #2c4d78);
    color: #fff;
    padding: 18px 18px 16px;
    margin-bottom: 14px;
    box-shadow: var(--kt-shadow-strong);
}
.hero-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: #ffd86b; font-weight: 700; }
.hero-title { font-size: 22px; font-weight: 800; margin: 2px 0 8px; }
.hero-sub { font-size: 13.5px; color: rgba(255, 255, 255, 0.78); }
.hero-stats { display: flex; gap: 8px; margin-top: 12px; }
.hero-stat {
    flex: 1;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    padding: 8px 10px;
}
.hero-stat .v { font-size: 20px; font-weight: 800; line-height: 1.1; }
.hero-stat .l { font-size: 11px; color: rgba(255, 255, 255, 0.75); text-transform: uppercase; letter-spacing: 0.05em; }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.quick-action {
    background: #fff; border: 1px solid var(--kt-border); border-radius: var(--kt-radius);
    padding: 12px 6px; text-align: center; text-decoration: none; color: var(--kt-text);
    box-shadow: var(--kt-shadow); font-size: 12.5px; font-weight: 600;
    display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative;
}
.quick-action i { font-size: 22px; color: var(--kt-primary); }
.quick-action:active { background: var(--kt-primary-soft); }
.quick-action .qa-badge {
    position: absolute; top: 6px; right: 6px;
    background: var(--kt-accent); color: #fff; font-size: 11px; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

.kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi {
    background: #fff; border: 1px solid var(--kt-border); border-radius: var(--kt-radius);
    padding: 12px 14px; box-shadow: var(--kt-shadow);
}
.kpi .kpi-value { font-size: 20px; font-weight: 800; color: var(--kt-primary); line-height: 1.1; }
.kpi .kpi-label { font-size: 12px; color: var(--kt-muted); font-weight: 600; }

/* ---------- Dettaglio: info list ---------- */

.info-list { margin: 0; }
.info-list dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--kt-muted); font-weight: 700; margin-bottom: 1px; }
.info-list dd { margin-bottom: 10px; font-size: 15px; word-break: break-word; }
.info-list dd:last-child { margin-bottom: 0; }
.info-list a { word-break: break-all; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-box { background: #fff; border: 1px solid var(--kt-border); border-radius: var(--kt-radius-sm); padding: 10px 12px; }
.detail-box .dl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--kt-muted); font-weight: 700; }
.detail-box .dv { font-size: 16px; font-weight: 700; color: var(--kt-primary); }

.subtitle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 8px; }
.subtitle-row h2 { font-size: 16px; font-weight: 800; margin: 0; }

/* ---------- Timeline diario ---------- */

.timeline { position: relative; padding-left: 26px; margin: 8px 0; }
.timeline::before {
    content: '';
    position: absolute; left: 8px; top: 6px; bottom: 6px;
    width: 2px; background: #d3dbe6; border-radius: 2px;
}
.timeline-item { position: relative; margin-bottom: 14px; }
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
    position: absolute; left: -23px; top: 5px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--kt-primary); border: 2px solid #fff;
    box-shadow: 0 0 0 2px #d3dbe6;
}
.timeline-item.is-pending .timeline-dot { background: var(--kt-accent); }
.timeline-time { font-weight: 800; font-size: 14px; color: var(--kt-primary); font-variant-numeric: tabular-nums; }
.timeline-text { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.timeline-text a { word-break: break-all; }
.timeline-link { font-size: 13px; margin-top: 3px; display: inline-flex; align-items: center; gap: 4px; }
.timeline-actions { display: flex; gap: 6px; margin-top: 6px; }
.timeline-actions .btn { min-height: 34px; font-size: 12.5px; padding: 2px 10px; }

/* ---------- Rimborsi ---------- */

.expense-row {
    display: flex; align-items: center; gap: 12px;
    background: #fff; border: 1px solid var(--kt-border); border-radius: var(--kt-radius-sm);
    padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--kt-shadow);
}
.expense-icon {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    background: var(--kt-primary-soft); color: var(--kt-primary);
    display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
}
.expense-main { flex: 1; min-width: 0; }
.expense-cat { font-weight: 700; font-size: 14px; }
.expense-note { font-size: 12.5px; color: var(--kt-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-amount { font-weight: 800; font-size: 16px; color: var(--kt-primary); white-space: nowrap; }
.receipt-preview { max-width: 100%; max-height: 220px; border-radius: 10px; border: 1px solid var(--kt-border); }

/* ---------- Veicolo e marker GPS ---------- */

.vehicle-stage {
    position: relative;
    background: #fff;
    border: 1px solid var(--kt-border);
    border-radius: var(--kt-radius);
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.vehicle-stage img, .vehicle-stage svg { display: block; width: 100%; height: auto; pointer-events: none; }
.marker-layer { position: absolute; inset: 0; cursor: crosshair; }
.marker-x {
    position: absolute;
    transform: translate(-50%, -50%);
    color: var(--kt-danger);
    font-size: 30px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 0 3px #fff, 0 0 6px #fff;
    pointer-events: none;
    animation: kt-pop .2s ease-out;
}
.marker-x.is-old { color: #a5adb8; font-size: 22px; opacity: 0.7; animation: none; }
.marker-x .marker-label {
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    font-size: 10px; font-weight: 700; color: #3c4655; background: rgba(255, 255, 255, 0.9);
    padding: 1px 5px; border-radius: 4px; white-space: nowrap;
}
@keyframes kt-pop { from { transform: translate(-50%, -50%) scale(0.4); } to { transform: translate(-50%, -50%) scale(1); } }
.view-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.view-tabs .btn { white-space: nowrap; min-height: 38px; font-size: 13px; }

/* ---------- Login ---------- */

.login-screen { max-width: 420px; margin: 0 auto; padding-top: 12px; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand img { border-radius: 18px; box-shadow: var(--kt-shadow-strong); }
.login-brand h2 { font-size: 24px; font-weight: 800; margin: 14px 0 2px; color: var(--kt-primary); }
.login-card {
    background: #fff; border: 1px solid var(--kt-border);
    border-radius: 18px; padding: 22px 18px;
    box-shadow: var(--kt-shadow);
}
.login-footer { text-align: center; margin-top: 18px; }

/* ---------- Profilo ---------- */

.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar {
    width: 58px; height: 58px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #2d5385, var(--kt-primary-dark));
    color: #fff; font-weight: 800; font-size: 20px;
    box-shadow: 0 6px 14px rgba(31, 58, 95, 0.3);
}
.profile-name { font-size: 18px; font-weight: 800; line-height: 1.2; }
.profile-mail { font-size: 13px; color: var(--kt-muted); word-break: break-all; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--kt-border); font-size: 14px; }
.status-row:last-child { border-bottom: none; }
.status-row .k { color: var(--kt-muted); }
.status-row .v { font-weight: 600; text-align: right; }
.outbox-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--kt-border); }
.outbox-item:last-child { border-bottom: none; }
.outbox-item .oi-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--kt-accent-soft); color: var(--kt-accent-dark); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.outbox-item.has-error .oi-icon { background: var(--kt-danger-soft); color: var(--kt-danger); }
.outbox-item .oi-main { flex: 1; min-width: 0; font-size: 13.5px; }
.outbox-item .oi-error { color: var(--kt-danger); font-size: 12.5px; margin-top: 2px; }
.outbox-item .btn { min-height: 36px; }

/* ---------- Notifiche ---------- */

.notif-item {
    display: flex; gap: 12px; align-items: flex-start;
    background: #fff; border: 1px solid var(--kt-border); border-radius: var(--kt-radius);
    padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--kt-shadow);
    text-decoration: none; color: var(--kt-text);
}
.notif-item:active { background: var(--kt-primary-soft); }
.notif-icon {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
    background: var(--kt-primary-soft); color: var(--kt-primary);
}
.notif-icon.n-warning { background: var(--kt-warning-soft); color: var(--kt-accent-dark); }
.notif-icon.n-info { background: var(--kt-info-soft); color: #1a5da8; }
.notif-icon.n-success { background: var(--kt-success-soft); color: #10693f; }
.notif-main { flex: 1; min-width: 0; }
.notif-title { font-weight: 700; font-size: 14.5px; }
.notif-body { font-size: 13.5px; color: #3c4655; }
.notif-date { font-size: 12px; color: var(--kt-muted); margin-top: 2px; }

/* ---------- Varie ---------- */

.sticky-actions {
    position: sticky;
    bottom: calc(var(--kt-nav-h) + var(--kt-sab) + 8px);
    display: flex; gap: 8px;
    padding: 8px 0;
    background: linear-gradient(to top, var(--kt-bg) 70%, transparent);
    z-index: 4;
}
.sticky-actions .btn { flex: 1; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #fff; border: 1px solid var(--kt-border); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.divider { height: 1px; background: var(--kt-border); margin: 14px 0; }
.text-small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.fade-in { animation: kt-fade .22s ease-out; }
@keyframes kt-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.readonly-note { font-size: 13px; color: var(--kt-muted); display: flex; gap: 6px; align-items: center; }

@media (min-width: 576px) {
    .quick-actions { grid-template-columns: repeat(4, 1fr); }
    .kpi-row { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
