/* ============================================================
   Kontrol — Design System
   Sidebar scura, header in vetro, card morbide, KPI scenografiche.
   ============================================================ */

:root {
    --kt-primary: #1f3a5f;
    --kt-primary-dark: #16293f;
    --kt-primary-deep: #0e1b2a;
    --kt-primary-light: #2f5788;
    --kt-primary-bright: #3f74b3;
    --kt-primary-soft: #e8eef6;
    --kt-accent: #e5a000;
    --kt-accent-soft: #fdf3dc;
    --kt-page: #eef2f6;
    --kt-card: #ffffff;
    --kt-text: #16212a;
    --kt-muted: #64727b;
    --kt-border: #dfe6ec;
    --kt-success: #198754;
    --kt-warning: #e5a000;
    --kt-danger: #d83b45;
    --kt-info: #2477d4;
    --kt-sidebar-width: 264px;
    --kt-radius-sm: 10px;
    --kt-radius-md: 16px;
    --kt-radius-lg: 22px;
    --kt-font-display: Sora, Inter, system-ui, sans-serif;
    --kt-shadow-soft: 0 10px 30px rgba(22, 33, 42, .06), 0 2px 8px rgba(22, 33, 42, .04);
    --kt-shadow-hover: 0 20px 46px rgba(31, 58, 95, .16), 0 6px 14px rgba(22, 33, 42, .07);
}

body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    background:
        radial-gradient(1100px 560px at 92% -12%, rgba(47, 87, 136, .10), transparent 60%),
        radial-gradient(1000px 560px at -12% 112%, rgba(229, 160, 0, .08), transparent 60%),
        var(--kt-page);
    background-attachment: fixed;
    color: var(--kt-text);
    font-size: 14.5px;
    line-height: 1.55;
}

h1, h2, h3, h4, h5, .page-title, .kpi-value, .modal-title, .stat-value { font-family: var(--kt-font-display); }
::selection { background: var(--kt-primary); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3cfd8; border-radius: 8px; border: 2px solid var(--kt-page); }
::-webkit-scrollbar-thumb:hover { background: #a5b4c0; }

/* ---------- Shell ---------- */

.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--kt-sidebar-width); }
.app-content { flex: 1; padding: 22px 26px 40px; }
.app-footer { padding: 14px 26px 22px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 991.98px) {
    .app-main { margin-left: 0; }
    .app-content { padding: 16px 14px 34px; }
}

/* ---------- Sidebar ---------- */

.app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--kt-sidebar-width);
    background: linear-gradient(178deg, var(--kt-primary-dark) 0%, var(--kt-primary-deep) 100%);
    color: #cfd9e4; display: flex; flex-direction: column; z-index: 1040;
    box-shadow: 4px 0 24px rgba(14, 27, 42, .18);
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 11px; padding: 20px 20px 16px;
    color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand .brand-mark {
    width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
    background: linear-gradient(140deg, var(--kt-primary-bright), var(--kt-accent));
    font-family: var(--kt-font-display); font-weight: 800; font-size: 18px; color: #0e1b2a;
}
.sidebar-brand .brand-name { font-family: var(--kt-font-display); font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.sidebar-brand .brand-sub { font-size: 11px; color: #8ea3ba; letter-spacing: .06em; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px 8px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-color: transparent; }
.nav-section { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #6f849c; padding: 14px 10px 6px; font-weight: 700; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin-bottom: 2px;
    color: #cfd9e4; border-radius: var(--kt-radius-sm); font-weight: 500; font-size: 14px;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar-nav .nav-link i { font-size: 17px; width: 20px; text-align: center; opacity: .85; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.sidebar-nav .nav-link.active { background: linear-gradient(100deg, var(--kt-primary-light), rgba(47, 87, 136, .35)); color: #fff; box-shadow: inset 3px 0 0 var(--kt-accent); }
.sidebar-nav .nav-link .badge { margin-left: auto; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--kt-radius-sm); background: rgba(255, 255, 255, .05); }
.sidebar-user .user-avatar { background: linear-gradient(140deg, var(--kt-primary-bright), var(--kt-accent)); color: #0e1b2a; }
.sidebar-user .u-name { color: #fff; font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.sidebar-user .u-role { color: #8ea3ba; font-size: 11.5px; }
.sidebar-pwa { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 9px 10px; border-radius: var(--kt-radius-sm); color: #cfd9e4; text-decoration: none; font-size: 13px; border: 1px dashed rgba(255, 255, 255, .18); }
.sidebar-pwa:hover { color: #fff; background: rgba(255, 255, 255, .06); }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(14, 27, 42, .5); z-index: 1035; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
}

/* ---------- Header ---------- */

.app-header {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 12px;
    padding: 11px 26px; background: rgba(255, 255, 255, .82); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--kt-border);
}
@media (max-width: 991.98px) { .app-header { padding: 10px 14px; } }
.sidebar-toggle { color: var(--kt-primary); padding: 2px 6px; }
.header-search { min-width: 340px; }
.header-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--kt-muted); font-size: 14px; }
.header-search .form-control { padding-left: 34px; border-radius: 999px; background: #f4f7fa; }
.search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: #fff; z-index: 1060;
    border: 1px solid var(--kt-border); border-radius: var(--kt-radius-md); box-shadow: var(--kt-shadow-hover);
    max-height: 60vh; overflow-y: auto; padding: 6px;
}
.search-results .sr-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--kt-muted); font-weight: 700; padding: 8px 10px 4px; }
.search-results a { display: block; padding: 7px 10px; border-radius: 9px; color: var(--kt-text); text-decoration: none; font-size: 13.5px; }
.search-results a:hover { background: var(--kt-primary-soft); color: var(--kt-primary); }

