/* ============================================
   NIS2 COMPLIANCE DASHBOARD - DESIGN SYSTEM
   Dark Tech Professional Style
   Palette: Deep Dark + Amber/Orange + Teal + Purple
   ============================================ */

/* ============= SELF-HOSTED FONTS ============= */
/* Inter variable font - self-hosted, no external CDN */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/inter-v20-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/inter-v20-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/inter-v20-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/inter-v20-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============= CSS VARIABLES ============= */
:root {
    /* Cyber Shield — Dark Theme (default) */

    /* Background Colors */
    --bg-main: #09090f;
    --bg-card: #0f1017;
    --bg-elevated: #14151f;
    --bg-hover: #1a1b28;
    --bg-secondary: #1e1f2e;
    --bg-input: #0c0d14;
    --sidebar-bg: #07080d;

    /* Backward-compat aliases */
    --primary: #09090f;
    --primary-light: #0f1017;
    --primary-dark: #07080d;
    --bg-card-solid: #0f1017;
    --bg-table-header: #14151f;

    /* Accent — Amber */
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-light: #fbbf24;
    --accent-glow: rgba(245, 158, 11, 0.15);

    /* Secondary Accents */
    --teal: #14b8a6;
    --teal-light: #2dd4bf;
    --teal-glow: rgba(20, 184, 166, 0.12);
    --purple: #a855f7;
    --purple-light: #c084fc;
    --purple-glow: rgba(168, 85, 247, 0.12);

    /* Text Colors */
    --text-primary: #f0f1f5;
    --text-secondary: #8b8da0;
    --text-muted: #5c5e72;
    --text-inverse: #111113;

    /* Status Colors */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --success-text: #34d399;
    --success-border: rgba(16, 185, 129, 0.2);

    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --warning-text: #fbbf24;
    --warning-border: rgba(245, 158, 11, 0.2);

    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --danger-text: #f87171;
    --danger-border: rgba(239, 68, 68, 0.2);

    --info: #06b6d4;
    --info-bg: rgba(6, 182, 212, 0.12);
    --info-text: #22d3ee;
    --info-border: rgba(6, 182, 212, 0.2);

    /* Border Colors */
    --border: #2a2b3d;
    --border-subtle: #1c1d2a;
    --border-default: #2a2b3d;
    --border-strong: #3a3b52;
    --border-dark: #3a3b52;
    --border-focus: var(--accent);
    --border-glow: rgba(245, 158, 11, 0.3);

    /* Shadows — Cyber Shield */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.65);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --shadow-teal-glow: 0 0 20px var(--teal-glow);
    --shadow-purple-glow: 0 0 20px var(--purple-glow);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

/* ============= LIGHT THEME ============= */
[data-theme="light"] {
    --bg-main: #f5f5f7;
    --bg-card: #ffffff;
    --bg-elevated: #fafafa;
    --bg-hover: #f0f0f2;
    --bg-secondary: #f0f0f2;
    --bg-input: #f5f5f7;
    --sidebar-bg: #ffffff;

    /* Backward-compat aliases */
    --primary: #f5f5f7;
    --primary-light: #ffffff;
    --primary-dark: #e8e8ea;
    --bg-card-solid: #ffffff;
    --bg-table-header: #fafafa;

    /* Text Colors */
    --text-primary: #111113;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --text-inverse: #ffffff;

    /* Border Colors */
    --border: #e4e4e7;
    --border-subtle: #f0f0f2;
    --border-default: #e4e4e7;
    --border-strong: #d4d4d8;
    --border-dark: #d4d4d8;

    /* Shadows — light */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.14);

    /* Glow — reduced in light mode */
    --accent-glow: rgba(245, 158, 11, 0.10);
    --teal-glow: rgba(20, 184, 166, 0.08);
    --purple-glow: rgba(168, 85, 247, 0.08);

    /* Status colors — darker text for light backgrounds */
    --success-text: #059669;
    --warning-text: #d97706;
    --danger-text: #dc2626;
    --info-text: #0891b2;

    /* Status backgrounds — lighter in light mode */
    --success-bg: rgba(16, 185, 129, 0.08);
    --success-border: rgba(16, 185, 129, 0.15);
    --warning-bg: rgba(245, 158, 11, 0.08);
    --warning-border: rgba(245, 158, 11, 0.15);
    --danger-bg: rgba(239, 68, 68, 0.08);
    --danger-border: rgba(239, 68, 68, 0.15);
    --info-bg: rgba(6, 182, 212, 0.08);
    --info-border: rgba(6, 182, 212, 0.15);
}

/* ============= THEME TRANSITION ============= */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease !important;
}

/* ============= RESET & BASE ============= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-main);
    background-image:
        radial-gradient(ellipse at 15% 20%, rgba(168, 85, 247, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 80%, rgba(20, 184, 166, 0.03) 0%, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
}

[data-theme="light"] body {
    background-image: none;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-light);
}

img {
    max-width: 100%;
    height: auto;
}

/* ============= LAYOUT ============= */
.layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity var(--transition-base);
}

.main-content.page-transition {
    opacity: 0;
}

.content-wrapper {
    padding: var(--space-6);
    flex: 1;
}

/* ============= SIDEBAR ============= */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
    border-right: 1px solid var(--border-subtle);
    transition: width var(--transition-slow);
}

/* Sidebar header — logo area */
.sidebar-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
    min-height: 64px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo .logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius);
}

.sidebar-brand {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-brand h1 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    margin: 0;
}

/* Sidebar nav — scrollable area */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: var(--radius-full);
}

/* Nav sections */
.nav-section {
    margin-bottom: var(--space-1);
}

/* Collapsible section toggle */
.nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-2) var(--space-5);
    margin-top: var(--space-3);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

.nav-section-toggle .nav-section-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: inherit;
    padding: 0;
}

.nav-section-chevron {
    width: 14px;
    height: 14px;
    transition: transform var(--transition-fast);
    opacity: 0.5;
}

.nav-section-toggle.collapsed .nav-section-chevron {
    transform: rotate(-90deg);
}

/* Collapsible section content */
.nav-section-items {
    overflow: hidden;
    max-height: 600px;
    transition: max-height var(--transition-slow);
}

.nav-section-items.collapsed {
    max-height: 0;
}

/* Standalone section label (non-collapsible) */
.nav-section-label {
    padding: var(--space-2) var(--space-5);
    margin-top: var(--space-3);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Nav items */
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-5);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
    border-left: 3px solid transparent;
    text-decoration: none;
    position: relative;
    white-space: nowrap;
}

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

