/* ================================================================
   LIMTECH — Design System Limca
   Identità limontacolori.com: blu LIMCA, giallo acceso, tricolore.
   Struttura e cura ereditate dal sistema Saturno, tema light + dark.
   ================================================================ */

/* ── Design Tokens ───────────────────────────────────────────── */

:root {
    /* Brand Limca (da limontacolori_sito/globals.css) */
    --lt-blue:        #0f3397;
    --lt-blue-soft:   #1c47b5;
    --lt-blue-deep:   #0a1355;
    --lt-yellow:      #ffe500;
    --lt-green:       #139b58;
    --lt-red:         #df2632;

    /* Tema light (default) */
    --lt-bg:          #eff4fb;
    --lt-bg-sidebar:  linear-gradient(180deg, #0f3397 0%, #0a1e6e 100%);
    --lt-surface:     #ffffff;
    --lt-surface-2:   #f4f7fc;
    --lt-surface-3:   #e9eef9;

    --lt-border:      rgba(15, 51, 151, 0.09);
    --lt-border-2:    rgba(15, 51, 151, 0.16);
    --lt-border-3:    rgba(15, 51, 151, 0.26);

    --lt-primary:        var(--lt-blue);
    --lt-primary-hover:  var(--lt-blue-soft);
    --lt-primary-glow:   rgba(15, 51, 151, 0.16);
    --lt-primary-subtle: rgba(15, 51, 151, 0.08);
    --lt-primary-muted:  rgba(15, 51, 151, 0.045);

    --lt-accent:         var(--lt-yellow);
    --lt-accent-ink:     var(--lt-blue);
    --lt-accent-glow:    rgba(255, 229, 0, 0.35);

    --lt-text:        #121827;
    --lt-text-2:      #3d4560;
    --lt-text-3:      #6b7591;
    --lt-text-4:      #9aa3bd;

    --lt-success:     #0f8a4f;
    --lt-danger:      #d02535;
    --lt-warning:     #b47c09;
    --lt-info:        #1c64c8;

    --lt-card-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 16px 42px -28px rgba(15, 23, 42, 0.32);
    --lt-card-shadow-hover: 0 1px 2px rgba(15, 23, 42, 0.06), 0 24px 60px -32px rgba(15, 51, 151, 0.35);

    --sidebar-w:      240px;
    --radius:         12px;
    --radius-lg:      16px;
    --radius-sm:      8px;

    --font-body:      'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-display:   'Bricolage Grotesque', 'Plus Jakarta Sans', sans-serif;

    --ease-out:       cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Tema dark: notte Limca, blu profondo invece del nero neutro */
html[data-theme="dark"] {
    --lt-bg:          #070b1d;
    --lt-bg-sidebar:  linear-gradient(180deg, #0a1240 0%, #060a24 100%);
    --lt-surface:     #0d1330;
    --lt-surface-2:   #111840;
    --lt-surface-3:   #16204f;

    --lt-border:      rgba(150, 175, 255, 0.10);
    --lt-border-2:    rgba(150, 175, 255, 0.16);
    --lt-border-3:    rgba(150, 175, 255, 0.26);

    --lt-primary:        #6d8dff;
    --lt-primary-hover:  #8aa5ff;
    --lt-primary-glow:   rgba(109, 141, 255, 0.22);
    --lt-primary-subtle: rgba(109, 141, 255, 0.12);
    --lt-primary-muted:  rgba(109, 141, 255, 0.06);

    --lt-text:        #e9edf8;
    --lt-text-2:      #aab4d4;
    --lt-text-3:      #707da6;
    --lt-text-4:      #495578;

    --lt-success:     #37d58c;
    --lt-danger:      #ff7080;
    --lt-warning:     #ffc93d;
    --lt-info:        #62a4ff;

    --lt-card-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --lt-card-shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 48px rgba(109, 141, 255, 0.08);
}

/* ── Base ────────────────────────────────────────────────────── */

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

html { scroll-behavior: smooth; }

body {
    background: var(--lt-bg) !important;
    color: var(--lt-text);
    font-family: var(--font-body);
    font-size: 0.875rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    transition: background 0.3s var(--ease-out), color 0.3s var(--ease-out);
}

::selection {
    background: var(--lt-yellow);
    color: var(--lt-blue);
}

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

/* ── Tipografia ──────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--lt-text);
}

.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }

.font-mono {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.85em;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--lt-text-3);
}

/* Firma Limca: bandierina tricolore */
.accent-rule {
    display: inline-block;
    height: 4px;
    width: 4.5rem;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        var(--lt-green) 0 33.333%,
        #ffffff 33.333% 66.666%,
        var(--lt-red) 66.666% 100%
    );
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
}

/* ── Layout App ──────────────────────────────────────────────── */

body.has-sidebar { display: flex; min-height: 100vh; }

body.has-sidebar .app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    transition: margin-left 0.4s var(--ease-out);
}

.app-content {
    padding: 2rem 2.5rem 3rem;
    max-width: 1400px;
}

/* Navigazione tra pagine: crossfade nativo del browser (View Transitions).
   Sostituisce le animazioni di ingresso che ripartivano a ogni pagina. */
@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation-duration: 90ms;
}

