/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    /* Primary palette - sophisticated indigo/slate */
    --primary: #4f46e5; --primary-light: #6366f1; --primary-dark: #3730a3;
    --primary-50: #eef2ff; --primary-100: #e0e7ff; --primary-200: #c7d2fe;
    --primary-600: #4f46e5; --primary-700: #4338ca; --primary-800: #3730a3;

    /* Accent */
    --accent: #6366f1; --accent-light: #818cf8;

    /* Semantic */
    --success: #059669; --success-light: #d1fae5; --success-bg: #ecfdf5; --success-600: #059669;
    --warning: #d97706; --warning-light: #fef3c7; --warning-bg: #fffbeb;
    --danger: #dc2626; --danger-light: #fee2e2; --danger-bg: #fef2f2;
    --info: #0891b2; --info-light: #cffafe; --info-bg: #ecfeff;

    /* Neutrals */
    --gray-25: #fcfcfd; --gray-50: #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
    --gray-300: #cbd5e1; --gray-400: #94a3b8; --gray-500: #64748b; --gray-600: #475569;
    --gray-700: #334155; --gray-800: #1e293b; --gray-900: #0f172a; --gray-950: #020617;

    /* Sidebar */
    --sidebar-bg: #0f172a; --sidebar-w: 272px; --sidebar-collapsed: 72px;

    /* Layout */
    --header-h: 68px; --radius: 14px; --radius-sm: 10px; --radius-xs: 8px; --radius-2xl: 20px;

    /* Shadows - layered for depth */
    --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 2px 4px rgba(0,0,0,.04), 0 4px 6px rgba(0,0,0,.03);
    --shadow-md: 0 4px 8px -2px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.04);
    --shadow-lg: 0 12px 24px -4px rgba(0,0,0,.08), 0 4px 8px -2px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 40px -8px rgba(0,0,0,.12), 0 8px 16px -4px rgba(0,0,0,.06);
    --shadow-2xl: 0 32px 64px -12px rgba(0,0,0,.14);
    --shadow-card: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.02);
    --shadow-card-hover: 0 8px 25px -5px rgba(0,0,0,.08), 0 4px 10px -3px rgba(0,0,0,.04);

    /* Transitions */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --transition: .2s var(--ease);
    --transition-slow: .35s var(--ease);
}

html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--gray-50); color: var(--gray-800); display: flex; min-height: 100vh; overflow-x: hidden; line-height: 1.6; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w); height: 100vh; position: fixed; left: 0; top: 0; z-index: 100;
    background: var(--sidebar-bg);
    display: flex; flex-direction: column; transition: width .3s var(--ease);
    border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text-wrap, .sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-details, .sidebar.collapsed .nav-section-label, .sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 20px 0; }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; margin: 2px 10px; }
.sidebar.collapsed .nav-item i { margin: 0; font-size: 1.15rem; }
.sidebar.collapsed .sidebar-footer { padding: 16px 0; justify-content: center; }
.sidebar.collapsed .user-info { justify-content: center; }

.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 24px 22px 20px; }
.logo { display: flex; align-items: center; gap: 14px; }
.logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
    border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff;
    box-shadow: 0 4px 12px rgba(79,70,229,.4);
}
.logo-text-wrap { display: flex; flex-direction: column; }
.logo-text { color: #fff; font-size: 1.2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; }
.logo-edition { color: var(--gray-400); font-size: .65rem; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; }
.sidebar-toggle { background: none; border: none; color: var(--gray-500); cursor: pointer; padding: 8px; border-radius: var(--radius-xs); transition: var(--transition); }
.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,.08); }

.sidebar-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-section-label { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--gray-500); padding: 20px 14px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: var(--gray-400);
    text-decoration: none; border-radius: var(--radius-xs); margin-bottom: 2px; transition: all .2s var(--ease);
    font-weight: 500; font-size: .9rem; white-space: nowrap; position: relative;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); box-shadow: 0 4px 12px rgba(79,70,229,.35); }