.nav-item.active {
    background: rgba(245, 158, 11, 0.08);
    color: var(--text-primary);
    border-left-color: var(--accent);
    border-left-width: 3px;
    border-left-style: solid;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.nav-icon {
    width: 20px;
    height: 20px;
    stroke-width: 1.75;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

/* Lucide icon base styles */
[data-lucide] {
    display: inline-block;
    vertical-align: middle;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}

/* Icon sizing by context */
.nav-item [data-lucide],
.sc-nav-item [data-lucide],
.cti-nav-item [data-lucide] {
    width: 20px;
    height: 20px;
}

.page-title [data-lucide],
h1 [data-lucide],
h2 [data-lucide],
h3 [data-lucide] {
    width: 24px;
    height: 24px;
}

.btn [data-lucide],
button [data-lucide] {
    width: 16px;
    height: 16px;
}

.stat-icon [data-lucide] {
    width: 22px;
    height: 22px;
}

.filter-search-icon,
.sc-search-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    stroke: currentColor;
    stroke-width: 1.75;
    fill: none;
}

.empty-state-icon [data-lucide] {
    width: 48px;
    height: 48px;
    opacity: 0.4;
}

.sc-countdown-icon [data-lucide] {
    width: 24px;
    height: 24px;
}

.btn-toggle-icon [data-lucide],
i.btn-toggle-icon[data-lucide] {
    width: 18px;
    height: 18px;
}

/* Notification badge on nav item */
.nav-item .nav-badge {
    margin-left: auto;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* ============= SIDEBAR FOOTER ============= */
.sidebar-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Theme toggle placeholder */
.sidebar-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    align-self: flex-end;
}

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

.theme-icon-dark { display: none; }
.theme-icon-light { display: block; }
[data-theme="light"] .theme-icon-dark { display: block; }
[data-theme="light"] .theme-icon-light { display: none; }

.sidebar-theme-toggle [data-lucide] {
    width: 16px;
    height: 16px;
}

/* User profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-inverse);
    box-shadow: var(--shadow-glow);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.btn-logout .nav-icon {
    width: 16px;
    height: 16px;
}

/* Sidebar collapse toggle */
.sidebar-collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: var(--space-2);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
    margin-top: var(--space-1);
}

.sidebar-collapse-toggle:hover {
    color: var(--text-primary);
}

.sidebar-collapse-toggle [data-lucide] {
    width: 18px;
    height: 18px;
}

.collapse-icon-closed { display: none; }
.collapse-icon-open { display: block; }

/* ============= SIDEBAR COLLAPSED STATE ============= */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-section-toggle .nav-section-label,
.sidebar.collapsed .nav-section-chevron,
.sidebar.collapsed .user-info,
.sidebar.collapsed .sidebar-theme-toggle,
.sidebar.collapsed .nav-badge {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: var(--space-4) var(--space-3);
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: var(--space-2) var(--space-3);
    border-left: none;
}

.sidebar.collapsed .nav-item.active {
    border-left: none;
    border-radius: var(--radius);
}

.sidebar.collapsed .nav-section-toggle {
    display: none;
}

.sidebar.collapsed .nav-section-items {
    max-height: 600px !important;
}

.sidebar.collapsed .user-profile {
    justify-content: center;
}

.sidebar.collapsed .btn-logout {
    justify-content: center;
    padding: var(--space-2);
}

.sidebar.collapsed .btn-logout .nav-label {
    display: none;
}

.sidebar.collapsed .collapse-icon-open { display: none; }
.sidebar.collapsed .collapse-icon-closed { display: block; }

/* Tooltip on collapsed sidebar */
.sidebar.collapsed .nav-item {
    position: relative;
}

.sidebar.collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-collapsed) - 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius);
    font-size: var(--text-xs);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 200;
}

.sidebar.collapsed .nav-item:hover::after {
    opacity: 1;
}

/* Collapsed main content adjustment */
.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

/* ============= MOBILE SIDEBAR ============= */
.sidebar-hamburger {
    display: none;
    position: fixed;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 110;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow);
}

.sidebar-hamburger [data-lucide] {
    width: 20px;
    height: 20px;
}

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

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ============= TOP LOADING BAR ============= */
.top-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
    background-size: 200% 100%;
    z-index: 9999;
    opacity: 0;
    transition: opacity 150ms ease;
    pointer-events: none;
}

.top-loading-bar.active {
    opacity: 1;
    animation: loadingBarProgress 1.8s ease-in-out infinite, shimmer 1.5s ease-in-out infinite;
}

@keyframes loadingBarProgress {
    0%   { width: 0%; }
    20%  { width: 30%; }
    50%  { width: 60%; }
    80%  { width: 85%; }
    100% { width: 95%; }
}

.top-loading-bar.complete {
    width: 100% !important;
    opacity: 0;
    transition: opacity 300ms ease 100ms;
}

/* ============= HEADER ============= */
.page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Sottile accento gradient sul bordo inferiore */
.page-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-glow), var(--teal-glow), transparent);
    pointer-events: none;
}

.page-header-left {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.page-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* Badge Tipo Soggetto NIS2 */
.tipo-soggetto-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.tipo-soggetto-badge.essenziale {
    background: linear-gradient(135deg, #059669, var(--success));
    color: white;
    box-shadow: 0 0 10px var(--success-border);
}

.tipo-soggetto-badge.importante {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    box-shadow: 0 0 10px var(--info-border);
}

/* Sezioni solo per Soggetti Essenziali */
.essenziali-only {
    position: relative;
    border-left: 3px solid var(--success);
}

.badge-essenziale {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Checklist per requisiti */
.checklist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.checklist-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checklist-item label {
    cursor: pointer;
    font-size: 0.9rem;
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ============= BREADCRUMB ============= */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.breadcrumb a {
    color: var(--text-secondary);
}

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

.breadcrumb-separator {
    color: var(--text-muted);
}

/* ============= STAT CARDS ============= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.stat-card:hover::before {
    opacity: 1;
}

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

.stat-icon.blue {
    background: var(--info-bg);
    box-shadow: 0 0 15px var(--info-border);
}
.stat-icon.green {
    background: var(--success-bg);
    box-shadow: 0 0 15px var(--success-border);
}
.stat-icon.yellow {
    background: var(--warning-bg);
    box-shadow: 0 0 15px var(--warning-border);
}
.stat-icon.red {
    background: var(--danger-bg);
    box-shadow: 0 0 15px var(--danger-border);
}
.stat-icon.purple {
    background: var(--purple-glow);
    box-shadow: 0 0 15px var(--purple-glow);
}
.stat-icon.cyan {
    background: var(--teal-glow);
    box-shadow: 0 0 15px var(--teal-glow);
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.stat-trend {
    font-size: var(--text-xs);
    margin-top: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.stat-trend.up { color: var(--success-text); }
.stat-trend.down { color: var(--danger-text); }

/* ============= CARDS ============= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Card cliccabile con effetto hover glow */
.card-hoverable {
    transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
    cursor: pointer;
}

.card-hoverable:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-default);
    transform: translateY(-1px);
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.04) 0%, transparent 50%, rgba(20, 184, 166, 0.03) 100%);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}

/* ============= BUTTONS ============= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 8px 16px;
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

/* Stato loading: aggiunge spinner inline e blocca interazioni */
.btn-loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: var(--radius-full);
    animation: spin 0.65s linear infinite;
    flex-shrink: 0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: var(--text-inverse);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 0 6px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-default);
}

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

.btn-secondary:active:not(:disabled) {
    background: var(--bg-secondary);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: var(--text-inverse);
    border-color: var(--success);
    box-shadow: 0 0 10px var(--success-border);
}

.btn-success:hover:not(:disabled) {
    box-shadow: var(--shadow-teal-glow);
    transform: translateY(-1px);
}

.btn-success:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
    box-shadow: 0 0 12px var(--danger-bg);
    transform: translateY(-1px);
}

.btn-danger:active:not(:disabled) {
    background: #b91c1c;
    transform: translateY(0);
    box-shadow: none;
}

.btn-danger:focus-visible {
    outline-color: var(--danger);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
    padding: var(--space-1) var(--space-2);
}

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