::view-transition-new(root) {
    animation-duration: 150ms;
}

/* La sidebar è identica su ogni pagina: non deve partecipare al fade */
.sidebar {
    view-transition-name: lt-sidebar;
}

/* ── Sidebar (sempre blu Limca, come l'header del sito) ──────── */

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--lt-bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.4s var(--ease-out);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.03));
}

.sidebar-brand {
    padding: 1.75rem 1.5rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    color: #ffffff;
    flex-shrink: 0;
}

.sidebar-brand:hover { color: var(--lt-yellow); }

.sidebar-logo {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    filter: drop-shadow(0 6px 14px rgba(4, 10, 40, 0.5));
}

.sidebar-brand-text {
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.sidebar-brand-sub {
    display: block;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    margin-top: 1px;
}

.sidebar-section { padding: 0.4rem 0.75rem; flex: 1; }

.sidebar-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(255,255,255,0.42);
    padding: 1.2rem 0.75rem 0.45rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.58rem 0.75rem;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    transition: all 0.2s var(--ease-out);
    position: relative;
}

.sidebar-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}

.sidebar-link.active {
    color: var(--lt-yellow);
    background: rgba(255,255,255,0.10);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 6px; bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--lt-yellow);
}

.sidebar-footer {
    padding: 0.9rem 1rem 1.1rem;
    border-top: 1px solid rgba(255,255,255,0.10);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.sidebar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255, 229, 0, 0.18);
    border: 1px solid rgba(255, 229, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--lt-yellow);
    flex-shrink: 0;
}

.sidebar-user-meta { min-width: 0; }

.sidebar-user-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255,255,255,0.92);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.sidebar-user-role {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.48);
    display: block;
}

.sidebar-icon-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.55);
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.sidebar-icon-btn:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.10);
}

.sidebar-icon-btn.danger:hover {
    color: #ffb3ba;
    background: rgba(223, 38, 50, 0.25);
}

/* ── Navigazione superiore ──────────────────────────────────── */

.topnav {
    position: sticky;
    top: 0;
    z-index: 1040;
    background: var(--lt-bg-sidebar);
    border-bottom: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 10px 30px -24px rgba(4, 10, 40, 0.8);
    view-transition-name: lt-topnav;
}

.topnav .navbar {
    min-height: 70px;
    padding: 0.65rem 1.5rem;
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #ffffff;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 2rem;
}

.topnav-brand:hover { color: var(--lt-yellow); }

.topnav-logo {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    filter: drop-shadow(0 6px 14px rgba(4, 10, 40, 0.5));
}

.topnav-brand-text {
    display: block;
    font-family: var(--font-display);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    line-height: 1.1;
    text-transform: uppercase;
}

.topnav-brand-sub {
    display: block;
    margin-top: 2px;
    color: rgba(255,255,255,0.55);
    font-size: 0.52rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    line-height: 1.1;
    text-transform: uppercase;
}

.topnav-links {
    align-items: center;
    gap: 0.2rem;
}

.topnav-link {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}

.topnav-link:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}

.topnav-link.active {
    color: var(--lt-yellow);
    background: rgba(255,255,255,0.10);
}

.topnav-user {
    margin-left: auto;
    padding-left: 1rem;
}

.topnav-user-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.55rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #ffffff;
    text-align: left;
    transition: background 0.2s;
}

.topnav-user-toggle:hover,
.topnav-user-toggle[aria-expanded="true"] {
    background: rgba(255,255,255,0.10);
}

