/**
 * STYLES.CSS - Stili Condivisi Gestione Paghe Pro
 * ================================================
 * Design system unificato per tutte le pagine.
 *
 * Sezioni:
 *  1. CSS Variables (Dark + Light theme)
 *  2. Reset & Base
 *  3. Layout (app-container, sidebar, main-content)
 *  4. Sidebar (logo, nav-section, nav-item, sidebar-footer)
 *  5. Header & Breadcrumb
 *  6. KPI Cards
 *  7. Cards
 *  8. Buttons
 *  9. Forms
 * 10. Tables
 * 11. Search & Filters
 * 12. Selectors & Theme Toggle
 * 13. Modals
 * 14. Toast Notifications
 * 15. Status Badges
 * 16. Pagination
 * 17. Empty State & Loading
 * 18. Utilities (badge, grid, chart)
 * 19. Animations
 * 20. Mobile / Responsive
 * 21. Print
 * 22. Scroll Progress
 */


/* ==========================================================================
   1. CSS VARIABLES
   ========================================================================== */

:root {
    /* Background */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-hover: #22222e;
    --bg-input: #16161f;

    /* Accent colors */
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-violet: #8b5cf6;
    --accent-orange: #f97316;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders */
    --border-color: #2a2a3a;
    --border-light: #3a3a4a;

    /* Gradients */
    --gradient-blue: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    --gradient-emerald: linear-gradient(135deg, #10b981, #34d399);
    --gradient-amber: linear-gradient(135deg, #f59e0b, #fbbf24);
    --gradient-rose: linear-gradient(135deg, #f43f5e, #fb7185);
    --gradient-violet: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transition */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Fonts */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* Light theme */
body[data-theme="light"],
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-input: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.15);
}


/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}


/* ==========================================================================
   3. LAYOUT
   ========================================================================== */

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main-content {
    flex: 1;
    /* GIORNO 5.5: rimosso margin-left:260px. La barra nuova (psb-sidebar.css) imposta body
       margin-left:240px, sufficiente per spostare il contenuto. */
    margin-left: 0;
    padding: 2rem;
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

/* GIORNO 5.5: nascondi sidebar legacy interna (svuotata da Components.renderSidebar no-op).
   La nuova sidebar e' iniettata da psb-navbar.js direttamente nel body. */
.app-container > .sidebar:empty,
.sidebar.legacy-hidden { display: none !important; }


/* ==========================================================================
   4. SIDEBAR
   ========================================================================== */

.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    width: 260px;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: var(--gradient-blue);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
}

.logo-text span {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.75rem;
    display: block;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 0.25rem;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.nav-item .icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent-blue);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.sidebar-overlay.open {
    display: block;
}


/* ==========================================================================
   5. HEADER & BREADCRUMB
   ========================================================================== */

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-left {
    flex: 1;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--accent-blue);
}

.breadcrumb-separator {
    opacity: 0.5;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
}


/* ==========================================================================
   6. KPI CARDS
   ========================================================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.blue::before   { background: var(--gradient-blue); }
.kpi-card.emerald::before { background: var(--gradient-emerald); }
.kpi-card.amber::before  { background: var(--gradient-amber); }
.kpi-card.rose::before   { background: var(--gradient-rose); }
.kpi-card.violet::before { background: var(--gradient-violet); }

.kpi-icon {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.kpi-delta {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

.kpi-delta.positive {
    background: rgba(16,185,129,0.15);
    color: var(--accent-emerald);
}

.kpi-delta.negative {
    background: rgba(244,63,94,0.15);
    color: var(--accent-rose);
}


/* ==========================================================================
   7. CARDS
   ========================================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}


/* ==========================================================================
   8. BUTTONS
   ========================================================================== */

.btn {
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-hover);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

/* Promossa da definizioni locali ripetute (audit/admin/import/...): bottone
   neutro secondario, identico ovunque (audit 2026-06-12). */
.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-success {
    background: var(--accent-emerald);
    border-color: var(--accent-emerald);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--accent-rose);
    border-color: var(--accent-rose);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-icon {
    padding: 0.5rem;
    min-width: 36px;
    justify-content: center;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}


/* ==========================================================================
   9. FORMS
   ========================================================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: border-color 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}


/* ==========================================================================
   10. TABLES
   ========================================================================== */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--text-primary);
}

.sort-icon {
    margin-left: 0.25rem;
    opacity: 0.5;
}

