:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f5f6fa;
    color: #333;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1e2a3a;
    --sidebar-text: #c8d3e0;
    --sidebar-active-bg: rgba(255,255,255,0.10);
    --sidebar-active-text: #ffffff;
    --sidebar-hover-bg: rgba(255,255,255,0.06);
    --topbar-height: 56px;
}

.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.25s ease;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.sidebar-brand i { font-size: 1.4rem; color: #4d9ef5; }
.sidebar-logo { max-height: 40px; width: auto; object-fit: contain; }
.sidebar-logo-subtitle { font-size: 10px; font-weight: 400; color: rgba(255,255,255,0.6); line-height: 1.3; }

.sidebar-close {
    background: none; border: none;
    color: var(--sidebar-text);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.sidebar-close:hover { color: #fff; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-menu {
    list-style: none;
    margin: 0; padding: 0;
}

.sidebar-section-label {
    padding: 16px 18px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(200,211,224,0.45);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: #fff;
}
.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0;
    width: 3px; height: 100%;
    background: #4d9ef5;
    border-radius: 0 2px 2px 0;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 12px 14px;
    flex-shrink: 0;
}


.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: #4d9ef5;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    color: var(--sidebar-text);
    font-size: 0.72rem;
    text-transform: capitalize;
}

.sidebar-logout {
    color: var(--sidebar-text);
    font-size: 1.1rem;
    text-decoration: none;
    padding: 4px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.sidebar-logout:hover { color: #ff6b6b; }

/* ── Topbar mobile ──────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.topbar-toggle {
    background: none; border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
}
.topbar-title {
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Overlay mobile ─────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ── Main content ───────────────────────────────────────────────── */
.main-content { min-height: 100vh; background: #f5f6fa; }
.main-footer { text-align: center; padding: 16px; font-size: 12px; color: #adb5bd; border-top: 1px solid #e9ecef; margin-top: 24px; }
.main-content.with-sidebar {
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
}

.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.commesse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.commessa-card { transition: transform 0.2s, box-shadow 0.2s; }
.commessa-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

.loader-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px; height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.badge.stato-da_iniziare { background-color: #6c757d; }
.badge.stato-in_corso { background-color: #0d6efd; }
.badge.stato-completata { background-color: #198754; }
.badge.stato-sospesa { background-color: #ffc107; color: #333; }

.nav-link.active { font-weight: 600; }

.table td, .table th { vertical-align: middle; }