.topnav-avatar {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 229, 0, 0.4);
    border-radius: 50%;
    background: rgba(255, 229, 0, 0.18);
    color: var(--lt-yellow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
}

.topnav-user-meta { line-height: 1.2; }

.topnav-user-name {
    display: block;
    max-width: 150px;
    overflow: hidden;
    color: rgba(255,255,255,0.92);
    font-size: 0.75rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topnav-user-role {
    display: block;
    margin-top: 2px;
    color: rgba(255,255,255,0.48);
    font-size: 0.56rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.topnav-toggler {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.22);
    color: #ffffff;
    font-size: 1.35rem;
}

.topnav-toggler:focus { box-shadow: 0 0 0 3px rgba(255, 229, 0, 0.25); }

.topnav-dropdown {
    min-width: 210px;
    padding: 0.45rem;
    border: 1px solid var(--lt-border-2);
    border-radius: var(--radius);
    background: var(--lt-surface);
    box-shadow: var(--lt-card-shadow-hover);
}

.topnav-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--lt-text-2);
    font-size: 0.78rem;
    font-weight: 600;
}

.topnav-dropdown .dropdown-item:hover {
    background: var(--lt-primary-muted);
    color: var(--lt-primary);
}

.topnav-dropdown .dropdown-divider { border-color: var(--lt-border); }
.topnav-dropdown .topnav-logout:hover {
    background: rgba(223, 38, 50, 0.08);
    color: var(--lt-danger);
}

/* Backdrop mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 10, 40, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1035;
    opacity: 0;
    transition: opacity 0.3s;
}

/* ── Mobile Header ───────────────────────────────────────────── */

.mobile-header {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--lt-border);
    background: var(--lt-surface);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.mobile-toggle {
    background: none;
    border: 1px solid var(--lt-border-2);
    color: var(--lt-text-2);
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.mobile-toggle:hover {
    border-color: var(--lt-primary);
    color: var(--lt-primary);
    background: var(--lt-primary-muted);
}

.mobile-brand {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    color: var(--lt-primary);
}

/* ── Card ────────────────────────────────────────────────────── */

.lt-card {
    background: var(--lt-surface);
    border: 1px solid var(--lt-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--lt-card-shadow);
    transition: border-color 0.35s var(--ease-out),
                box-shadow 0.35s var(--ease-out),
                transform 0.35s var(--ease-out);
}

.lt-card:hover {
    border-color: var(--lt-border-2);
    box-shadow: var(--lt-card-shadow-hover);
}

.lt-card-clickable { cursor: pointer; }
.lt-card-clickable:hover { transform: translateY(-3px); }

/* KPI */
.kpi-card {
    position: relative;
    overflow: hidden;
    padding: 1.15rem 1.3rem;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--lt-blue), var(--lt-blue-soft));
    opacity: 0.85;
}

.kpi-card.kpi-accent::before {
    background: linear-gradient(90deg, var(--lt-yellow), #ffd23d);
}

.kpi-label {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lt-text-3);
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi-hint {
    font-size: 0.72rem;
    color: var(--lt-text-3);
}

/* ── Bottoni ─────────────────────────────────────────────────── */

.lt-btn {
    background: var(--lt-blue) !important;
    border: 1px solid var(--lt-blue) !important;
    color: #ffffff !important;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.52rem 1.2rem;
    border-radius: 999px;
    transition: all 0.25s var(--ease-out);
    position: relative;
    overflow: hidden;
}

html[data-theme="dark"] .lt-btn {
    background: var(--lt-blue-soft) !important;
    border-color: var(--lt-blue-soft) !important;
}

.lt-btn:hover {
    background: var(--lt-blue-soft) !important;
    border-color: var(--lt-blue-soft) !important;
    box-shadow: 0 10px 24px -12px rgba(15, 51, 151, 0.7);
    transform: translateY(-1px);
}

html[data-theme="dark"] .lt-btn:hover {
    background: #2a55c9 !important;
    border-color: #2a55c9 !important;
}

.lt-btn:active { transform: translateY(0); box-shadow: none; }

/* Sheen sweep come i bottoni del sito */
.lt-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 0%, rgba(255,255,255,0.35) 50%, transparent 100%);
    transform: translateX(-130%);
    transition: transform 420ms var(--ease-out);
    pointer-events: none;
}