.nav-item i { width: 20px; text-align: center; font-size: .95rem; flex-shrink: 0; }
.nav-badge {
    margin-left: auto; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    padding: 0 6px;
}
.nav-badge:empty { display: none; }

.sidebar-footer { padding: 20px 16px; border-top: 1px solid rgba(255,255,255,.06); }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-avatar-sidebar {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; }
.user-name { color: #fff; font-weight: 600; font-size: .85rem; }
.user-role { color: var(--gray-500); font-size: .72rem; }

/* ===== MAIN ===== */
.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; transition: margin-left .3s var(--ease); }
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

/* ===== HEADER ===== */
.top-header {
    height: var(--header-h); background: rgba(255,255,255,.8); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px; position: sticky; top: 0; z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.2rem; color: var(--gray-600); cursor: pointer; }
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--gray-400); font-size: .85rem; }
.breadcrumb .separator { font-size: .6rem; }
.bc-home { cursor: pointer; transition: var(--transition); }
.bc-home:hover { color: var(--primary); }
#breadcrumbPage { color: var(--gray-800); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-search {
    display: flex; align-items: center; gap: 10px; background: var(--gray-100);
    padding: 8px 16px; border-radius: 12px; border: 1px solid transparent; transition: var(--transition);
}
.header-search:focus-within { border-color: var(--primary-200); background: #fff; box-shadow: 0 0 0 4px rgba(79,70,229,.08); }
.header-search i { color: var(--gray-400); font-size: .85rem; }
.header-search input { border: none; background: none; outline: none; font-family: inherit; font-size: .85rem; width: 200px; color: var(--gray-700); }
.header-search kbd { font-family: inherit; font-size: .7rem; color: var(--gray-400); background: var(--gray-200); padding: 2px 6px; border-radius: 4px; }
.header-btn {
    position: relative; background: none; border: none; width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; color: var(--gray-500); cursor: pointer; transition: var(--transition);
}
.header-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.badge-dot {
    position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger); border: 2px solid #fff; display: none;
}
.badge-dot.active { display: block; animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); } 50% { box-shadow: 0 0 0 6px rgba(220,38,38,0); } }
.header-divider { width: 1px; height: 24px; background: var(--gray-200); }
.header-date { color: var(--gray-500); font-size: .85rem; display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* ===== PAGE CONTENT ===== */
.page-content { padding: 32px; }
.page-header { margin-bottom: 28px; }
.page-title { font-size: 1.7rem; font-weight: 800; color: var(--gray-900); letter-spacing: -.03em; line-height: 1.2; }
.page-subtitle { color: var(--gray-500); font-size: .9rem; margin-top: 4px; }

/* ===== CARDS ===== */
.card {
    background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-100);
    box-shadow: var(--shadow-card); transition: all .25s var(--ease); overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-card-hover); }
.card-header {
    padding: 20px 24px; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: .95rem; font-weight: 700; color: var(--gray-800); display: flex; align-items: center; gap: 10px; }
.card-header h3 .card-icon { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: .8rem; }
.card-body { padding: 24px; }

/* ===== KPI CARDS ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 28px; }
.kpi-card {
    background: #fff; border-radius: var(--radius); padding: 24px;
    border: 1px solid var(--gray-100);
    display: flex; align-items: flex-start; justify-content: space-between;
    box-shadow: var(--shadow-card); transition: all .3s var(--ease);
    position: relative; overflow: hidden; cursor: pointer;
}
.kpi-card::after {
    content: ''; position: absolute; inset: 0; opacity: 0;
    background: linear-gradient(135deg, rgba(79,70,229,.03), rgba(99,102,241,.06));
    transition: opacity .3s var(--ease);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-card:hover::after { opacity: 1; }
.kpi-card:active { transform: translateY(-1px); }
.kpi-info { position: relative; z-index: 1; }
.kpi-info h4 { font-size: .78rem; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.kpi-value { font-size: 2rem; font-weight: 900; color: var(--gray-900); line-height: 1; letter-spacing: -.03em; }
.kpi-change { font-size: .78rem; margin-top: 10px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }
.kpi-change.neutral { color: var(--gray-500); }
.kpi-icon {
    width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0; position: relative; z-index: 1;
}
.kpi-icon.blue { background: var(--primary-50); color: var(--primary); }
.kpi-icon.green { background: var(--success-bg); color: var(--success); }
.kpi-icon.orange { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.red { background: var(--danger-bg); color: var(--danger); }
.kpi-icon.cyan { background: var(--info-bg); color: var(--info); }
.kpi-icon.purple { background: #f5f3ff; color: #7c3aed; }

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-bottom: 28px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-bottom: 28px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; margin-bottom: 28px; }

/* ===== TABLES ===== */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 14px 18px; font-size: .75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500);
    background: var(--gray-50); border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