th.sorted .sort-icon {
    opacity: 1;
    color: var(--accent-blue);
}

tr:hover td {
    background: var(--bg-hover);
}

.col-name {
    font-weight: 500;
}

.col-amount {
    font-family: var(--font-mono);
    text-align: right;
}

.col-center {
    text-align: center;
}

.row-total {
    background: var(--bg-secondary);
    font-weight: 600;
}

.variance-positive { color: var(--accent-emerald); }
.variance-negative { color: var(--accent-rose); }


/* ==========================================================================
   11. SEARCH & FILTERS
   ========================================================================== */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 350px;
}

.search-box input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: border-color 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box .search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip:hover {
    background: var(--bg-hover);
}

.filter-chip.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}


/* ==========================================================================
   12. SELECTORS & THEME TOGGLE
   ========================================================================== */

.selector {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.6rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.selector:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}


/* ==========================================================================
   13. MODALS
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-lg {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--accent-rose);
    color: white;
}


/* ==========================================================================
   14. TOAST NOTIFICATIONS
   ========================================================================== */

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.success { background: var(--accent-emerald); }
.toast.error   { background: var(--accent-rose); }
.toast.warning { background: var(--accent-amber); }
.toast.info    { background: var(--accent-blue); }


/* ==========================================================================
   15. STATUS BADGES
   ========================================================================== */

.status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-da-pagare         { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.status-da-pagare .status-dot { background: var(--accent-amber); }

.status-pagato            { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.status-pagato .status-dot    { background: var(--accent-emerald); }

.status-non-pagare        { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.status-non-pagare .status-dot { background: var(--text-muted); }

.status-parziale          { background: rgba(139, 92, 246, 0.15); color: var(--accent-violet); }
.status-parziale .status-dot  { background: var(--accent-violet); }

/* Partial payments detail */
.pagamenti-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
}

.pagamenti-detail .pag-item {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
}

.pagamenti-detail .pag-data    { color: var(--text-secondary); }
.pagamenti-detail .pag-importo { font-family: var(--font-mono); color: var(--accent-emerald); }

.pagamenti-detail .pag-resto {
    font-weight: 600;
    color: var(--accent-amber);
    border-top: 1px dashed var(--border-color);
    margin-top: 0.25rem;
    padding-top: 0.25rem;
}


/* ==========================================================================
   16. PAGINATION
   ========================================================================== */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 0.25rem;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* ==========================================================================
   17. EMPTY STATE & LOADING
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}


/* ==========================================================================
   18. UTILITIES
   ========================================================================== */

/* Generic badges */
.badge-small {
    display: inline-flex;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent-rose);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chart container */
.chart-container {
    height: 250px;
    position: relative;
}

.chart-container.tall {
    height: 350px;
}

/* Progress bars */
.progress-container {
    margin-top: 0.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill.ok      { background: var(--accent-emerald); }
.progress-fill.warning  { background: var(--accent-amber); }
.progress-fill.danger   { background: var(--accent-rose); }

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Action dropdown */
.action-dropdown {
    position: relative;
    display: inline-block;
}

.action-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 100;
    display: none;
    overflow: hidden;
}

.action-menu.show {
    display: block;
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    color: var(--text-primary);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
}

.action-menu-item:hover {
    background: var(--bg-hover);
}

.action-menu-item.danger {
    color: var(--accent-rose);
}

.action-menu-item .menu-icon {
    width: 20px;
    text-align: center;
}

.action-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

/* Checkbox group (scadenzario) */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.checkbox-item:hover {
    background: var(--bg-hover);
}

.checkbox-item.selected {
    background: rgba(59,130,246,0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}


/* ==========================================================================
   19. ANIMATIONS
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}


/* ==========================================================================
   20. MOBILE / RESPONSIVE
   ========================================================================== */

.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: none;
    }

    .header {
        gap: 0.75rem;
    }

    .header-right {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}


/* ==========================================================================
   21. PRINT
   ========================================================================== */

@media print {
    body {
        background: white;
        color: black;
        font-size: 10pt;
    }

    .sidebar,
    .mobile-menu-btn,
    .sidebar-overlay,
    .theme-toggle,
    .btn,
    .toast,
    .scroll-progress {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
    }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .kpi-card::before {
        display: none;
    }
}


/* ==========================================================================
   22. SCROLL PROGRESS
   ========================================================================== */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--gradient-blue);
    z-index: 9999;
    transition: width 0.1s ease;
}