.lt-btn:hover::after { transform: translateX(130%); }

.lt-btn-accent {
    background: var(--lt-yellow) !important;
    border: 1px solid var(--lt-yellow) !important;
    color: var(--lt-blue) !important;
    font-weight: 800;
    font-size: 0.82rem;
    padding: 0.52rem 1.2rem;
    border-radius: 999px;
    transition: all 0.25s var(--ease-out);
    box-shadow: 0 12px 28px -14px rgba(255, 229, 0, 0.8);
}

.lt-btn-accent:hover {
    background: #fff04d !important;
    transform: translateY(-1px);
}

.lt-btn-outline {
    background: transparent !important;
    border: 1px solid var(--lt-border-3) !important;
    color: var(--lt-text-2) !important;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.52rem 1.2rem;
    border-radius: 999px;
    transition: all 0.25s var(--ease-out);
}

.lt-btn-outline:hover {
    border-color: var(--lt-primary) !important;
    color: var(--lt-primary) !important;
    background: var(--lt-primary-muted) !important;
}

.btn-sm.lt-btn,
.btn-sm.lt-btn-outline,
.btn-sm.lt-btn-accent {
    padding: 0.32rem 0.85rem;
    font-size: 0.76rem;
}

/* ── Input & Form ────────────────────────────────────────────── */

.lt-input,
.form-control.lt-input,
.form-select.lt-input {
    background: var(--lt-surface) !important;
    border: 1px solid var(--lt-border-2) !important;
    color: var(--lt-text) !important;
    font-size: 0.84rem;
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius) !important;
    transition: all 0.25s var(--ease-out);
}

.lt-input:focus {
    border-color: var(--lt-primary) !important;
    box-shadow: 0 0 0 3px var(--lt-primary-glow) !important;
    background: var(--lt-surface) !important;
}

.lt-input::placeholder { color: var(--lt-text-4) !important; }

.form-label {
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--lt-text-2);
}

.form-text { color: var(--lt-text-3); font-size: 0.72rem; }

.form-check-input:checked {
    background-color: var(--lt-blue);
    border-color: var(--lt-blue);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px var(--lt-primary-glow);
    border-color: var(--lt-primary);
}

.invalid-feedback { display: block; font-size: 0.72rem; }

/* Anteprima Google: colori coerenti con il tema della ricerca */
.seo-google-preview {
    background: #ffffff;
    border: 1px solid #dadce0;
}

