/* ============================================================
   TOKENS
   ============================================================ */
:root {
    --bg: #FFF9F4;
    --bg-sunk: #FCEEE1;
    --surface: #FFFFFF;
    --surface-tint: #FFF3E8;
    --border: #F1E1D0;
    --border-strong: #E9CDAE;
    --ink: #2B211A;
    --ink-soft: #6E5D4F;
    --ink-faint: #A9967F;
    --primary: #FF6A1A;
    --primary-600: #E85A0C;
    --primary-700: #C24700;
    --primary-100: #FFE3CC;
    --primary-050: #FFF1E2;
    --ok: #1F8B5C;
    --ok-bg: #E4F5EC;
    --warn: #C77900;
    --warn-bg: #FFF1D6;
    --danger: #D6402F;
    --danger-bg: #FCE7E3;
    --deleted: #5f5f5f;
    --deleted-bg: #5f5f5f6e;
    --neutral: #7C6F63;
    --neutral-bg: #F1EAE2;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-1: 0 1px 2px rgba(43,33,26,.06), 0 1px 1px rgba(43,33,26,.04);
    --shadow-2: 0 6px 16px -6px rgba(43,33,26,.14), 0 2px 6px -2px rgba(43,33,26,.08);
    --shadow-3: 0 20px 40px -12px rgba(196,71,0,.22);
    --font-display: 'Manrope', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --ease: cubic-bezier(.2,.7,.3,1);
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

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

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: radial-gradient(1100px 480px at 100% -10%, var(--primary-050) 0%, transparent 60%), var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ============================================================
   SFONDO ANIMATO A COSTELLAZIONE (tema chiaro)
   ------------------------------------------------------------
   Adattato dallo snippet fornito: stessa geometria SVG, ma colori
   allineati ai token --primary/--primary-600 (non hex arbitrari, per
   restare coerenti col resto del design system) e opacità ridotta,
   pensata come texture sottile sul crema chiaro di --bg, non come
   sfondo scuro a piena intensità.
   ============================================================ */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.35;

    /* Linee stroke #E85A0C (var(--primary-600)), punti #FF6A1A (var(--primary)) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Cg fill='none' stroke='%23E85A0C' stroke-width='0.6' opacity='0.4'%3E%3Cpath d='M50 80 L180 40 L260 120 L120 220 L50 80' /%3E%3Cpath d='M260 120 L350 200 L300 320 L180 280 L120 220' /%3E%3Cpath d='M180 40 L300 320' /%3E%3C/g%3E%3Cg fill='%23FF6A1A'%3E%3Ccircle cx='50' cy='80' r='2.5' /%3E%3Ccircle cx='180' cy='40' r='2' /%3E%3Ccircle cx='260' cy='120' r='3' /%3E%3Ccircle cx='120' cy='220' r='2' /%3E%3Ccircle cx='350' cy='200' r='2.5' /%3E%3Ccircle cx='300' cy='320' r='3' /%3E%3Ccircle cx='180' cy='280' r='2' /%3E%3C/g%3E%3C/svg%3E");

    background-repeat: repeat;
    background-size: 400px 400px;

    /* Movimento e pulsazione sottile della luminosità */
    animation: moveConstellations 40s linear infinite, pulseOpacity 4s ease-in-out infinite alternate;
}

@keyframes moveConstellations {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(-400px, -400px);
    }
}

@keyframes pulseOpacity {
    0% {
        opacity: 0.15;
    }

    100% {
        opacity: 0.32;
    }
}

/* Il contenuto applicativo resta sopra il layer animato di sfondo */
#app-root, #app-shell {
    position: relative;
    z-index: 1;
}

h1, h2, h3 {
    font-family: var(--font-display);
    margin: 0;
}

button {
    font-family: inherit;
}

:focus-visible {
    outline: 2.5px solid var(--primary-600);
    outline-offset: 2px;
    border-radius: 6px;
}

.material-symbols-outlined {
    font-size: 20px;
    line-height: 1;
    vertical-align: middle;
    user-select: none;
}

/* ============================================================
   SHELL
   ============================================================ */
.shell {
    max-width: 1420px;
    margin: 0 auto;
    padding: 16px 0px 0px;
    height: 100%;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(155deg, var(--primary) 0%, var(--primary-700) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-2);
    flex-shrink: 0;
}