.btn-ghost:active:not(:disabled) {
    background: var(--bg-secondary);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

.btn-icon {
    padding: var(--space-2);
}

/* ============= TABLES ============= */

/* Wrapper responsive con fade shadow sui bordi per scroll orizzontale */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    -webkit-overflow-scrolling: touch;
    background:
        linear-gradient(to right, var(--bg-card) 30%, transparent),
        linear-gradient(to left, var(--bg-card) 30%, transparent) 100% 0,
        radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.12), transparent),
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.12), transparent) 100% 0;
    background-repeat: no-repeat;
    background-color: var(--bg-card);
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}

/* Alias per compatibilità con codice esistente */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* Thead sticky */
.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    background: var(--bg-secondary);
    padding: 10px 16px;
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--accent-glow);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
    color: var(--text-primary);
    vertical-align: middle;
    line-height: 1.5;
}

/* Fix allineamento righe tabella */
.data-table th,
.data-table td {
    vertical-align: middle;
    text-align: left;
}

.data-table td .badge {
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
}

/* Colore alternato righe — sottile */
.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.012);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table code {
    background: var(--accent-glow);
    color: var(--accent-light);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    white-space: nowrap;
}

/* Light theme override per righe alternate */
body.light-theme .data-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.018);
}

/* ============= BADGES ============= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-border);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: var(--danger-border);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: var(--info-border);
}

.badge-neutral {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

.badge-primary {
    background: var(--purple-glow);
    color: var(--purple-light);
    border-color: var(--border-strong);
}

/* Varianti cromatiche aggiuntive — palette Cyber Shield */
.badge-amber {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}

.badge-teal {
    background: var(--teal-glow);
    color: var(--teal-light);
    border-color: rgba(20, 184, 166, 0.2);
}

.badge-purple {
    background: var(--purple-glow);
    color: var(--purple-light);
    border-color: rgba(168, 85, 247, 0.2);
}

/* Variante dot: indicatore colorato prima del testo */
.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: currentColor;
    flex-shrink: 0;
    margin-right: var(--space-1);
}

/* ============= TAGS ============= */
/* Tag: più piccolo del badge, per metadati e categorie */
.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    white-space: nowrap;
    transition: background var(--transition-fast);
}

.tag-amber {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}

.tag-teal {
    background: var(--teal-glow);
    color: var(--teal-light);
    border-color: rgba(20, 184, 166, 0.2);
}

.tag-purple {
    background: var(--purple-glow);
    color: var(--purple-light);
    border-color: rgba(168, 85, 247, 0.2);
}

/* ============= FORMS ============= */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.form-label .required {
    color: var(--danger);
    margin-left: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
    background: var(--bg-elevated);
}

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

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: var(--bg-elevated);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Stato errore: bordo rosso + messaggio */
.form-input.is-invalid,
.form-input.error,
.form-select.is-invalid,
.form-select.error,
.form-textarea.is-invalid,
.form-textarea.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px var(--danger-bg);
}

.form-input.is-invalid:focus,
.form-input.error:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px var(--danger-bg);
}

/* Required field asterisk via CSS ::after */
.form-label.required::after {
    content: ' *';
    color: var(--danger);
    font-weight: 600;
}

/* Messaggi di errore sotto i campi */
.form-error-message {
    font-size: var(--text-xs);
    color: var(--danger-text);
    margin-top: var(--space-1);
    display: none;
    align-items: center;
    gap: var(--space-1);
}

/* Transizione smooth per bordo errore */
.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    /* Freccia custom — colore neutro dark (visibile su sfondo scuro) */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%235c5e72' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Freccia select in light theme — colore più scuro per leggibilità */
[data-theme="light"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2352525b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
}

.form-checkbox,
.form-radio {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.form-checkbox input,
.form-radio input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger-text);
    margin-top: var(--space-1);
}

/* ============= TIMELINE ============= */
.timeline {
    position: relative;
    padding-left: var(--space-8);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--space-6);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -30px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-card-solid);
    z-index: 1;
}

.timeline-marker.badge-info {
    background: var(--info);
}

.timeline-marker.badge-success {
    background: var(--success);
}

.timeline-marker.badge-warning {
    background: var(--warning);
}

.timeline-marker.badge-danger {
    background: var(--danger);
}

.timeline-marker.badge-neutral {
    background: var(--text-muted);
}

.timeline-content {
    background: var(--bg-table-header);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
    gap: var(--space-2);
}

.timeline-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.timeline-description {
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
}

.timeline-user {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin: var(--space-2) 0 0 0;
}

/* ============= MODALS ============= */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-8);
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 560px;
    margin: auto;
    animation: modalSlideIn 0.2s ease;
}

.modal-content.modal-lg {
    max-width: 800px;
}

.modal-content.modal-xl {
    max-width: 1024px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, var(--accent-glow) 0%, transparent 100%);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--text-xl);
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--danger-text);
}

.modal-body {
    padding: var(--space-5);
    max-height: calc(80vh - 140px);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    background: var(--bg-elevated);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ============= ALERTS ============= */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-border);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: var(--danger-border);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: var(--info-border);
}

/* Toast notifications — container fisso top-right */
.alert-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 400px;
    pointer-events: none;
}

/* Ogni toast nel container ha stile bg-elevated + border-left colorato */
.alert-container .alert {
    margin: 0;
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-default) !important;
    border-left-width: 3px !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
    min-width: 280px;
    pointer-events: auto;
}

/* Colori border-left per tipo toast */
.alert-container .alert.alert-success { border-left-color: var(--success) !important; }
.alert-container .alert.alert-error,
.alert-container .alert.alert-danger  { border-left-color: var(--danger)  !important; }
.alert-container .alert.alert-warning { border-left-color: var(--warning) !important; }
.alert-container .alert.alert-info    { border-left-color: var(--info)    !important; }

/* Pulsante chiudi toast */
.alert-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 var(--space-1);
    font-size: var(--text-lg);
    line-height: 1;
    margin-left: auto;
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.alert-close:hover {
    color: var(--text-primary);
}

/* Toast che sta per essere rimosso */
.alert-container .alert.toast-dismissing {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

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

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

/* ============= NOTIFICATION BELL & PANEL ============= */
.notification-bell-container {
    position: relative;
}

.notification-bell {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius);
    transition: background 0.2s;
}

.notification-bell:hover {
    background: rgba(255, 255, 255, 0.08);
}

.bell-icon {
    font-size: 1.25rem;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--danger);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.notification-badge.critical {
    animation: pulse-critical 2s ease-in-out infinite;
}

.notification-bell.has-critical .bell-icon {
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

@keyframes pulse-critical {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
        transform: scale(1.1);
    }
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 380px;
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    display: none;
    overflow: hidden;
    animation: dropdownFadeIn 0.2s ease;
}

.notification-dropdown.open {
    display: block;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.notification-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
}

.notification-dropdown-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.notification-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.notification-header-actions button {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 0.75rem;
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.notification-header-actions button:hover {
    background: rgba(255, 255, 255, 0.06);
    text-decoration: underline;
}

.notif-sound-toggle {
    font-size: 1rem !important;
    color: var(--text-secondary) !important;
}

.notification-dropdown-body {
    max-height: 360px;
    overflow-y: auto;
}

.notification-dropdown-footer {
    padding: var(--space-3);
    text-align: center;
    border-top: 1px solid var(--border);
}

.notification-dropdown-footer a {
    color: var(--accent);
    font-size: 0.8rem;
    text-decoration: none;
}

.notification-dropdown-footer a:hover {
    text-decoration: underline;
}

.notification-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.notification-item.unread {
    background: var(--warning-bg);
}

.notification-item.unread .notification-title {
    font-weight: 600;
}

.notification-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1.4;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    font-size: 0.85rem;
}