.seo-google-preview-label { color: #5f6368; }
.seo-google-preview-url { color: #202124; }
.seo-google-preview-title { color: #1a0dab; }
.seo-google-preview-description { color: #4d5156; }

html[data-theme="dark"] .seo-google-preview {
    background: #202124;
    border-color: #3c4043;
}

html[data-theme="dark"] .seo-google-preview-label,
html[data-theme="dark"] .seo-google-preview-url,
html[data-theme="dark"] .seo-google-preview-description {
    color: #bdc1c6;
}

html[data-theme="dark"] .seo-google-preview-title { color: #8ab4f8; }

/* Preferenze layout */
.layout-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.layout-option {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1rem;
    border: 1px solid var(--lt-border-2);
    border-radius: var(--radius-lg);
    background: var(--lt-surface-2);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.layout-option:hover {
    border-color: var(--lt-primary);
    transform: translateY(-2px);
}

.layout-option:has(.layout-option-input:checked) {
    border-color: var(--lt-primary);
    background: var(--lt-primary-muted);
    box-shadow: 0 0 0 3px var(--lt-primary-glow);
}

.layout-option-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.layout-option-input:focus-visible + .layout-option-preview {
    outline: 2px solid var(--lt-accent);
    outline-offset: 3px;
}

.layout-option-preview {
    display: flex;
    width: 100%;
    height: 115px;
    overflow: hidden;
    border: 1px solid var(--lt-border-2);
    border-radius: var(--radius);
    background: var(--lt-bg);
}

.layout-preview-nav { background: var(--lt-bg-sidebar); }

.layout-option-preview-sidebar .layout-preview-nav {
    width: 24%;
    height: 100%;
}

.layout-option-preview-top {
    flex-direction: column;
}

.layout-option-preview-top .layout-preview-nav {
    width: 100%;
    height: 24%;
}

.layout-preview-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem;
}

.layout-preview-content span {
    display: block;
    height: 12px;
    border-radius: 999px;
    background: var(--lt-surface-3);
}

.layout-preview-content span:first-child { width: 48%; background: var(--lt-primary-subtle); }
.layout-preview-content span:last-child { width: 72%; }

.layout-option-copy { display: block; }

.layout-option-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--lt-text);
    font-size: 0.88rem;
    font-weight: 700;
}

.layout-option-title i {
    color: var(--lt-primary);
    opacity: 0;
    transition: opacity 0.2s;
}

.layout-option-input:checked ~ .layout-option-copy .layout-option-title i { opacity: 1; }

.layout-option-description {
    display: block;
    margin-top: 0.2rem;
    color: var(--lt-text-3);
    font-size: 0.72rem;
}

/* Search */
.lt-search-wrap {
    position: relative;
    max-width: 320px;
    flex: 1;
}

.lt-search-wrap i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--lt-text-4);
    font-size: 0.85rem;
    pointer-events: none;
}

.lt-search {
    width: 100%;
    background: var(--lt-surface);
    border: 1px solid var(--lt-border-2);
    color: var(--lt-text);
    font-size: 0.82rem;
    padding: 0.5rem 0.85rem 0.5rem 2.3rem;
    border-radius: 999px;
    transition: all 0.25s var(--ease-out);
}

.lt-search:focus {
    outline: none;
    border-color: var(--lt-primary);
    box-shadow: 0 0 0 3px var(--lt-primary-glow);
}

/* ── Tabelle ─────────────────────────────────────────────────── */

.lt-table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--lt-text);
    --bs-table-border-color: var(--lt-border);
    --bs-table-hover-bg: var(--lt-primary-muted);
    --bs-table-hover-color: var(--lt-text);
    font-size: 0.82rem;
    margin-bottom: 0;
}

.lt-table th {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    color: var(--lt-text-3);
    padding: 0.8rem 0.75rem;
    border-bottom: 1px solid var(--lt-border-2);
    white-space: nowrap;
}

.lt-table td {
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--lt-border);
    color: var(--lt-text-2);
}

.lt-table tbody tr { transition: background-color 0.15s; }
.lt-table tbody tr:last-child td { border-bottom: 0; }

/* ── Badge ───────────────────────────────────────────────────── */

.badge {
    font-weight: 700;
    font-size: 0.66rem;
    padding: 0.32em 0.75em;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.badge.bg-success {
    background: rgba(19, 155, 88, 0.12) !important;
    color: var(--lt-success) !important;
    border: 1px solid rgba(19, 155, 88, 0.25);
}

.badge.bg-danger {
    background: rgba(223, 38, 50, 0.10) !important;
    color: var(--lt-danger) !important;
    border: 1px solid rgba(223, 38, 50, 0.22);
}

.badge.bg-warning {
    background: rgba(255, 200, 40, 0.16) !important;
    color: var(--lt-warning) !important;
    border: 1px solid rgba(200, 150, 20, 0.3);
}

.badge.bg-info {
    background: var(--lt-primary-subtle) !important;
    color: var(--lt-primary) !important;
    border: 1px solid var(--lt-primary-glow);
}

.badge.bg-secondary {
    background: var(--lt-surface-3) !important;
    color: var(--lt-text-3) !important;
    border: 1px solid var(--lt-border);
}

.badge.bg-accent {
    background: rgba(255, 229, 0, 0.22) !important;
    color: #8a7a00 !important;
    border: 1px solid rgba(255, 229, 0, 0.55);
}

html[data-theme="dark"] .badge.bg-accent {
    color: var(--lt-yellow) !important;
}

/* ── Toast / Flash ───────────────────────────────────────────── */

.lt-toast-container {
    position: fixed;
    top: 1rem;
    right: 1.25rem;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 420px;
}

.topnav .lt-toast-container {
    position: absolute;
    top: calc(100% + 1rem);
}

.lt-toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--lt-surface);
    border: 1px solid var(--lt-border-2);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    box-shadow: 0 18px 45px -18px rgba(15, 23, 42, 0.45);
    font-size: 0.8rem;
    position: relative;
    overflow: hidden;
    animation: toastIn 0.45s var(--ease-spring) both;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px) scale(0.97); }
}