/* Logo Analist Group (SVG) — SENZA contenitore/pulsante attorno (era dentro
   .brand-mark, un riquadro colorato che lo vincolava/ritagliava): solo
   l'immagine, con una classe dedicata e vuota apposta. Nessuna dimensione
   di default imposta oltre a queste due righe minime, cosi le regolazioni
   successive (altezza, larghezza, margini) restano libere da qui. */
.brand-logo {
    height: 34px;
    width: auto;
}

    .brand-mark .material-symbols-outlined {
        color: #fff;
        font-size: 22px;
    }

.brand-text h1 {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.01em;
}

.brand-text p {
    margin: 1px 0 0;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .16s var(--ease);
}

    .icon-btn:hover {
        background: var(--surface-tint);
        color: var(--primary-700);
        border-color: var(--border-strong);
    }

.avatar-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 12px 5px 5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
}

    .avatar-chip .dot {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background: linear-gradient(155deg,#FFB077,var(--primary-600));
        color: #fff;
        font-weight: 700;
        font-size: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .avatar-chip span {
        font-size: 12.5px;
        font-weight: 600;
        color: var(--ink);
    }

/* ============================================================
   KPI STAT CARDS
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px 12px;
    box-shadow: var(--shadow-1);
    position: relative;
    overflow: hidden;
}

    .stat-card::before {
        content: '';
        position: absolute;
        inset: 0 0 auto 0;
        height: 3px;
        background: var(--bar, var(--primary));
    }

    .stat-card .top-row {
        display: flex;
        align-items: flex-start;
        /* justify-content: space-between; */
        gap: 15px;
    }

    .stat-card .icon-wrap {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--iconbg, var(--primary-050));
        color: var(--iconfg, var(--primary-700));
    }

        .stat-card .icon-wrap .material-symbols-outlined {
            font-size: 18px;
        }

    .stat-card .label {
        font-size: 16px;
        color: var(--ink-soft);
        font-weight: 600;
        margin-top: 7px;
    }

    .stat-card .value {
        font-family: var(--font-display);
        font-size: 27px;
        font-weight: 800;
        margin-top: 2px;
        letter-spacing: -.02em;
    }

        .stat-card .value.is-loading {
            color: var(--ink-faint);
        }

    .stat-card .sub {
        font-size: 11.5px;
        color: var(--ink-faint);
        margin-top: 3px;
    }

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: var(--shadow-1);
    margin-bottom: 14px;
}

.search-field {
    position: relative;
    flex: 1 1 260px;
    min-width: 220px;
}

    .search-field .material-symbols-outlined {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--ink-faint);
    }

    .search-field input {
        width: 100%;
        height: 34px;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: var(--bg-sunk);
        padding: 0 34px 0 38px;
        font-size: 13.5px;
        color: var(--ink);
        transition: all .15s var(--ease);
    }

        .search-field input:focus {
            background: #fff;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-100);
        }

    .search-field .clear-btn {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        width: 22px;
        height: 22px;
        border-radius: 50%;
        border: none;
        background: transparent;
        color: var(--ink-faint);
        cursor: pointer;
        display: none;
        align-items: center;
        justify-content: center;
    }

    .search-field.has-value .clear-btn {
        display: flex;
    }

    .search-field .search-spinner {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        display: none;
        width: 15px;
        height: 15px;
        border-radius: 50%;
        border: 2px solid var(--primary-100);
        border-top-color: var(--primary);
        animation: spin .7s linear infinite;
    }

    .search-field.loading .search-spinner {
        display: block;
    }

    .search-field.loading .clear-btn {
        display: none;
    }

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

.select-field select {
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-sunk);
    padding: 0 32px 0 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    appearance: none;
    background-image: url(data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236E5D4F' viewBox='0 0 24 24'><path d='M7 10l5 5 5-5z'/></svg>);
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: all .15s var(--ease);
    /* display: flex; */
    justify-content: center;
    align-items: center;
}

    .select-field select:hover {
        border-color: var(--border-strong);
        background-color: #fff;
    }

    .select-field select:focus {
        background-color: #fff;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-100);
    }

    .select-field select:disabled {
        opacity: .55;
        cursor: default;
        background-color: var(--bg-sunk);
    }