.notification-message {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.notification-empty {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.notification-section-header {
    padding: var(--space-2) var(--space-4);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
}

.notification-section-header.critical {
    background: var(--danger-bg);
    color: var(--danger);
}

.notification-item.critical {
    background: var(--danger-bg);
    border-left: 3px solid var(--danger);
}

.notification-item.critical:hover {
    background: rgba(239, 68, 68, 0.15);
}

.notification-item.critical .notification-title {
    color: var(--danger-text);
}

/* ============= FILTERS ============= */
.filters-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--space-4) var(--space-5);
    background: var(--bg-table-header);
    border-bottom: 1px solid var(--border);
}

.filter-search {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
    position: relative;
}

.filter-search input {
    padding-left: 2.5rem;
}

.filter-search-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.filter-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ============= TABS ============= */
/* ============= MANUALE HERO SECTION ============= */
.manuale-hero-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.manuale-hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--teal));
}

.manuale-hero-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: var(--warning-bg);
    box-shadow: 0 0 15px var(--warning-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent);
}

.manuale-hero-info {
    flex: 1;
    min-width: 0;
}

.manuale-hero-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-1) 0;
}

.manuale-hero-desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--space-1) 0;
}

.manuale-hero-version {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.manuale-hero-btn {
    flex-shrink: 0;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
}

@media (max-width: 768px) {
    .manuale-hero-section {
        flex-direction: column;
        text-align: center;
    }
    .manuale-hero-btn {
        width: 100%;
    }
}

/* ============= TABS ============= */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-5);
}

.tab-btn {
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============= EMPTY STATE ============= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-secondary);
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-4);
    color: var(--text-muted);
    opacity: 0.6;
}

.empty-state-icon [data-lucide] {
    width: 48px;
    height: 48px;
    stroke-width: 1.5;
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
    max-width: 320px;
}

/* ============= LOADING STATE ============= */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

/* ============= TABLE LOADING SKELETON ============= */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

.skeleton-cell {
    height: 14px;
    border-radius: var(--radius-sm);
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-elevated)  50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* Varianti larghezza per evitare uniformità robotica */
.skeleton-cell.w-40  { width: 40%; }
.skeleton-cell.w-60  { width: 60%; }
.skeleton-cell.w-80  { width: 80%; }
.skeleton-cell.w-100 { width: 100%; }

.skeleton-row td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.skeleton-row:last-child td {
    border-bottom: none;
}

/* ============= GENERAL SKELETON LOADING ============= */
/* Classe base: applica shimmer a qualsiasi elemento */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-elevated)  50%,
        var(--bg-secondary) 75%
    ) !important;
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    color: transparent !important;
    border-color: transparent !important;
    pointer-events: none;
    user-select: none;
}

/* Placeholder testo: barra rettangolare bassa */
.skeleton-text {
    height: 14px;
    border-radius: var(--radius-sm);
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-elevated)  50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
    width: 60%;
}

/* Placeholder cerchio: avatar, icone */
.skeleton-circle {
    border-radius: var(--radius-full);
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-elevated)  50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-circle.sm  { width: 32px;  height: 32px; }
.skeleton-circle.md  { width: 48px;  height: 48px; }
.skeleton-circle.lg  { width: 64px;  height: 64px; }

/* Placeholder rettangolo: card, immagini, grafici */
.skeleton-rect {
    border-radius: var(--radius-md);
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-elevated)  50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-rect.sm  { height: 80px; }
.skeleton-rect.md  { height: 120px; }
.skeleton-rect.lg  { height: 200px; }

/* ============= PAGE CONTENT TRANSITION ============= */
.content-wrapper {
    animation: fadeInContent 200ms ease both;
}

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

/* ============= PAGINATION ============= */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    gap: var(--space-4);
    flex-wrap: wrap;
}

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

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1;
}

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

.pagination-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-inverse);
    font-weight: 600;
}

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

.pagination-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    color: var(--text-muted);
    font-size: var(--text-sm);
    user-select: none;
}

/* ============= LOGIN PAGE ============= */
/* Login styles are now scoped in login.html template */

/* ============= DASHBOARD ============= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--space-5);
}

.dashboard-grid .col-8 {
    grid-column: span 8;
}

.dashboard-grid .col-4 {
    grid-column: span 4;
}

.dashboard-grid .col-6 {
    grid-column: span 6;
}

.dashboard-grid .col-12 {
    grid-column: span 12;
}

/* ============= BENTO KPI GRID ============= */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.bento-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.bento-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.bento-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.bento-card:hover::before {
    opacity: 1;
}

/* Large compliance card spans 2 rows + 1 col */
.bento-card.bento-lg {
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.bento-icon-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.bento-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bento-icon svg,
.bento-icon i {
    width: 22px;
    height: 22px;
}

.bento-icon.red {
    background: var(--danger-bg);
    color: var(--danger-text);
    box-shadow: 0 0 12px var(--danger-bg);
}
.bento-icon.amber {
    background: var(--warning-bg);
    color: var(--warning-text);
    box-shadow: 0 0 12px var(--warning-bg);
}
.bento-icon.blue {
    background: var(--info-bg);
    color: var(--info-text);
    box-shadow: 0 0 12px var(--info-bg);
}
.bento-icon.teal {
    background: var(--teal-glow);
    color: var(--teal-light);
    box-shadow: 0 0 12px var(--teal-glow);
}
.bento-icon.purple {
    background: var(--purple-glow);
    color: var(--purple-light);
    box-shadow: 0 0 12px var(--purple-glow);
}

.bento-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: var(--space-1);
}

.bento-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.bento-trend {
    font-size: var(--text-xs);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.bento-sparkline {
    margin-top: var(--space-3);
    height: 32px;
}

/* Compliance Ring */
.compliance-ring-wrap {
    width: 120px;
    height: 120px;
    margin: var(--space-3) auto;
}

.compliance-ring {
    width: 100%;
    height: 100%;
}

.compliance-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.compliance-ring-fill {
    fill: none;
    stroke: var(--teal);
    stroke-width: 8;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: center;
}

.compliance-ring-value {
    fill: var(--text-primary);
    font-size: 22px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
}

.compliance-ring-label {
    fill: var(--text-secondary);
    font-size: 10px;
    text-anchor: middle;
    dominant-baseline: middle;
}

/* Compliance Breakdown Bar */
.compliance-breakdown {
    width: 100%;
    margin-top: var(--space-3);
}

.compliance-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.compliance-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 1.2s ease-out;
}