.lt-toast.toast-exit { animation: toastOut 0.3s var(--ease-out) forwards; }

@keyframes toastOut {
    to { opacity: 0; transform: translateX(24px); }
}

.lt-toast-icon { font-size: 1rem; flex-shrink: 0; }
.lt-toast-success .lt-toast-icon { color: var(--lt-success); }
.lt-toast-danger  .lt-toast-icon { color: var(--lt-danger); }
.lt-toast-warning .lt-toast-icon { color: var(--lt-warning); }
.lt-toast-info    .lt-toast-icon { color: var(--lt-info); }

.lt-toast-msg { flex: 1; color: var(--lt-text); }

.lt-toast-close {
    background: none;
    border: none;
    color: var(--lt-text-4);
    padding: 0.15rem;
    cursor: pointer;
    font-size: 0.75rem;
}

.lt-toast-close:hover { color: var(--lt-text); }

.lt-toast-progress {
    position: absolute;
    left: 0; bottom: 0;
    height: 2px;
    width: 100%;
    transform-origin: left;
    animation: toastProgress 4s linear forwards;
}

.lt-toast-success .lt-toast-progress { background: var(--lt-success); }
.lt-toast-danger  .lt-toast-progress { background: var(--lt-danger); }
.lt-toast-warning .lt-toast-progress { background: var(--lt-warning); }
.lt-toast-info    .lt-toast-progress { background: var(--lt-info); }

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ── Page chrome ─────────────────────────────────────────────── */

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

.page-title {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0;
}

.page-title i {
    color: var(--lt-primary);
    font-size: 1.15rem;
}

.page-subtitle {
    font-size: 0.78rem;
    color: var(--lt-text-3);
    margin-top: 0.2rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--lt-text-3);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    transition: color 0.2s;
    margin-bottom: 0.4rem;
}

.back-link:hover { color: var(--lt-primary); }

/* ── Empty state ─────────────────────────────────────────────── */

.empty-state-illustration {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.empty-state-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--lt-primary);
    opacity: 0.75;
}

/* ── Marchio (monogramma SVG) ────────────────────────────────── */

.lt-mark {
    width: 100%;
    height: 100%;
    display: block;
}

/* ── Login (staff) ───────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 2rem;
    background:
        radial-gradient(120% 90% at 50% 0%, #17307e 0%, #0c1a55 48%, #060d33 100%) !important;
}

/* Scena: aurore, griglia prospettica e fascio di luce */
.login-scene {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.login-aurora {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.55;
    will-change: transform;
    animation: auroraDrift 26s ease-in-out infinite alternate;
}

.login-aurora-1 {
    width: 46rem; height: 46rem;
    top: -22rem; left: -14rem;
    background: radial-gradient(circle, rgba(53, 96, 233, 0.85), transparent 65%);
}

.login-aurora-2 {
    width: 34rem; height: 34rem;
    bottom: -16rem; right: -10rem;
    background: radial-gradient(circle, rgba(24, 52, 158, 0.9), rgba(90, 130, 255, 0.25) 45%, transparent 68%);
    animation-duration: 32s;
    animation-delay: -8s;
}

.login-aurora-3 {
    width: 22rem; height: 22rem;
    top: 12%; right: 16%;
    background: radial-gradient(circle, rgba(255, 229, 0, 0.16), transparent 62%);
    opacity: 0.8;
    animation-duration: 22s;
    animation-delay: -14s;
}

@keyframes auroraDrift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(4rem, 2.5rem, 0) scale(1.12); }
}

/* Griglia tecnica che sfuma verso l'alto */
.login-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(80% 68% at 50% 52%, rgba(0,0,0,0.9), transparent 78%);
    mask-image: radial-gradient(80% 68% at 50% 52%, rgba(0,0,0,0.9), transparent 78%);
}

/* Fascio diagonale di luce dietro la card */
.login-beam {
    position: absolute;
    top: -30%;
    left: 50%;
    width: 130rem;
    height: 46rem;
    transform: translateX(-50%) rotate(-9deg);
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(120, 155, 255, 0.10) 42%,
        rgba(255, 229, 0, 0.05) 58%,
        transparent 100%);
    filter: blur(26px);
}

/* Vignettatura + grana sottile per togliere l'effetto "flat" */
.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(120% 100% at 50% 50%, transparent 55%, rgba(2, 6, 28, 0.55) 100%);
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: overlay;
}