/*
 * <option> — limite onestamente documentato, non aggirabile solo con
 * CSS: il popup nativo di un <select> è disegnato dal sistema
 * operativo/browser fuori dal box model della pagina. Niente hover
 * per-riga, niente border-radius, niente ombra sul popup: sono fuori
 * dal nostro controllo indipendentemente da quanto sia rifinito il
 * <select> chiuso sopra. Quel che i motori più diffusi onorano
 * davvero è colore testo/sfondo (e :checked in alcuni): applicato qui,
 * senza promettere un dropdown "a card" che il CSS da solo non offre.
 */
.select-field select option {
    background-color: var(--surface);
    color: var(--ink);
    font-weight: 500;
}

.select-field select option:checked {
    background-color: var(--primary-050);
    color: var(--primary-700);
}

.select-field select option:disabled {
    color: var(--ink-faint);
}

/* Variante con icona a sinistra (es. selettore lingua): stesso pattern
   già usato da .search-field per l'icona di ricerca, riproposto qui
   perché finora nessun <select> del progetto ne aveva bisogno. */
.select-field.has-icon {
    position: relative;
}

    .select-field.has-icon .material-symbols-outlined {
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--ink-faint);
        font-size: 16px;
        pointer-events: none;
    }

    .select-field.has-icon select {
        padding-left: 32px;
    }

.chip-group {
    display: flex;
    gap: 6px;
}

.chip {
    height: 34px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-sunk);
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all .15s var(--ease);
}

    .chip:hover {
        border-color: var(--border-strong);
    }

    .chip.active {
        background: var(--primary);
        border-color: var(--primary);
        color: #fff;
        box-shadow: 0 4px 10px -3px rgba(232,90,12,.5);
    }

.toolbar-spacer {
    flex: 1 1 auto;
}

.btn-refresh {
    height: 34px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--primary-700);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all .15s var(--ease);
}

    .btn-refresh:hover {
        background: var(--primary-050);
    }

    .btn-refresh .material-symbols-outlined {
        font-size: 18px;
        transition: transform .5s var(--ease);
    }

    .btn-refresh.spinning .material-symbols-outlined {
        animation: spin .6s linear infinite;
    }

.btn-export {
    height: 34px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-sunk);
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

    .btn-export:hover {
        border-color: var(--border-strong);
        color: var(--ink);
    }

/* ============================================================
   TABLE (DESKTOP)
   ============================================================ */
.data-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
/* Contenitore con scroll verticale proprio: qui dentro avviene l'infinite scroll,
   non sulla pagina intera. */
.scroll-container {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

    .scroll-container::-webkit-scrollbar {
        width: 10px;
    }

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

    .scroll-container::-webkit-scrollbar-thumb {
        background: var(--border-strong);
        border-radius: 100px;
    }

        .scroll-container::-webkit-scrollbar-thumb:hover {
            background: var(--primary-100);
        }

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

table.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.data-table thead th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    font-weight: 700;
    padding: 13px 16px;
    background: var(--bg-sunk);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

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

        .data-table thead th.sortable .th-inner {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .data-table thead th.sortable:hover {
            color: var(--primary-700);
        }

    .data-table thead th .sort-icon {
        font-size: 15px;
        opacity: .35;
        transition: all .15s var(--ease);
    }

    .data-table thead th.sort-asc .sort-icon,
    .data-table thead th.sort-desc .sort-icon {
        opacity: 1;
        color: var(--primary);
    }

    .data-table thead th.sort-asc .sort-icon {
        transform: rotate(180deg);
    }

.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background .12s var(--ease);
}

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

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

.cell-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-faint);
}

.owner-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.owner-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    color: #fff;
    font-weight: 700;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
}

.owner-name {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--ink);
}

.owner-sub {
    font-size: 11.5px;
    color: var(--ink-faint);
    font-family: var(--font-mono);
}

.resource-name {
    font-weight: 600;
    font-size: 13.5px;
}

.resource-sub {
    font-size: 11.5px;
    color: var(--ink-faint);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px 4px 8px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

    .badge .dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: currentColor;
    }

    .badge.st-active {
        background: var(--ok-bg);
        color: var(--ok);
    }

    .badge.st-pending {
        background: var(--warn-bg);
        color: var(--warn);
    }

    .badge.st-expired {
        background: var(--danger-bg);
        color: var(--danger);
    }

    .badge.st-revoked {
        background: var(--danger-bg);
        color: var(--danger);
    }

    .badge.st-deleted {
        background: #5f5f5f;
        color: #ffffff;
    }