.compliance-bar-legend {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* ============= SKELETON LOADING ============= */
.bento-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.skeleton-line {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.skeleton-circle {
    background: var(--bg-elevated);
    border-radius: 50%;
}

.skeleton-shimmer {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.chart-skeleton {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
}

/* ============= CHARTS BENTO GRID ============= */
.charts-bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.chart-bento-card {
    min-width: 0;
}

.chart-bento-card.chart-wide {
    grid-column: span 2;
}

.chart-body {
    height: 260px;
    position: relative;
}

.chart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: var(--space-2);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.chart-empty-state i,
.chart-empty-state svg {
    width: 32px;
    height: 32px;
    opacity: 0.4;
}

/* ============= URGENT ACTIONS ============= */
.urgent-list {
    display: flex;
    flex-direction: column;
}

.urgent-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    text-decoration: none;
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

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

.urgent-item:last-child {
    border-bottom: none;
}

.urgent-type {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    min-width: 80px;
}

.urgent-title {
    flex: 1;
    font-size: var(--text-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============= EMPTY STATE INLINE ============= */
.empty-state-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.empty-state-inline i,
.empty-state-inline svg {
    width: 18px;
    height: 18px;
    opacity: 0.5;
}

/* ============= ACTIVITY FEED ============= */
.activity-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg,
.activity-icon i {
    width: 16px;
    height: 16px;
}

.activity-icon.red {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.activity-icon.amber {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.activity-text {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: var(--text-sm);
    color: var(--text-primary);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin: 2px 0 0;
}

/* ============= CHARTS ============= */
.chart-container {
    position: relative;
    height: 300px;
}

/* ============= RESPONSIVE ============= */
@media (max-width: 1024px) {
    .dashboard-grid .col-8,
    .dashboard-grid .col-4,
    .dashboard-grid .col-6 {
        grid-column: span 12;
    }

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

    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bento-card.bento-lg {
        grid-column: span 2;
        grid-row: span 1;
    }

    .charts-bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-bento-card.chart-wide {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        box-shadow: none;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    /* Forza espansione sidebar su mobile (mai collapsed) */
    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

    .sidebar.collapsed .sidebar-brand,
    .sidebar.collapsed .nav-label,
    .sidebar.collapsed .nav-section-label,
    .sidebar.collapsed .nav-section-toggle .nav-section-label,
    .sidebar.collapsed .nav-section-chevron,
    .sidebar.collapsed .user-info {
        display: revert;
    }

    .sidebar.collapsed .nav-item {
        justify-content: flex-start;
        padding: var(--space-2) var(--space-5);
    }

    .sidebar.collapsed .nav-section-toggle {
        display: flex;
    }

    .sidebar-hamburger {
        display: flex;
    }

    .sidebar-collapse-toggle {
        display: none;
    }

    .main-content,
    .main-content.sidebar-collapsed {
        margin-left: 0;
    }

    .page-header {
        padding: var(--space-3) var(--space-4);
        padding-left: calc(var(--space-4) + 48px);
    }

    .content-wrapper {
        padding: var(--space-4);
    }

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

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

    .bento-card.bento-lg {
        grid-column: span 1;
        grid-row: span 1;
    }

    .bento-value {
        font-size: var(--text-2xl);
    }

    .charts-bento-grid {
        grid-template-columns: 1fr;
    }

    .chart-bento-card.chart-wide {
        grid-column: span 1;
    }

    .urgent-type {
        display: none;
    }

    .modal {
        padding: var(--space-4);
    }

    .modal-content {
        max-width: 100%;
    }
}

/* ============= UTILITIES ============= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger-text); }
.text-info { color: var(--info-text); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.mr-2 { margin-right: var(--space-2); }
.ml-2 { margin-left: var(--space-2); }

.p-0 { padding: 0; }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   ROLE-BASED PERMISSIONS
   ============================================ */

/* Classi esplicite per controllo permessi */
body.role-viewer .admin-only,
body.role-viewer .edit-only,
body.role-viewer .export-only,
body.role-auditor .admin-only,
body.role-auditor .edit-only {
    display: none !important;
}

/* Nascondi pulsanti di creazione/modifica per non-admin */
body.role-viewer [onclick*="edit"],
body.role-viewer [onclick*="Edit"],
body.role-viewer [onclick*="delete"],
body.role-viewer [onclick*="Delete"],
body.role-viewer [onclick*="openModal"],
body.role-viewer [onclick*="Modal()"],
body.role-viewer [onclick*="save"],
body.role-viewer [onclick*="Save"],
body.role-viewer [onclick*="create"],
body.role-viewer [onclick*="Create"],
body.role-viewer [onclick*="add"],
body.role-viewer [onclick*="Add"],
body.role-viewer [onclick*="new"],
body.role-viewer [onclick*="New"],
body.role-auditor [onclick*="edit"],
body.role-auditor [onclick*="Edit"],
body.role-auditor [onclick*="delete"],
body.role-auditor [onclick*="Delete"],
body.role-auditor [onclick*="openModal"],
body.role-auditor [onclick*="Modal()"],
body.role-auditor [onclick*="save"],
body.role-auditor [onclick*="Save"],
body.role-auditor [onclick*="create"],
body.role-auditor [onclick*="Create"],
body.role-auditor [onclick*="add"],
body.role-auditor [onclick*="Add"],
body.role-auditor [onclick*="new"],
body.role-auditor [onclick*="New"] {
    display: none !important;
}

/* Nascondi export per viewer */
body.role-viewer [onclick*="export"],
body.role-viewer [onclick*="Export"],
body.role-viewer [onclick*="download"],
body.role-viewer [onclick*="Download"],
body.role-viewer [onclick*="pdf"],
body.role-viewer [onclick*="PDF"],
body.role-viewer .btn-export,
body.role-viewer .btn-download {
    display: none !important;
}

/* Pulsanti che devono essere sempre visibili (es. chiusura modal di benvenuto) */
.btn-always-visible {
    display: inline-flex !important;
}

/* Banner informativo per utenti non-admin */
.role-banner {
    background: linear-gradient(90deg, var(--warning-bg), var(--accent-glow));
    color: var(--warning-text);
    padding: 10px 20px;
    font-size: 0.9rem;
    text-align: center;
    border-bottom: 1px solid var(--warning-border);
    font-weight: 500;
}

body.role-viewer .role-banner {
    background: linear-gradient(90deg, var(--purple-glow), transparent);
    color: var(--purple-light);
    border-bottom: 1px solid var(--border-strong);
}

/* Stile per form disabilitati in modalità view-only */
body.role-viewer input:not([type="search"]):not(.search-input),
body.role-viewer select:not(.filter-select),
body.role-viewer textarea,
body.role-auditor input:not([type="search"]):not(.search-input),
body.role-auditor select:not(.filter-select),
body.role-auditor textarea {
    pointer-events: none;
    background-color: var(--bg-elevated) !important;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Nascondi pulsanti nelle azioni tabella */
body.role-viewer .table-actions .btn:not(.btn-view),
body.role-viewer td .btn:not(.btn-view),
body.role-auditor .table-actions .btn:not(.btn-view):not(.btn-export):not(.btn-download),
body.role-auditor td .btn:not(.btn-view):not(.btn-export):not(.btn-download) {
    display: none !important;
}

/* ============= COMPLIANCE SCORE TOOLTIP ============= */
.compliance-area {
    position: relative;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.compliance-area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-sm);
    margin-bottom: 0.25rem;
}

.compliance-area-name {
    color: var(--text-primary);
}

.compliance-area-score {
    font-weight: 600;
    color: var(--text-primary);
}

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

.compliance-progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-base), background-color var(--transition-base);
}

.compliance-progress-fill.score-high {
    background: linear-gradient(90deg, var(--success), #34d399);
    box-shadow: 0 0 10px var(--success-border);
}

.compliance-progress-fill.score-medium {
    background: linear-gradient(90deg, var(--warning), var(--accent-light));
    box-shadow: 0 0 10px var(--accent-glow);
}

.compliance-progress-fill.score-low {
    background: linear-gradient(90deg, var(--danger), #f87171);
    box-shadow: 0 0 10px var(--danger-border);
}

/* Tooltip styling */
.compliance-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    background: var(--bg-card-solid);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: var(--text-xs);
    min-width: 220px;
    max-width: 300px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

.compliance-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--bg-card-solid);
}

.compliance-area:hover .compliance-tooltip {
    opacity: 1;
    visibility: visible;
}

.compliance-tooltip-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.compliance-tooltip-suggestions {
    list-style: none;
    padding: 0;
    margin: 0;
}

.compliance-tooltip-suggestions li {
    padding: 0.25rem 0;
    padding-left: 1rem;
    position: relative;
    line-height: 1.4;
}

.compliance-tooltip-suggestions li::before {
    content: '';
    position: absolute;
    left: 0;
    color: var(--warning);
}

.compliance-tooltip-ok {
    color: var(--success-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compliance-tooltip-ok::before {
    content: '';
}

/* Compliance score main number color based on value */
.compliance-score-high {
    color: var(--success-text) !important;
}

.compliance-score-medium {
    color: var(--warning-text) !important;
}

.compliance-score-low {
    color: var(--danger-text) !important;
}

/* ============= SUPER ADMIN STYLES ============= */
.super-admin-header {
    background: linear-gradient(135deg, var(--purple-glow) 0%, var(--accent-glow) 50%, var(--teal-glow) 100%);
    border-bottom: 1px solid var(--border);
    padding: var(--space-6);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.super-admin-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--purple), var(--accent), var(--teal));
}

.super-admin-logo {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

.super-admin-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    background: linear-gradient(135deg, var(--purple-light), var(--accent-light), var(--teal-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-2);
}

.super-admin-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-base);
}

/* Tenant cards for super admin */
.tenant-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.tenant-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--teal), var(--accent));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.tenant-card:hover {
    border-color: var(--teal);
    box-shadow: var(--shadow-teal-glow);
    transform: translateY(-2px);
}

.tenant-card:hover::before {
    opacity: 1;
}

.tenant-card.active {
    border-color: var(--success);
}

.tenant-card.inactive {
    border-color: var(--danger);
    opacity: 0.7;
}

/* Stats for super admin */
.super-admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.super-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.super-stat-card.purple::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--purple), var(--purple-light));
}