.login-card {
    width: 100%;
    max-width: 410px;
    position: relative;
    z-index: 1;
}

/* Bordo gradiente sottile attorno al pannello */
.login-panel {
    position: relative;
    background: linear-gradient(168deg, rgba(255,255,255,0.085), rgba(255,255,255,0.035) 55%, rgba(255,255,255,0.06));
    border: 1px solid transparent;
    border-radius: 24px;
    padding: 2.6rem 2.4rem 2.2rem;
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    background-clip: padding-box;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.16),
        0 1px 1px rgba(255,255,255,0.05),
        0 40px 90px -30px rgba(1, 5, 30, 0.95),
        0 0 120px -40px rgba(70, 110, 240, 0.5);
}

.login-panel::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 25px;
    padding: 1px;
    background: linear-gradient(165deg,
        rgba(255,255,255,0.45) 0%,
        rgba(255,255,255,0.10) 28%,
        rgba(255,255,255,0.04) 60%,
        rgba(255, 229, 0, 0.22) 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeUp 0.7s var(--ease-out) both;
}

.login-logo {
    width: 68px; height: 68px;
    margin: 0 auto 1.25rem;
    position: relative;
    filter: drop-shadow(0 20px 34px rgba(3, 8, 40, 0.65)) drop-shadow(0 4px 18px rgba(255, 229, 0, 0.28));
}

/* Alone morbido dietro il monogramma */
.login-logo::before {
    content: '';
    position: absolute;
    inset: -34px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 229, 0, 0.16), transparent 62%);
    z-index: -1;
}

.login-title {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: 0.22em;
    margin-bottom: 0.35rem;
    padding-left: 0.22em; /* compensa il letter-spacing per centrare */
    background: linear-gradient(180deg, #ffffff 30%, rgba(214, 226, 255, 0.78));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    font-size: 0.74rem;
    color: rgba(226, 234, 255, 0.55);
    font-weight: 500;
    letter-spacing: 0.06em;
}

.login-form { animation: fadeUp 0.7s var(--ease-out) 0.15s both; }

.login-form .form-control {
    background: rgba(6, 12, 44, 0.35) !important;
    border: 1px solid rgba(255,255,255,0.16) !important;
    color: #ffffff !important;
    padding: 0.78rem 1.05rem;
    font-size: 0.88rem;
    border-radius: 14px;
    box-shadow: inset 0 1px 3px rgba(2, 6, 28, 0.4);
    transition: all 0.25s var(--ease-out);
}

.login-form .form-control:hover {
    border-color: rgba(255,255,255,0.28) !important;
}

.login-form .form-control:focus {
    border-color: rgba(255, 229, 0, 0.85) !important;
    box-shadow:
        inset 0 1px 3px rgba(2, 6, 28, 0.4),
        0 0 0 3px rgba(255, 229, 0, 0.18),
        0 0 24px -6px rgba(255, 229, 0, 0.35) !important;
    background: rgba(6, 12, 44, 0.5) !important;
}

.login-form .form-control::placeholder { color: rgba(226, 234, 255, 0.4) !important; }

.login-form .form-check-input {
    background-color: rgba(6, 12, 44, 0.35);
    border-color: rgba(255,255,255,0.3);
}

.login-form .form-check-input:checked {
    background-color: var(--lt-yellow);
    border-color: var(--lt-yellow);
    /* spunta blu su fondo giallo */
    --bs-form-check-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%230f3397' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3E%3C/svg%3E");
}

.login-form .form-check-label {
    color: rgba(226, 234, 255, 0.68);
    font-size: 0.78rem;
}

.login-form .btn {
    padding: 0.72rem;
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.login-form .lt-btn-accent {
    background: linear-gradient(180deg, #fff173 0%, var(--lt-yellow) 55%, #f2c800 100%) !important;
    border: 1px solid rgba(255, 244, 130, 0.9) !important;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.55),
        0 14px 34px -12px rgba(255, 229, 0, 0.55),
        0 4px 12px -4px rgba(2, 6, 28, 0.5);
}

.login-form .lt-btn-accent:hover {
    background: linear-gradient(180deg, #fff59a 0%, #ffe926 55%, #f5cd00 100%) !important;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.6),
        0 18px 40px -12px rgba(255, 229, 0, 0.65),
        0 4px 12px -4px rgba(2, 6, 28, 0.5);
}

.login-flag {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    margin-top: 1.8rem;
}

/* Filetti laterali che incorniciano il tricolore */
.login-flag::before,
.login-flag::after {
    content: '';
    height: 1px;
    flex: 1;
    max-width: 5.5rem;
}

.login-flag::before {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22));
}

.login-flag::after {
    background: linear-gradient(90deg, rgba(255,255,255,0.22), transparent);
}

/* ── Errori ──────────────────────────────────────────────────── */

.error-code {
    font-family: var(--font-display);
    font-size: 5.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--lt-blue), var(--lt-blue-soft));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