.date-primary {
    font-size: 13px;
    font-weight: 600;
}

.date-sub {
    font-size: 11.5px;
    color: var(--ink-faint);
}

.expiry-cell {
    min-width: 150px;
}

.expiry-track {
    width: 100%;
    height: 5px;
    border-radius: 100px;
    background: var(--bg-sunk);
    margin-top: 6px;
    overflow: hidden;
}

.expiry-fill {
    height: 100%;
    border-radius: 100px;
    transition: width .3s var(--ease);
}

.row-actions {
    display: flex;
    gap: 4px;
    opacity: .35;
    transition: opacity .15s var(--ease);
    justify-content: right;
}

tr:hover .row-actions, .card-actions {
    opacity: 1;
}

.action-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s var(--ease);
}

    .action-btn:hover {
        background: var(--surface-tint);
        color: var(--primary-700);
    }

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

    .action-btn .material-symbols-outlined {
        font-size: 18px;
    }

/* skeleton */
.skel {
    background: linear-gradient(90deg, var(--bg-sunk) 25%, #fff 50%, var(--bg-sunk) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s infinite;
    border-radius: 6px;
}

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

    100% {
        background-position: -200% 0;
    }
}

.skel-line {
    height: 11px;
    width: 80%;
}

/* empty / error state */
.empty-state {
    padding: 70px 20px;
    text-align: center;
}

    .empty-state.is-error .material-symbols-outlined {
        background: var(--danger-bg);
        color: var(--danger);
    }

    .empty-state .material-symbols-outlined {
        font-size: 44px;
        color: var(--primary-100);
        background: var(--primary-050);
        width: 78px;
        height: 78px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 16px;
    }

    .empty-state h3 {
        font-size: 16px;
        margin-bottom: 4px;
    }

    .empty-state p {
        font-size: 13px;
        color: var(--ink-soft);
        margin: 0 0 16px;
    }

    .empty-state button {
        height: 38px;
        padding: 0 16px;
        border-radius: 10px;
        border: 1px solid var(--border-strong);
        background: #fff;
        color: var(--primary-700);
        font-weight: 700;
        cursor: pointer;
    }

/* ============================================================
   CARDS (MOBILE)
   ============================================================ */
.card-list {
    display: none;
    padding: 12px;
    gap: 12px;
    flex-direction: column;
}

.share-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-1);
    position: relative;
    overflow: hidden;
}

    .share-card::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        background: var(--accent, var(--primary));
    }

    .share-card .card-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
        gap: 8px;
    }

    .share-card .owner-cell {
        gap: 10px;
    }

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    margin: 12px 0;
}

.card-field-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-faint);
    font-weight: 700;
    margin-bottom: 2px;
}

.card-field-value {
    font-size: 13px;
    font-weight: 600;
}

.card-actions {
    display: flex;
    gap: 6px;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 2px;
}

/* ============================================================
   INFINITE SCROLL â€” loader / end-of-list
   ============================================================ */
#scroll-sentinel {
    height: 1px;
}

.scroll-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px;
    font-size: 12.5px;
    color: var(--ink-soft);
    font-weight: 600;
}

.mini-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2.5px solid var(--primary-100);
    border-top-color: var(--primary);
    animation: spin .7s linear infinite;
}

.scroll-end {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    font-size: 12.5px;
    color: var(--ink-faint);
    font-weight: 600;
    border-top: 1px dashed var(--border);
}

    .scroll-end .material-symbols-outlined {
        font-size: 16px;
        color: var(--ok);
    }

/* ============================================================
   FOOTER
   ============================================================ */
.footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-sunk);
}

.footer-info {
    font-size: 12.5px;
    color: var(--ink-soft);
}

    .footer-info strong {
        color: var(--ink);
    }

.back-to-top {
    border: none;
    background: transparent;
    color: var(--primary-700);
    font-weight: 700;
    font-size: 12.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s var(--ease);
}

    .back-to-top.visible {
        opacity: 1;
        pointer-events: auto;
    }

/* ============================================================
   BANNER DATI FITTIZI (fallback quando il server non risponde)
   ============================================================ */