.super-stat-card.teal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--teal), var(--teal-light));
}

.super-stat-card.amber::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
}

.super-stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
}

.super-stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-2);
}

/* Glow effects for interactive elements */
.glow-amber:hover {
    box-shadow: var(--shadow-glow);
}

.glow-teal:hover {
    box-shadow: var(--shadow-teal-glow);
}

.glow-purple:hover {
    box-shadow: var(--shadow-purple-glow);
}

/* ============================================
   SUPPLY CHAIN MODULE STYLES
   Prefisso: sc-* per tutte le classi Supply Chain
   ============================================ */

/* ----------- ACCENT DISTINTIVO ----------- */
.sc-accent {
    border-color: var(--purple) !important;
}

.sc-accent:hover {
    border-color: var(--purple-light) !important;
    box-shadow: var(--shadow-purple-glow);
}

.sc-badge-fornitore {
    background: linear-gradient(135deg, var(--purple), var(--purple-light));
    color: white;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    box-shadow: 0 0 10px var(--purple-glow);
}

/* ----------- FORM SEZIONI COLLAPSABILI ----------- */
.sc-form-section {
    margin-bottom: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
}

.sc-form-section.sc-accent {
    border-color: var(--purple);
}

.sc-form-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    background: var(--bg-table-header);
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
}

.sc-form-section-header:hover {
    background: var(--bg-hover);
}

.sc-form-section-header h3,
.sc-form-section-header .sc-section-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
}

.sc-form-section-header .sc-section-icon {
    transition: transform var(--transition-fast);
}

.sc-form-section.collapsed .sc-form-section-header .sc-section-icon {
    transform: rotate(-90deg);
}

.sc-form-section-body {
    padding: var(--space-4);
    max-height: 2000px;
    overflow: hidden;
    transition: max-height var(--transition-slow), padding var(--transition-slow);
}

.sc-form-section.collapsed .sc-form-section-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.sc-field-required::after {
    content: '*';
    color: var(--danger);
    margin-left: var(--space-1);
    font-weight: 600;
}

/* ----------- TABELLA INTERATTIVA ----------- */
.sc-table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sc-table-container::-webkit-scrollbar {
    height: 8px;
}

.sc-table-container::-webkit-scrollbar-track {
    background: transparent;
}

.sc-table-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.sc-table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-1);
    white-space: nowrap;
}

.sc-table-actions .btn {
    padding: var(--space-1) var(--space-2);
}

/* Stati riga tabella */
.sc-row-draft {
    background: var(--warning-bg) !important;
    border-left: 3px solid var(--warning);
}

.sc-row-draft:hover {
    background: var(--warning-border) !important;
}

.sc-row-complete {
    background: var(--success-bg) !important;
    border-left: 3px solid var(--success);
}

.sc-row-complete:hover {
    background: var(--success-border) !important;
}

.sc-row-expired {
    background: var(--danger-bg) !important;
    border-left: 3px solid var(--danger);
}

.sc-row-expired:hover {
    background: var(--danger-border) !important;
}

/* Editing inline */
.sc-inline-edit {
    position: relative;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.sc-inline-edit:hover {
    background: var(--bg-hover);
}

.sc-inline-edit::after {
    content: '\270E';
    position: absolute;
    right: var(--space-1);
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-xs);
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.sc-inline-edit:hover::after {
    opacity: 1;
}

.sc-inline-edit.editing {
    background: var(--bg-secondary);
    padding: 0;
}

.sc-inline-edit.editing::after {
    display: none;
}

.sc-inline-edit-input {
    width: 100%;
    padding: var(--space-2);
    background: var(--bg-secondary);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: inherit;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.sc-inline-edit-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ----------- DASHBOARD CHARTS ----------- */
.sc-chart-container {
    position: relative;
    height: 280px;
    padding: var(--space-3);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.sc-chart-container.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sc-chart-container canvas {
    max-width: 100%;
}

/* KPI Cards */
.sc-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.sc-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--purple), var(--teal));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.sc-kpi-card:hover {
    border-color: var(--purple);
    transform: translateY(-2px);
    box-shadow: var(--shadow-purple-glow);
}

.sc-kpi-card:hover::before {
    opacity: 1;
}

.sc-kpi-card .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: var(--space-3);
    background: var(--purple-glow);
    box-shadow: 0 0 15px var(--purple-glow);
}