html[data-theme="dark"] .error-code {
    background: linear-gradient(135deg, #8aa5ff, #5272e0);
    -webkit-background-clip: text;
    background-clip: text;
}

/* ── Utilities ───────────────────────────────────────────────── */

.text-limca   { color: var(--lt-primary) !important; }
.text-success { color: var(--lt-success) !important; }
.text-danger  { color: var(--lt-danger) !important; }
.text-warning { color: var(--lt-warning) !important; }
.text-muted   { color: var(--lt-text-3) !important; }

a.text-limca:hover { color: var(--lt-primary-hover) !important; }

.thumb {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--lt-border-2);
    background: var(--lt-surface-3);
}

.thumb-placeholder {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--lt-border-3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lt-text-4);
    font-size: 1rem;
    background: var(--lt-surface-2);
}

.avatar-thumb { border-radius: 50%; }

/* Pagination */
.lt-page-link {
    background: var(--lt-surface) !important;
    border: 1px solid var(--lt-border-2) !important;
    color: var(--lt-text-2) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 0.78rem;
    min-width: 32px;
    text-align: center;
}

.lt-page-link:hover {
    border-color: var(--lt-primary) !important;
    color: var(--lt-primary) !important;
}

.page-item.active .lt-page-link {
    background: var(--lt-blue) !important;
    border-color: var(--lt-blue) !important;
    color: #fff !important;
}

.page-item.disabled .lt-page-link { opacity: 0.4; }

/* Filtri a pillole */
.filter-pills {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.24rem;
    background: var(--lt-surface);
    border: 1px solid var(--lt-border-2);
    border-radius: 999px;
    flex-wrap: wrap;
}

.filter-pill {
    color: var(--lt-text-3);
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.45rem 0.75rem;
    text-decoration: none;
    transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out);
    white-space: nowrap;
    border: none;
    background: transparent;
    cursor: pointer;
}

.filter-pill:hover,
.filter-pill.active {
    background: var(--lt-primary-subtle);
    color: var(--lt-primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--lt-border-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--lt-text-4); }

/* ── Animazioni ──────────────────────────────────────────────── */

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

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

/* Le classi di ingresso restano nei template ma non animano più a ogni
   navigazione: il passaggio pagina è gestito dalle View Transitions. */
.fade-up,
.fade-in { opacity: 1; }

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

/* ── Modal Bootstrap override ────────────────────────────────── */

.modal-content {
    background: var(--lt-surface);
    border: 1px solid var(--lt-border-2);
    border-radius: var(--radius-lg);
    color: var(--lt-text);
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.has-sidebar .app-main { margin-left: 0; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }
    .mobile-header { display: flex; }
    .app-content { padding: 1.25rem 1rem 2rem; }

    .topnav .navbar { padding: 0.65rem 1rem; }
    .topnav-brand { margin-right: 0; }
    .topnav .navbar-collapse {
        margin-top: 0.65rem;
        padding-top: 0.65rem;
        border-top: 1px solid rgba(255,255,255,0.10);
    }
    .topnav-links { align-items: stretch; }
    .topnav-link { padding: 0.65rem 0.75rem; }
    .topnav-user {
        margin: 0.55rem 0 0;
        padding: 0.55rem 0 0;
        border-top: 1px solid rgba(255,255,255,0.10);
    }
    .topnav-user-toggle { width: 100%; }
    .topnav-dropdown { width: 100%; }
}

@media (max-width: 575.98px) {
    .app-content { padding: 1rem 0.75rem 2rem; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .layout-options { grid-template-columns: 1fr; }
    .topnav .lt-toast-container {
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }
}