td { padding: 14px 18px; border-bottom: 1px solid var(--gray-100); font-size: .88rem; color: var(--gray-700); transition: background .15s; }
tr { transition: background .15s; }
tbody tr:hover td { background: var(--gray-25); }
tbody tr.clickable-row { cursor: pointer; }
tbody tr.clickable-row:hover td { background: var(--primary-50); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
th.sortable::after { content: ' ↕'; font-size: .65rem; opacity: .3; }
th.sort-asc::after { content: ' ↑'; opacity: 1; color: var(--primary); }
th.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--primary); }

/* ===== BADGES & STATUS ===== */
.badge-status {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px;
    border-radius: 20px; font-size: .75rem; font-weight: 600; letter-spacing: .01em;
}
.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-status.attivo, .badge-status.active, .badge-status.approvato, .badge-status.consegnato { background: var(--success-light); color: var(--success); }
.badge-status.sospeso, .badge-status.pending, .badge-status.imminente { background: var(--warning-light); color: var(--warning); }
.badge-status.completato { background: var(--primary-100); color: var(--primary); }
.badge-status.danger, .badge-status.rifiutato, .badge-status.scaduto { background: var(--danger-light); color: var(--danger); }
.badge-status.ordinato, .badge-status.info { background: var(--info-light); color: var(--info); }
.badge-status.in-transito { background: #fef3c7; color: #b45309; }
.badge-status.ok { background: var(--success-light); color: var(--success); }

/* Animated dot for live states */
.badge-status.attivo::before { animation: pulse-dot 2s infinite; }

/* Badge count */
.badge-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 6px;
    background: var(--primary); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 11px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-xs); font-family: inherit;
    font-size: .85rem; font-weight: 600; border: none; cursor: pointer;
    transition: all .2s var(--ease); white-space: nowrap; position: relative; overflow: hidden;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(79,70,229,.35); transform: translateY(-1px); }
.btn-secondary { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; box-shadow: 0 4px 12px rgba(5,150,105,.3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }
.btn-sm { padding: 6px 14px; font-size: .8rem; border-radius: var(--radius-xs); }
.btn-xs { padding: 4px 10px; font-size: .75rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); }
.btn-group { display: flex; gap: 8px; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid var(--gray-200); border-radius: var(--radius-xs);
    font-family: inherit; font-size: .88rem; color: var(--gray-800); background: #fff; transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 4px rgba(79,70,229,.08); }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ===== FILTERS BAR ===== */
.filters-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; flex-wrap: wrap; }
.filters-bar .form-control { width: auto; min-width: 160px; padding: 9px 14px; font-size: .84rem; }
.filters-bar .search-input { position: relative; flex: 1; min-width: 200px; }
.filters-bar .search-input i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }
.filters-bar .search-input input { padding-left: 38px; }