.sc-kpi-card .kpi-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.sc-kpi-card .kpi-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.sc-kpi-card .kpi-trend {
    font-size: var(--text-xs);
    margin-top: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.sc-kpi-card .kpi-trend.up {
    color: var(--success-text);
}

.sc-kpi-card .kpi-trend.down {
    color: var(--danger-text);
}

/* KPI Grid */
.sc-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

/* ----------- STATUS BADGES ----------- */
.sc-status-bozza {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.sc-status-completato {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.sc-status-scaduto {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.sc-status-attivo {
    background: var(--info-bg);
    color: var(--info-text);
    border: 1px solid var(--info-border);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.sc-status-sospeso {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

/* ----------- RISK LEVEL BADGES ----------- */
.sc-risk-alto {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.sc-risk-medio {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.sc-risk-basso {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

/* ----------- SUPPLY CHAIN BUTTONS ----------- */
.btn-sc-primary {
    background: linear-gradient(135deg, var(--purple), var(--purple-light));
    color: white;
    border: 1px solid var(--purple);
    box-shadow: 0 0 10px var(--purple-glow);
}

.btn-sc-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-purple-glow);
    transform: translateY(-1px);
}

/* Filters Row */
.sc-filters .filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    margin-bottom: var(--space-4);
}

.sc-filters .filter-group {
    min-width: 150px;
}

.sc-filters .filter-group input,
.sc-filters .filter-group select {
    width: 100%;
}

/* Supply Chain Table */
.sc-table {
    width: 100%;
    border-collapse: collapse;
}

.sc-table th {
    background: var(--bg-table-header);
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    position: relative;
    user-select: none;
}

.sc-table th[data-sortable="true"] {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sc-table th[data-sortable="true"]:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.sc-table th.sort-asc::after,
.sc-table th.sort-desc::after {
    content: '';
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
}

.sc-table th.sort-asc::after {
    border-bottom-color: var(--accent);
    margin-top: -3px;
}

.sc-table th.sort-desc::after {
    border-top-color: var(--accent);
    margin-top: 3px;
}

.sc-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.sc-table tbody tr {
    transition: all var(--transition-fast);
}

.sc-table tbody tr:hover {
    background: var(--bg-hover);
}

.sc-table tbody tr[data-id] {
    cursor: pointer;
}

/* Table Actions */
.sc-table .table-actions {
    display: flex;
    gap: var(--space-1);
    justify-content: flex-end;
}

/* Inline Edit */
.sc-table td.editing {
    padding: var(--space-2);
}

.inline-edit-input {
    width: 100%;
    padding: var(--space-2);
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.inline-edit-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Pagination */
.sc-pagination {
    margin-top: var(--space-4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.sc-pagination .pagination {
    display: flex;
    gap: var(--space-1);
    align-items: center;
}

.sc-pagination .pagination button {
    min-width: 36px;
}

/* Supply Chain Stats */
.sc-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.sc-stats .stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.sc-stats .stat-card:hover {
    border-color: var(--teal);
    transform: translateY(-2px);
}

.sc-stats .stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--teal), var(--accent));
}

.sc-stats .stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
}

.sc-stats .stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-2);
}

/* Supply Chain Dashboard Grid */
.sc-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-6);
}

.sc-dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.sc-dashboard-card h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.sc-chart-container {
    height: 250px;
    position: relative;
}

/* Scadenze List */
.sc-scadenze-list {
    max-height: 300px;
    overflow-y: auto;
}

.scadenza-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-bottom: 1px solid var(--border);
    transition: all var(--transition-fast);
}

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

.scadenza-item.urgente {
    background: var(--danger-bg);
    border-left: 3px solid var(--danger);
}

.scadenza-nome {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.scadenza-giorni {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.scadenza-item.urgente .scadenza-giorni {
    color: var(--danger-text);
}

/* Supply Chain Modal */
.sc-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
}

.sc-modal.active {
    display: flex;
}

.sc-modal-content {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.sc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card-solid);
    z-index: 1;
}

.sc-modal-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
}

.sc-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: var(--space-2);
    line-height: 1;
    transition: color var(--transition-fast);
}

.sc-modal-close:hover {
    color: var(--danger);
}

.sc-modal-body {
    padding: var(--space-5);
}

.sc-modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    padding: var(--space-5);
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: var(--bg-card-solid);
}

/* Form Sections */
.sc-form-section {
    margin-bottom: var(--space-6);
}

.sc-form-section-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--accent);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.sc-form-section-title::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--accent);
    border-radius: 2px;
}

.sc-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-4);
}

/* Delete Confirmation Modal */
.sc-delete-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.sc-delete-modal.active {
    display: flex;
}

.sc-delete-modal-content {
    background: var(--bg-card-solid);
    border: 1px solid var(--danger);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.sc-delete-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
}

.sc-delete-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.sc-delete-message {
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
}

.sc-delete-item-name {
    font-weight: 600;
    color: var(--accent);
}

.sc-delete-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
}

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

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

/* Toast Container Animation */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Supply Chain */
@media (max-width: 1024px) {
    .sc-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sc-filters .filters-row {
        flex-direction: column;
    }

    .sc-filters .filter-group {
        width: 100%;
    }

    .sc-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .sc-modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

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

    .sc-table {
        display: block;
        overflow-x: auto;
    }

    .sc-kpi-grid {
        grid-template-columns: 1fr;
    }

    .sc-kpi-card {
        padding: var(--space-4);
    }

    .sc-kpi-card .kpi-value {
        font-size: var(--text-2xl);
    }

    .sc-chart-container {
        height: 220px;
    }

    .sc-form-section-header {
        padding: var(--space-3);
    }

    .sc-form-section-body {
        padding: var(--space-3);
    }

    .sc-table-actions {
        flex-wrap: wrap;
    }
}

/* ============= TOGGLE BUTTONS (Super Admin) ============= */

.btn-group-toggle {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn-toggle {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-toggle:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.btn-toggle.active {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-toggle-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.btn-toggle-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-toggle-desc {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 2px;
}

.tenant-type-selector,
.nis2-subtype-selector {
    margin-bottom: 20px;
}

.nis2-subtype-selector .btn-toggle {
    padding: 12px 10px;
}

.nis2-subtype-selector .btn-toggle.active {
    background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%);
    border-color: var(--teal);
    box-shadow: 0 4px 15px var(--teal-glow);
}

/* ============= PROFILO AZIENDALE MODAL ============= */

/* Logo Section */
.profilo-logo-section {
    text-align: center;
}

.profilo-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.profilo-logo-preview {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-inverse);
    box-shadow: var(--shadow-glow);
    overflow: hidden;
    position: relative;
}

.profilo-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profilo-logo-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: center;
}

/* Info Grid */
.profilo-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

@media (max-width: 600px) {
    .profilo-info-grid {
        grid-template-columns: 1fr;
    }
}

.profilo-info-item {
    background: var(--bg-secondary);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.profilo-info-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-1);
}

.profilo-info-value {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-primary);
    font-weight: 500;
}

/* Info List (dinamiche) */
.profilo-info-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.profilo-info-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.profilo-info-list-item:hover {
    border-color: var(--accent);
}

.profilo-info-list-item-content {
    flex: 1;
    display: flex;
    gap: var(--space-4);
    align-items: center;
}

.profilo-info-list-item-chiave {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    min-width: 120px;
    font-weight: 500;
}

.profilo-info-list-item-valore {
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.profilo-info-list-item-actions {
    display: flex;
    gap: var(--space-1);
}

/* Add Info Form */
.profilo-add-info-form {
    background: var(--bg-table-header);
    padding: var(--space-4);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: var(--space-4);
}

/* Edit Mode */
.profilo-info-list-item.editing {
    background: var(--bg-table-header);
    border-color: var(--accent);
}

.profilo-info-list-item.editing .profilo-info-list-item-content {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
}

.profilo-info-list-item .edit-input {
    display: none;
}

.profilo-info-list-item.editing .edit-input {
    display: block;
}

.profilo-info-list-item.editing .profilo-info-list-item-chiave,
.profilo-info-list-item.editing .profilo-info-list-item-valore {
    display: none;
}

/* User Avatar Clickable */
.user-avatar.clickable,
.sc-user-avatar.clickable {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-avatar.clickable:hover,
.sc-user-avatar.clickable:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-glow);
}