.demo-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--warn-bg);
    border: 1px solid #F0CB86;
    color: #8A5B00;
    border-radius: var(--radius-md);
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
}

    .demo-banner .material-symbols-outlined:first-child {
        color: var(--warn);
        flex-shrink: 0;
    }

    .demo-banner span:nth-child(2) {
        flex: 1;
    }

    .demo-banner button {
        border: none;
        background: transparent;
        color: #8A5B00;
        cursor: pointer;
        opacity: .7;
        width: 26px;
        height: 26px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .demo-banner button:hover {
            opacity: 1;
            background: rgba(255,255,255,.5);
        }

/* ============================================================
   TOASTS
   ============================================================ */
#toast-root {
    position: fixed;
    bottom: 22px;
    right: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 999;
}

.toast {
    min-width: 260px;
    max-width: 340px;
    background: var(--ink);
    color: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    box-shadow: 0 12px 30px -8px rgba(0,0,0,.35);
    animation: toast-in .25s var(--ease);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.toast.leaving {
    animation: toast-out .18s var(--ease) forwards;
    display: inline !important;
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(12px);
    }
}

.toast .material-symbols-outlined {
    font-size: 19px;
    flex-shrink: 0;
    margin-top: 1px;
    display: inline !important;
}

.toast.success .material-symbols-outlined {
    color: #7CDCA6;
    display: inline !important;
}

.toast.success {
    display: inline !important;
}

.toast.danger {
    display: inline !important;
}

    .toast.danger .material-symbols-outlined {
        color: #F19E93;
        display: inline !important;
    }

.toast.info {
    display: inline !important;
}

    .toast.info .material-symbols-outlined {
        color: #FFB077;
        display: inline !important;
    }

.toast p {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
}

.toast strong {
    display: block;
    font-size: 12.5px;
    margin-bottom: 1px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 980px) {
    .stat-grid {
        grid-template-columns: repeat(2,1fr);
    }
}

@media (max-width: 860px) {
    .shell {
        padding: 14px 14px 14px;
    }

    .table-scroll {
        display: none;
    }

    .card-list {
        display: flex;
    }

    .toolbar {
        padding: 10px;
    }

    .scroll-container {
        max-height: 70vh;
    }
}

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

    .topbar {
        flex-wrap: wrap;
    }

    .stat-card .value {
        font-size: 22px;
    }

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

.hide {
    display: none;
}

.right_col {
    padding: 0 10px 0 !important;
}

#mainbody {
    margin: 0 !important;
    padding: 0 !important;
}

/* ============================================================
   INTEGRAZIONE MODALE LICENZA (DESIGN SYSTEM COMPATIBLE)
   ============================================================ */
.custom-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(43, 33, 26, 0.4); /* Coerente con --ink opacity */
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.custom-modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-3);
    position: relative;
    animation: modalShow .25s var(--ease);
}

.modal-close-x {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: var(--ink-faint);
    transition: all .15s var(--ease);
}

    .modal-close-x .material-symbols-outlined {
        font-size: 20px;
    }

    .modal-close-x:hover {
        background: var(--surface-tint);
        color: var(--primary-700);
    }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    gap: 12px;
}

.modal-body {
    padding-top: 4px;
}

.modal-footer {
    border-top: 1px dashed var(--border);
    padding-top: 16px;
}

@keyframes modalShow {
    from {
        transform: translateY(10px) scale(.98);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Adattamento Responsive Interno alla Modale */
@media (max-width: 480px) {
    .modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

        .modal-header .badge {
            align-self: flex-start;
        }
}

/* ============================================================
   PROGRESS BAR DENTRO LA MODALE LICENZA
   ============================================================ */
.modal-progress-track {
    width: 100%;
    height: 7px;
    border-radius: 100px;
    background: var(--bg-sunk);
    overflow: hidden;
    border: 1px solid var(--border);
}

.modal-progress-fill {
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-600) 100%);
    transition: width 0.4s var(--ease);
}

/* Modifica opzionale: se le condivisioni raggiungono il massimo, 
   puoi eventualmente iniettare una classe via JS per cambiare il background in var(--danger) */
.modal-progress-track.is-full .modal-progress-fill {
    background: var(--danger);
}

/* ============================================================
   CONFIRM MODAL (core, ConfirmModal.js) — sostituisce window.confirm.
   Riusa .custom-modal-backdrop/.custom-modal-content/.modal-header/
   .modal-body/.modal-footer sopra (già esistenti per la modale licenza);
   qui solo ciò che mancava: tipografia titolo/messaggio e riga bottoni.
   ============================================================ */