/* ===== PROGRESS BAR ===== */
.progress-bar { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .8s var(--ease); position: relative; }
.progress-fill.blue { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.progress-fill.green { background: linear-gradient(90deg, #059669, #34d399); }
.progress-fill.orange { background: linear-gradient(90deg, #d97706, #fbbf24); }
.progress-fill.red { background: linear-gradient(90deg, #dc2626, #f87171); }
.progress-fill.purple { background: linear-gradient(90deg, #7c3aed, #a78bfa); }

/* ===== CHART CONTAINER ===== */
.chart-container { position: relative; height: 300px; }
.chart-container canvas { width: 100% !important; }
.chart-container.clickable canvas { cursor: pointer; }

/* ===== MAP ===== */
.map-container { height: 360px; border-radius: var(--radius-sm); overflow: hidden; }
.leaflet-container { height: 100%; border-radius: var(--radius-sm); }

/* ===== NOTIFICATION PANEL ===== */
.notification-panel {
    position: fixed; top: 0; right: -400px; width: 400px; height: 100vh;
    background: #fff; box-shadow: var(--shadow-2xl); z-index: 200; transition: right .35s var(--ease);
    display: flex; flex-direction: column;
}
.notification-panel.open { right: 0; }
.notif-header { padding: 24px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.notif-header h3 { font-size: 1.15rem; font-weight: 800; }
.notif-close { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 1.1rem; padding: 6px; border-radius: 8px; transition: var(--transition); }
.notif-close:hover { background: var(--gray-100); color: var(--gray-700); }
.notif-list { flex: 1; overflow-y: auto; padding: 12px; }
.notif-item { display: flex; gap: 14px; padding: 16px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); margin-bottom: 4px; }
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: var(--primary-50); border-left: 3px solid var(--primary); }
.notif-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: .85rem; }
.notif-icon.info { background: var(--primary-100); color: var(--primary); }
.notif-icon.warn { background: var(--warning-light); color: var(--warning); }
.notif-icon.err { background: var(--danger-light); color: var(--danger); }
.notif-icon.ok { background: var(--success-light); color: var(--success); }
.notif-text { flex: 1; }
.notif-text p { font-size: .85rem; color: var(--gray-700); line-height: 1.5; font-weight: 500; }
.notif-text .notif-time { font-size: .75rem; color: var(--gray-400); margin-top: 4px; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.6); z-index: 300;
    display: none; align-items: center; justify-content: center; backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff; border-radius: var(--radius-2xl); width: 92%; max-width: 720px; max-height: 88vh;
    overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-2xl);
    animation: modalIn .3s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(.96); } }
.modal-header { padding: 24px 28px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
.modal-close { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 1.1rem; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 28px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 18px 28px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== DRILL-DOWN PANEL ===== */
.drill-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 250;
    display: none; backdrop-filter: blur(4px);
}
.drill-overlay.open { display: block; }
.drill-panel {
    position: fixed; top: 0; right: -540px; width: 540px; height: 100vh;
    background: #fff; box-shadow: var(--shadow-2xl); z-index: 251;
    display: flex; flex-direction: column; transition: right .35s var(--ease);
}
.drill-overlay.open .drill-panel { right: 0; }
.drill-header { padding: 24px 28px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.drill-header h3 { font-size: 1.1rem; font-weight: 800; }
.drill-close { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 1.1rem; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.drill-close:hover { background: var(--gray-100); color: var(--gray-700); }
.drill-body { flex: 1; overflow-y: auto; padding: 28px; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 28px; right: 28px; z-index: 400; display: flex; flex-direction: column; gap: 10px; }
.toast {
    display: flex; align-items: center; gap: 12px; padding: 16px 22px;
    background: var(--gray-900); color: #fff; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xl); font-size: .88rem; font-weight: 500;
    animation: toastIn .4s var(--ease); min-width: 300px;
}
.toast.success { background: linear-gradient(135deg, #059669, #10b981); }
.toast.error { background: linear-gradient(135deg, #dc2626, #ef4444); }
.toast.warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) translateX(16px); } }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-100); margin-bottom: 24px; overflow-x: auto; }
.tab {
    padding: 12px 22px; font-size: .88rem; font-weight: 600; color: var(--gray-500);
    cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: var(--transition); white-space: nowrap;
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== DETAIL PAGE ===== */
.detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.detail-header .back-btn {
    display: flex; align-items: center; gap: 8px; color: var(--gray-500); font-size: .88rem;
    cursor: pointer; background: none; border: none; font-family: inherit; font-weight: 500;
    transition: var(--transition); padding: 8px 14px; border-radius: var(--radius-xs);
}
.detail-header .back-btn:hover { color: var(--primary); background: var(--primary-50); }
.detail-title-group h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.detail-title-group p { color: var(--gray-500); font-size: .88rem; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; }
.pagination-info { font-size: .84rem; color: var(--gray-500); font-weight: 500; }
.pagination-btns { display: flex; gap: 4px; }
.pagination-btns button {
    width: 36px; height: 36px; border: 1px solid var(--gray-200); background: #fff;
    border-radius: var(--radius-xs); font-family: inherit; font-size: .84rem; color: var(--gray-600);
    cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.pagination-btns button:hover { background: var(--gray-50); border-color: var(--gray-300); }
.pagination-btns button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-btns button:disabled { opacity: .3; cursor: not-allowed; }

/* ===== CHECKLIST ===== */
.checklist-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.checklist-item:last-child { border: none; }
.checklist-check { width: 24px; height: 24px; border: 2px solid var(--gray-300); border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: var(--transition); flex-shrink: 0; }
.checklist-check.checked { background: var(--success); border-color: var(--success); color: #fff; }
.checklist-label { font-size: .88rem; flex: 1; }
.checklist-label.checked { text-decoration: line-through; color: var(--gray-400); }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: 32px; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--gray-200); border-radius: 1px; }
.timeline-item { position: relative; padding-bottom: 24px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: ''; position: absolute; left: -25px; top: 6px; width: 12px; height: 12px;
    border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary-200);
}
.timeline-item.type-rap::before { background: var(--primary); box-shadow: 0 0 0 2px var(--primary-200); }
.timeline-item.type-tim::before { background: var(--success); box-shadow: 0 0 0 2px var(--success-light); }
.timeline-item.type-ddt::before { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-light); }
.timeline-item.type-sic::before { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-light); }
.timeline-item.type-default::before { background: var(--gray-400); box-shadow: 0 0 0 2px var(--gray-200); }
.timeline-item .tl-date { font-size: .75rem; color: var(--gray-400); margin-bottom: 4px; font-weight: 500; }
.timeline-item .tl-text { font-size: .88rem; color: var(--gray-700); line-height: 1.5; }
.timeline-item .tl-text strong { color: var(--gray-900); }

/* ===== AVATAR ===== */
.avatar {
    display: inline-flex; align-items: center; justify-content: center; border-radius: 10px;
    font-weight: 700; color: #fff; flex-shrink: 0; letter-spacing: -.02em;
}
.avatar-sm { width: 32px; height: 32px; font-size: .7rem; border-radius: 8px; }
.avatar-md { width: 42px; height: 42px; font-size: .85rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; border-radius: 14px; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.4rem; border-radius: 18px; }

/* Avatar color palette */
.avatar-1 { background: linear-gradient(135deg, #6366f1, #818cf8); }
.avatar-2 { background: linear-gradient(135deg, #ec4899, #f472b6); }
.avatar-3 { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.avatar-4 { background: linear-gradient(135deg, #10b981, #34d399); }
.avatar-5 { background: linear-gradient(135deg, #06b6d4, #22d3ee); }
.avatar-6 { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.avatar-7 { background: linear-gradient(135deg, #ef4444, #f87171); }
.avatar-8 { background: linear-gradient(135deg, #f97316, #fb923c); }

/* ===== CALENDAR GRID ===== */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-header-cell { padding: 10px; text-align: center; font-size: .75rem; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .06em; }
.calendar-cell {
    min-height: 88px; padding: 8px 10px; background: #fff; border: 1px solid var(--gray-100);
    border-radius: var(--radius-xs); font-size: .78rem; cursor: pointer; transition: var(--transition);
}
.calendar-cell:hover { border-color: var(--primary-200); background: var(--primary-50); }
.calendar-cell.other-month { background: var(--gray-50); color: var(--gray-300); cursor: default; }
.calendar-cell.other-month:hover { background: var(--gray-50); border-color: var(--gray-100); }
.calendar-cell.today { border-color: var(--primary); background: var(--primary-50); box-shadow: inset 0 0 0 1px var(--primary-200); }
.calendar-cell .day-num { font-weight: 700; margin-bottom: 6px; color: var(--gray-700); }
.calendar-cell.today .day-num { color: var(--primary); }
.calendar-cell .presence-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.presence-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; cursor: pointer; transition: transform .15s; }
.presence-dot:hover { transform: scale(1.4); }
.presence-dot.present { background: var(--success); }
.presence-dot.absent { background: var(--danger); }
.presence-dot.late { background: var(--warning); }

/* ===== ALERTS ===== */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item {
    display: flex; align-items: center; gap: 14px; padding: 14px 18px;
    border-radius: var(--radius-sm); font-size: .85rem; font-weight: 500;
}
.alert-item.warn { background: var(--warning-bg); color: #92400e; border-left: 3px solid var(--warning); }
.alert-item.danger { background: var(--danger-bg); color: #991b1b; border-left: 3px solid var(--danger); }
.alert-item.info { background: var(--primary-50); color: var(--primary-dark); border-left: 3px solid var(--primary); }
.alert-item.success { background: var(--success-bg); color: #065f46; border-left: 3px solid var(--success); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 72px 20px; color: var(--gray-400); }
.empty-state i { font-size: 4rem; margin-bottom: 20px; opacity: .5; }
.empty-state h4 { font-size: 1.1rem; font-weight: 700; color: var(--gray-500); margin-bottom: 8px; }
.empty-state p { font-size: .92rem; max-width: 360px; margin: 0 auto; }

/* ===== SKELETON LOADING ===== */
.skeleton { background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-xs); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 200px; margin-bottom: 12px; }
.skeleton-card { height: 120px; border-radius: var(--radius); }

/* ===== SETTINGS FORM ===== */
.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--gray-100); }

/* ===== CLICKABLE LINK ===== */
.link-clickable {
    color: var(--primary); cursor: pointer; font-weight: 600; transition: var(--transition);
    text-decoration: none;
}
.link-clickable:hover { color: var(--primary-dark); text-decoration: underline; }

/* ===== INFO GRID ===== */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.info-item { }
.info-item .info-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500); margin-bottom: 4px; }
.info-item .info-value { font-size: .92rem; color: var(--gray-800); font-weight: 600; }

/* ===== STAT MINI ===== */
.stat-mini { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.stat-mini:last-child { border: none; }
.stat-mini .stat-label { font-size: .85rem; color: var(--gray-600); }
.stat-mini .stat-value { font-size: .95rem; font-weight: 700; color: var(--gray-900); }

/* ===== COUNTER ANIMATION ===== */
.counter-animated { transition: all .3s; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.fade-in { animation: fadeIn .4s var(--ease); }
.fade-in-up { animation: fadeInUp .5s var(--ease); }
.slide-in-right { animation: slideInRight .4s var(--ease); }

/* Stagger children */
.stagger-in > * { animation: fadeInUp .4s var(--ease) both; }
.stagger-in > *:nth-child(1) { animation-delay: .05s; }
.stagger-in > *:nth-child(2) { animation-delay: .1s; }
.stagger-in > *:nth-child(3) { animation-delay: .15s; }
.stagger-in > *:nth-child(4) { animation-delay: .2s; }
.stagger-in > *:nth-child(5) { animation-delay: .25s; }
.stagger-in > *:nth-child(6) { animation-delay: .3s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) { .grid-2 { grid-template-columns: 1fr; } .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 1024px) {
    .sidebar { left: -300px; }
    .sidebar.mobile-open { left: 0; }
    .main-content { margin-left: 0 !important; }
    .mobile-menu-btn { display: block; }
    .drill-panel { width: 100%; right: -100%; }
}
@media (max-width: 768px) {
    .page-content { padding: 20px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .header-search, .header-date { display: none; }
}

/* ===== UTILITY ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--gray-500); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mb-28 { margin-bottom: 28px; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.cursor-pointer { cursor: pointer; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded-full { border-radius: 9999px; }
.w-full { width: 100%; }
.whitespace-nowrap { white-space: nowrap; }