/* User Avatar with Image */
.user-avatar.has-logo,
.sc-user-avatar.has-logo {
    padding: 0;
    overflow: hidden;
}

.user-avatar.has-logo img,
.sc-user-avatar.has-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Profilo Modal Divider */
.profilo-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-5) 0;
}

/* Profilo Section Header */
.profilo-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.profilo-section-title {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* No Info Message */
.profilo-no-info {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
    padding: var(--space-4);
}

/* ============= TOOLTIPS ============= */
/* Tooltip puro CSS via attributo data-tooltip.
   Posizionamento default: sopra l'elemento (top).
   Freccia triangolare generata con ::before. */
[data-tooltip] {
    position: relative;
}

/* Contenuto tooltip */
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    max-width: 200px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    z-index: 1000;
    transition: opacity 150ms ease;
    transition-delay: 200ms;
    box-shadow: var(--shadow-md);
}

/* Freccia triangolare */
[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-default);
    pointer-events: none;
    opacity: 0;
    z-index: 1000;
    transition: opacity 150ms ease;
    transition-delay: 200ms;
}

/* Mostra tooltip all'hover */
[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
}

/* Rimuovi delay all'uscita (scompare subito) */
[data-tooltip]:not(:hover)::after,
[data-tooltip]:not(:hover)::before {
    transition-delay: 0ms;
}

/* Variante: tooltip sotto l'elemento */
[data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 8px);
}

[data-tooltip-pos="bottom"]::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--border-default);
}

/* ============= ACCESSIBILITY [TASK-FE-024] ============= */

/* --- Global :focus-visible --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.nav-item:focus-visible,
.nav-section-toggle:focus-visible,
.sidebar-theme-toggle:focus-visible,
.sidebar-collapse-toggle:focus-visible,
.btn-logout:focus-visible,
.user-avatar.clickable:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Remove default outline for non-keyboard focus */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
    outline: none;
}

/* --- Skip to Content Link --- */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    z-index: 9999;
    padding: var(--space-3) var(--space-5);
    background: var(--accent);
    color: var(--text-inverse);
    font-weight: 600;
    font-size: var(--text-sm);
    border-radius: 0 0 var(--radius) var(--radius);
    text-decoration: none;
    transition: top var(--transition-fast);
}

.skip-to-content:focus {
    top: 0;
}

/* --- Contrast Fixes --- */
/* Dark theme: text-muted #5c5e72 on #09090f = 3.1:1 (FAIL) → bump to #9294a6 ≈ 5.0:1 */
/* Dark theme: text-secondary #8b8da0 on #09090f = 5.6:1 (PASS) — OK */
:root {
    --text-muted: #9294a6;
}

/* Light theme: text-muted #a1a1aa on #f5f5f7 = 2.6:1 (FAIL) → bump to #6b6b75 ≈ 5.0:1 */
/* Light theme: text-secondary #52525b on #f5f5f7 = 7.0:1 (PASS) — OK */
[data-theme="light"] {
    --text-muted: #6b6b75;
}

/* --- prefers-reduced-motion --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    html {
        scroll-behavior: auto;
    }

    .modal-content {
        animation: none;
    }

    .top-loading-bar {
        animation: none;
    }
}

/* ============================================
   CHATBOT WIDGET — Assistente AI NIS2
   Prefisso: .chatbot-
   ============================================ */

/* --- Trigger bubble (bottom-right) --- */
.chatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: var(--text-inverse);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
    transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
}

.chatbot-trigger:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-xl), 0 0 30px var(--accent-glow);
    background: var(--accent-hover);
}

.chatbot-trigger--active {
    transform: scale(0.92);
    opacity: 0;
    pointer-events: none;
}

.chatbot-trigger-icon {
    width: 24px;
    height: 24px;
}

.chatbot-trigger-pulse {
    position: absolute;
    inset: -4px;
    border-radius: var(--radius-full);
    border: 2px solid var(--accent);
    opacity: 0;
    animation: chatbot-pulse 2s ease-out infinite;
}

@keyframes chatbot-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* --- Panel --- */
.chatbot-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 380px;
    max-height: 560px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.chatbot-panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* --- Header --- */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), var(--teal));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    flex-shrink: 0;
}

.chatbot-avatar svg {
    width: 20px;
    height: 20px;
}

.chatbot-header-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.chatbot-header-subtitle {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.2;
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.chatbot-btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.chatbot-btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chatbot-btn-icon svg {
    width: 16px;
    height: 16px;
}

/* --- Suggestions --- */
.chatbot-suggestions {
    display: none;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.chatbot-suggestion {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.4;
}

.chatbot-suggestion:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--accent);
}

/* --- Messages area --- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-height: 200px;
    max-height: 340px;
    scroll-behavior: smooth;
}

/* Scrollbar sottile */
.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

/* --- Welcome message --- */
.chatbot-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-6) var(--space-4);
    gap: var(--space-3);
}

.chatbot-welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.chatbot-welcome-icon svg {
    width: 24px;
    height: 24px;
}

.chatbot-welcome-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 280px;
    margin: 0;
}

/* --- Message bubbles --- */
.chatbot-message {
    display: flex;
    max-width: 100%;
}

.chatbot-message--user {
    justify-content: flex-end;
}

.chatbot-message--assistant {
    justify-content: flex-start;
}

.chatbot-bubble {
    max-width: 85%;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    line-height: 1.5;
    word-break: break-word;
}

.chatbot-bubble--user {
    background: var(--accent);
    color: var(--text-inverse);
    border-bottom-right-radius: var(--radius-sm);
}

.chatbot-bubble--assistant {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: var(--radius-sm);
}

/* Markdown minimale */
.chatbot-md-para {
    margin: 0;
}

.chatbot-md-para + .chatbot-md-para,
.chatbot-md-para + .chatbot-md-list,
.chatbot-md-list + .chatbot-md-para,
.chatbot-md-list + .chatbot-md-list {
    margin-top: var(--space-2);
}

.chatbot-md-list {
    margin: 0;
    padding-left: var(--space-4);
}

.chatbot-md-list li {
    margin-bottom: var(--space-1);
}

.chatbot-md-list li:last-child {
    margin-bottom: 0;
}

.chatbot-bubble--assistant strong {
    font-weight: 600;
    color: var(--accent-light);
}

/* --- Typing indicator --- */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-3) var(--space-4);
    min-width: 60px;
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    animation: chatbot-typing-bounce 1.4s ease-in-out infinite;
}

.chatbot-typing-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.chatbot-typing-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes chatbot-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Input area --- */
.chatbot-input-area {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-card);
}

.chatbot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-3);
    transition: border-color var(--transition-fast);
}

.chatbot-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.chatbot-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 20px;
}

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

.chatbot-send-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--text-inverse);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition-fast), opacity var(--transition-fast);
}

.chatbot-send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

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

.chatbot-send-btn svg {
    width: 16px;
    height: 16px;
}

.chatbot-input-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: var(--space-1);
}

/* --- Responsive: mobile full-screen overlay --- */
@media (max-width: 768px) {
    .chatbot-trigger {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .chatbot-panel {
        inset: 0;
        width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
        bottom: 0;
        right: 0;
    }

    .chatbot-messages {
        max-height: none;
        flex: 1;
    }
}
