:root {
    --brand-primary: #1c64f2;
    --brand-secondary: #4c1d95;
    --brand-surface: #f4f7ff;
    --brand-border: #d0dcff;
    --brand-text: #1f2937;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.app-body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--brand-surface);
    color: var(--brand-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1c64f2 0%, #1e3a8a 100%);
    color: #ffffff;
    padding: 1.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1), width 0.35s ease, padding 0.35s ease, box-shadow 0.35s ease;
    will-change: transform, width;
}

.app-sidebar__close {
    background: #ffffff;
    border: none;
    color: var(--brand-primary);
    width: 44px;
    height: 44px;
    border-radius: 0.75rem;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.app-sidebar__actions {
    display: inline-flex;
    gap: 0.5rem;
}

.app-sidebar__collapse {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.app-mobile-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 2100;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 0.75rem;
    background: #ffffff;
    color: var(--brand-primary);
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.app-overlay {
    display: none;
}


.app-sidebar__header {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.app-sidebar__brand {
    font-size: 1.2rem;
    font-weight: 600;
    color: #ffffff;
    text-decoration: none;
}

.app-sidebar__nav .nav {
    gap: 0.35rem;
}

.app-nav-link {
    color: rgba(255, 255, 255, 0.85);
    border-radius: 0.75rem;
    padding: 0.6rem 0.9rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.app-nav-link:hover,
.app-nav-link:focus {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
}

.app-nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.28);
}

.app-sidebar__footer {
    margin-top: auto;
    font-size: 0.9rem;
}

.app-sidebar__user {
    opacity: 0.9;
}

.landing-body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    color: var(--brand-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-hero {
    position: relative;
    background: linear-gradient(140deg, rgba(28, 100, 242, 0.95), rgba(76, 29, 149, 0.9));
    overflow: hidden;
}

.landing-hero .overlay-gradient {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.35), transparent 55%);
    pointer-events: none;
}

.landing-nav .btn-outline-light {
    border-width: 2px;
}

.hero-copy i {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.75rem;
    line-height: 1;
}

.highlight-card {
    border-radius: 1.25rem;
    border: 1px solid rgba(28, 100, 242, 0.08);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 12px 40px rgba(28, 100, 242, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.highlight-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 50px rgba(28, 100, 242, 0.18);
}

.landing-form-section {
    background: #f5f7ff;
}

.landing-form-section .card {
    border: none;
}

.landing-footer {
    background: linear-gradient(135deg, #1c64f2, #4c1d95);
}

.landing-footer a {
    text-decoration: none;
}

.main-content {
    flex: 1;
    min-height: 0;
}

.hero-card {
    background: linear-gradient(135deg, var(--brand-primary), #0ea5e9);
    color: #ffffff;
    border: none;
}

.hero-card .btn-light {
    color: var(--brand-primary);
}

.metric-card {
    border: 1px solid var(--brand-border);
    border-radius: 1rem;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(28, 100, 242, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px rgba(28, 100, 242, 0.16);
}

.metric-card .metric-value {
    font-size: 2.5rem;
    font-weight: 700;
}

.table-dashboard thead {
    background: #eef3ff;
    color: #1e3a8a;
}

.table-dashboard tbody tr:hover {
    background: rgba(28, 100, 242, 0.05);
}

.ticket-badge {
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}

.ticket-badge.aperto {
    background: #fee2e2;
    color: #b91c1c;
}

.ticket-badge.in_lavorazione {
    background: #fef3c7;
    color: #b45309;
}

.ticket-badge.chiuso {
    background: #dcfce7;
    color: #15803d;
}

.badge-priorita {
    font-size: 0.75rem;
    letter-spacing: 0.03em;
}

.admin-users-table {
    max-height: calc(3 * 3.75rem + 3rem);
    overflow-y: auto;
}

.admin-users-table table thead th {
    height: 3rem;
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8f9fa;
}

.admin-users-table table tbody tr {
    height: 3.75rem;
}

.privacy-footer {
    text-align: center;
    padding: 1.5rem 0 2rem;
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: auto;
}

.ticket-timer {
    font-weight: 600;
    color: #0f172a;
}

.ticket-timer--urgent {
    color: #dc2626;
}

.ticket-row--expired {
    background: #fee2e2;
}

.ticket-row--expired td {
    color: #7f1d1d;
}

@keyframes ticket-blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.2;
    }
}

.ticket-timer--expired {
    color: #b91c1c;
    font-size: 1.15rem;
    font-weight: 700;
    animation: ticket-blink 1s infinite;
}

.privacy-footer a {
    color: inherit;
    text-decoration: none;
}

.privacy-footer a:hover,
.privacy-footer a:focus {
    text-decoration: underline;
}

.card-activity {
    border-left: 4px solid var(--brand-primary);
}

.login-body {
    background: linear-gradient(120deg, rgba(76, 29, 149, 0.85), rgba(28, 100, 242, 0.75));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.login-card {
    border-radius: 1.5rem;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}

.login-card .card-header {
    background: transparent;
}

.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.attachment-thumb {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    border: 1px solid var(--brand-border);
    border-radius: 0.75rem;
    overflow: hidden;
    text-decoration: none;
    background: #fff;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.attachment-thumb img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.attachment-thumb:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.attachment-caption {
    font-size: 0.8rem;
    color: #475569;
    padding: 0 0.75rem 0.75rem;
}

.signature-pad-wrapper {
    border: 2px dashed var(--brand-border);
    border-radius: 1rem;
    padding: 1rem;
    background: #f8fbff;
}

.signature-pad-wrapper canvas {
    width: 100%;
    height: 220px;
    border-radius: 0.75rem;
    background: #fff;
    cursor: crosshair;
}

.signature-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

@media (max-width: 767px) {
    .main-content {
        width: 100%;
    }

    .metric-card .metric-value {
        font-size: 2rem;
    }

    .landing-nav {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .landing-nav .btn {
        width: 100%;
    }

    .app-sidebar__nav .nav {
        flex-direction: column;
        flex-wrap: nowrap;
    }
}

@media (max-width: 992px) {
    body.no-scroll {
        overflow: hidden;
    }

    .app-mobile-toggle {
        display: inline-flex;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 2000;
        transform: translate3d(-100%, 0, 0);
        transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.35s ease;
        overflow-y: auto;
        box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
        will-change: transform;
    }

    .app-sidebar.sidebar--open {
        transform: translate3d(0, 0, 0);
    }

    .app-sidebar__close {
        display: inline-flex;
    }

    .app-sidebar__collapse {
        display: none;
    }

    .app-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1900;
        opacity: 0;
        transition: opacity 0.35s ease;
    }

    .app-overlay.overlay--open {
        display: block;
        opacity: 1;
    }

    .main-content {
        padding-top: 4rem;
        min-height: auto;
    }

    .app-sidebar__nav .nav {
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .app-nav-link {
        padding: 0.5rem 0.8rem;
    }
}

@media (min-width: 993px) {
    .app-mobile-toggle,
    .app-sidebar__close,
    .app-overlay {
        display: none !important;
    }
}

.app-shell.sidebar--collapsed .app-sidebar {
    width: 0;
    padding: 0;
    overflow: hidden;
    transform: translateX(-100%);
}

.app-shell.sidebar--collapsed .app-sidebar__header,
.app-shell.sidebar--collapsed .app-sidebar__nav,
.app-shell.sidebar--collapsed .app-sidebar__footer {
    display: none;
}

.app-shell.sidebar--collapsed .app-mobile-toggle {
    display: inline-flex !important;
}

.hamburger {
    display: none !important;
}

@media (max-width: 992px) {
    .hamburger {
        display: inline-flex !important;
    }
}

body.no-scroll .hamburger {
    display: none !important;
}

@media (max-width: 992px) {
    input,
    select,
    textarea,
    .form-control-sm,
    .form-select-sm,
    .btn-sm {
        font-size: 1rem;
    }
}
