:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #1e2933;
    --muted: #667085;
    --line: #d9e2ec;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --danger: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; display: flex; }
.main-shell { flex: 1; min-width: 0; }
.sidebar {
    width: 240px;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    background: #102a43;
    color: #f8fafc;
    flex: 0 0 240px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.brand {
    display: block;
    margin-bottom: 28px;
    font-weight: 700;
    letter-spacing: 0;
}
.brand-logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}
.brand-logo img {
    display: block;
    width: 170px;
    max-width: 100%;
    height: auto;
}
.sidebar nav { display: grid; gap: 8px; flex: 1 1 auto; }
.sidebar a:not(.brand) { padding: 10px 12px; border-radius: 6px; color: #dbeafe; }
.sidebar a:hover { background: rgba(255, 255, 255, 0.1); }
.sidebar-profile {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
}
.sidebar-logout {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #dbeafe;
    font-weight: 700;
}
.sidebar-logout:hover {
    background: rgba(56, 189, 248, 0.18);
    color: #ffffff;
}
.sidebar-avatar {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #ffffff;
    color: #102a43;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    padding-top: 1px;
    flex: 0 0 auto;
}
.sidebar-profile-meta {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.sidebar-profile-meta strong,
.sidebar-profile-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-profile-meta small {
    color: rgba(219, 234, 254, 0.82);
    font-size: 12px;
}
.mobile-drawer-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
}
.mobile-drawer-avatar {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    padding: 0;
    flex: 0 0 auto;
}
.mobile-drawer-profile-meta {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.mobile-drawer-profile-meta strong,
.mobile-drawer-profile-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-drawer-profile-meta small {
    color: var(--muted);
    font-size: 12px;
}
.topbar { min-height: 64px; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar span { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.topbar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.topbar-logo img {
    display: block;
    width: 118px;
    height: auto;
}
.topbar-title {
    min-width: 0;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid var(--line);
}
.topbar-avatar {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    padding: 0;
    flex: 0 0 auto;
}
.topbar-user-inline {
    display: none;
}
.topbar-user-desktop {
    display: none;
}
.topbar-user-meta {
    display: grid;
    gap: 1px;
    line-height: 1.1;
}
.topbar-user-meta strong {
    font-size: 14px;
}
.topbar-user-meta small {
    color: var(--muted);
    font-size: 12px;
}
.content { padding: 28px; }
.page-heading { margin-bottom: 22px; }
h1, h2, p { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 22px;
    margin-bottom: 22px;
}
.card, .panel, .login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
.card { padding: 18px; }
.metric { display: block; margin-bottom: 8px; color: var(--brand); font-size: 32px; font-weight: 700; }
.dashboard-card {
    display: block;
    min-height: 118px;
    padding: 22px;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    border-color: #38bdf8;
    box-shadow: 0 8px 22px rgba(56, 189, 248, 0.16);
}

.dashboard-card .metric,
.dashboard-card strong {
    display: block;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.panel { padding: 22px; }
.button, button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border: 0; border-radius: 6px; background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; }
.button-light { background: #e6fffb; color: var(--brand-dark); }
.login-page { width: 100%; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: min(100%, 420px); padding: 28px; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.alert { margin-bottom: 14px; padding: 10px 12px; border-radius: 6px; background: #fee4e2; color: var(--danger); }
.footer { padding: 18px 28px; color: var(--muted); }

.profile-layout {
    display: grid;
    grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.profile-summary {
    display: grid;
    justify-items: start;
    gap: 12px;
}

.profile-avatar-large {
    width: 72px;
    height: 72px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 24px;
    font-weight: 800;
}

.profile-summary h2 {
    margin-bottom: 0;
}

.profile-summary p {
    color: var(--muted);
}

@media (max-width: 860px) {
    .app-shell { display: block; }
    .sidebar { width: 100%; min-height: auto; position: static; overflow: visible; flex: initial; }
    .sidebar-profile { display: none; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .topbar { display: none; }
    .content { padding: 18px; }
    .stats-grid { grid-template-columns: 1fr; }
}

.login-body {
    background: #eef3f6;
}

.login-body .app-shell {
    display: block;
}

.login-body .main-shell {
    min-height: 100vh;
}

.login-body .footer {
    display: none;
}

.login-page {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(420px, 0.88fr);
    padding: 0;
    background: #f7fafc;
}

.login-visual {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: flex-end;
    padding: clamp(36px, 6vw, 72px);
    overflow: hidden;
    background-image: linear-gradient(90deg, rgba(7, 47, 73, 0.72), rgba(7, 47, 73, 0.12)), url('../img/login-area-clienti.svg');
    background-size: cover;
    background-position: center;
    color: #ffffff;
}

.login-visual::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(3, 31, 48, 0.46));
    pointer-events: none;
}

.login-visual-content {
    position: relative;
    z-index: 1;
    max-width: 680px;
}

.login-kicker {
    display: inline-flex;
    margin-bottom: 18px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #e6fffb;
    font-size: 14px;
    font-weight: 700;
}

.login-visual h1 {
    margin-bottom: 18px;
    color: #ffffff;
    font-size: 56px;
    line-height: 1.04;
    font-weight: 800;
}

.login-visual p {
    max-width: 560px;
    margin-bottom: 0;
    color: rgba(255, 255, 255, 0.86);
    font-size: 19px;
    line-height: 1.55;
}

.login-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(28px, 5vw, 64px);
    background: #ffffff;
}

.login-box {
    width: min(100%, 430px);
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.login-heading {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.login-logo {
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 14px;
    background: var(--brand);
    color: #ffffff;
    font-weight: 800;
}

.login-heading h2 {
    margin-bottom: 4px;
    font-size: 30px;
    font-weight: 800;
}

.login-heading p {
    margin-bottom: 0;
    color: var(--muted);
}

.login-box label {
    color: #344054;
    font-weight: 700;
}

.login-box .form-control {
    min-height: 48px;
    border-color: #cbd5e1;
    border-radius: 8px;
}

.login-box .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(15, 118, 110, 0.18);
}

.btn-login {
    width: 100%;
    min-height: 48px;
    margin-top: 4px;
    border-radius: 8px;
    background: var(--brand);
}

.btn-login:hover,
.btn-login:focus {
    background: var(--brand-dark);
}

@media (max-width: 960px) {
    .login-page {
        grid-template-columns: 1fr;
    }

    .login-visual {
        min-height: 42vh;
        align-items: center;
    }

    .login-panel {
        min-height: auto;
    }

    .login-visual h1 {
        font-size: 42px;
    }
}

@media (max-width: 560px) {
    .login-visual {
        min-height: 34vh;
        padding: 28px;
    }

    .login-visual h1 {
        font-size: 34px;
    }

    .login-visual p {
        font-size: 16px;
    }

    .login-panel {
        padding: 28px 20px;
    }

    .login-heading {
        align-items: flex-start;
    }
}

.password-page {
    display: flex;
    justify-content: center;
}

.password-panel {
    width: min(100%, 520px);
}

.registration-page {
    display: flex;
    justify-content: center;
}

.registration-panel {
    width: min(100%, 920px);
}

.registration-form {
    display: grid;
    gap: 16px;
}

.registration-type {
    display: none;
}

.registration-type[data-visible='true'] {
    display: block;
}

@media (max-width: 860px) {
    body {
        overflow-x: hidden;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 14px 16px;
    }

    .brand {
        margin-bottom: 12px;
    }

    .sidebar nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar a:not(.brand) {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .topbar {
        padding: 12px 16px;
    }

    .content {
        padding: 20px 16px;
    }

    .panel,
    .card {
        border-radius: 8px;
    }
}

@media (max-width: 560px) {
    h1 {
        font-size: 28px;
        line-height: 1.15;
    }

    h2 {
        font-size: 22px;
        line-height: 1.2;
    }

    .topbar .button,
    .topbar .button-light {
        width: 100%;
    }

    .panel {
        padding: 18px;
    }

    .card {
        padding: 16px;
    }

    .metric {
        font-size: 28px;
    }

    .login-page {
        min-height: 100svh;
    }

    .login-visual {
        min-height: 30svh;
    }

    .login-panel {
        align-items: flex-start;
        min-height: 70svh;
    }

    .login-heading h2 {
        font-size: 26px;
    }

    .password-page {
        display: block;
    }
}

.setup-button {
    width: 100%;
    margin-top: 14px;
}

.setup-copy {
    color: var(--muted);
    line-height: 1.5;
}

.modal-body label + label {
    margin-top: 12px;
}

/* MINISA visual identity overrides */
:root {
    --bg: #f5f5f3;
    --panel: #ffffff;
    --text: #111111;
    --muted: #686b70;
    --line: #e4e1dc;
    --brand: #ef4b4f;
    --brand-dark: #111111;
    --brand-warm: #ffc84a;
    --brand-gray: #9da0a4;
    --danger: #c62828;
}

.sidebar {
    background: #111111;
}

.sidebar a:not(.brand) {
    color: #f5f5f3;
}

.sidebar a:hover {
    background: rgba(239, 75, 79, 0.18);
}

.metric,
.brand {
    color: var(--brand);
}

.button,
button,
.btn-login {
    background: var(--brand);
    color: #ffffff;
}

.button:hover,
button:hover,
.btn-login:hover,
.btn-login:focus {
    background: #111111;
    color: #ffffff;
}

.button-light {
    background: #fff4d8;
    color: #111111;
}

.login-body {
    background: #ffffff;
}

.brand-home.login-page,
.login-page.brand-home {
    grid-template-columns: minmax(0, 1.24fr) minmax(380px, 0.76fr);
    background: #ffffff;
}

.brand-home .login-visual {
    align-items: stretch;
    justify-content: space-between;
    flex-direction: column;
    gap: 34px;
    background: #ffffff;
    color: #111111;
    border-right: 1px solid var(--line);
}

.brand-home .login-visual::after {
    display: none;
}

.brand-hero {
    position: relative;
    z-index: 1;
    max-width: 760px;
}

.brand-hero-logo {
    width: min(100%, 360px);
    height: auto;
    display: block;
    margin-bottom: 22px;
}

.brand-dots {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.brand-dots span {
    width: 18px;
    height: 18px;
    display: block;
    border: 2px solid #111111;
    border-radius: 50%;
}

.brand-dots span:nth-child(1) { background: var(--brand); }
.brand-dots span:nth-child(2) { background: var(--brand-gray); }
.brand-dots span:nth-child(3) { background: var(--brand-warm); }

.brand-home .login-kicker {
    border-color: #111111;
    background: #111111;
    color: #ffffff;
}

.brand-home .login-visual h1 {
    color: #111111;
    font-size: clamp(42px, 5.6vw, 76px);
    letter-spacing: 0;
}

.brand-home .login-visual p {
    color: #3b3b3b;
    font-size: 18px;
}

.partners-panel {
    width: min(100%, 980px);
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 34px rgba(17, 17, 17, 0.08);
}

.partners-panel span {
    display: block;
    margin-bottom: 10px;
    color: #111111;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.partners-panel img {
    width: 100%;
    max-height: 190px;
    display: block;
    object-fit: contain;
}

.brand-home .login-panel {
    background: #f5f5f3;
}

.brand-home .login-box {
    width: min(100%, 410px);
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 50px rgba(17, 17, 17, 0.1);
}

.login-heading-stacked {
    display: grid;
    gap: 18px;
}

.login-brand-logo {
    width: 210px;
    max-width: 100%;
    height: auto;
    display: block;
}

.brand-home .login-heading h2 {
    color: #111111;
}

.brand-home .login-box .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(239, 75, 79, 0.18);
}

.brand-home .modal-content {
    border-radius: 8px;
}

@media (max-width: 1100px) {
    .brand-home.login-page,
    .login-page.brand-home {
        grid-template-columns: 1fr;
    }

    .brand-home .login-visual {
        min-height: auto;
        padding: 34px 28px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .partners-panel img {
        max-height: 150px;
    }

    .brand-home .login-panel {
        min-height: auto;
        padding: 32px 20px;
    }
}

@media (max-width: 560px) {
    .brand-home .login-visual {
        padding: 26px 18px;
        gap: 24px;
    }

    .brand-hero-logo {
        width: min(100%, 260px);
        margin-bottom: 16px;
    }

    .brand-home .login-visual h1 {
        font-size: 34px;
    }

    .brand-home .login-visual p {
        font-size: 15px;
    }

    .partners-panel {
        padding: 14px;
    }

    .partners-panel img {
        max-height: 118px;
    }

    .brand-home .login-box {
        padding: 24px 18px;
    }

    .login-brand-logo {
        width: 180px;
    }
}

/* Pulizia home MINISA */
.minisa-home.login-page {
    min-height: 100vh;
    grid-template-columns: minmax(0, 1fr) 430px;
    background: #ffffff;
}

.minisa-home .login-visual {
    min-height: 100vh;
    align-items: stretch;
    justify-content: space-between;
    flex-direction: column;
    padding: clamp(28px, 5vw, 58px);
    background: #ffffff;
    color: #111111;
    border-right: 1px solid #e6e2dd;
}

.minisa-home .login-visual::after {
    display: none;
}

.minisa-home .login-visual-content {
    max-width: 620px;
}

.minisa-logo-main {
    width: min(100%, 300px);
    height: auto;
    display: block;
    margin-bottom: 36px;
}

.minisa-home .login-kicker {
    margin-bottom: 18px;
    border-color: #111111;
    background: #111111;
    color: #ffffff;
}

.minisa-home .login-visual h1 {
    margin-bottom: 16px;
    color: #111111;
    font-size: clamp(40px, 5vw, 68px);
    line-height: 1.03;
}

.minisa-home .login-visual p {
    max-width: 520px;
    color: #3f3f3f;
    font-size: 18px;
}

.partners-strip {
    width: min(100%, 860px);
    padding: 16px 18px;
    border: 1px solid #e6e2dd;
    border-radius: 8px;
    background: #ffffff;
}

.partners-strip span {
    display: block;
    margin-bottom: 10px;
    color: #111111;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.partners-strip img {
    width: 100%;
    max-height: 155px;
    display: block;
    object-fit: contain;
}

.minisa-home .login-panel {
    min-height: 100vh;
    background: #f6f4f1;
}

.minisa-home .login-box {
    width: min(100%, 370px);
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.minisa-home .login-heading {
    display: block;
}

.minisa-home .login-heading h2 {
    color: #111111;
}

.minisa-home .btn-login,
.minisa-home button[type='submit'] {
    background: #ef4b4f;
}

.minisa-home .btn-login:hover,
.minisa-home button[type='submit']:hover {
    background: #111111;
}

.minisa-home .form-control:focus {
    border-color: #ef4b4f;
    box-shadow: 0 0 0 0.2rem rgba(239, 75, 79, 0.18);
}

@media (max-width: 980px) {
    .minisa-home.login-page {
        grid-template-columns: 1fr;
    }

    .minisa-home .login-visual {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid #e6e2dd;
    }

    .minisa-home .login-panel {
        min-height: auto;
        padding: 34px 20px;
    }
}

@media (max-width: 560px) {
    .minisa-home .login-visual {
        padding: 24px 18px;
    }

    .minisa-logo-main {
        width: 230px;
        margin-bottom: 24px;
    }

    .minisa-home .login-visual h1 {
        font-size: 34px;
    }

    .partners-strip img {
        max-height: 110px;
    }
}

/* Richiesta layout centrato home */
.minisa-home.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    background: #ffffff;
}

.minisa-home .login-visual {
    min-height: 0;
    align-items: center;
    justify-content: center;
    padding: 32px 20px 18px;
    border: 0;
    text-align: center;
}

.minisa-home .login-visual-content {
    max-width: 520px;
    margin: 0 auto;
}

.minisa-logo-main {
    margin-right: auto;
    margin-left: auto;
}

.minisa-home .login-visual h1,
.minisa-home .login-visual p {
    margin-right: auto;
    margin-left: auto;
}

.minisa-home .login-panel {
    min-height: 0;
    padding: 0 20px 28px;
    background: #ffffff;
}

.minisa-home .login-box {
    width: min(100%, 380px);
    margin: 0 auto;
}

.minisa-home .login-heading {
    text-align: center;
}

.partners-strip {
    width: min(100% - 32px, 900px);
    margin: 0 auto 22px;
    padding: 12px 14px;
    border: 0;
    box-shadow: none;
}

.partners-strip img {
    max-height: 120px;
}

@media (max-width: 560px) {
    .minisa-home .login-visual {
        padding-top: 24px;
    }

    .partners-strip img {
        max-height: 86px;
    }
}

/* Form login centrato nella home */
.minisa-home.login-page {
    min-height: 100vh;
    grid-template-rows: 1fr auto;
}

.minisa-home .login-visual {
    padding-bottom: 12px;
}

.minisa-home .login-panel {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 240px 20px 150px;
    pointer-events: none;
}

.minisa-home .login-box {
    pointer-events: auto;
}

.minisa-home .partners-strip {
    position: relative;
    z-index: 2;
}

@media (max-height: 760px), (max-width: 760px) {
    .minisa-home .login-panel {
        position: static;
        padding: 0 20px 26px;
    }
}

/* Correzione sovrapposizione: layout verticale ordinato */
.minisa-home.login-page {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
}

.minisa-home .login-visual,
.minisa-home .login-panel {
    display: block;
    min-height: 0;
    padding: 0 20px;
    background: #ffffff;
    border: 0;
}

.minisa-home .login-visual {
    padding-top: 28px;
}

.minisa-home .login-visual-content {
    max-width: 520px;
    margin: 0 auto 24px;
    text-align: center;
}

.minisa-home .login-panel {
    position: static;
    inset: auto;
    pointer-events: auto;
}

.minisa-home .login-box {
    width: min(100%, 380px);
    margin: 0 auto;
    pointer-events: auto;
}

.minisa-home .partners-strip {
    width: min(100% - 32px, 900px);
    margin: 32px auto 22px;
}

@media (max-width: 560px) {
    .minisa-home.login-page {
        justify-content: flex-start;
    }

    .minisa-home .login-visual {
        padding-top: 22px;
    }

    .minisa-home .login-visual-content {
        margin-bottom: 18px;
    }

    .minisa-home .partners-strip {
        margin-top: 24px;
    }
}

/* Home definitiva: blocco accesso centrato, partner in basso */
.login-body .app-shell,
.login-body .main-shell {
    min-height: 100vh;
}

.minisa-home {
    min-height: 100vh;
    display: grid;
    grid-template-rows: 1fr auto;
    background: #ffffff;
}

.home-center {
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 40px 20px 24px;
    display: flex;
    min-height: calc(100vh - 150px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    text-align: center;
}

.home-intro {
    width: 100%;
}

.home-intro .minisa-logo-main {
    width: min(100%, 260px);
    margin: 0 auto 18px;
}

.home-intro h1 {
    margin-bottom: 8px;
    color: #111111;
    font-size: 38px;
    line-height: 1.08;
}

.home-intro p {
    max-width: 460px;
    margin: 0 auto;
    color: #454545;
    font-size: 16px;
    line-height: 1.5;
}

.minisa-home .login-box {
    width: min(100%, 420px);
    margin: 0 auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    display: block;
    text-align: left;
}

.minisa-home .login-heading {
    margin-bottom: 18px;
    display: block;
    text-align: center;
}

.minisa-home .login-heading h2 {
    margin-bottom: 4px;
    color: #111111;
}

.minisa-home .login-box form {
    width: 100%;
    text-align: left;
}

.minisa-home .login-box label,
.minisa-home .login-box .check-row {
    width: 100%;
}

.minisa-home .login-box .btn-login {
    width: 100%;
}

.minisa-home .btn-login,
.minisa-home button[type='submit'] {
    background: #ef4b4f;
}

.minisa-home .btn-login:hover,
.minisa-home button[type='submit']:hover {
    background: #111111;
}

.minisa-home .partners-strip {
    width: min(100% - 32px, 900px);
    margin: 0 auto 18px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.minisa-home .partners-strip img {
    width: 100%;
    max-height: 118px;
    display: block;
    object-fit: contain;
}

@media (max-width: 560px) {
    .home-center {
        min-height: calc(100vh - 100px);
        padding: 24px 18px 18px;
        gap: 18px;
    }

    .home-intro .minisa-logo-main {
        width: 220px;
    }

    .home-intro h1 {
        font-size: 32px;
    }

    .home-intro p {
        font-size: 15px;
    }

    .minisa-home .partners-strip img {
        max-height: 78px;
    }
}

/* Respiro laterale testo home su smartphone */
@media (max-width: 560px) {
    .home-intro p {
        max-width: calc(100% - 28px);
        padding-right: 8px;
        padding-left: 8px;
    }
}

.settings-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
    align-items: start;
}

.settings-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.settings-tab {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    text-align: left;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.settings-tab strong {
    display: block;
    font-size: 14px;
}

.settings-tab span {
    color: var(--muted);
    font-size: 12px;
}

.settings-tab:hover {
    transform: translateY(-1px);
    border-color: #38bdf8;
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.12);
}

.settings-tab.is-active {
    border-color: #38bdf8;
    background: #eff8ff;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.18) inset;
}

.settings-page {
    width: 100%;
}

.settings-panel-page {
    width: 100%;
    display: grid;
    gap: 16px;
}

.settings-layout > .panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-card {
    padding: 0;
    overflow: hidden;
}

.settings-card > summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px;
    cursor: pointer;
    list-style: none;
}

.settings-card > summary::-webkit-details-marker {
    display: none;
}

.settings-card > summary h2 {
    margin-bottom: 4px;
    font-size: 20px;
}

.settings-card > summary p {
    margin-bottom: 0;
    color: var(--muted);
}

.settings-card-hint {
    flex: 0 0 auto;
    color: var(--brand);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.settings-card[open] > summary {
    border-bottom: 1px solid var(--line);
}

.settings-card-body {
    display: grid;
    gap: 14px;
    padding: 22px;
}

.settings-form,
.settings-test-form {
    margin-top: 18px;
}

.settings-form {
    display: grid;
    gap: 14px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

.settings-meta {
    margin-top: 18px;
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 14px;
}

.code-box {
    margin: 12px 0 18px;
    padding: 14px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111111;
    color: #f8fafc;
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 980px) {
    .settings-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .settings-layout {
        grid-template-columns: 1fr;
    }
}

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

.admin-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.admin-grid .card h2 {
    margin-bottom: 8px;
    font-size: 22px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: #111111;
    font-size: 13px;
    text-transform: uppercase;
}

.data-table td span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.compact-table {
    min-width: 620px;
}

@media (max-width: 640px) {
    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }
}

.page-heading-actions {
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
}

.page-heading-actions > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.page-heading-actions > .heading-actions {
    flex: 0 0 auto;
    justify-content: flex-end;
    margin-left: auto;
}

.search-box {
    min-width: min(100%, 320px);
    color: var(--text);
    font-weight: 700;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.type-company {
    background: #fff4d8;
    color: #6f4a00;
}

.type-private {
    background: #fee4e2;
    color: #9b1c1c;
}

.table-action {
    min-height: 34px;
    padding: 0 12px;
    white-space: nowrap;
}

.muted-count {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.detail-item {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.detail-item strong {
    display: block;
    margin-bottom: 5px;
    color: #111;
    font-size: 12px;
    text-transform: uppercase;
}

.detail-item span {
    color: var(--muted);
    overflow-wrap: anywhere;
}

@media (max-width: 700px) {
    .page-heading-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .search-box {
        min-width: 0;
    }
}

/* Spaziatura coerente dei paragrafi */
.page-heading p,
.panel p,
.login-heading p,
.home-intro p,
.setup-copy {
    line-height: 1.55;
}

.panel > p:last-child,
.page-heading p:last-child,
.login-heading p:last-child,
.home-intro p:last-child {
    margin-bottom: 0;
}

.panel p + p {
    margin-top: 10px;
}

.table-muted {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.inline-upload {
    margin: 0;
}

.upload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 6px;
    background: #fff4d8;
    color: #111111;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.upload-button input {
    display: none;
}

/* Override finale login home: blocco unico davvero centrato */
body.login-body .minisa-home {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
}

body.login-body .minisa-home .home-center {
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 44px 20px 24px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    text-align: center;
}

body.login-body .minisa-home .home-intro,
body.login-body .minisa-home .login-box,
body.login-body .minisa-home .partners-strip {
    width: 100%;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

body.login-body .minisa-home .home-intro {
    text-align: center;
}

body.login-body .minisa-home .login-box {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    display: block;
    text-align: left;
}

body.login-body .minisa-home .login-heading {
    text-align: center;
}

body.login-body .minisa-home .login-box form,
body.login-body .minisa-home .login-box label,
body.login-body .minisa-home .login-box .check-row,
body.login-body .minisa-home .login-box .alert,
body.login-body .minisa-home .login-box .table-muted,
body.login-body .minisa-home .login-box .btn-login,
body.login-body .minisa-home .login-box .setup-button {
    width: 100%;
}

body.login-body .minisa-home .login-box .btn-login,
body.login-body .minisa-home .login-box .setup-button {
    min-height: 48px;
}

body.login-body .minisa-home .login-box .check-row {
    align-items: flex-start;
    gap: 8px;
    font-weight: 600;
    line-height: 1.45;
    text-align: left;
}

body.login-body .minisa-home .login-box .check-row input {
    margin-top: 3px;
}

body.login-body .minisa-home .login-box .registration-captcha {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

body.login-body .minisa-home .login-box .g-recaptcha {
    display: inline-block;
    transform-origin: center top;
}

body.login-body .minisa-home .partners-strip {
    padding: 0;
    border: 0;
    box-shadow: none;
}

body.login-body .minisa-home .login-box .table-muted {
    text-align: center;
    white-space: normal;
}

.ticket-tags-grid,
.ticket-tags-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ticket-tag-choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-weight: 600;
}

.ticket-tag-choice input {
    width: 16px;
    min-height: 16px;
    margin: 0;
}

.ticket-tag-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.ticket-tags-editor {
    display: grid;
    gap: 14px;
}

.ticket-tag-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.ticket-tag-row .check-row {
    align-self: center;
    margin: 0;
}

.ticket-tag-remove {
    justify-self: end;
}

.ticket-tag-row input[type='color'] {
    min-height: 42px;
    padding: 4px;
}

@media (max-width: 960px) {
    .ticket-tag-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

body.login-body .minisa-home .login-box input,
body.login-body .minisa-home .login-box select,
body.login-body .minisa-home .login-box textarea {
    text-align: center;
}

body.login-body .minisa-home .login-box .g-recaptcha {
    margin: 0 auto;
}

body.login-body .minisa-home .login-box form {
    justify-items: center;
}

body.login-body .minisa-home .login-box label {
    justify-items: center;
    text-align: center;
}

body.login-body .minisa-home .login-box,
body.login-body .minisa-home .login-box form,
body.login-body .minisa-home .login-box label,
body.login-body .minisa-home .login-box .check-row,
body.login-body .minisa-home .login-box .alert,
body.login-body .minisa-home .login-box .table-muted,
body.login-body .minisa-home .login-box .registration-captcha,
body.login-body .minisa-home .login-box .btn-login,
body.login-body .minisa-home .login-box .setup-button {
    margin-left: auto;
    margin-right: auto;
}

body.login-body .minisa-home .login-box form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

body.login-body .minisa-home .login-box label {
    width: min(100%, 430px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

body.login-body .minisa-home .login-box input,
body.login-body .minisa-home .login-box select,
body.login-body .minisa-home .login-box textarea {
    width: 100%;
    text-align: center;
}

body.login-body .minisa-home .login-box .check-row {
    width: min(100%, 430px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    text-align: center;
}

body.login-body .minisa-home .login-box .check-row input {
    margin-top: 4px;
    flex: 0 0 auto;
}

body.login-body .minisa-home .login-box .alert,
body.login-body .minisa-home .login-box .table-muted {
    width: min(100%, 430px);
    text-align: center;
}

body.login-body .minisa-home .login-box .registration-captcha {
    width: min(100%, 430px);
    display: flex;
    justify-content: center;
}

body.login-body .minisa-home .login-box .registration-terms {
    width: min(100%, 430px);
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    justify-content: center;
    gap: 10px;
    text-align: left;
}

body.login-body .minisa-home .login-box .registration-terms span {
    display: block;
    line-height: 1.5;
}

body.login-body .minisa-home .login-box .g-recaptcha {
    display: inline-block;
    margin: 0 auto;
    transform-origin: center top;
}

body.login-body .minisa-home .login-box .btn-login,
body.login-body .minisa-home .login-box .setup-button {
    width: min(100%, 430px);
}

@media (max-width: 560px) {
    body.login-body .minisa-home .home-center {
        width: 100%;
        padding: 20px 12px 14px;
        gap: 14px;
    }

    body.login-body .minisa-home .home-intro h1 {
        font-size: 28px;
        line-height: 1.1;
    }

    body.login-body .minisa-home .home-intro p {
        font-size: 14px;
        line-height: 1.45;
    }

    body.login-body .minisa-home .login-box .registration-terms {
        width: 100%;
        grid-template-columns: 18px minmax(0, 1fr);
        gap: 8px;
        text-align: left;
    }

    body.login-body .minisa-home .login-box .registration-terms span {
        font-size: 13px;
        line-height: 1.45;
    }

    body.login-body .minisa-home .partners-strip {
        width: 100%;
        padding: 0 4px;
    }

    body.login-body .minisa-home .partners-strip img {
        width: 100%;
        max-width: 100%;
    }
}

.pdf-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pdf-present {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e8f5e9;
    color: #1b5e20;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.heading-actions {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-section {
    display: grid;
    gap: 14px;
}

.settings-panel-page .privilege-check {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #38bdf8;
    transform: scale(0.95);
}

.settings-panel-page .privilege-role-select {
    min-width: 150px;
}

.form-section h2 {
    margin-bottom: 0;
    font-size: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.data-table td .status-badge {
    display: inline-flex;
    margin-top: 0;
}

.status-badge.priority-bassa,
.data-table td .status-badge.priority-bassa { background: #dcfce7; color: #166534; }

.status-badge.priority-media,
.data-table td .status-badge.priority-media { background: #fef3c7; color: #92400e; }

.status-badge.priority-alta,
.data-table td .status-badge.priority-alta { background: #ffedd5; color: #c2410c; }

.status-badge.priority-urgente,
.data-table td .status-badge.priority-urgente { background: #fee2e2; color: #991b1b; }

.status-badge.ticket-aperto,
.data-table td .status-badge.ticket-aperto { background: #dbeafe; color: #1d4ed8; }

.status-badge.ticket-in_lavorazione,
.data-table td .status-badge.ticket-in_lavorazione { background: #e0f2fe; color: #0369a1; }

.status-badge.ticket-in_attesa,
.data-table td .status-badge.ticket-in_attesa { background: #fef3c7; color: #92400e; }

.status-badge.ticket-chiuso,
.data-table td .status-badge.ticket-chiuso { background: #e5e7eb; color: #374151; }

.resolved-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    margin-top: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #16a34a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.ticket-badges .resolved-badge {
    margin-top: 0;
}

.ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 18px;
    align-items: start;
}

.ticket-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.ticket-title-row h2 {
    margin-bottom: 6px;
}

.ticket-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ticket-description {
    margin-bottom: 22px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    line-height: 1.55;
}

.ticket-thread {
    display: grid;
    gap: 12px;
    margin: 14px 0 18px;
}

.ticket-message {
    max-width: 82%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.ticket-message-staff {
    margin-left: auto;
    border-color: rgba(239, 75, 79, 0.28);
    background: #fff8f8;
}

.ticket-message-client {
    margin-right: auto;
    background: #f8fafc;
}

.ticket-message-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
}

.ticket-message-head strong {
    color: #111111;
}

.ticket-message p {
    margin-bottom: 0;
    line-height: 1.5;
}

.ticket-reply-form,
.ticket-status-form {
    margin-top: 18px;
}

.ticket-side {
    position: sticky;
    top: 18px;
}

.ticket-detail-grid {
    grid-template-columns: 1fr;
}

.alert-success {
    background: #e8f5e9;
    color: #1b5e20;
}

@media (max-width: 980px) {
    .ticket-layout {
        grid-template-columns: 1fr;
    }

    .ticket-side {
        position: static;
    }
}

@media (max-width: 700px) {
    .heading-actions,
    .form-actions,
    .ticket-title-row {
        align-items: stretch;
        flex-direction: column;
    }

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

    .ticket-message {
        max-width: 100%;
    }
}

/* Tema gestionale: pulsanti celesti e font Montserrat */
body {
    font-family: 'Montserrat', Arial, Helvetica, sans-serif;
}

.button,
button,
.btn-login,
.minisa-home .btn-login,
.minisa-home button[type='submit'] {
    background: #38bdf8;
    color: #ffffff;
}

.button:hover,
button:hover,
.btn-login:hover,
.btn-login:focus,
.minisa-home .btn-login:hover,
.minisa-home button[type='submit']:hover {
    background: #0284c7;
    color: #ffffff;
}

.button-light,
.upload-button {
    background: #e0f2fe;
    color: #075985;
}

.button-light:hover,
.upload-button:hover {
    background: #bae6fd;
    color: #075985;
}

/* Adattamento smartphone, senza alterare desktop */
@media (max-width: 700px) {
    .topbar {
        gap: 12px;
    }

    .topbar > div,
    .topbar .button {
        width: 100%;
    }

    .topbar-logout {
        display: none;
    }

    .content {
        padding: 16px 12px;
    }

    .page-heading {
        margin-bottom: 16px;
    }

    .page-heading h1 {
        font-size: 26px;
        line-height: 1.15;
    }

    .page-heading p {
        font-size: 14px;
    }

    .panel {
        padding: 14px;
        border-radius: 8px;
    }

    .heading-actions,
    .search-box,
    .heading-actions .button,
    .form-actions .button,
    .form-actions button {
        width: 100%;
    }

    .data-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 12px;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #ffffff;
    }

    .data-table td {
        display: grid;
        grid-template-columns: 116px minmax(0, 1fr);
        gap: 10px;
        padding: 8px 0;
        border-bottom: 1px solid #eef2f6;
        overflow-wrap: anywhere;
    }

    .data-table td:last-child {
        border-bottom: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
    }

    .data-table td[data-label=''] {
        display: block;
        padding-top: 12px;
    }

    .data-table td[data-label='']::before {
        display: none;
    }

    .table-action {
        width: 100%;
    }

    .data-table td .status-badge,
    .resolved-badge {
        justify-self: start;
        margin-top: 0;
    }

    .data-table td .status-badge.priority-bassa { background: #dcfce7 !important; color: #166534 !important; }
    .data-table td .status-badge.priority-media { background: #fef3c7 !important; color: #92400e !important; }
    .data-table td .status-badge.priority-alta { background: #ffedd5 !important; color: #c2410c !important; }
    .data-table td .status-badge.priority-urgente { background: #fee2e2 !important; color: #991b1b !important; }
    .data-table td .status-badge.ticket-aperto { background: #dbeafe !important; color: #1d4ed8 !important; }
    .data-table td .status-badge.ticket-in_lavorazione { background: #e0f2fe !important; color: #0369a1 !important; }
    .data-table td .status-badge.ticket-in_attesa { background: #fef3c7 !important; color: #92400e !important; }
    .data-table td .status-badge.ticket-chiuso { background: #e5e7eb !important; color: #374151 !important; }
.data-table td .resolved-badge { background: #16a34a !important; color: #ffffff !important; }

.invoice-client-results {
    max-height: 240px;
    overflow: auto;
    border-radius: 0.5rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.invoice-client-results .list-group-item {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
}

.invoice-client-results .list-group-item:first-child {
    border-top: 0;
}

.invoice-client-results .list-group-item:last-child {
    border-bottom: 0;
}

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

.catalog-mosaic {
    margin-left: 0;
    margin-right: 0;
}

.catalog-mosaic-item {
    display: flex;
}

.catalog-mosaic-item > .catalog-card {
    width: 100%;
}

.catalog-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid rgba(148, 163, 184, 0.22);
    overflow: hidden;
    border-radius: 1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.catalog-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 44px rgba(15, 23, 42, 0.12);
}

.catalog-card-main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.catalog-card-media {
    position: relative;
    background: #f8fafc;
    height: 240px;
    overflow: hidden;
    flex: 0 0 240px;
}

.catalog-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.catalog-card-body {
    padding: 1rem 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    flex: 1 1 auto;
    min-height: 0;
}

.catalog-card-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.catalog-card-body .small.text-muted {
    line-height: 1.5;
}

.catalog-card-topline {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.catalog-card-kindline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.55rem;
}

.catalog-card-kindline .catalog-kind-badge {
    padding: 0.56rem 0.92rem;
    font-size: 0.84rem;
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
}

.catalog-card-title {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 800;
    line-height: 1.25;
}

.catalog-card-price {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 42px;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    background: #e0f2fe;
    border: 1px solid rgba(14, 165, 233, 0.18);
    font-size: 1rem;
    font-weight: 800;
    color: #0ea5e9;
    white-space: nowrap;
    text-align: center;
    flex: 0 0 auto;
    align-self: flex-start;
}

.catalog-card-description {
    margin: 0;
    color: #475569;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 4.5em;
}

.catalog-card-footer {
    padding: 0.9rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(248, 250, 252, 0.82);
    margin-top: auto;
}

.catalog-card-actions-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    flex-wrap: nowrap;
}

.catalog-card-actions-admin {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.catalog-card-actions-admin form {
    display: inline-flex;
    margin: 0;
}

.catalog-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.catalog-card-actions form {
    display: inline-flex;
    margin: 0;
}

.catalog-card-actions-main .catalog-card-price {
    margin-right: auto;
    align-self: flex-end;
}

.catalog-card-actions-main .btn {
    margin-left: auto;
    flex: 0 0 auto;
    align-self: flex-end;
}

.catalog-card-price-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.75rem;
}

.catalog-card-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.6rem;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
}

.catalog-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    padding-top: 0.2rem;
}

.catalog-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 0.45rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: #f8fafc;
}

.catalog-thumb-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 0.45rem;
    background: #e2e8f0;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 700;
}

.catalog-kind-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0.42rem 0.7rem;
    border-radius: 999px;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
    letter-spacing: 0;
}

.catalog-kind-badge.catalog-kind-product {
    background: #16a34a;
}

.catalog-kind-badge.catalog-kind-service {
    background: #0ea5e9;
}

.catalog-kind-badge.catalog-kind-neutral {
    background: #6b7280;
}

.catalog-card-content .catalog-kind-badge {
    align-self: flex-start;
    margin: 0 0 0.35rem 0;
}

.catalog-card-kicker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
}

.catalog-card-kicker .badge {
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
    font-size: 0.78rem;
    font-weight: 800;
    padding: 0.48rem 0.7rem;
}

.catalog-details-image-wrap {
    border-radius: 1rem;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.catalog-details-image {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #ffffff;
}

.catalog-details-empty {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 1rem;
    background: #f8fafc;
    border: 1px dashed rgba(148, 163, 184, 0.35);
    color: #64748b;
    font-weight: 700;
}

@media (min-width: 992px) {
    .catalog-details-image-wrap,
    .catalog-details-image,
    .catalog-details-empty {
        min-height: 480px;
        aspect-ratio: 1 / 1;
    }
}

.catalog-details-price {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: #e0f2fe;
    border: 1px solid rgba(14, 165, 233, 0.18);
    color: #0ea5e9;
    font-size: 1.05rem;
    font-weight: 800;
}

.catalog-details-full {
    color: #334155;
    line-height: 1.6;
    white-space: pre-line;
}

.catalog-detail-panel {
    padding: 1.25rem;
}

.catalog-detail-meta {
    display: grid;
    gap: 10px;
    margin-bottom: 1.25rem;
}

.catalog-detail-meta-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    background: #ffffff;
}

.catalog-detail-meta-item span:first-child {
    color: #64748b;
    font-weight: 700;
}

.catalog-detail-meta-item span:last-child {
    text-align: right;
    font-weight: 700;
    color: #0f172a;
}

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

    .catalog-card-main {
        flex-direction: column;
    }

    .catalog-card-media {
        flex-basis: auto;
        width: 100%;
        height: 220px;
    }

    .catalog-card-topline {
        flex-direction: column;
    }

    .catalog-card-footer {
        align-items: stretch;
    }

    .catalog-card-actions-main {
        align-items: stretch;
    }

    .catalog-card-actions {
        width: 100%;
    }

    #itemDetailsModal .modal-content {
        border-radius: 0;
        min-height: 100dvh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
    }

    #itemDetailsModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100dvh;
    }

    #itemDetailsModal .modal-header,
    #itemDetailsModal .modal-footer {
        flex: 0 0 auto;
    }

    #itemDetailsModal .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
    }
}

#itemDetailsModal .modal-content {
    display: flex;
    flex-direction: column;
}

#itemDetailsModal .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

#itemDetailsModal .modal-dialog {
    max-width: 960px;
    margin: 1rem auto;
}

#itemDetailsModal .modal-content {
    max-height: calc(100dvh - 2rem);
}

html,
body {
    overflow-y: auto !important;
    min-height: 100%;
}

body {
    position: static !important;
}

    .ticket-title-row {
        gap: 10px;
    }

    .ticket-badges {
        justify-content: flex-start;
    }

    .ticket-description {
        padding: 12px;
    }

    .ticket-message-head {
        display: grid;
        gap: 3px;
    }

    input,
    select,
    textarea,
    .form-control {
        font-size: 16px;
    }
}

@media (max-width: 420px) {
    .data-table td {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* Navigazione mobile */
.mobile-nav,
.mobile-drawer,
.mobile-drawer-backdrop {
    display: none;
}

@media (min-width: 701px) {
    .mobile-nav,
    .mobile-drawer,
    .mobile-drawer-backdrop {
        display: none !important;
    }
}

@media (max-width: 700px) {
    .sidebar {
        display: none;
    }

    .app-shell {
        display: block;
    }

    .main-shell {
        position: relative;
        z-index: 1;
        width: 100%;
        min-height: 100vh;
        background: var(--bg);
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }

    .main-shell > * {
        position: relative;
        z-index: 1;
    }

    .mobile-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 40;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0;
        padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        box-shadow: 0 -8px 24px rgba(17, 17, 17, 0.08);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 60px;
        gap: 4px;
        border: 0;
        background: transparent;
        color: #0f172a;
        font: inherit;
        font-weight: 700;
        text-align: center;
    }

    .mobile-nav-icon {
        width: 22px;
        height: 22px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #38bdf8;
    }

    .mobile-nav-icon svg {
        width: 22px;
        height: 22px;
        display: block;
    }

    .mobile-nav-label {
        font-size: 11px;
        line-height: 1.1;
    }

    .mobile-drawer-backdrop {
        position: fixed;
        inset: 0;
        z-index: 45;
        background: rgba(15, 23, 42, 0.42);
    }

    .mobile-drawer {
        position: fixed;
        right: 10px;
        bottom: calc(86px + env(safe-area-inset-bottom));
        left: 10px;
        z-index: 50;
        display: block;
        max-height: min(70vh, 540px);
        overflow: auto;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #ffffff;
        box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
        transform: translateY(18px);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.18s ease, opacity 0.18s ease;
    }

    .mobile-drawer.is-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-drawer-backdrop.is-open {
        display: block;
    }

    .mobile-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 14px 10px;
        border-bottom: 1px solid var(--line);
    }

    .mobile-drawer-brand {
        display: grid;
        gap: 6px;
        max-width: calc(100% - 52px);
    }

    .mobile-brand-logo {
        display: block;
        max-width: 100%;
        height: auto;
        object-fit: contain;
    }

    .mobile-brand-logo-main {
        width: 165px;
    }

    .mobile-drawer-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 36px;
        min-width: 36px;
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: #e0f2fe;
        color: #075985;
    }

    .mobile-drawer-close svg {
        width: 18px;
        height: 18px;
    }

    .mobile-drawer-nav {
        display: grid;
        gap: 6px;
        padding: 12px;
    }

    .mobile-drawer-nav a {
        display: block;
        padding: 12px 14px;
        border-radius: 10px;
        background: #f8fafc;
        color: #0f172a;
        font-weight: 600;
    }

    .mobile-drawer-nav a:last-child {
        color: #b42318;
    }

}
