:root {
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-success: #059669;
    --bs-success-rgb: 5, 150, 105;
    --bs-danger: #e11d48;
    --bs-danger-rgb: 225, 29, 72;
    --bs-warning: #d97706;
    --bs-warning-rgb: 217, 119, 6;
    --bs-info: #0891b2;
    --bs-info-rgb: 8, 145, 178;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-bg: #f6f7fb;
    --bs-border-radius: 0.6rem;
    --bs-border-radius-sm: 0.45rem;
    --bs-border-radius-lg: 0.85rem;

    --sidebar-bg: #12131c;
    --sidebar-bg-hover: #1d1f2c;
    --sidebar-text: #9297ab;
    --sidebar-text-active: #ffffff;
}

body {
    background-color: var(--bs-body-bg);
    letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, .navbar-brand {
    letter-spacing: -0.02em;
}

.btn {
    font-weight: 500;
    letter-spacing: -0.01em;
}

.btn-primary {
    --bs-btn-hover-bg: #4338ca;
    --bs-btn-hover-border-color: #4338ca;
    --bs-btn-active-bg: #3730a3;
    --bs-btn-active-border-color: #3730a3;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}

.card {
    border: 1px solid rgba(17, 24, 39, 0.06);
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04);
}

/* ---- Sidebar ---- */
.app-sidebar {
    background: var(--sidebar-bg);
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-sidebar .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--bs-primary), #818cf8);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.05rem;
}

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--sidebar-text);
    padding: 0.55rem 0.75rem;
    border-radius: var(--bs-border-radius-sm);
    font-size: 0.925rem;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}

.app-sidebar .nav-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
}

.app-sidebar .nav-link:hover {
    background: var(--sidebar-bg-hover);
    color: #e5e7eb;
}

.app-sidebar .nav-link.active {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
    box-shadow: inset 3px 0 0 var(--bs-primary);
}

.app-sidebar .nav-section-label {
    color: #565a6e;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
}

/* ---- Stat tiles ---- */
.stat-tile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-tile .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--bs-border-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-tile .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-tile .stat-label {
    color: #6b7280;
    font-size: 0.85rem;
}

/* ---- Tables ---- */
.table-card {
    background: #fff;
    border: 1px solid rgba(17, 24, 39, 0.06);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04);
    overflow: hidden;
}

.table-card table {
    margin-bottom: 0;
}

.table-card thead th {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: #6b7280;
    border-bottom-width: 1px;
    background: #fafafc;
    white-space: nowrap;
}

.table-card tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.035);
}

.table-card thead th a {
    color: inherit;
    text-decoration: none;
}

.table-card thead th a:hover {
    color: var(--bs-primary);
}

.table-card td, .table-card th {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

/* ---- Badges ---- */
.badge.rounded-pill {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.4em 0.75em;
}

/* Bootstrap calcola il colore del testo di .text-bg-* in fase di compilazione,
   sui colori originali del tema: con --bs-info/--bs-warning rese più scure va
   forzato il testo bianco per restare leggibili. */
.text-bg-info,
.text-bg-warning {
    color: #fff !important;
}

/* ---- Timeline (dettaglio email) ---- */
.timeline-item {
    display: flex;
    gap: 0.85rem;
}

.timeline-item .timeline-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.timeline-item .timeline-line {
    width: 2px;
    flex: 1;
    background: #e5e7eb;
    margin: 0.25rem 0;
}

/* ---- Empty states ---- */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: #9ca3af;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* ---- Login ---- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(79, 70, 229, 0.16), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(8, 145, 178, 0.14), transparent 45%),
        var(--bs-body-bg);
}