.confirm-modal-content {
    max-width: 420px;
}

.confirm-modal-header {
    /* .modal-header (condivisa con la vecchia modale licenza) usa
       justify-content:space-between per badge a destra + titolo a
       sinistra — qui ci sono solo icona+titolo, che devono stare
       vicini, non ai due estremi. padding-right riserva lo spazio
       per la X assoluta in alto (top:16px;right:18px) così un
       titolo lungo non ci finisce sotto. */
    justify-content: flex-start;
    gap: 14px;
    padding-right: 44px; /* right:12px + width:32px del .modal-close-x */
}

.confirm-modal-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-050);
    color: var(--primary-700);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .confirm-modal-icon .material-symbols-outlined {
        font-size: 22px;
    }

    .confirm-modal-icon.is-danger {
        background: var(--danger-bg);
        color: var(--danger);
    }

.confirm-modal-header h3 {
    font-size: 17px;
    font-weight: 800;
    color: var(--ink);
}

.confirm-modal-body p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink-soft);
    margin: 0;
}

.confirm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
}

.btn-modal-secondary,
.btn-modal-primary {
    height: 36px;
    padding: 0 18px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}

    .btn-modal-secondary .material-symbols-outlined,
    .btn-modal-primary .material-symbols-outlined {
        font-size: 18px;
    }

.btn-modal-secondary {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink-soft);
}

    .btn-modal-secondary:hover {
        background: var(--bg-sunk);
        color: var(--ink);
    }

.btn-modal-primary {
    border: none;
    background: var(--primary);
    color: #fff;
}

    .btn-modal-primary:hover {
        background: var(--primary-600);
    }

    .btn-modal-primary.is-danger {
        background: var(--danger);
    }

        .btn-modal-primary.is-danger:hover {
            background: #B8352A;
        }

@media (max-width: 480px) {
    .confirm-modal-footer {
        flex-direction: column-reverse;
    }

        .confirm-modal-footer .btn-modal-secondary,
        .confirm-modal-footer .btn-modal-primary {
            width: 100%;
            justify-content: center;
        }
}

/* ============================================================
   SELECT v2 — dropdown stilabile (progressive enhancement)
   Blocco additivo. Supera il limite documentato sopra (sezione
   <option>): con `appearance: base-select` + `::picker(select)`
   (Chromium 135+) il popup del <select> entra nel box model della
   pagina e diventa interamente stilabile. Nei browser SENZA
   supporto il blocco @supports viene ignorato in toto e resta la
   resa attuale (regole option base sopra): nessuna regressione.
   ============================================================ */
@supports (appearance: base-select) {
    /* Opt-in: va dichiarato sia sul select sia sul picker. */
    .select-field select,
    .select-field select::picker(select) {
        appearance: base-select;
    }

    /* La freccia custom è già disegnata via background-image sul
       select chiuso: la picker-icon nativa duplicherebbe. */
    .select-field select::picker-icon {
        display: none;
    }

    /* Popup: stesso linguaggio delle card/dropdown dell'app
       (surface, border, radius 10, shadow-2) — il riferimento è
       il dropdown dello user menu. */
    .select-field select::picker(select) {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: var(--shadow-2);
        padding: 5px;
        margin-top: 6px;
        min-width: anchor-size(width);
    }

    /* Righe option: stesso linguaggio delle voci dello user menu
       (hover primary-050/primary-700, radius interno 7px). */
    .select-field select option {
        border-radius: 7px;
        padding: 8px 10px;
        font-size: 13px;
        font-weight: 600;
        color: var(--ink-soft);
        cursor: pointer;
        transition: background .12s var(--ease), color .12s var(--ease);
    }

        .select-field select option:hover,
        .select-field select option:focus {
            background: var(--primary-050);
            color: var(--primary-700);
        }

        /* Selezionata: stesso linguaggio di .chip.active. */
        .select-field select option:checked {
            background: var(--primary);
            color: #fff;
        }

        .select-field select option:disabled {
            color: var(--ink-faint);
            background: transparent;
            cursor: default;
        }

        /* Spunta nativa della option selezionata: spenta, la
           selezione è già comunicata dal fondo pieno primary. */
        .select-field select option::checkmark {
            display: none;
        }
}