.user-avatar { width: 32px; height: 32px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--kt-primary); color: #fff; font-weight: 700; font-size: 12.5px; flex: 0 0 auto; }
.user-menu { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .7); border: 1px solid var(--kt-border); border-radius: 999px; padding: 3px 12px 3px 4px; }

/* ---------- Page header ---------- */

.page-header { margin-bottom: 22px; }
.page-title { font-size: 25px; font-weight: 700; letter-spacing: -.015em; }
.breadcrumb { font-size: 12.5px; margin-bottom: 2px; }
.breadcrumb-item + .breadcrumb-item::before { content: "›"; }

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

.card { border: 1px solid var(--kt-border); border-radius: var(--kt-radius-md); box-shadow: var(--kt-shadow-soft); background: var(--kt-card); }
.card-header { background: transparent; border-bottom: 1px solid var(--kt-border); padding: 14px 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-header h2, .card-header h3, .card-header .card-title { font-size: 16px; margin: 0; font-weight: 700; }
.card-body { padding: 18px; }
.card-hover { transition: transform .16s ease, box-shadow .16s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--kt-shadow-hover); }

/* ---------- KPI ---------- */

.kpi-card {
    position: relative; overflow: hidden; padding: 18px 18px 16px; border-radius: var(--kt-radius-md);
    background: var(--kt-card); border: 1px solid var(--kt-border); box-shadow: var(--kt-shadow-soft);
    color: var(--kt-text); transition: transform .16s ease, box-shadow .16s ease;
}
a.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--kt-shadow-hover); color: var(--kt-text); }
.kpi-card::after { content: ""; position: absolute; inset: auto -30px -40px auto; width: 130px; height: 130px; border-radius: 50%; opacity: .1; background: var(--kt-primary); }
.kpi-value { font-size: 27px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.kpi-value .kpi-suffix { font-size: 15px; font-weight: 600; color: var(--kt-muted); margin-left: 3px; }
.kpi-title { font-size: 12.5px; color: var(--kt-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }
.kpi-hint { font-size: 12px; color: var(--kt-muted); margin-top: 6px; }
.kpi-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; position: relative; z-index: 1; }
.kpi-primary .kpi-icon { background: var(--kt-primary-soft); color: var(--kt-primary); }
.kpi-primary::after { background: var(--kt-primary); }
.kpi-success .kpi-icon { background: #ddf2e6; color: #10693f; }
.kpi-success::after { background: var(--kt-success); }
.kpi-warning .kpi-icon { background: var(--kt-accent-soft); color: #9a6c00; }
.kpi-warning::after { background: var(--kt-warning); }
.kpi-danger .kpi-icon { background: #fbe2e4; color: #b02a33; }
.kpi-danger::after { background: var(--kt-danger); }
.kpi-info .kpi-icon { background: #e2eefb; color: #1b5da8; }
.kpi-info::after { background: var(--kt-info); }

/* ---------- Bottoni ---------- */

.btn { border-radius: 11px; font-weight: 600; transition: all .16s ease; }
.btn-sm { border-radius: 9px; }
.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);
    background-image: linear-gradient(135deg, var(--kt-primary-light), var(--kt-primary-dark));
    border: none; box-shadow: 0 6px 16px rgba(31, 58, 95, .26);
}
.btn-primary:hover { background-image: linear-gradient(135deg, #3a6aa3, var(--kt-primary-deep)); transform: translateY(-1px); box-shadow: 0 10px 22px rgba(31, 58, 95, .34); }
.btn-primary:active { transform: translateY(0); }
.btn-glow { box-shadow: 0 10px 26px rgba(31, 58, 95, .38); }
.btn-warning { --bs-btn-bg: var(--kt-accent); --bs-btn-border-color: var(--kt-accent); --bs-btn-color: #3d2c00; --bs-btn-hover-bg: #cc8f00; --bs-btn-hover-border-color: #cc8f00; --bs-btn-hover-color: #3d2c00; }
.btn-outline-primary { --bs-btn-color: var(--kt-primary); --bs-btn-border-color: #bcccdf; --bs-btn-hover-bg: var(--kt-primary); --bs-btn-hover-border-color: var(--kt-primary); background: rgba(255, 255, 255, .7); }
.btn-outline-secondary { background: rgba(255, 255, 255, .7); border-color: var(--kt-border); }
.btn-outline-primary:hover, .btn-outline-secondary:hover { transform: translateY(-1px); }
a { color: var(--kt-primary-light); text-decoration: none; }
a:hover { color: var(--kt-primary); text-decoration: underline; }
.text-primary { color: var(--kt-primary) !important; }
.bg-primary { background-color: var(--kt-primary) !important; }

/* ---------- Form ---------- */

.form-control, .form-select { border-radius: 11px; border-color: var(--kt-border); background-color: #fbfcfe; }
.form-control:focus, .form-select:focus { border-color: var(--kt-primary-light); background-color: #fff; box-shadow: 0 0 0 .22rem rgba(47, 87, 136, .13); }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: .3rem; }
.form-text { font-size: 12px; }
.form-check-input:checked { background-color: var(--kt-primary); border-color: var(--kt-primary); }
.input-icon-group { position: relative; }
.input-icon-group > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--kt-muted); font-size: 15px; pointer-events: none; }
.input-icon-group > .form-control { padding-left: 38px; }
.input-group-text { border-radius: 11px; background: #f2f5f9; border-color: var(--kt-border); font-size: 13px; }

/* ---------- Badge ---------- */

.badge { border-radius: 8px; font-weight: 600; letter-spacing: .01em; padding: .38em .62em; }
.badge.rounded-pill { border-radius: 999px; }
.badge.text-bg-success { background: #ddf2e6 !important; color: #10693f !important; }
.badge.text-bg-danger { background: #fbe2e4 !important; color: #b02a33 !important; }
.badge.text-bg-warning { background: var(--kt-accent-soft) !important; color: #8a6100 !important; }
.badge.text-bg-info { background: #e2eefb !important; color: #1b5da8 !important; }
.badge.text-bg-primary { background: var(--kt-primary-soft) !important; color: var(--kt-primary) !important; }
.badge.text-bg-secondary { background: #eceff3 !important; color: #566270 !important; }
.badge.text-bg-dark { background: #dfe4ea !important; color: #2c3742 !important; }

/* ---------- Tabelle ---------- */

.table { --bs-table-hover-bg: #f6f9fc; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .68rem .7rem; }
.table > thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--kt-muted); font-weight: 700; border-bottom: 1px solid var(--kt-border); background: #f8fafc; white-space: nowrap; }
.table td { vertical-align: middle; border-color: #eef2f6; }
.table-responsive { border-radius: var(--kt-radius-sm); }
div.dt-container .dt-search input, div.dt-container .dt-length select { border-radius: 9px; border: 1px solid var(--kt-border); padding: .28rem .6rem; }
div.dt-container .dt-paging .dt-paging-button.current { background: var(--kt-primary) !important; border-color: var(--kt-primary) !important; color: #fff !important; border-radius: 8px; }
div.dt-container .dt-paging .dt-paging-button { border-radius: 8px; }
div.dt-container .dt-info, div.dt-container .dt-length label, div.dt-container .dt-search label { font-size: 12.5px; color: var(--kt-muted); }

/* ---------- Select2 ---------- */

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple { border-radius: 11px; border-color: var(--kt-border); min-height: 38px; background-color: #fbfcfe; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 36px; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default .select2-selection--single:focus { border-color: var(--kt-primary-light); }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--kt-primary); }
.select2-dropdown { border-color: var(--kt-border); border-radius: 11px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice { background: var(--kt-primary-soft); border-color: #c7d6e6; color: var(--kt-primary); border-radius: 7px; }

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

.empty-state { text-align: center; padding: 42px 20px; }
.empty-state .es-icon { width: 78px; height: 78px; border-radius: 26px; display: inline-grid; place-items: center; font-size: 34px; background: var(--kt-primary-soft); color: var(--kt-primary-light); margin-bottom: 14px; }
.empty-state h4 { font-size: 17px; font-weight: 700; margin-bottom: 5px; }
.empty-state p { color: var(--kt-muted); max-width: 420px; margin: 0 auto 16px; font-size: 13.5px; }

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

.kt-timeline { position: relative; padding-left: 28px; }
.kt-timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--kt-primary-light), var(--kt-border)); border-radius: 2px; }
.kt-timeline .tl-item { position: relative; padding-bottom: 16px; }
.kt-timeline .tl-item::before { content: ""; position: absolute; left: -24px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--kt-primary-light); }
.kt-timeline .tl-time { font-family: var(--kt-font-display); font-weight: 700; font-size: 13px; color: var(--kt-primary); }
.kt-timeline .tl-text { font-size: 13.8px; white-space: pre-wrap; }

/* ---------- Giornate / diario ---------- */

.kt-day-card { border: 1px solid var(--kt-border); border-radius: var(--kt-radius-md); background: #fff; box-shadow: var(--kt-shadow-soft); overflow: hidden; margin-bottom: 16px; }
.kt-day-card .day-head { padding: 12px 16px; background: linear-gradient(100deg, var(--kt-primary-soft), #fff); border-bottom: 1px solid var(--kt-border); display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.kt-day-card .day-date { font-family: var(--kt-font-display); font-weight: 700; font-size: 15px; }
.kt-day-card .day-body { padding: 14px 16px; }
.kt-stat { display: flex; flex-direction: column; }
.kt-stat .s-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--kt-muted); font-weight: 700; }
.kt-stat .s-value { font-family: var(--kt-font-display); font-weight: 700; font-size: 15px; }

/* ---------- Riepilogo economico ---------- */

.kt-summary { border-radius: var(--kt-radius-md); border: 1px solid var(--kt-border); overflow: hidden; }
.kt-summary .row-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 16px; border-bottom: 1px solid #eef2f6; font-size: 14px; }
.kt-summary .row-line:last-child { border-bottom: none; }
.kt-summary .row-line.subtotal { background: #f7f9fc; font-weight: 700; }
.kt-summary .row-line.total { background: var(--kt-primary); color: #fff; font-weight: 700; font-size: 16px; }
.kt-summary .row-line.balance { background: var(--kt-accent-soft); font-weight: 700; font-size: 16px; }
.kt-summary .row-line .val { font-family: var(--kt-font-display); font-variant-numeric: tabular-nums; }

/* ---------- Marker veicolo ---------- */

.kt-marker-layer { position: relative; }

/* ---------- Utility ---------- */

.text-muted { color: var(--kt-muted) !important; }
.fs-tiny { font-size: 11.5px; }
.fs-sm { font-size: 12.8px; }
.mono { font-variant-numeric: tabular-nums; }
.cursor-pointer { cursor: pointer; }
.dashboard-card { will-change: transform, opacity; }
.nav-tabs { border-bottom: 1px solid var(--kt-border); gap: 2px; }
.nav-tabs .nav-link { border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--kt-muted); font-weight: 600; font-size: 13.8px; padding: 9px 14px; }
.nav-tabs .nav-link:hover { border-bottom-color: #c7d6e6; color: var(--kt-primary); }
.nav-tabs .nav-link.active { color: var(--kt-primary); border-bottom-color: var(--kt-primary); background: transparent; }
.nav-pills .nav-link { border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--kt-muted); padding: 6px 12px; }
.nav-pills .nav-link.active { background: var(--kt-primary); color: #fff; }
.modal-content { border: none; border-radius: var(--kt-radius-lg); box-shadow: 0 30px 70px rgba(14, 27, 42, .28); }
.modal-header { border-bottom: 1px solid var(--kt-border); padding: 16px 20px; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--kt-border); padding: 14px 20px; }
.offcanvas { border-left: none; }
.alert { border-radius: var(--kt-radius-sm); border: none; font-size: 13.8px; }
.alert-info { background: #e2eefb; color: #1b5da8; }
.alert-warning { background: var(--kt-accent-soft); color: #8a6100; }
.alert-success { background: #ddf2e6; color: #10693f; }
.alert-danger { background: #fbe2e4; color: #b02a33; }
.spinner-pad { padding: 40px; text-align: center; color: var(--kt-muted); }

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

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: radial-gradient(1000px 600px at 20% 10%, rgba(47, 87, 136, .35), transparent 60%), linear-gradient(160deg, #16293f, #0e1b2a 70%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: var(--kt-radius-lg); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); padding: 34px 32px; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: linear-gradient(140deg, var(--kt-primary-light), var(--kt-accent)); font-family: var(--kt-font-display); font-weight: 800; font-size: 22px; color: #0e1b2a; }
.auth-foot { text-align: center; color: rgba(255, 255, 255, .55); font-size: 12.5px; margin-top: 18px; }

/* ---------- Stampa ---------- */

@media print {
    .app-sidebar, .app-header, .app-footer, .page-actions, .btn, .no-print { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ccc; }
}
