/* =====================================================================
   DynamoHelp – Design system
   ===================================================================== */
:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e6e9f0;
    --border-strong: #d5dae4;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --primary: #4f46e5;
    --ai: #0d9488;
    --primary-2: #7c3aed;
    --primary-soft: #eef2ff;
    --primary-text: #4338ca;
    --ring: rgba(79, 70, 229, .18);
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --sidebar-bg: #0f172a;
    --sidebar-bg-2: #131c34;
    --sidebar-text: #aab4c8;
    --radius: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 10px 30px -12px rgba(15, 23, 42, .14);
    --shadow-lg: 0 20px 50px -12px rgba(15, 23, 42, .25);
    --sidebar-w: 268px;
    --topbar-h: 66px;
    color-scheme: light;

    /* colori semantici dei badge */
    --c-open: #2563eb;
    --c-progress: #7c3aed;
    --c-waiting: #c2410c;
    --c-resolved: #047857;
    --c-closed: #64748b;
    --c-high: #dc2626;
    --c-normal: #0369a1;
    --c-low: #64748b;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0a0f1d;
        --surface: #111827;
        --surface-2: #151e30;
        --surface-3: #1a2438;
        --border: #222d42;
        --border-strong: #2e3a52;
        --text: #e7ebf3;
        --text-2: #c3cada;
        --muted: #8b97ad;
        --primary: #818cf8;
        --ai: #2dd4bf;
        --primary-2: #a78bfa;
        --primary-soft: rgba(129, 140, 248, .14);
        --primary-text: #a5b4fc;
        --ring: rgba(129, 140, 248, .28);
        --success: #34d399;
        --warning: #fbbf24;
        --danger: #f87171;
        --info: #38bdf8;
        --sidebar-bg: #0b1222;
        --sidebar-bg-2: #0e1629;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .5);
        --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .6);
        --c-open: #60a5fa;
        --c-progress: #a78bfa;
        --c-waiting: #fb923c;
        --c-resolved: #34d399;
        --c-closed: #94a3b8;
        --c-high: #f87171;
        --c-normal: #38bdf8;
        --c-low: #94a3b8;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0a0f1d;
    --surface: #111827;
    --surface-2: #151e30;
    --surface-3: #1a2438;
    --border: #222d42;
    --border-strong: #2e3a52;
    --text: #e7ebf3;
    --text-2: #c3cada;
    --muted: #8b97ad;
    --primary: #818cf8;
    --ai: #2dd4bf;
    --primary-2: #a78bfa;
    --primary-soft: rgba(129, 140, 248, .14);
    --primary-text: #a5b4fc;
    --ring: rgba(129, 140, 248, .28);
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #38bdf8;
    --sidebar-bg: #0b1222;
    --sidebar-bg-2: #0e1629;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .5);
    --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .6);
    --c-open: #60a5fa;
    --c-progress: #a78bfa;
    --c-waiting: #fb923c;
    --c-resolved: #34d399;
    --c-closed: #94a3b8;
    --c-high: #f87171;
    --c-normal: #38bdf8;
    --c-low: #94a3b8;
    color-scheme: dark;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
}
body.no-scroll { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 750; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0 0 1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--surface-3); padding: .1em .4em; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; align-items: center; gap: .5rem; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 14px 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; font-weight: 750; font-size: 16.5px; letter-spacing: -.02em; }
.brand:hover { color: #fff; }
.brand-logo {
    width: 38px; height: 38px; border-radius: 11px;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    box-shadow: 0 8px 20px -6px rgba(124, 58, 237, .65), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.brand-logo .icon { width: 20px; height: 20px; }
.brand-logo { overflow: hidden; flex: none; }
.brand-logo .brand-mark, .brand-logo img { display: block; width: 100%; height: 100%; }
/* Seconda parola del nome (es. «Help» in DynamoHelp) colorata come nel logo */
.brand-accent { background: linear-gradient(90deg, #a5b4fc, #d8b4fe); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-mobile-brand .brand-accent { background-image: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.sidebar-close { display: none; color: var(--sidebar-text); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #5b6880; padding: 18px 12px 8px; font-weight: 650; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; margin-bottom: 2px;
    border-radius: 11px;
    color: var(--sidebar-text);
    font-weight: 520; font-size: 14px;
    transition: background .15s, color .15s;
}
.nav-link .icon { opacity: .85; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, .95), rgba(139, 92, 246, .92));
    color: #fff;
    box-shadow: 0 10px 22px -10px rgba(99, 102, 241, .8);
}
.nav-link.active .icon { opacity: 1; }
.nav-count {
    margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px;
    border-radius: 999px; font-size: 11.5px; font-weight: 700;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .1); color: #e2e8f0;
}
.nav-link.active .nav-count { background: rgba(255, 255, 255, .22); color: #fff; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .06); }
.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; color: #fff; }
.sidebar-user:hover, .sidebar-user.active { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sidebar-user-info strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info small { font-size: 12px; color: var(--sidebar-text); }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.topbar {
    position: sticky; top: 0; z-index: 40;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 14px;
    padding: 0 28px;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.menu-toggle { display: none; }
.topbar-search {
    flex: 1; max-width: 480px;
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px; height: 40px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; color: var(--muted);
    transition: border-color .15s, box-shadow .15s;
}
.topbar-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.topbar-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.btn-icon {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; border-radius: 11px;
    border: 1px solid transparent; background: transparent;
    color: var(--muted); cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon.menu-toggle, .btn-icon.sidebar-close { display: none; }
.btn-icon.sidebar-close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-light { display: inline; }
    :root:not([data-theme="light"]) .theme-icon-dark { display: none; }
}

/* dropdown utente */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.user-chip:hover { border-color: var(--border-strong); }
.user-chip-name { font-weight: 600; font-size: 13.5px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 240px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-lg);
    animation: pop .14s ease-out;
    z-index: 70;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.dropdown-header { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; }
.dropdown-header small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 12px; border-radius: 9px; border: 0; background: none;
    color: var(--text-2); font: inherit; font-weight: 500; text-align: left; cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-3); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }

.content { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; padding: 18px 28px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--border); }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.back-link:hover { color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; min-height: 40px;
    border-radius: 11px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 14px; line-height: 1.2;
    cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: transform .08s, box-shadow .15s, background .15s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    box-shadow: 0 8px 18px -8px rgba(79, 70, 229, .7), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.btn-primary:hover { color: #fff; box-shadow: 0 12px 24px -10px rgba(79, 70, 229, .85), inset 0 1px 0 rgba(255, 255, 255, .15); filter: brightness(1.05); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { color: var(--text); border-color: var(--muted); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { color: #fff; filter: brightness(1.08); }
.btn-danger-soft { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.btn-danger-soft:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.btn-success-soft { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); }
.btn-success-soft:hover { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.btn-soft { background: var(--primary-soft); color: var(--primary-text); }
.btn-soft:hover { color: var(--primary-text); filter: brightness(.97); }
.btn-sm { padding: 7px 12px; min-height: 34px; font-size: 13px; border-radius: 9px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { padding: 13px 22px; min-height: 48px; font-size: 15px; border-radius: 13px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card + .card { margin-top: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; font-size: 15.5px; display: flex; align-items: center; gap: 10px; }
.card-header h2 .icon, .card-header h3 .icon { color: var(--muted); }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.card-flush .card-body { padding: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.layout-side-main { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; align-items: start; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 20px); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
    padding: 18px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    color: inherit; transition: transform .15s, box-shadow .15s;
}
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: inherit; }
.stat-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.tone-blue { --tone: var(--c-open); }
.tone-violet { --tone: var(--c-progress); }
.tone-orange { --tone: var(--c-waiting); }
.tone-green { --tone: var(--c-resolved); }
.tone-red { --tone: var(--c-high); }
.tone-slate { --tone: var(--c-closed); }
.tone-indigo { --tone: var(--primary); }

/* ---------- Welcome banner ---------- */
.hero-banner {
    position: relative; overflow: hidden;
    border-radius: 20px; padding: 26px 28px; margin-bottom: 24px;
    background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 55%, #c026d3 100%);
    color: #fff; box-shadow: 0 20px 40px -20px rgba(79, 70, 229, .7);
    display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.hero-banner::after { content: ''; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.hero-banner::before { content: ''; position: absolute; right: 120px; bottom: -110px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.hero-banner h1 { color: #fff; margin: 0 0 4px; font-size: 1.5rem; }
.hero-banner p { margin: 0; opacity: .88; }
.hero-banner > * { position: relative; z-index: 1; }
.hero-banner .btn-light { background: #fff; color: #4338ca; box-shadow: 0 8px 20px -8px rgba(0,0,0,.35); }
.hero-banner .btn-light:hover { color: #3730a3; background: #f5f3ff; }
.hero-banner .btn-glass { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.25); }
.hero-banner .btn-glass:hover { background: rgba(255,255,255,.22); color: #fff; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
    color: var(--muted);
    background: color-mix(in srgb, currentColor 11%, transparent);
}
.badge .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.badge-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-open { color: var(--c-open); }
.status-in_progress { color: var(--c-progress); }
.status-waiting { color: var(--c-waiting); }
.status-resolved { color: var(--c-resolved); }
.status-closed { color: var(--c-closed); }
.prio-high { color: var(--c-high); }
.prio-normal { color: var(--c-normal); }
.prio-low { color: var(--c-low); }
.role-admin { color: #db2777; }
.role-agent_l2 { color: var(--c-progress); }
.role-agent_l1 { color: var(--c-open); }
.role-client { color: var(--c-resolved); }
.level-1 { color: var(--c-normal); }
.level-2 { color: var(--c-progress); }
.badge-success { color: var(--success); }
.badge-danger { color: var(--danger); }
.badge-warning { color: var(--warning); }
.badge-neutral { color: var(--muted); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
.cat-chip { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; color: var(--text-2); }

/* ---------- Avatars ---------- */
.avatar {
    --h: 240;
    width: 38px; height: 38px; border-radius: 50%;
    display: inline-grid; place-items: center; flex-shrink: 0;
    font-size: 13.5px; font-weight: 700; letter-spacing: .02em;
    color: hsl(var(--h) 55% 32%);
    background: hsl(var(--h) 75% 90%);
}
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 85% 82%); background: hsl(var(--h) 35% 24%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--h) 85% 82%); background: hsl(var(--h) 35% 24%); } }
.sidebar .avatar { color: #fff; background: hsl(var(--h) 45% 38%); }

/* ---------- Alerts ---------- */
.alert {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 13px 14px 13px 16px; margin-bottom: 18px;
    border-radius: 13px; border: 1px solid;
    font-weight: 500; animation: pop .2s ease-out;
    --tone: var(--info);
    color: var(--tone);
    background: color-mix(in srgb, var(--tone) 8%, var(--surface));
    border-color: color-mix(in srgb, var(--tone) 25%, transparent);
}
.alert > div { flex: 1; color: var(--text); }
.alert > .icon { margin-top: 1px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert-success { --tone: var(--success); }
.alert-error { --tone: var(--danger); }
.alert-warning { --tone: var(--warning); }
.alert-info { --tone: var(--info); }
.alert-close { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; display: grid; }
.alert-close:hover { color: var(--text); }
.alert-close .icon { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }
.label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 7px; color: var(--text-2); }
.label .req { color: var(--danger); margin-left: 2px; }
.label .opt { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.input, .select, .textarea {
    width: 100%; min-height: 42px;
    padding: 10px 13px;
    font: inherit; font-size: 14.5px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px;
    transition: border-color .15s, box-shadow .15s, background .15s;
    box-shadow: var(--shadow-xs);
}
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--muted) 55%, var(--border-strong)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
.select {
    appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b97ad' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.input-color { padding: 4px; height: 42px; width: 64px; cursor: pointer; }
.input-sm, .select-sm { min-height: 36px; padding: 7px 11px; font-size: 13.5px; border-radius: 9px; }
.select-sm { padding-right: 34px; background-position: right 9px center; background-size: 16px; }
.input-group { position: relative; }
.input-group > .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-group > .input { padding-left: 40px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.field-error { font-size: 12.5px; color: var(--danger); margin-top: 6px; font-weight: 500; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.form-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 26px 0 14px; display: flex; align-items: center; gap: 10px; }
.form-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.form-section-title:first-child { margin-top: 0; }

/* checkbox & switch */
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 6px 0; font-weight: 500; color: var(--text-2); }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); flex-shrink: 0; cursor: pointer; }
.check small { display: block; color: var(--muted); font-weight: 400; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; font-weight: 500; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); transition: background .2s; flex-shrink: 0; }
.switch-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 4px var(--ring); }
.switch small { display: block; color: var(--muted); font-weight: 400; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.check-card { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 11px; cursor: pointer; transition: border-color .15s, background .15s; font-weight: 500; }
.check-card:hover { border-color: var(--muted); }
.check-card input { width: 17px; height: 17px; accent-color: var(--primary); margin: 0; }
.check-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }

/* priority picker */
.priority-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.priority-option { position: relative; cursor: pointer; }
.priority-option input { position: absolute; opacity: 0; pointer-events: none; }
.priority-option .po-box {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 13px 14px; border-radius: 13px; height: 100%;
    border: 1.5px solid var(--border-strong); background: var(--surface);
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.priority-option .po-title { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--tone); }
.priority-option .po-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.priority-option:hover .po-box { border-color: color-mix(in srgb, var(--tone) 50%, var(--border-strong)); }
.priority-option input:checked + .po-box { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 7%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 15%, transparent); }
.priority-option input:focus-visible + .po-box { box-shadow: 0 0 0 4px var(--ring); }
.priority-option.p-high { --tone: var(--c-high); }
.priority-option.p-normal { --tone: var(--c-normal); }
.priority-option.p-low { --tone: var(--c-low); }

/* category picker */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.cat-card { position: relative; cursor: pointer; }
.cat-card input { position: absolute; opacity: 0; pointer-events: none; }
.cat-card .cc-box {
    display: flex; align-items: flex-start; gap: 11px; height: 100%;
    padding: 12px 14px; border-radius: 13px;
    border: 1.5px solid var(--border-strong); background: var(--surface);
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.cat-card .cc-box .color-dot { margin-top: 6px; }
.cat-card .cc-box strong { display: block; font-weight: 650; color: var(--text); }
.cat-card .cc-box small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 2px; }
.cat-card .cc-dept { display: inline-flex !important; align-items: center; gap: 4px; margin-top: 5px !important; font-weight: 600; }
.cat-card:hover .cc-box { border-color: color-mix(in srgb, var(--primary) 45%, var(--border-strong)); }
.cat-card input:checked + .cc-box { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--ring); }
.cat-card input:focus-visible + .cc-box { box-shadow: 0 0 0 4px var(--ring); }

/* dropzone */
.dropzone {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 24px 16px; text-align: center;
    border: 2px dashed var(--border-strong); border-radius: 14px;
    background: var(--surface-2); color: var(--muted);
    cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone .dz-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); margin-bottom: 4px; }
.dropzone strong { color: var(--text); font-weight: 600; }
.dropzone small { font-size: 12px; }
.dropzone-compact { flex-direction: row; padding: 12px 16px; gap: 12px; text-align: left; justify-content: flex-start; }
.dropzone-compact .dz-icon { width: 36px; height: 36px; margin: 0; }
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px 9px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); animation: pop .15s ease-out; }
.file-item .icon { color: var(--primary); }
.file-item .fi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 13.5px; }
.file-item .fi-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.file-item button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 7px; display: grid; }
.file-item button:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.file-item.error { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.file-item.error .fi-size { color: var(--danger); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .input, .filters .select { width: auto; min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.filters .filter-search { flex: 2 1 220px; max-width: 360px; }
.filters .filter-search .input { width: 100%; max-width: none; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 12px 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px 12px; color: var(--muted); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-text); border-bottom-color: var(--primary); }
.tab .tab-count { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.tab.active .tab-count { background: var(--primary-soft); color: var(--primary-text); }

/* ---------- Ticket list ---------- */
.ticket-list { display: flex; flex-direction: column; }
.ticket-row {
    display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 16px; align-items: center;
    padding: 15px 20px 15px 0; color: inherit;
    border-bottom: 1px solid var(--border); transition: background .12s;
}
.ticket-row:last-child { border-bottom: 0; }
.ticket-row:hover { background: var(--surface-2); color: inherit; }
.ticket-row .tr-bar { align-self: stretch; border-radius: 0 4px 4px 0; background: transparent; }
.ticket-row.prio-row-high .tr-bar { background: var(--c-high); }
.tr-main { min-width: 0; }
.tr-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.tr-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tr-subject { font-weight: 650; font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-meta { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; margin-top: 5px; color: var(--muted); font-size: 12.5px; }
.tr-meta span { display: inline-flex; align-items: center; gap: 5px; }
.tr-meta .icon { width: 13px; height: 13px; }
.tr-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; font-size: 12.5px; color: var(--muted); }
.tr-assignee { display: flex; align-items: center; gap: 8px; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.new-reply { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--primary-text); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .t-actions { text-align: right; white-space: nowrap; }
.table .t-actions .btn + .btn, .table .t-actions form { margin-left: 4px; }
.table .t-actions form { display: inline; }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-user strong { display: block; font-weight: 600; }
.cell-user small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Ticket view ---------- */
.ticket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.ticket-head h1 { font-size: 1.45rem; margin: 6px 0 10px; word-break: break-word; }
.ticket-head .badges { display: flex; gap: 8px; flex-wrap: wrap; }
.thread { display: flex; flex-direction: column; gap: 16px; }
.message { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; }
.message-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.message-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.message-author { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.message-author strong { font-weight: 650; }
.message-time { font-size: 12.5px; color: var(--muted); }
.message-body { padding: 16px 18px; color: var(--text-2); word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.65; }
.message-body a { text-decoration: underline; text-underline-offset: 2px; }
.message.from-staff .message-card { border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 4%, var(--surface)), var(--surface)); }
.message.is-first .message-card { border-left: 3px solid var(--primary); }
.message.internal .message-card { border: 1.5px dashed color-mix(in srgb, var(--warning) 60%, transparent); background: color-mix(in srgb, var(--warning) 6%, var(--surface)); }
.internal-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: var(--warning); text-transform: uppercase; letter-spacing: .05em; }
.attachments { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 18px 16px; }
.attachment {
    display: inline-flex; align-items: center; gap: 10px; max-width: 100%;
    padding: 8px 12px 8px 9px; border-radius: 11px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
    font-size: 13px; transition: border-color .15s, background .15s;
}
.attachment:hover { border-color: var(--primary); color: var(--text); background: var(--primary-soft); }
.attachment .att-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); color: var(--primary); flex-shrink: 0; }
.attachment .att-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.attachment .att-size { display: block; font-size: 11.5px; color: var(--muted); }
.attachment-img { display: block; width: 132px; height: 96px; border-radius: 11px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); position: relative; }
.attachment-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.attachment-img:hover img { transform: scale(1.05); }
.attachment-img span { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 5px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event { display: flex; align-items: center; gap: 10px; padding: 2px 0 2px 52px; color: var(--muted); font-size: 13px; }
.event .event-icon { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex-shrink: 0; margin-left: -38px; }
.event .event-icon .icon { width: 13px; height: 13px; }
.event strong { color: var(--text-2); font-weight: 600; }
.reply-box { margin-top: 24px; }
.reply-box .textarea { min-height: 130px; }
.reply-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.reply-opts { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }

.detail-list { display: flex; flex-direction: column; }
.detail-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.detail-item:last-child { border-bottom: 0; }
.detail-item dt, .detail-label { color: var(--muted); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.detail-item dt .icon { width: 15px; height: 15px; }
.detail-item dd { margin: 0; text-align: right; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.side-stack { display: flex; flex-direction: column; gap: 20px; }
.side-stack .card + .card { margin-top: 0; }
.product-box { padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.product-box h4 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.product-box h4 .icon { color: var(--primary); }
.product-box dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.product-box dt { color: var(--muted); }
.product-box dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.product-notes { margin-top: 10px; font-size: 13px; color: var(--text-2); white-space: pre-wrap; }

/* ---------- Distribuzione per categoria ---------- */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 6px; }
.bar-row-head span:first-child { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.bar-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--c, var(--primary)); min-width: 6px; }

/* ---------- Product / software cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.item-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; }
.item-card:hover { box-shadow: var(--shadow); }
.item-card-head { display: flex; align-items: flex-start; gap: 14px; }
.item-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7); box-shadow: 0 8px 18px -8px rgba(99, 102, 241, .7); }
.item-icon .icon { width: 24px; height: 24px; }
.item-card h3 { margin: 0 0 2px; font-size: 16px; }
.item-card .item-sub { color: var(--muted); font-size: 13px; }
.item-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13.5px; }
.item-card dt { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.item-card dt .icon { width: 14px; height: 14px; }
.item-card dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.item-card .item-actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.software-hero { display: flex; gap: 22px; align-items: center; padding: 24px; margin-bottom: 24px; border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border)); }
.software-hero .item-icon { width: 64px; height: 64px; border-radius: 18px; }
.software-hero .item-icon .icon { width: 32px; height: 32px; }
.software-hero p { margin: 4px 0 0; color: var(--text-2); }
.steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.step { position: relative; padding: 16px 16px 16px 58px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 16px; top: 16px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--primary-text); background: var(--primary-soft); }
.step strong { display: block; color: var(--text); margin-bottom: 2px; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .empty-icon { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 20px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty-state .empty-icon .icon { width: 28px; height: 28px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }
.empty-state p { max-width: 420px; margin: 0 auto 18px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; padding: 16px; flex-wrap: wrap; }
.page-btn { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 10px; display: inline-grid; place-items: center; font-weight: 600; font-size: 13.5px; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: .4; pointer-events: none; }
.page-gap { color: var(--muted); padding: 0 4px; }
.list-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; min-height: 52px; flex-wrap: wrap; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); background: var(--surface-2); }
.list-footer .pagination { padding: 0; }

/* ---------- Auth pages ---------- */
.auth-body { background: var(--surface); }
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.auth-hero { position: relative; overflow: hidden; color: #fff; background: radial-gradient(1200px 600px at 10% 10%, #6d28d9 0%, transparent 60%), linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #4c1d95 100%); }
.auth-hero-inner { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 44px 52px; }
.auth-hero-text { max-width: 480px; }
.auth-hero-text h2 { color: #fff; font-size: 2.35rem; line-height: 1.12; font-weight: 800; letter-spacing: -.035em; margin-bottom: 16px; }
.auth-hero-text p { color: rgba(255, 255, 255, .78); font-size: 15.5px; margin-bottom: 26px; }
.auth-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-features li { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.9); font-weight: 500; }
.auth-features .icon { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .12); }
.auth-hero-foot { color: rgba(255, 255, 255, .55); font-size: 13px; }
.auth-blob { position: absolute; border-radius: 50%; filter: blur(10px); z-index: 1; }
.auth-blob-1 { width: 420px; height: 420px; right: -140px; top: -120px; background: radial-gradient(circle, rgba(168, 85, 247, .55), transparent 70%); }
.auth-blob-2 { width: 380px; height: 380px; left: -120px; bottom: -140px; background: radial-gradient(circle, rgba(99, 102, 241, .5), transparent 70%); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 410px; }
.auth-mobile-brand { display: none; color: var(--text); margin-bottom: 28px; }
.auth-mobile-brand:hover { color: var(--text); }
.auth-title { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: 6px; }
.auth-subtitle { color: var(--muted); margin-bottom: 26px; }
.auth-links { margin-top: 22px; text-align: center; color: var(--muted); font-size: 13.5px; display: flex; flex-direction: column; gap: 10px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 22px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 46px; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; }
.captcha { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.captcha-img { display: block; width: 190px; height: 64px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #f1f5f9; user-select: none; }
.captcha-refresh { flex: none; border: 1px solid var(--border); }
.captcha .input { flex: 1 1 140px; min-width: 0; height: 48px; font-size: 1.05rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
.captcha .input::placeholder { letter-spacing: normal; text-transform: none; font-weight: 400; }
.captcha-question { font-weight: 700; font-size: 1.05rem; padding: 0 6px; }

/* installer */
.install-wrap { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; background: radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent), var(--bg); }
.install-card { width: 100%; max-width: 760px; }
.install-card .brand { color: var(--text); margin-bottom: 22px; }

/* ---------- Smistamento ticket ---------- */
.routing-summary { display: grid; gap: 10px; padding: 12px 14px; margin-bottom: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.routing-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.routing-label { font-size: 12.5px; color: var(--muted); font-weight: 500; flex: none; }
.routing-value { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; min-width: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level-steps { display: inline-flex; align-items: center; }
.level-step { display: inline-grid; place-items: center; width: 30px; height: 24px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); }
.level-step.done { background: var(--primary); color: #fff; border-color: var(--primary); }
.level-line { width: 22px; height: 2px; background: var(--border-strong, var(--border)); }
.level-line.done { background: var(--primary); }
.action-panel { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 8px; background: var(--surface); transition: border-color .15s; }
.action-panel[open] { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: 0 0 0 3px var(--primary-soft); }
.action-panel > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 13px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text-2, var(--text)); border-radius: var(--radius-sm); user-select: none; }
.action-panel > summary::-webkit-details-marker { display: none; }
.action-panel > summary:hover { background: var(--surface-2); }
.action-panel > summary .icon { color: var(--primary); }
.action-panel > summary .chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.action-panel[open] > summary .chev { transform: rotate(180deg); }
.action-panel-body { padding: 4px 13px 13px; }
.action-panel-body .form-group { margin-bottom: 12px; }
.textarea.textarea-sm { min-height: 78px; }
.grid-2.grid-2-tight { gap: 10px; }
.grid-2.grid-2-tight .form-group { margin-bottom: 12px; }
.canned-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--muted); }
.canned-picker .select { flex: 1; min-width: 0; }
.canned-preview { max-width: 520px; }

/* ---------- Notifiche ---------- */
.notif-bell { position: relative; }
.notif-badge { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.notif-badge[hidden] { display: none; }
.notif-menu { width: min(380px, calc(100vw - 24px)); padding: 0; overflow: hidden; }
.notif-menu-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-menu-head a { font-size: 13px; font-weight: 600; }
.notif-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 16px; color: var(--muted); font-size: 13.5px; }
.notif-empty .icon { width: 26px; height: 26px; }
.notif-list { display: flex; flex-direction: column; }
.notif-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; position: relative; }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item.compact { padding: 11px 14px; }
.notif-item.unread { background: color-mix(in srgb, var(--primary-soft) 70%, transparent); }
.notif-item.unread::before { content: ''; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--primary); }
.notif-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3); color: var(--muted); }
.notif-icon .icon { width: 17px; height: 17px; }
.notif-icon.type-created { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.notif-icon.type-reply { background: var(--primary-soft); color: var(--primary); }
.notif-icon.type-note { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.notif-icon.type-assigned, .notif-icon.type-transferred { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.notif-icon.type-escalated, .notif-icon.type-deescalated { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.notif-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notif-text strong { font-weight: 600; font-size: 13.5px; line-height: 1.4; }
.notif-item:not(.unread) .notif-text strong { font-weight: 500; color: var(--text-2, var(--text)); }
.notif-text small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
.card-header .tabs-inline { padding: 0; border: 0; margin: -16px 0 -17px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .layout-main-side { grid-template-columns: minmax(0, 1fr) 300px; }
    .layout-side-main { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
    .btn-icon.sidebar-close, .btn-icon.menu-toggle { display: inline-grid; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(2, 6, 23, .55); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .25s; display: block; }
    .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0; }
    .layout-main-side { grid-template-columns: 1fr; }
    .sticky-side { position: static; }
    .auth { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-mobile-brand { display: inline-flex; }
}
@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .user-chip-name { display: none; }
    .user-chip { padding: 3px; }
    .user-chip > .icon { display: none; }
    .ticket-row { grid-template-columns: 4px minmax(0, 1fr); padding-right: 16px; gap: 12px; }
    .tr-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
    .tr-subject { white-space: normal; }
    .filters .input, .filters .select { max-width: none; flex: 1 1 calc(50% - 10px); }
    .filters .filter-search { flex-basis: 100%; max-width: none; }
    .priority-picker { grid-template-columns: 1fr; }
    .priority-option .po-box { flex-direction: row; align-items: center; justify-content: space-between; }

    /* tabelle → card */
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .table-stack tr:last-child { border-bottom: 0; }
    .table-stack td { padding: 5px 0; border: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
    .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; text-align: left; flex-shrink: 0; }
    .table-stack td.t-main { display: block; text-align: left; padding-bottom: 8px; }
    .table-stack td.t-main::before { display: none; }
    .table-stack td.t-actions { justify-content: flex-end; padding-top: 10px; }
    .table-stack td.t-actions::before { display: none; }
    .table-stack tbody tr:hover td { background: transparent; }
    .message { grid-template-columns: minmax(0, 1fr); }
    .message > .avatar { display: none; }
    .event { padding-left: 14px; }
    .event .event-icon { margin-left: 0; }
}
@media (max-width: 640px) {
    .notif-item { padding: 12px 14px; }
    .notif-time { display: none; }
    .notif-dropdown { position: static; }
    .notif-dropdown .notif-menu { left: 12px; right: 12px; width: auto; }
    body { font-size: 14px; }
    .content { padding: 18px 14px 28px; }
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar-search { display: none; }
    .hide-xs { display: none !important; }
    .app-footer { padding: 14px; }
    h1, .page-head h1 { font-size: 1.35rem; }
    .card-header, .card-body { padding-left: 16px; padding-right: 16px; }
    .hero-banner { padding: 22px 20px; }
    .hero-banner .btn { flex: 1; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat { flex-direction: column; align-items: flex-start; gap: 10px; padding: 15px; }
    .stat-icon { width: 38px; height: 38px; border-radius: 11px; }
    .stat-value { font-size: 22px; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .software-hero { flex-direction: column; align-items: flex-start; padding: 20px; }
    .attachment .att-name { max-width: 160px; }
    .attachment-img { width: calc(50% - 5px); height: 110px; }
    .reply-opts .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
    .sidebar, .topbar, .app-footer, .reply-box, .page-actions, .side-actions { display: none !important; }
    .main { margin: 0; }
    .layout-main-side { grid-template-columns: 1fr; }
}

/* ==========================================================
   v2: lingue, SLA
   ========================================================== */
.auth-panel { position: relative; }
.auth-topbar { position: absolute; top: 16px; right: 20px; z-index: 5; }
.lang-switch > summary { gap: 6px; }
.lang-switch .dropdown-menu { min-width: 170px; }
.dropdown-item.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 650; }
.lang-menu { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 6px 0; padding: 8px 4px; }
.dropdown-label { display: flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; padding: 0 8px 6px; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.lang-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; cursor: pointer; text-align: center; }
.lang-btn:hover { background: var(--surface-3); color: var(--text); }
.lang-btn.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); font-weight: 650; }

.sla-badge { gap: 4px; }
.sla-badge.sla-ok { background: rgba(5, 150, 105, .12); color: var(--success); }
.sla-badge.sla-warning { background: rgba(217, 119, 6, .14); color: var(--warning); }
.sla-badge.sla-breached { background: rgba(220, 38, 38, .14); color: var(--danger); }
@media (max-width: 640px) {
    .auth-topbar { top: 10px; right: 10px; }
}

/* SLA nel ticket */
.sla-box { display: flex; flex-direction: column; gap: 10px; }
.sla-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sla-row > div { display: flex; flex-direction: column; min-width: 0; }
.sla-label { font-weight: 600; font-size: 13.5px; }
.sla-badge.sla-ok, .sla-badge.sla-warning, .sla-badge.sla-breached { white-space: nowrap; }

/* Valutazione del cliente */
.rating-card { margin-bottom: 18px; border-color: var(--primary); }
.rating-card h3 { display: flex; align-items: center; gap: 8px; }
.star-input { display: inline-flex; flex-direction: row-reverse; gap: 4px; }
.star-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-input label { cursor: pointer; color: var(--border-strong); transition: color .12s, transform .12s; }
.star-input label .icon { width: 30px; height: 30px; }
.star-input label:hover, .star-input label:hover ~ label, .star-input input:checked ~ label { color: #f59e0b; }
.star-input label:hover .icon, .star-input label:hover ~ label .icon, .star-input input:checked ~ label .icon { fill: currentColor; }
.star-input input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.stars { display: inline-flex; gap: 2px; color: var(--border-strong); }
.stars .on { color: #f59e0b; }
.stars .on .icon { fill: currentColor; }
.rating-comment { margin-top: 8px; font-style: italic; color: var(--text-2); }

/* Tempo lavorato e pacchetti ore */
.package-mini { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.package-mini-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.package-mini.is-low { border-color: var(--warning); }
.package-mini.is-empty { border-color: var(--danger); }
.progress { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.is-low .progress > span { background: var(--warning); }
.is-empty .progress > span { background: var(--danger); }
.time-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.time-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.time-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.time-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.time-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.btn-icon-sm { width: 30px; height: 30px; }
.btn-icon-sm .icon { width: 15px; height: 15px; }

/* Anteprima immagini ingrandita */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(2, 6, 23, .86); display: flex; align-items: center; justify-content: center; padding: 24px; animation: pop .14s ease-out; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); background: #fff; }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100%; }
.lightbox figcaption { color: #e2e8f0; font-size: 13px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.lightbox figcaption a { color: #c7d2fe; }
.lightbox-close, .lightbox-nav { position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255, 255, 255, .22); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-nav.prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-nav.next { right: 16px; top: 50%; transform: translateY(-50%); }

/* Anteprima dei file scelti / incollati */
.file-thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid var(--border); }
.paste-hint { animation: pop .2s ease-out; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 210; background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; animation: pop .15s ease-out; transition: opacity .4s; }
.toast.hide { opacity: 0; }

/* Elenchi: scheda SLA a rischio, riepilogo ore, tabella SLA */
.tab.tab-alert { color: var(--danger); }
.tab.tab-alert .tab-count { background: rgba(220, 38, 38, .12); color: var(--danger); }
.hours-group { border-top: 1px solid var(--border); }
.hours-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 20px 6px; }
.duration-input { display: flex; align-items: center; gap: 6px; }
.duration-input .input { width: 60px; padding-left: 10px; padding-right: 6px; }
.duration-input span { color: var(--muted); font-size: 13px; }
.sla-table td { vertical-align: middle; }
.sla-table td.has-error .input { border-color: var(--danger); }
@media (max-width: 640px) {
    .duration-input .input { width: 64px; }
}
.sla-table td:last-child { min-width: 170px; white-space: normal; }
.sla-table th, .sla-table td { padding-left: 10px; padding-right: 10px; }
.btn-wrap { white-space: normal; height: auto; min-height: 34px; text-align: center; line-height: 1.3; padding-top: 7px; padding-bottom: 7px; }
.package-mini-head span, .package-mini-head strong { white-space: nowrap; }
.package-mini-head { flex-wrap: wrap; }
.hours-group td strong, .time-main > strong { white-space: nowrap; }
.notif-icon.type-sla_warning { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.notif-icon.type-sla_breached { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.notif-icon.type-rating { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #f59e0b; }
.notif-icon.type-hours { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }

/* ===================== Assistente virtuale ===================== */
.badge-ai { color: var(--ai); }
.avatar-ai { background: color-mix(in srgb, var(--ai) 16%, var(--surface)); color: var(--ai); }
.avatar-ai .icon { width: 58%; height: 58%; }
.message.from-ai .message-card { border-color: color-mix(in srgb, var(--ai) 30%, var(--border)); background: linear-gradient(180deg, color-mix(in srgb, var(--ai) 5%, var(--surface)), var(--surface)); }
.message.from-ai.internal .message-card { border: 1.5px dashed color-mix(in srgb, var(--warning) 60%, transparent); background: color-mix(in srgb, var(--warning) 6%, var(--surface)); }
.ai-thinking .message-body { padding: 14px 18px; }
.ai-thinking-line { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--ai); animation: ai-dot 1.2s infinite ease-in-out; }
.ai-dots span:nth-child(2) { animation-delay: .15s; }
.ai-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.ai-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: ai-spin .8s linear infinite; display: inline-block; flex-shrink: 0; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-feedback { margin: 18px 0 0 54px; border-color: color-mix(in srgb, var(--ai) 35%, var(--border)); }
.ai-feedback h3 { display: flex; align-items: center; gap: 8px; }
.ai-feedback h3 .icon { color: var(--ai); }
.ai-feedback-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.ai-handoff-details > summary { list-style: none; cursor: pointer; }
.ai-handoff-details > summary::-webkit-details-marker { display: none; }
.ai-handoff-details[open] { flex-basis: 100%; }
.ai-handoff-form { margin-top: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2, var(--surface)); }
.tab-ai { color: var(--ai); }
.tab-ai.active { color: var(--ai); border-bottom-color: var(--ai); }
.ai-card .card-header { gap: 8px; }
@media (max-width: 640px) { .ai-feedback { margin-left: 0; } }
@media (prefers-reduced-motion: reduce) { .ai-dots span, .ai-spinner { animation: none; } }

.org-billing { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.org-billing summary { cursor: pointer; font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }

/* Vendite: servizi del cliente nella pagina del ticket */
.svc-mini { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.svc-mini:last-child { border-bottom: 0; }
.svc-mini > div { min-width: 0; }
.svc-mini small { display: block; color: var(--muted); }
dl.detail-list { margin: 0; }

/* Licenza dell'istanza */
.license-modules { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.license-modules li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.license-modules li small { margin-left: auto; color: var(--muted); font-weight: 600; }
.license-modules li.on .icon { color: var(--success); }
.license-modules li.off { color: var(--muted); }
.license-usage { font-size: 15px; color: var(--muted); margin: 0 0 10px; }
.license-usage strong { font-size: 26px; color: var(--text); letter-spacing: -.02em; }

/* Server: accesso SSH e indirizzi bloccati */
.server-modes { display: grid; gap: 8px; }
.server-mode { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.server-mode span { display: grid; gap: 2px; }
.server-mode small { color: var(--muted); }
.banned-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.banned-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.banned-list { max-height: 26rem; overflow-y: auto; }
.banned-list li > span { display: grid; gap: 2px; min-width: 0; }
.jail-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.jail-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.code-block { margin: 8px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); overflow-x: auto; white-space: pre; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Accesso arrivando dal negozio: invito a creare l'account */
.signup-callout { display: grid; gap: 12px; padding: 16px; border-radius: var(--radius-md, 12px); background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); margin-bottom: 4px; }
.signup-callout strong { display: block; font-size: 15px; }
.signup-callout span { color: var(--text-2); font-size: 13.5px; }
.trial-box form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
