:root {
    --bg-page: #eef1f5;
    --bg-surface: #ffffff;
    --bg-muted: #f3f4f6;
    --bg-sidebar: #1e3a5f;
    --bg-sidebar-hover: #2a4a73;
    --bg-sidebar-active: #2563eb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-inverse: #ffffff;
    --border: #d1d5db;
    --border-light: #e5e7eb;
    --primary: #1e3a5f;
    --primary-hover: #2a4a73;
    --success: #059669;
    --success-hover: #047857;
    --danger: #dc2626;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
    --radius: 10px;
    --sidebar-width: 240px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
}

html:has(.app),
html:has(.app) body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

.app {
    display: flex;
    height: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

/* ── Sidebar desktop ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    padding: 20px 14px;
    flex-shrink: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.15);
}

@media (min-width: 769px) {
    .app {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 100;
        width: var(--sidebar-width);
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .content {
        margin-left: var(--sidebar-width);
        height: 100%;
        min-height: 0;
    }

    main.content:has(.list-page),
    main.content:has(.scheda-page) {
        padding-top: 0;
    }
}

.sidebar .app-nav {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px);
    min-height: calc(100dvh - 40px);
}

.app-nav .nav-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius);
    color: #dbeafe;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.app-nav .nav-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-inverse);
    border-color: rgba(255, 255, 255, 0.2);
}

.app-nav .nav-btn.active {
    background: var(--bg-sidebar-active);
    color: var(--text-inverse);
    border-color: var(--bg-sidebar-active);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.app-nav-section {
    display: flex;
    flex-direction: column;
    margin: 6px 0 4px;
}

.app-nav-section-title {
    margin: 4px 0 8px;
    padding: 0 16px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: rgba(219, 234, 254, 0.7);
}

.app-nav-section .nav-btn {
    margin-bottom: 6px;
}

.app-nav-mobile {
    display: none;
}

.mobile-topbar,
.mobile-nav-backdrop,
.mobile-nav-drawer {
    display: none;
}

body.mobile-nav-open {
    overflow: hidden;
}

/* ── Contenuto ── */
.content {
    --content-pad-x: 32px;
    flex: 1;
    padding: 24px var(--content-pad-x);
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-page);
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 12px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.page-toolbar-start {
    justify-content: flex-start;
}

.page-toolbar-split {
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.page-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.scheda-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: var(--bg-muted);
    color: var(--text-secondary);
    font-size: 1.45rem;
    line-height: 1;
    text-decoration: none;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.scheda-close:hover {
    background: #e5e7eb;
    color: var(--text-primary);
}

.page-toolbar .btn,
.list-page-head .btn,
.list-page-head .btn-add-item,
.list-page-add-row .btn,
.admin-subnav a {
    border-width: 1px;
    border-style: solid;
}

.page-toolbar .btn-primary,
.list-page-head .btn-add-item,
.list-page-add-row .btn-add-item {
    border-color: #0b1f38;
}

.page-toolbar .btn-danger,
.list-page-head .btn-danger {
    border-color: #7f1d1d;
}

.page-toolbar .btn-secondary,
.list-page-head .btn-secondary,
.list-page-add-row .btn-secondary {
    border-color: #4b5563;
}

.card-list {
    border-color: rgba(37, 99, 235, 0.22);
    border-top: 3px solid var(--bg-sidebar-active);
    box-shadow: var(--shadow-sm);
    overflow: visible;
}

.card-list-compact {
    padding: 12px 14px;
    margin-bottom: 0;
}

.list-page {
    --list-head-top: 0;
    --list-sticky-height: 0;
    margin-bottom: 20px;
}

.list-page-head {
    position: sticky;
    top: var(--list-head-top);
    z-index: 270;
    margin: 0 calc(-1 * var(--content-pad-x, 32px)) 10px;
    padding: 10px var(--content-pad-x, 32px);
    background: #ffffff;
    background-color: #ffffff;
    box-shadow: 0 1px 0 var(--border-light);
}

@media (max-width: 768px) {
    .list-page,
    .scheda-page {
        -webkit-overflow-scrolling: touch;
    }
}

.list-page-bar {
    display: grid;
    gap: 10px;
}

.list-page-bar-meta {
    min-width: 0;
}

.list-page-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.list-page-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
}

.list-page-title-row .list-page-title {
    flex: 1 1 auto;
    min-width: 0;
}

.list-page-controls-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}

.list-page-control-section {
    min-width: 0;
}

.list-page-section-heading {
    margin: 0 0 4px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}

.list-page-control-section--sort .list-page-sort-wrap {
    max-width: 100%;
}

.list-page-filter-tools-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: nowrap;
}

.list-page-sort-select {
    width: 100%;
    height: 34px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    font-size: 0.84rem;
    color: var(--text-primary);
}

.list-page-filter-status {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: left;
    margin-left: 6px;
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.list-page-head .rapporti-alerts {
    margin-bottom: 8px;
}

.rapporti-alert-message {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.45;
}

.rapporti-alert-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin: 2px 0 2px 10px;
    padding: 4px 12px;
    border: 1px solid rgba(146, 64, 14, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    color: #92400e;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.rapporti-alert-dismiss:hover {
    background: #fff;
    border-color: rgba(146, 64, 14, 0.45);
    color: #78350f;
}

.list-page-add-row {
    margin: 10px 0 0;
}

.list-page-add-row--split {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.list-page-add-row--split .btn-add-item-head,
.list-page-add-row--split [data-import-toggle] {
    flex: 1 1 180px;
}

.list-page-add-row .btn-add-item-head {
    display: flex;
    width: 100%;
    justify-content: center;
    padding: 10px 14px 10px 12px;
    font-size: 0.9rem;
}

@media (min-width: 769px) {
    .list-page-bar-actions .list-page-inline-search-form {
        min-width: 220px;
        max-width: 420px;
    }
}

.list-page-inline-search-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.list-page-inline-search-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.list-page-inline-search-form input[type="search"] {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}

.list-page-filters-bar {
    padding-top: 0;
}

.list-page-actions-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
}

.list-page-actions-tools [data-filter-reset][hidden] {
    display: none !important;
}

.btn-list-action {
    padding: 8px 10px;
    font-size: 0.82rem;
    white-space: nowrap;
    text-align: center;
    min-height: 36px;
}

.btn-list-filters {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 5.5rem;
}

.btn-list-filters-label {
    display: inline-block;
}

.btn-list-filters-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    font-size: 0.85rem;
    line-height: 1;
    flex-shrink: 0;
}

.btn-list-filters[aria-expanded="false"] .btn-list-filters-chevron::before {
    content: '▼';
}

.btn-list-filters[aria-expanded="true"] .btn-list-filters-chevron::before {
    content: '▲';
}

.btn-list-reset {
    min-width: 4.5rem;
}

@media (min-width: 769px) {
    .list-page-add-row .btn-add-item-head {
        width: auto;
        margin-left: 0;
        display: inline-flex;
    }

    .list-page-add-row {
        display: flex;
        justify-content: center;
    }

    .list-page-bar,
    .list-page-filters-bar {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
        gap: 16px;
    }

    .list-page-controls-row {
        flex-direction: row;
        align-items: end;
        flex-wrap: wrap;
        gap: 20px 24px;
        margin-top: 8px;
    }

    .list-page-control-section--sort {
        flex: 0 1 320px;
        min-width: 200px;
    }

    .list-page-control-section--filters {
        flex: 0 1 320px;
        min-width: 240px;
    }

    .list-page-control-section--sort .list-page-sort-wrap {
        max-width: 320px;
    }

    .list-page-control-section--filters .list-page-filter-tools-row {
        justify-content: flex-start;
        flex-wrap: nowrap;
    }
}

.list-filters-panel {
    --filter-control-height: 42px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.list-filters-panel[hidden] {
    display: none;
}

.list-filters-mobile-actions {
    display: none;
}

.list-filters-mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 360;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.list-filters-mobile-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.filters-toolbar-compact {
    gap: 8px;
}

.filters-toolbar-compact .form-group {
    gap: 4px;
}

.filters-toolbar-compact label {
    font-size: 0.82rem;
}

.filters-toolbar-compact input,
.filters-toolbar-compact select,
.filters-toolbar-compact textarea {
    font-size: 16px;
}

.list-filters-panel .filters-toolbar-compact input:not([type="hidden"]):not([type="date"]):not([type="checkbox"]),
.list-filters-panel .filters-toolbar-compact select,
.list-filters-panel .anagrafica-trigger,
.list-filters-panel .date-range-trigger,
.list-filters-panel .operatore-ms-trigger {
    box-sizing: border-box;
    height: var(--filter-control-height);
    min-height: var(--filter-control-height);
    max-height: var(--filter-control-height);
    padding: 0 10px;
    line-height: 1.25;
}

.list-filters-panel .date-range-trigger {
    display: flex;
    align-items: stretch;
    padding: 0;
    gap: 0;
    cursor: pointer;
    caret-color: transparent;
    user-select: none;
    font-weight: 400;
}

.list-filters-panel .anagrafica-trigger {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.list-filters-panel .date-range-trigger-text {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 4px 0 8px;
    font-size: 16px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}

.list-filters-panel .date-range-trigger-text.is-placeholder {
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 400;
}

.list-filters-panel .date-range-chevron-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    margin: 0;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    caret-color: transparent;
    user-select: none;
    font-family: inherit;
}

.list-filters-panel .date-range-chevron-btn:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.list-filters-panel .date-range-chevron-btn:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.list-filters-panel .date-range-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    font-size: 0.65rem;
    line-height: 1;
}

.list-filters-panel .date-range-chevron::before {
    content: '▼';
}

.list-filters-panel .date-range-trigger[aria-expanded="true"] .date-range-chevron::before {
    content: '▲';
}

.list-filters-panel .filters-toolbar-compact select {
    padding-right: 28px;
}

.filters-toolbar-grid.filters-toolbar-compact {
    gap: 10px;
}

.filters-toolbar-grid .form-group {
    min-width: 0;
}

.list-results {
    overflow-x: auto;
}

.list-card-top {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 16px;
}

.btn-add-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px 9px 10px;
    border: 1px solid rgba(37, 99, 235, 0.35);
    border-radius: var(--radius);
    background: var(--bg-sidebar-active);
    color: var(--text-inverse);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.24);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn-add-item:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: var(--text-inverse);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-add-item__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.card h2 {
    margin: 0 0 16px;
    font-size: 1.15rem;
    color: var(--text-primary);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.filters-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.filters-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.filters-status {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
}

.filters-status-none {
    color: var(--text-muted);
}

.filters-status-active {
    color: #c2410c;
}

.filters-bar-actions,
.list-page-bar-actions {
    display: grid;
    gap: 8px;
}

.filters-panel {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.filters-panel[hidden] {
    display: none;
}

.filters-panel .toolbar {
    margin-bottom: 0;
}

.filters-toolbar-grid {
    display: grid;
    grid-template-columns:
        minmax(100px, 0.85fr)
        minmax(150px, 1.35fr)
        minmax(155px, 1.15fr)
        minmax(90px, 0.8fr)
        minmax(110px, 0.95fr)
        minmax(90px, 0.8fr)
        minmax(140px, 1.1fr);
    gap: 10px;
    align-items: end;
}

.form-group-date-range {
    container-type: inline-size;
    container-name: date-range-field;
    min-width: 0;
}

.operatore-ms {
    position: relative;
}

.operatore-ms-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
}

.operatore-ms-trigger:hover,
.operatore-ms-trigger[aria-expanded="true"] {
    border-color: var(--primary);
}

.operatore-ms-trigger-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.operatore-ms-trigger-text.is-placeholder {
    color: var(--text-muted);
}

.operatore-ms-popover {
    position: absolute;
    z-index: 50;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 240px;
    max-height: 320px;
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    box-shadow: var(--shadow-md);
}

.operatore-ms-popover[hidden] {
    display: none !important;
}

.operatore-ms-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.operatore-ms-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.operatore-ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

.operatore-ms-option input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}

.date-range-filter {
    position: relative;
}

.date-range-trigger {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    caret-color: transparent;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.date-range-trigger:hover {
    border-color: var(--primary);
}

.date-range-trigger:focus-within {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.date-range-trigger-text {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
    caret-color: transparent;
}

.date-range-trigger-text.is-placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.date-range-popover {
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    left: 0;
    width: max(100%, 300px);
    min-width: min(100%, 300px);
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    box-shadow: var(--shadow-md, 0 8px 24px rgba(15, 23, 42, 0.12));
}

.date-range-popover[hidden] {
    display: none;
}

.date-range-popover-note {
    margin: 0 0 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.date-range-popover-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.date-range-popover-field {
    container-type: inline-size;
    container-name: date-range-popover-field;
    min-width: 0;
}

.date-range-popover-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.date-range-native-wrap {
    position: relative;
    display: flex;
    align-items: center;
    height: var(--filter-control-height, 42px);
}

.date-range-native-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.date-range-native-btn {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--filter-control-height, 42px);
    min-height: var(--filter-control-height, 42px);
    margin: 0;
    padding: 0 36px 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: inherit;
    font-weight: 400;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
}

.date-range-native-btn:hover {
    border-color: var(--primary);
}

.date-range-native-btn:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.date-range-native-display {
    display: block;
    width: 100%;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    font-weight: 400;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

.date-range-native-display.is-placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.date-range-clear-btn {
    position: absolute;
    top: 50%;
    right: 6px;
    z-index: 3;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.date-range-clear-btn:hover {
    background: #e5e7eb;
    color: var(--text-primary);
}

.date-range-popover-error {
    margin: 8px 0 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--danger, #dc2626);
}

.date-range-popover-error[hidden] {
    display: none;
}

.filters-toolbar-inline {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 12px;
}

.filters-toolbar-inline .form-group-grow {
    flex: 1 1 auto;
    min-width: 0;
}

.toolbar .form-group-grow {
    flex: 1 1 220px;
    min-width: 200px;
}

.toolbar input[type="date"] {
    min-width: 150px;
}

.filter-picker {
    display: block;
    width: 100%;
}

.anagrafica-trigger {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.anagrafica-trigger:hover {
    border-color: var(--primary);
}

.anagrafica-trigger:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.anagrafica-trigger-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.anagrafica-trigger-text.is-placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

.anag-picker-current {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
}

.anag-picker-current[hidden] {
    display: none !important;
}

.anag-picker-current-name {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.anag-picker-current-name strong {
    font-weight: 600;
}

.anag-picker-current .btn {
    flex: 0 0 auto;
    height: 42px;
    min-height: 42px;
    white-space: nowrap;
}

.anag-picker-search[hidden] {
    display: none !important;
}

.anag-picker-lock-hint {
    margin: 0 0 10px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    font-size: 0.9rem;
    font-weight: 600;
}

.anag-picker-lock-hint[hidden] {
    display: none !important;
}

.anag-picker-hint {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.anag-picker-hint[hidden] {
    display: none !important;
}

.anag-picker.is-locked .anag-picker-search input {
    background: var(--bg-muted);
    color: var(--text-muted);
    cursor: not-allowed;
}

.anag-picker-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-bottom: 1px solid var(--border-light);
    background: #fff;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.anag-picker-item:last-child {
    border-bottom: 0;
}

.anag-picker-item:hover,
.anag-picker-item:focus-visible {
    background: #eef4ff;
    outline: none;
}

.anag-picker-item-title {
    font-weight: 700;
    color: var(--text-primary);
}

.anag-picker-item-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.filter-picker .btn-sm {
    flex-shrink: 0;
    height: 42px;
    padding: 0 14px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-height: 42px;
    padding: 6px 8px 6px 12px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.filter-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(220px, 100%);
}

.filter-chip-clear {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.filter-chip-clear:hover {
    background: var(--border-light);
    color: var(--danger);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.anag-picker-list {
    position: fixed;
    z-index: 11000;
    min-height: 0;
    max-height: 280px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.anag-picker-list[hidden] {
    display: none !important;
}

.anag-picker-empty {
    margin: 0;
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.anag-picker-empty[hidden] {
    display: none !important;
}

.modal-body > .anag-picker {
    display: flex;
    flex-direction: column;
}

.anag-picker-inline {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
}

.anag-picker-search {
    flex-shrink: 0;
}

.anag-picker-search input[type="search"] {
    min-height: 46px;
    font-size: 1rem;
}

.modal-picker-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.form-group.full,
.full {
    grid-column: 1 / -1;
}

.anagrafica-cf-piva-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px;
}

.anagrafica-cf-piva-row > .form-group,
.anagrafica-cf-piva-row > [data-piva-block] {
    flex: 1 1 11rem;
    max-width: 16.5rem;
    min-width: 0;
}

.piva-fields {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    overflow: visible;
}

.piva-fields:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.piva-fields .piva-nazione,
.piva-fields .piva-numero {
    border: none;
    border-radius: 0;
    box-shadow: none;
    min-height: 42px;
}

.piva-fields .piva-nazione {
    flex: 0 0 6.25rem;
    width: 6.25rem;
    max-width: 6.25rem;
    padding-right: 36px;
    border-right: 1px solid var(--border-light);
    background-color: var(--bg-muted);
    font-weight: 700;
    cursor: pointer;
}

.piva-fields .piva-nazione:focus,
.piva-fields .piva-numero:focus {
    box-shadow: none;
}

.piva-numero {
    flex: 1 1 auto;
    min-width: 0;
}

.utente-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}

.utente-name-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.utente-password-link {
    padding: 0;
    font-size: 0.85rem;
}

.hint.full {
    margin: 0;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.password-toggle::before {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    margin: 0 auto;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
}

.password-toggle[aria-pressed="true"]::before {
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M3 3l18 18M10.6 10.6A3 3 0 0012 15a3 3 0 002.4-4.4M9.9 5.1A10.8 10.8 0 0112 5c6.5 0 10 7 10 7a18.6 18.6 0 01-4.2 4.8M6.7 6.7C4.2 8.4 2 12 2 12s3.5 7 10 7c1.5 0 2.9-.3 4.1-.8'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M3 3l18 18M10.6 10.6A3 3 0 0012 15a3 3 0 002.4-4.4M9.9 5.1A10.8 10.8 0 0112 5c6.5 0 10 7 10 7a18.6 18.6 0 01-4.2 4.8M6.7 6.7C4.2 8.4 2 12 2 12s3.5 7 10 7c1.5 0 2.9-.3 4.1-.8'/%3E%3C/svg%3E") center / contain no-repeat;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    color: var(--text-primary);
    background: var(--bg-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* iOS Safari: sotto 16px il focus zoomma la pagina e rompe lo scroll */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="url"],
select,
textarea,
.time-text-input,
.ore-duration-input,
.ore-hm-input,
.list-filters-panel .anagrafica-trigger,
.list-filters-panel .date-trigger,
.list-filters-panel .date-range-trigger {
    font-size: 16px;
}

input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--bg-muted);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 1;
}

input[readonly] {
    background-color: var(--bg-muted);
    color: var(--text-secondary);
}

input[data-rapporto-codice][readonly] {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    cursor: default;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b5563' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ── Pulsanti ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-muted);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.btn-success {
    background: var(--success);
    color: var(--text-inverse);
    border-color: var(--success);
}

.btn-success:hover {
    background: var(--success-hover);
    border-color: var(--success-hover);
}

.btn-danger {
    background: var(--danger);
    color: var(--text-inverse);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.btn-warning {
    background: #ea580c;
    color: var(--text-inverse);
    border-color: #ea580c;
}

.btn-warning:hover {
    background: #c2410c;
    border-color: #c2410c;
}

.btn-success:hover {
    background: var(--success-hover);
    border-color: var(--success-hover);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* ── Tabelle ── */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    vertical-align: middle;
}

tbody tr {
    background: var(--bg-surface);
}

tbody tr:hover {
    background: #f9fafb;
}

.list-group-header th {
    background: var(--bg-muted);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: normal;
    border-bottom: 1px solid var(--border);
    padding-top: 18px;
}

.list-group-header:first-child th {
    padding-top: 12px;
}

.list-group-header:hover {
    background: transparent;
}

.list-group-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.list-row-clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.08s ease, border-color 0.08s ease;
}

.list-row-clickable:active,
.list-row-clickable.is-row-activating {
    background: rgba(37, 99, 235, 0.14) !important;
}

.list-row-clickable:focus-visible {
    outline: 2px solid var(--bg-sidebar-active);
    outline-offset: -2px;
}

.list-table a,
.list-cell-primary a {
    color: inherit;
    text-decoration: none;
}

.list-table a:hover,
.list-cell-primary a:hover {
    color: var(--primary);
    text-decoration: none;
}

.list-cell-check {
    width: 2.75rem;
    white-space: nowrap;
}

.list-cell-check input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    vertical-align: middle;
    pointer-events: auto;
}

.list-table-rapporti .list-cell-anagrafica-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-table-rapporti tbody tr.list-row-stato-completato {
    background: #d1fae5;
}

.list-table-rapporti tbody tr.list-row-stato-bozza {
    background: #fef3c7;
}

.list-table-rapporti tbody tr.list-row-stato-completato:hover {
    background: #bbf7d0;
}

.list-table-rapporti tbody tr.list-row-stato-bozza:hover {
    background: #fde68a;
}

th {
    background: var(--bg-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.badge-bozza {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

.badge-completato {
    background: #d1fae5;
    color: #065f46;
    border-color: #6ee7b7;
}

.badge-da_firmare {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fdba74;
}

.badge-non-inviato {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.rapporti-alerts {
    margin-bottom: 16px;
}

.rapporti-alert {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.rapporti-alert-firma {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fdba74;
}

.rapporti-alert-mail {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

.rapporti-alert a {
    color: inherit;
    font-weight: 700;
    margin-left: 8px;
}

.scheda-sign-block {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.scheda-sign-actions {
    margin-top: 20px;
}

.scheda-alert-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.scheda-tabs {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 8px;
    background: #d7dee8;
    border-bottom: 1px solid #b7c2d0;
}

.scheda-tab-btn {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 11px 10px;
    border: 1px solid #64748b;
    border-radius: 8px;
    background: #fff;
    color: var(--primary);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.scheda-tab-btn:hover {
    color: var(--primary);
    background: #e8eef6;
    border-color: var(--primary);
}

.scheda-tab-btn[aria-selected="true"] {
    color: var(--text-inverse);
    background: var(--bg-sidebar-active);
    border-color: #1d4ed8;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.scheda-tab-btn[aria-selected="true"]:hover {
    color: var(--text-inverse);
    background: var(--bg-sidebar-active);
}

.scheda-tab-btn:focus-visible {
    outline: 2px solid var(--bg-sidebar-active);
    outline-offset: 2px;
}

.scheda-tab-panels {
    padding-top: 16px;
}

.scheda-tab-panel[hidden] {
    display: none !important;
}

.scheda-intervento-block,
.scheda-gestionale-block,
.scheda-invii-block {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.scheda-intervento-sections {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
}

.scheda-intervento-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.scheda-intervento-parti-row,
.scheda-intervento-head-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: stretch;
}

.scheda-intervento-fatture-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

@media (max-width: 1100px) {
    .scheda-intervento-parti-row,
    .scheda-intervento-head-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scheda-intervento-fatture-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .scheda-intervento-parti-row,
    .scheda-intervento-fatture-row {
        grid-template-columns: 1fr;
    }
}

.scheda-detail-block {
    margin: 0;
    padding: 16px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.04));
    min-height: 0;
}

.scheda-detail-block--compact .scheda-detail-block-title {
    margin-bottom: 10px;
    padding-bottom: 8px;
}

.scheda-detail-block--compact .scheda-detail-block-lead {
    font-size: 0.92rem;
}

.scheda-detail-block-title {
    margin: 0 0 14px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary);
}

.scheda-detail-block-body {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-primary);
    word-break: break-word;
    white-space: pre-wrap;
}

.scheda-detail-block .scheda-dettaglio-list {
    margin: 0;
}

.scheda-detail-block--plain {
    padding-top: 14px;
    padding-bottom: 14px;
}

.scheda-detail-block-lead {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.scheda-detail-block-hint {
    margin: -4px 0 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Spaziatura interna uniforme nelle schede (cliente + rapporto) */
.scheda-page .card {
    padding: 16px 18px;
}

.scheda-page .card .scheda-tab-panels {
    padding-top: 12px;
}

.scheda-page .card .anagrafica-form .form-grid {
    gap: 14px;
}

.scheda-page .card .form-group {
    gap: 8px;
}

.scheda-page .card .scheda-intervento-sections {
    gap: 12px;
}

.scheda-page .card .scheda-detail-block {
    padding: 14px 16px;
}

.scheda-page .card .scheda-detail-block--compact {
    padding: 12px 14px;
}

.scheda-page .card .scheda-detail-block-title {
    margin-bottom: 12px;
    padding-bottom: 10px;
}

.scheda-page .card .scheda-detail-block-body,
.scheda-page .card .scheda-detail-block-lead {
    margin-top: 2px;
}

.scheda-page .card .scheda-detail-block .scheda-dettaglio-list {
    margin-top: 10px;
    gap: 12px 16px;
}

.scheda-page .card .scheda-dettaglio-list--stack {
    gap: 12px;
}

/* Dati intervento: stesso riquadro grigio su tutti i valori */
.scheda-intervento-sections .scheda-dettaglio-row,
.scheda-intervento-sections .scheda-detail-block-body,
.scheda-intervento-sections .scheda-detail-block-lead {
    margin: 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
}

.scheda-intervento-sections .scheda-detail-block .scheda-dettaglio-list {
    gap: 10px;
}

.scheda-intervento-sections .scheda-dettaglio-list--stack {
    gap: 10px;
}

.scheda-intervento-sections .scheda-dettaglio-row dt {
    margin-bottom: 4px;
}

.scheda-intervento-sections .scheda-dettaglio-row dd {
    margin: 0;
}

.scheda-intervento-sections .scheda-dettaglio-row--fatturare {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 10px;
}

.scheda-detail-block--tight {
    padding: 12px 14px;
}

.scheda-detail-block--tight .scheda-detail-block-title {
    margin-bottom: 10px;
    padding-bottom: 8px;
}

.scheda-detail-block--tight .scheda-dettaglio-list,
.scheda-detail-block--tight .scheda-dettaglio-list--stack {
    grid-template-columns: 1fr;
    gap: 8px;
}

.scheda-intervento-sections .scheda-detail-block--tight .scheda-dettaglio-row {
    padding: 8px 10px;
}

.scheda-intervento-sections .signature-preview {
    margin-top: 4px;
}

/* Registro invii: spaziatura interna leggibile */
.scheda-page .card .scheda-invii-block {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.scheda-page .card .scheda-invii-block > .scheda-invii-creazione-flag,
.scheda-page .card .scheda-invii-block > .scheda-empty-inline,
.scheda-page .card .scheda-invii-block > .scheda-mail-no-email {
    margin: 0;
}

.scheda-page .card .scheda-invii-block .scheda-mail-block {
    margin: 0;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
}

.scheda-page .card .scheda-invii-block .scheda-invii-list-block {
    margin: 0;
    padding: 16px 0 0;
    border-top: 1px solid var(--border-light);
}

.scheda-page .card .scheda-invii-block .scheda-subsection-title {
    margin: 0 0 12px;
}

.scheda-page .card .scheda-invii-block .scheda-mail-target {
    margin: 0 0 14px;
}

.scheda-page .card .scheda-invii-block .scheda-mail-form {
    margin: 0;
}

.scheda-page .card .scheda-invii-block .invii-list {
    gap: 12px;
}

.scheda-page .card .scheda-invii-block .invii-item {
    padding: 14px 16px;
}

.scheda-page .card .scheda-invii-block .invii-item-meta {
    margin-top: 8px;
}

.scheda-page .card .scheda-invii-block .scheda-invii-empty {
    margin: 4px 0 0;
}

.scheda-page .card .scheda-gestionale-hint {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
}

.scheda-page .card .scheda-gestione-stack {
    gap: 18px;
    padding: 2px 4px;
}

.scheda-page .card .scheda-note-field textarea {
    min-height: 110px;
}

.scheda-page .card .scheda-fatturato-label {
    margin-bottom: 12px;
}

.scheda-page .card .fatturato-stato-picker {
    gap: 10px;
}

.scheda-fatturazione-list .scheda-dettaglio-row dt {
    min-width: 11rem;
}

.fatturare-flag-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.3;
}

.fatturare-flag-badge--si,
.scheda-dettaglio-row--fatturare .fatturare-flag-badge--si,
.scheda-intervento-sections .fatturare-flag-badge--si {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.fatturare-flag-badge--no,
.scheda-dettaglio-row--fatturare .fatturare-flag-badge--no,
.scheda-intervento-sections .fatturare-flag-badge--no {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.scheda-detail-block--completato .scheda-dettaglio-row dd {
    font-weight: 700;
    color: var(--text-primary);
}

.fatturare-flag-badge--unset {
    background: #fef3c7;
    color: #92400e;
}

.scheda-dettaglio-row--fatturare {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    grid-column: 1 / -1;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
}

.scheda-dettaglio-list--stack {
    grid-template-columns: 1fr;
}

.scheda-detail-block .scheda-dettaglio-list {
    grid-template-columns: 1fr;
}

@media (min-width: 720px) {
    .scheda-detail-block .scheda-dettaglio-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scheda-detail-block--tight .scheda-dettaglio-list,
    .scheda-detail-block--tight .scheda-dettaglio-list--stack {
        grid-template-columns: 1fr;
    }
}

.scheda-dettaglio-row--fatturare dt {
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.scheda-dettaglio-row--fatturare dd {
    margin: 0;
    flex-shrink: 0;
}

.scheda-subsection-title {
    margin: 0 0 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.scheda-invii-list-block {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.scheda-invii-block .scheda-mail-block {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.scheda-alert {
    margin: 0;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.scheda-alert-firma {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fdba74;
}

.scheda-alert-mail {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

.scheda-fai-firmare-wrap {
    margin-top: 16px;
}

.firma-necessaria-btn {
    flex: 1;
    min-height: 40px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
}

.firma-necessaria-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.firma-necessaria-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.sign-overlay {
    position: fixed;
    inset: 0;
    z-index: 10070;
    background: var(--bg-page, #f3f4f6);
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.sign-overlay-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 12px;
    gap: 12px;
}

.sign-overlay-print {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.scheda-stampa-header h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.scheda-stampa-codice {
    margin: 0 0 12px;
    font-size: 0.9rem;
}

.scheda-stampa-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    margin: 0;
}

.scheda-stampa-list div {
    margin: 0;
}

.scheda-stampa-list dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.scheda-stampa-list dd {
    margin: 2px 0 0;
    font-size: 0.9rem;
}

.scheda-stampa-list .full {
    grid-column: 1 / -1;
}

.scheda-stampa-firma-label {
    margin: 12px 0 0;
    font-weight: 700;
    font-size: 0.85rem;
}

.sign-overlay-firma {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.sign-signature-wrap {
    flex: 1;
    min-height: 200px;
    display: flex;
}

.sign-signature-wrap .signature-canvas {
    flex: 1;
    width: 100% !important;
    min-height: 200px;
    height: auto !important;
}

body.sign-overlay-open {
    overflow: hidden;
}

.hidden {
    display: none !important;
}

@media (orientation: landscape) and (max-height: 500px) {
    .sign-overlay-inner {
        flex-direction: row;
        padding: 8px;
    }

    .sign-overlay-print {
        flex: 0 0 42%;
        max-height: calc(100vh - 16px);
        overflow: auto;
        font-size: 0.85rem;
    }

    .sign-overlay-firma {
        flex: 1;
        min-height: 0;
    }

    .sign-signature-wrap {
        min-height: calc(100vh - 80px);
    }

    .sign-signature-wrap .signature-canvas {
        min-height: calc(100vh - 100px);
    }
}

.badge-fatturato {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

.badge-non-fatturato {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-color: #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.hint-error {
    color: var(--danger);
}

.input-invalid {
    border-color: var(--danger);
}

.empty {
    color: var(--text-muted);
    padding: 32px 0;
    text-align: center;
    background: var(--bg-muted);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.link:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

button.link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
}

.link-danger {
    color: var(--danger);
}

.link-danger:hover {
    color: #b91c1c;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

td.cell-actions,
th.cell-actions {
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}

td.cell-actions .link-arrow {
    justify-content: flex-end;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
}

.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.link-arrow .arrow {
    font-size: 1.1em;
    line-height: 1;
}

.card-topbar {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 6px 0;
}

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

/* ── Toast (banner centrale) ── */
.toast-container {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: none;
}

.toast-container.is-active {
    display: flex;
    pointer-events: auto;
}

.toast-shield {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: rgba(15, 23, 42, 0.4);
    cursor: default;
}

body.toast-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.toast {
    position: relative;
    z-index: 1;
    min-width: 280px;
    max-width: min(420px, calc(100vw - 48px));
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(10px) scale(0.97);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
}

.toast-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.toast-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.toast-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ── Modale ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
    pointer-events: none;
    visibility: hidden;
}

.modal-backdrop.is-open {
    display: flex;
    pointer-events: auto;
    visibility: visible;
}

.modal-backdrop[hidden] {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.modal-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 24px;
    width: min(520px, 96vw);
    max-height: 92vh;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.modal-panel.modal-lg {
    width: min(720px, 96vw);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.modal-close {
    border: 1px solid var(--border);
    background: var(--bg-muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.modal-close:hover {
    background: #e5e7eb;
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-surface);
}

.modal-body:has(.modal-form) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    max-height: calc(92vh - 120px);
}

.modal-form-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    margin-right: -4px;
}

.modal-form-closing {
    flex-shrink: 0;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface);
}

.modal-form-closing[hidden] {
    display: none !important;
}

.actions-finish {
    margin-top: 16px;
    padding-top: 4px;
}

.actions-finish:empty {
    display: none;
}

.actions-finish .btn {
    width: 100%;
}

.firma-choice-hint {
    display: block;
    margin: -6px 0 12px;
}

.firma-choice-hint[hidden] {
    display: none !important;
}

.modal-form-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 0;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface);
}

.modal-form-footer[hidden] {
    display: none !important;
}

.modal-form-footer .actions-left,
.modal-form-footer .actions-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-form-footer .actions-right {
    margin-left: auto;
}

body.modal-open {
    overflow: hidden;
    overscroll-behavior: none;
}

html.modal-open {
    overflow: hidden;
    overscroll-behavior: none;
    height: 100%;
}

.modal-backdrop.is-open input,
.modal-backdrop.is-open textarea,
.modal-backdrop.is-open select {
    font-size: 16px;
}

html.modal-open .mobile-topbar,
body.modal-open .mobile-topbar {
    visibility: hidden;
    pointer-events: none;
}

html.modal-open .mobile-nav-backdrop,
html.modal-open .mobile-nav-drawer,
body.modal-open .mobile-nav-backdrop,
body.modal-open .mobile-nav-drawer {
    visibility: hidden;
    pointer-events: none;
}

.modal-backdrop.is-open {
    overscroll-behavior: none;
}

.modal-panel {
    overflow: hidden;
}

.modal-form-scroll {
    overscroll-behavior: contain;
}

.modal-form-bozza {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.bozza-wizard {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.bozza-wizard-head {
    flex-shrink: 0;
    padding-bottom: 12px;
    margin-bottom: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    z-index: 2;
}

.bozza-wizard-head[hidden] {
    display: none !important;
}

.bozza-wizard-progress {
    margin: 0 0 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.bozza-wizard-head .bozza-step-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.bozza-wizard-steps {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0;
}

.bozza-wizard-step {
    padding: 12px 0 8px;
    min-height: 0;
}

.bozza-wizard-step-active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.bozza-wizard-step--fill.bozza-wizard-step-active {
    overflow: hidden;
}

.bozza-step-body {
    flex: 1;
    min-height: 0;
}

.bozza-wizard-step--fill .bozza-step-body {
    display: flex;
    flex-direction: column;
}

.bozza-descrizione-group {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin: 0;
}

.bozza-field-no-label .ore-mode-block > label:first-child {
    display: none;
}

.modal-backdrop.modal-bozza-active .modal-body {
    overflow: hidden !important;
    overscroll-behavior: none;
}

.modal-backdrop.modal-bozza-active .modal-form-bozza {
    overflow: hidden;
}

.modal-backdrop.modal-bozza-active .modal-panel {
    overscroll-behavior: none;
}

.bozza-delete-slot {
    display: flex;
    flex: 1;
    min-width: 0;
    width: 100%;
}

.bozza-delete-slot[hidden] {
    display: none;
}

.btn-bozza-step-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

.modal-bozza-wizard-footer.is-preparing {
    visibility: hidden;
}

.modal-bozza-wizard-footer .btn {
    min-height: 44px;
}

.bozza-descrizione-input {
    flex: 1;
    min-height: 160px;
    width: 100%;
    height: auto;
    resize: none;
    font-size: 18px;
    line-height: 1.45;
}

.bozza-firma-canvas-hint {
    margin: 0 0 10px;
    font-size: 0.92rem;
    color: var(--text-secondary);
    text-align: center;
}

.bozza-step-grid {
    margin-top: 0;
}

.bozza-riepilogo {
    margin: 0 0 20px;
}

.bozza-firma-section {
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.bozza-firma-callout {
    margin: 0 0 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.bozza-firma-captured-label {
    margin: 0 0 10px;
    font-weight: 700;
    color: var(--success);
}

.bozza-firma-captured-list {
    margin: 0 0 12px;
    display: grid;
    gap: 8px;
}

.bozza-firma-captured-list dt {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.bozza-firma-captured-list dd {
    margin: 2px 0 0;
}

.bozza-firma-preview {
    margin-bottom: 12px;
}

.modal-form-footer.modal-bozza-wizard-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    gap: 10px;
    justify-content: initial;
}

.modal-form-footer.modal-bozza-wizard-footer .actions-left,
.modal-form-footer.modal-bozza-wizard-footer .actions-right {
    display: flex;
    align-items: stretch;
    gap: 10px;
    min-width: 0;
    width: 100%;
    margin-left: 0;
    justify-content: stretch;
}

.modal-form-footer.modal-bozza-wizard-footer .actions-left .btn-bozza-step-action,
.modal-form-footer.modal-bozza-wizard-footer .actions-right .btn-bozza-step-action,
.modal-form-footer.modal-bozza-wizard-footer .bozza-delete-slot {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
}

.modal-form-footer.modal-bozza-wizard-footer .bozza-delete-slot {
    display: flex;
}

.modal-form-footer.modal-bozza-wizard-footer .bozza-delete-slot .btn {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
}

.bozza-firma-canvas-step {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0;
}

.bozza-firma-canvas-body {
    flex: 1;
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

.bozza-signature-wrap {
    flex: 1;
    min-height: 240px;
    display: flex;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: #fff;
}

.bozza-signature-wrap .signature-canvas {
    flex: 1;
    width: 100% !important;
    min-height: 240px;
    height: auto !important;
    touch-action: none;
}

.bozza-firma-canvas-footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: stretch;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
}

.bozza-firma-side-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex: 2 1 0;
    min-width: 0;
}

.bozza-firma-canvas-footer > .btn-success {
    flex: 1.4 1 0;
    min-width: 0;
}

.bozza-firma-canvas-footer .btn {
    min-height: 48px;
    font-size: 0.88rem;
    padding-left: 8px;
    padding-right: 8px;
}

.bozza-firma-side-actions .btn {
    flex: 1 1 0;
    min-width: 0;
}

.modal-panel.modal-bozza-firma-fullscreen {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    padding: 0;
}

.modal-panel.modal-bozza-firma-fullscreen .modal-header,
.modal-panel.modal-bozza-firma-fullscreen .bozza-wizard-progress {
    display: none;
}

.modal-panel.modal-bozza-firma-fullscreen .bozza-firma-canvas-hint {
    display: none;
}

.modal-panel.modal-bozza-firma-fullscreen .modal-body {
    padding: 0;
    overflow: hidden;
}

.modal-panel.modal-bozza-firma-fullscreen .modal-form-bozza {
    height: 100%;
    max-height: none;
}

.modal-panel.modal-bozza-firma-fullscreen .bozza-wizard {
    height: 100%;
}

.modal-panel.modal-bozza-firma-fullscreen .bozza-wizard-steps {
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.modal-backdrop.modal-bozza-firma-mode {
    padding: 0;
    align-items: stretch;
}

.modal-backdrop.modal-bozza-firma-mode .modal-panel {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
}

.modal-backdrop.modal-bozza-firma-mode .bozza-firma-canvas-step {
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.modal-backdrop.modal-bozza-firma-mode .bozza-firma-canvas-body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
}

.modal-backdrop.modal-bozza-firma-mode .bozza-signature-wrap {
    flex: 1;
    min-height: 0;
    border: none;
    border-radius: 0;
}

.modal-backdrop.modal-bozza-firma-mode .bozza-signature-wrap .signature-canvas {
    min-height: 0;
    height: 100% !important;
    border: none;
    border-radius: 0;
}

.modal-backdrop.modal-bozza-firma-mode .bozza-firma-canvas-footer {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    flex-shrink: 0;
    padding: 8px 12px;
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface);
}

.modal-backdrop.modal-bozza-firma-mode .bozza-firma-side-actions {
    display: flex;
    flex: 2 1 0;
    flex-direction: row;
    gap: 8px;
    min-width: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.modal-backdrop.modal-bozza-firma-mode .bozza-firma-side-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 0.85rem;
    writing-mode: horizontal-tb;
    transform: none;
    white-space: nowrap;
}

.modal-backdrop.modal-bozza-firma-mode .bozza-firma-canvas-footer > .btn-success {
    flex: 1.4 1 0;
    min-width: 0;
    width: auto;
    min-height: 44px;
    margin: 0;
    border-top: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
}

@media (orientation: portrait) {
    .modal-backdrop.modal-bozza-firma-mode .bozza-firma-canvas-hint {
        display: block;
        margin: 0;
        padding: 8px 12px;
        font-size: 0.85rem;
        text-align: center;
        background: #fef3c7;
        color: #92400e;
        border-bottom: 1px solid #fcd34d;
    }
}

.sign-overlay-client .sign-overlay-client-form {
    padding: 0 0 12px;
}

.sign-overlay-client-title {
    margin: 0 0 6px;
    font-size: 1.05rem;
}

.sign-overlay-client-hint {
    margin: 0 0 12px;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.modal-complete-swipe {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-complete-track {
    display: flex;
    width: 200%;
    height: 100%;
    transition: transform 0.28s ease;
}

.modal-complete-track.is-firma-step {
    transform: translateX(-50%);
}

.modal-complete-pane {
    width: 50%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal-complete-pane[hidden] {
    display: none !important;
}

.modal-complete-track.is-firma-step .modal-complete-pane[data-complete-pane="firma"] {
    display: flex !important;
}

.modal-complete-firma-inner,
.scheda-complete-firma-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 0 12px;
}

.modal-complete-firma-title,
.scheda-complete-firma-title {
    margin: 12px 0 8px;
    font-size: 1.05rem;
}

.modal-complete-firma-hint,
.scheda-complete-firma-hint {
    margin: 0 0 16px;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.modal-complete-firma-status,
.scheda-complete-firma-status {
    margin: 0 0 12px;
    color: var(--success);
    font-weight: 600;
}

.modal-complete-back,
.scheda-complete-back {
    align-self: flex-start;
}

.scheda-complete-firma-panel {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-muted);
}

.scheda-complete-firma-panel[hidden] {
    display: none !important;
}

.scheda-completa-wrap {
    margin-top: 16px;
}

.scheda-completa-wrap .btn {
    width: 100%;
}

.modal-bozza-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
}

.modal-bozza-actions .btn {
    width: 100%;
}

.modal-form-footer .actions-right.modal-bozza-actions {
    margin-left: auto;
}

/* ── Ore lavorate ── */
.ore-mode-block {
    padding: 16px;
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.ore-mode-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.ore-mode-btn {
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 9px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    touch-action: manipulation;
    min-height: 44px;
}

.ore-mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.ore-mode-btn:hover:not(.active) {
    background: #e5e7eb;
}

.ore-grid {
    margin-top: 0;
}

.ore-time-grid {
    align-items: start;
}

.ore-duration-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 16px;
    letter-spacing: 0.04em;
    text-align: center;
    width: 100%;
    max-width: 140px;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-user-select: text;
    user-select: text;
}

.ore-hm-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 280px;
    gap: 12px;
}

.ore-hm-input {
    font-variant-numeric: tabular-nums;
    font-size: 16px;
    text-align: center;
    min-height: 48px;
    touch-action: manipulation;
}

#modal_ore_totali_calc,
[id$="ore_totali_calc"] {
    font-variant-numeric: tabular-nums;
    text-align: center;
    max-width: 120px;
}

.time-field-wrap {
    position: relative;
}

.time-field-input-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.time-text-input {
    flex: 1;
    min-width: 0;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.time-text-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.time-text-input:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.time-picker-open-btn {
    flex-shrink: 0;
    min-height: 42px;
    white-space: nowrap;
}

.time-field-wrap.is-mode-disabled .time-text-input,
.time-field-wrap.is-mode-disabled .time-picker-open-btn {
    cursor: not-allowed;
    opacity: 0.55;
}

.time-field-wrap.has-error .time-text-input {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.time-trigger,
.date-trigger {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.time-trigger:hover:not(:disabled),
.date-trigger:hover:not(:disabled) {
    border-color: var(--primary);
}

.time-trigger:focus,
.date-trigger:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.time-trigger:disabled,
.date-trigger:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.time-trigger-text,
.date-trigger-text {
    display: block;
}

.time-trigger-text.is-placeholder,
.date-trigger-text.is-placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

.date-field-wrap {
    position: relative;
}

.date-field-wrap .date-trigger {
    position: relative;
    z-index: 1;
    width: 100%;
    pointer-events: none;
}

.date-field-wrap .date-trigger-text {
    pointer-events: none;
}

.date-field-wrap .date-field-native {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
    border: 0;
    background: transparent;
    font-size: 16px;
}

.bozza-data-intervento-input {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.date-field-wrap .date-clear-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    z-index: 3;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.date-field-wrap .date-clear-btn:hover {
    background: #e5e7eb;
    color: var(--text-primary);
}

.date-field-wrap[data-date-clearable] .date-trigger {
    padding-right: 36px;
}

.date-field-wrap[data-date-clearable] .date-field-native {
    right: 36px;
}

.time-field-wrap.is-disabled .time-trigger,
.time-field-wrap.is-mode-disabled .time-trigger {
    cursor: not-allowed;
    opacity: 0.55;
}

.time-field-wrap.has-error .time-trigger {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.time-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: auto;
}

.app-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: auto;
}

.app-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    border: none;
    padding: 0;
    cursor: default;
}

.app-confirm-sheet {
    position: relative;
    z-index: 1;
    width: min(360px, calc(100vw - 32px));
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 20px 18px 16px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
}

.app-confirm-title {
    margin: 0 0 10px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.app-confirm-message {
    margin: 0 0 16px;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.app-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.app-confirm-actions .btn {
    min-height: 40px;
    padding: 8px 16px;
}

body.confirm-open {
    overflow: hidden;
}

.time-picker-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    border: none;
    padding: 0;
    cursor: default;
}

.time-picker-sheet {
    position: relative;
    z-index: 1;
    width: min(200px, calc(100vw - 32px));
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 14px 12px 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
}

.time-picker-title {
    margin: 0 0 10px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.time-picker-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.time-picker-actions .btn {
    flex: 1;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 0.88rem;
}

.time-wheel-frame-compact {
    height: 156px;
}

.time-wheel-wrap {
    position: relative;
}

.time-wheel {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.time-wheel-frame {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 220px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    overflow: hidden;
}

.time-wheel-frame::before,
.time-wheel-frame::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: calc(50% - 18px);
    z-index: 2;
    pointer-events: none;
}

.time-wheel-frame::before {
    top: 0;
    background: linear-gradient(to bottom, var(--bg-surface), rgba(255, 255, 255, 0));
}

.time-wheel-frame::after {
    bottom: 0;
    background: linear-gradient(to top, var(--bg-surface), rgba(255, 255, 255, 0));
}

.time-wheel-highlight {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    height: 36px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
    pointer-events: none;
    z-index: 1;
}

.time-wheel-list {
    position: relative;
    z-index: 0;
    height: 100%;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scroll-padding-block: calc(50% - 18px);
    -webkit-overflow-scrolling: touch;
    list-style: none;
    margin: 0;
    padding: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.time-wheel-list::-webkit-scrollbar {
    display: none;
}

.time-wheel-option {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: color 0.12s ease, font-size 0.12s ease, opacity 0.12s ease;
    opacity: 0.45;
}

.time-wheel-option.is-selected {
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 700;
    opacity: 1;
}

.time-wheel-spacer {
    flex-shrink: 0;
    pointer-events: none;
}

.time-wheel-clear {
    align-self: center;
}

.time-field-wrap.has-error .time-trigger,
.time-wheel-wrap.has-error .time-wheel-frame {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.ore-panel[hidden] {
    display: none !important;
}

.field-clear-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-clear-wrap input {
    flex: 1;
    min-width: 0;
}

.field-clear-btn {
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
}

.field-clear-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.inline-form-wrap {
    margin-top: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}

@media (max-width: 1100px) and (min-width: 769px) {
    .filters-toolbar-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    /* Mobile bozza: evita blocchi scroll quando la tastiera cambia viewport. */
    .modal-backdrop.modal-bozza-active.is-open {
        touch-action: pan-y;
    }

    .modal-backdrop.modal-bozza-active.is-open .modal-panel {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .modal-backdrop.modal-bozza-active.is-open.modal-keyboard-open .modal-body {
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }

    .modal-backdrop.modal-bozza-active.is-open .bozza-wizard-step-active {
        touch-action: pan-y;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        overflow-y: auto !important;
    }

    .modal-backdrop.modal-bozza-active.is-open input,
    .modal-backdrop.modal-bozza-active.is-open textarea,
    .modal-backdrop.modal-bozza-active.is-open select {
        touch-action: manipulation;
    }

    .ore-mode-toggle {
        flex-direction: column;
    }

    .ore-mode-btn {
        width: 100%;
    }

    .ore-duration-input {
        max-width: none;
    }

    .modal-bozza-wizard-footer {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .modal-bozza-wizard-footer .actions-left,
    .modal-bozza-wizard-footer .actions-right {
        width: 100%;
    }

    .modal-bozza-wizard-footer .actions-left .btn,
    .modal-bozza-wizard-footer .actions-right .btn,
    .modal-bozza-wizard-footer .bozza-delete-slot .btn {
        min-height: 48px;
        font-size: 1rem;
    }

    .modal-panel.modal-bozza-firma-fullscreen .bozza-wizard-steps {
        padding: 0;
    }

    .bozza-firma-canvas-footer {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    :root {
        --app-mobile-header-height: clamp(34px, 5.8vh, 42px);
        --scheda-mobile-chrome-top: calc(var(--app-mobile-header-height) + env(safe-area-inset-top, 0px));
        --scheda-head-top: 0;
    }

    .app {
        flex-direction: column;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    .sidebar {
        display: none;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: clamp(2px, 0.9vw, 6px);
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        flex-shrink: 0;
        width: 100%;
        z-index: 300;
        min-height: var(--app-mobile-header-height);
        padding: 1px clamp(2px, 1vw, 6px);
        padding-top: calc(1px + env(safe-area-inset-top, 0px));
        background: var(--bg-sidebar);
        color: var(--text-inverse);
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.15);
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: clamp(32px, 7.6vw, 38px);
        height: clamp(32px, 7.6vw, 38px);
        margin: 0;
        padding: 0;
        border: none;
        border-radius: var(--radius);
        background: transparent;
        color: inherit;
        cursor: pointer;
        flex-shrink: 0;
    }

    .mobile-menu-toggle:hover {
        background: var(--bg-sidebar-hover);
    }

    .mobile-menu-bars {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 22px;
    }

    .mobile-menu-bars span {
        display: block;
        height: 2px;
        background: currentColor;
        border-radius: 1px;
    }

    .mobile-topbar-title {
        margin: 0;
        font-size: 1rem;
        font-weight: 700;
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-topbar--has-back {
        gap: 6px;
    }

    .mobile-topbar-back {
        flex: 1 1 auto;
        min-width: 0;
        display: inline-flex;
        align-items: center;
        align-self: stretch;
        min-height: clamp(30px, 5vh, 34px);
        color: var(--text-inverse);
        text-decoration: none;
        font-weight: 700;
        font-size: clamp(0.66rem, 2.35vw, 0.82rem);
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: clamp(2px, 0.6vw, 4px) clamp(3px, 1vw, 6px);
        margin: 0 -4px;
        border-radius: var(--radius);
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-topbar-back::before {
        content: '←\00a0';
        flex-shrink: 0;
        font-size: 0.9rem;
        font-weight: 800;
    }

    .mobile-topbar-back:hover,
    .mobile-topbar-back:active {
        color: #fff;
        background: var(--bg-sidebar-hover);
        text-decoration: none;
    }

    .mobile-topbar--has-back .mobile-topbar-title {
        display: none;
    }

    .mobile-topbar-actions {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: clamp(2px, 0.8vw, 4px);
        margin-left: auto;
        min-width: 0;
    }

    .mobile-topbar--has-actions.mobile-topbar--has-back .mobile-topbar-back {
        flex: 1;
        min-width: 0;
    }

    .mobile-topbar .scheda-close {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        border-color: rgba(255, 255, 255, 0.7);
        background: transparent;
        color: #fff;
        font-size: 1.5rem;
    }

    .mobile-topbar .scheda-close:hover {
        background: var(--bg-sidebar-hover);
        color: #fff;
    }

    .mobile-topbar-btn {
        min-height: clamp(30px, 5vh, 34px);
        min-width: clamp(30px, 7vw, 34px);
        padding: clamp(2px, 0.8vw, 5px) clamp(5px, 1.4vw, 8px);
        font-size: clamp(0.62rem, 2.1vw, 0.76rem);
        font-weight: 700;
        white-space: nowrap;
        -webkit-tap-highlight-color: transparent;
        line-height: 1.05;
        border: 1px solid rgba(255, 255, 255, 0.88);
    }

    .mobile-topbar-back {
        border: 1px solid rgba(255, 255, 255, 0.55);
    }

    .mobile-topbar-actions .btn {
        border: 1px solid rgba(255, 255, 255, 0.88);
    }

    .mobile-topbar-btn--compact {
        padding: clamp(2px, 0.8vw, 5px) clamp(4px, 1.1vw, 7px);
    }

    body.has-mobile-back .scheda-sticky-head .scheda-toolbar-desktop {
        display: none !important;
    }

    body.has-mobile-back .scheda-page[data-cliente-scheda] .scheda-sticky-head,
    body.has-mobile-back .scheda-page[data-utente-scheda] .scheda-sticky-head {
        display: none !important;
    }

    body.has-mobile-back .scheda-page[data-cliente-scheda],
    body.has-mobile-back .scheda-page[data-utente-scheda] {
        padding-top: 0 !important;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] {
        padding-top: var(--scheda-sticky-height);
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head {
        padding: 0 0 2px;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head .scheda-tabs {
        margin: 0;
        padding: clamp(2px, 0.8vw, 4px);
        gap: clamp(2px, 0.7vw, 4px);
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head .scheda-tab-btn {
        padding: clamp(5px, 1.6vw, 7px) clamp(3px, 1vw, 5px);
        font-size: clamp(0.64rem, 2.3vw, 0.72rem);
        line-height: 1.15;
    }

    body.has-mobile-back .mobile-topbar--has-actions .mobile-topbar-actions {
        max-width: 66%;
    }

    body.has-mobile-back .mobile-topbar-btn--danger {
        margin-left: auto;
    }

    /* Override finale mobile schede: nessun margine laterale */
    body.has-mobile-back .mobile-topbar {
        min-height: 30px !important;
        padding-top: env(safe-area-inset-top, 0px) !important;
        padding-bottom: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    body.has-mobile-back .mobile-topbar--has-back .mobile-menu-toggle {
        display: none !important;
    }

    body.has-mobile-back .mobile-topbar--has-back {
        gap: 0 !important;
    }

    body.has-mobile-back .mobile-topbar-back {
        min-height: 28px !important;
        font-size: 0.68rem !important;
        padding: 2px 4px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    body.has-mobile-back .mobile-topbar-actions {
        flex: 0 0 auto !important;
        max-width: none !important;
        gap: 2px !important;
        padding-right: 2px;
    }

    body.has-mobile-back .mobile-topbar-btn {
        min-height: 28px !important;
        min-width: 28px !important;
        font-size: 0.62rem !important;
        padding: 2px 5px !important;
        line-height: 1 !important;
    }

    body.has-mobile-back .scheda-page {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    body.has-mobile-back .scheda-page > .card {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0 !important;
    }

    body.has-mobile-back .scheda-page .scheda-sticky-head,
    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    body.has-mobile-back .scheda-page .scheda-sticky-head .scheda-tabs {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0 !important;
    }

    body.has-mobile-back .scheda-page > .card {
        margin-left: 0;
        margin-right: 0;
        border-radius: 0;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .card.rapporto-scheda {
        border-left: none;
        border-right: none;
    }

    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 280;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .mobile-nav-backdrop.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .mobile-nav-drawer {
        display: block;
        position: fixed;
        top: var(--scheda-mobile-chrome-top);
        left: 0;
        bottom: 0;
        z-index: 290;
        width: min(280px, 85vw);
        padding: 16px 14px;
        background: var(--bg-sidebar);
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.2);
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

    .mobile-nav-drawer.is-open {
        transform: translateX(0);
    }

    .content {
        --content-pad-x: 14px;
        padding: 14px var(--content-pad-x) 20px;
    }

    main.content:has(.scheda-page),
    main.content:has(.list-page) {
        padding-top: 0;
        padding-left: var(--content-pad-x);
        padding-right: var(--content-pad-x);
        padding-bottom: 20px;
    }

    .page-toolbar {
        padding: 10px 12px;
        margin-bottom: 10px;
    }

    .list-page {
        --list-head-top: 0;
    }

    .list-page-head {
        top: 0;
        margin: 0 calc(-1 * var(--content-pad-x)) 8px;
        padding: 14px var(--content-pad-x) 10px;
        background: #ffffff;
        background-color: #ffffff;
    }

    .list-page-title {
        display: none;
    }

    .list-page-head--simple .list-page-title {
        display: block;
    }

    .list-page-title-row {
        justify-content: flex-end;
    }

    .list-page-filter-status {
        margin-top: 0;
        font-size: 0.82rem;
    }

    .scheda-page {
        padding-top: var(--scheda-sticky-height);
        margin: 0 0 16px;
    }

    .scheda-page > .card {
        margin-left: 0;
        margin-right: 0;
    }

    body.has-mobile-back .scheda-page .scheda-sticky-head {
        padding: 0 var(--content-pad-x) 4px;
    }

    .scheda-page .scheda-sticky-head {
        position: sticky;
        top: 0;
        z-index: 295;
        margin: 0 calc(-1 * var(--content-pad-x)) 8px;
        padding: 0 var(--content-pad-x) 8px;
        background: #ffffff;
        background-color: #ffffff;
        border-bottom: 1px solid var(--border-light);
        box-shadow: none;
    }

    /* Mobile scheda: una sola barra fissa con back + tabs insieme. */
    .scheda-page .scheda-sticky-head {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .scheda-page .scheda-sticky-head .back-link {
        display: inline-flex;
    }

    .scheda-page .scheda-sticky-head .page-toolbar {
        padding: 10px var(--content-pad-x);
        margin: 0 calc(-1 * var(--content-pad-x));
        border-radius: 0;
        border: 1px solid var(--border-light);
        border-left: 0;
        border-right: 0;
        border-bottom: none;
        box-shadow: none;
    }

    .scheda-page .scheda-sticky-head:not(:has(.scheda-tabs)) .page-toolbar {
        margin-bottom: 0;
    }

    .scheda-page .scheda-sticky-head .scheda-tabs {
        margin: 0;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 4px 5px;
        gap: 4px;
    }

    body.has-mobile-back .scheda-page .scheda-sticky-head .scheda-tab-btn {
        padding: clamp(5px, 1.6vw, 8px) clamp(3px, 1vw, 5px);
        font-size: clamp(0.64rem, 2.3vw, 0.72rem);
    }

    .scheda-page .scheda-sticky-head .scheda-tabs::-webkit-scrollbar {
        display: none;
    }

    .scheda-page[data-rapporto-scheda] .scheda-sticky-head,
    .scheda-page[data-cliente-scheda] .scheda-sticky-head,
    .scheda-page[data-utente-scheda] .scheda-sticky-head {
        position: sticky !important;
        top: 0 !important;
        z-index: 295 !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
    }

    .scheda-page[data-rapporto-scheda] .scheda-sticky-head .page-toolbar,
    .scheda-page[data-rapporto-scheda] .scheda-sticky-head .scheda-tabs,
    .scheda-page[data-cliente-scheda] .scheda-sticky-head .page-toolbar,
    .scheda-page[data-utente-scheda] .scheda-sticky-head .page-toolbar {
        display: flex !important;
    }

    .scheda-page[data-rapporto-scheda],
    .scheda-page[data-cliente-scheda],
    .scheda-page[data-utente-scheda] {
        padding-top: 0;
    }

    body.mobile-nav-open .scheda-page .scheda-sticky-head {
        z-index: 240 !important;
    }

    .app-nav-mobile {
        display: none !important;
    }

    .card {
        padding: 16px;
    }

    .card.card-list,
    .card-list {
        overflow: visible;
    }

    .filters-toolbar-grid {
        grid-template-columns: 1fr;
    }

    .date-range-popover-fields {
        grid-template-columns: 1fr;
    }

    .filters-toolbar-inline {
        flex-wrap: wrap;
    }

    .time-picker-actions .btn {
        flex: 1;
        min-width: 0;
    }

    .filter-picker {
        flex-wrap: wrap;
    }

    .filter-chip-label {
        max-width: 100%;
    }

    .card .actions {
        flex-direction: column;
    }

    .card .actions .btn {
        width: 100%;
    }

    .modal-backdrop.is-open {
        padding: 0;
        align-items: stretch;
    }

    .modal-panel {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        padding: max(12px, env(safe-area-inset-top, 0px)) 14px 0;
        overflow: hidden;
    }

    .modal-header {
        margin-bottom: 12px;
        padding-bottom: 10px;
        flex-shrink: 0;
    }

    .modal-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .modal-body:has(.modal-form) {
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .modal-form {
        max-height: none;
        flex: 1;
        min-height: 0;
    }

    .modal-form-footer {
        position: relative;
        bottom: auto;
        z-index: 1;
        flex-shrink: 0;
        flex-direction: column;
        align-items: stretch;
        margin-top: auto;
        padding-top: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-surface);
        box-shadow: none;
        border-top: 1px solid var(--border-light);
    }

    .bozza-wizard-steps {
        padding-bottom: 16px;
    }

    .modal-form-closing {
        padding-bottom: 8px;
    }

    .actions-finish .btn {
        min-height: 48px;
        font-size: 1rem;
    }

    .modal-form-footer .actions-left {
        order: 1;
        width: 100%;
        flex-direction: column;
    }

    .modal-form-footer .actions-center {
        order: 2;
        width: 100%;
        flex-direction: column;
    }

    .modal-form-footer .actions-right {
        order: 3;
        width: 100%;
        margin-left: 0;
        flex-direction: column;
    }

    .modal-form-footer .btn {
        width: 100%;
        flex: none;
        min-width: 0;
    }

    .list-table {
        display: block;
        width: 100%;
        overflow: visible;
    }

    .list-table thead {
        display: none;
    }

    .list-table tbody {
        display: block;
    }

    .list-table tr.list-row-clickable {
        display: block;
        margin-bottom: 10px;
        padding: 12px 14px;
        border: 1px solid var(--border-light);
        border-radius: var(--radius);
        background: var(--bg-surface);
    }

    .list-table tr.list-group-header {
        display: block;
        margin: 18px 0 8px;
        padding: 0;
        border: none;
        background: transparent;
    }

    .list-table tr.list-group-header:first-child {
        margin-top: 0;
    }

    .list-table tr.list-group-header th {
        display: block;
        padding: 0 0 8px;
        border: none;
        background: transparent;
        font-size: 0.95rem;
    }

    .list-table tr.list-group-header:hover {
        background: transparent;
    }

    .list-table tr.list-row-clickable:hover {
        background: #f9fafb;
    }

    .list-table tr.list-row-clickable:active,
    .list-table tr.list-row-clickable.is-row-activating {
        background: rgba(37, 99, 235, 0.14) !important;
        border-color: rgba(37, 99, 235, 0.45);
        box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
    }

    .list-table td {
        display: block;
        border: none;
        padding: 0;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .list-table tbody tr.list-row-data {
        display: block;
        position: relative;
        margin-bottom: 10px;
        padding: 12px 14px 12px 42px;
        border: 1px solid var(--border-light);
        border-radius: var(--radius);
        background: var(--bg-surface);
    }

    .list-table .list-cell-check {
        position: absolute;
        left: 12px;
        top: 14px;
        width: auto;
        padding: 0;
    }

    .list-table .list-cell-primary {
        margin-bottom: 6px;
        font-size: 1rem;
    }

    .list-table-rapporti tbody tr.list-row-data {
        padding: 10px 14px;
    }

    .list-table-rapporti tbody tr.list-row-stato-completato,
    .list-table-rapporti tbody tr.list-row-stato-completato:hover {
        background: #d1fae5;
        border-color: #6ee7b7;
    }

    .list-table-rapporti tbody tr.list-row-stato-bozza,
    .list-table-rapporti tbody tr.list-row-stato-bozza:hover {
        background: #fef3c7;
        border-color: #fcd34d;
    }

    .list-table-rapporti tbody tr.list-row-stato-completato:hover {
        background: #bbf7d0;
    }

    .list-table-rapporti tbody tr.list-row-stato-bozza:hover {
        background: #fde68a;
    }

    .list-table-rapporti .list-cell-primary,
    .list-table-rapporti .list-cell-anagrafica {
        white-space: nowrap;
        overflow: hidden;
        word-break: normal;
        overflow-wrap: normal;
    }

    .list-table-rapporti .list-cell-anagrafica {
        display: block;
        margin-bottom: 0;
        font-size: 0.9rem;
        color: var(--text-primary);
    }

    .list-table .list-cell-meta {
        display: inline-block;
        margin-right: 12px;
        font-size: 0.875rem;
        color: var(--text-secondary);
        vertical-align: middle;
    }

    .list-table .list-cell-meta:last-child {
        margin-right: 0;
    }

    .list-table-anagrafica .list-cell-meta + .list-cell-meta::before {
        content: '·';
        margin-right: 12px;
        color: var(--text-muted);
    }

    .anag-picker-current {
        gap: 8px;
    }

    .anag-picker .list-table tr.list-row-clickable.is-selected {
        border-color: var(--primary);
        background: rgba(37, 99, 235, 0.08);
    }

    .list-table-utenti tbody tr.utente-row {
        display: block;
        margin: 0 0 12px;
        padding: 12px 14px;
        border: 1px solid var(--border-light);
        border-radius: var(--radius);
        background: var(--bg-surface);
    }

    .list-table-utenti tbody tr.utente-row:last-child {
        margin-bottom: 0;
    }

    .list-table-utenti .list-cell-primary {
        display: block;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border-light);
        font-size: 1rem;
        font-weight: 700;
    }

    .list-table-utenti .list-cell-meta {
        display: block;
        width: 100%;
        margin: 0 0 6px;
        font-size: 0.9rem;
        color: var(--text-primary);
    }

    .list-table-utenti .list-cell-meta[data-label]::before {
        content: attr(data-label) '\00a0·\00a0';
        color: var(--text-muted);
        font-weight: 600;
    }

    .list-table-utenti .utente-row-actions-cell {
        display: block;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--border-light);
    }

    .list-table-utenti .utente-row-actions {
        justify-content: flex-start;
    }
}

/* ── Firma ── */
[data-firma-block] {
    padding: 16px;
    background: var(--bg-muted);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.firma-mode-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.firma-mode-btn {
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 9px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
}

.firma-mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.firma-mode-btn:hover:not(.active) {
    background: #e5e7eb;
}

.firma-panel[hidden] {
    display: none !important;
}

.signature-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.signature-canvas {
    width: 100%;
    max-width: 100%;
    min-height: 160px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: #fff;
    touch-action: none;
    cursor: crosshair;
    display: block;
}

.signature-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    max-width: 100%;
}

.signature-hint {
    margin: 0;
    flex: 1;
    min-width: 180px;
}

.firma-section-label {
    display: block;
    font-weight: 700;
    margin: 16px 0 10px;
    font-size: 0.95rem;
}

.finalize-modal-footer {
    margin-top: 16px;
    padding-top: 0;
    border-top: none;
    justify-content: flex-end;
}

.finalize-modal [data-firma-block] {
    margin-top: 8px;
}

.rapporto-completato-meta {
    margin: 0 0 14px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.rapporto-riepilogo {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.riepilogo-title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.riepilogo-list {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
}

.riepilogo-row {
    margin: 0;
    min-width: 0;
}

.riepilogo-row-full {
    grid-column: 1 / -1;
}

.riepilogo-row dt {
    margin: 0 0 2px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.riepilogo-row dd {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    word-break: break-word;
}

.riepilogo-firma-preview {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.riepilogo-firmatario {
    margin: 0 0 10px;
}

.rapporto-note-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.rapporto-note-section .actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* ── Scheda dettaglio (cliente / rapporto): toolbar + tab fissi in alto (non scorrono) ── */
.scheda-page {
    --scheda-head-top: 0;
    --scheda-sticky-height: 0;
    padding-top: 0;
    margin-bottom: 20px;
    scroll-padding-top: calc(var(--scheda-head-top) + var(--scheda-sticky-height) + 8px);
}

.scheda-page .scheda-sticky-head {
    position: sticky;
    top: var(--scheda-head-top);
    z-index: 280;
    margin: 0 calc(-1 * var(--content-pad-x, 32px)) 12px;
    padding: 8px var(--content-pad-x, 32px);
    box-sizing: border-box;
    background: #ffffff;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-light);
    box-shadow: none;
}

.scheda-page .scheda-sticky-head .back-link {
    flex-shrink: 0;
}

.scheda-page .scheda-sticky-head .page-toolbar {
    position: relative;
    z-index: 1;
    margin: 0 calc(-1 * var(--content-pad-x, 32px));
    padding-left: var(--content-pad-x, 32px);
    padding-right: var(--content-pad-x, 32px);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    background: #ffffff;
    background-color: #ffffff;
    border-bottom: none;
    box-shadow: none;
}

.scheda-page .scheda-sticky-head .scheda-tabs {
    position: relative;
    z-index: 1;
    margin: 0 calc(-1 * var(--content-pad-x, 32px));
    padding-left: var(--content-pad-x, 32px);
    padding-right: var(--content-pad-x, 32px);
    background: #d7dee8;
    border: 1px solid #b7c2d0;
    border-left: 0;
    border-right: 0;
    border-top: none;
    border-radius: 0;
    box-shadow: none;
}

.scheda-page .scheda-sticky-head:not(:has(.scheda-tabs)) .page-toolbar {
    border-radius: 0;
    border-bottom: 1px solid var(--border-light);
}

.rapporto-scheda {
    padding-top: 0;
}

.scheda-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 12px;
}

.scheda-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.scheda-codice {
    margin: 4px 0 0;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.02em;
}

.scheda-header-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scheda-readonly {
    margin-top: 8px;
}

.scheda-readonly .rapporto-riepilogo {
    margin-bottom: 0;
}

.scheda-mail-optout,
.scheda-invii-creazione-flag {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.45;
}

.scheda-invii-creazione-flag--si {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.scheda-invii-creazione-flag--no {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.scheda-invii-creazione-flag--unset {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.scheda-mail-no-email {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    font-size: 0.95rem;
}

.btn.is-loading {
    pointer-events: none;
    opacity: 0.85;
}

.scheda-mail-form .btn.is-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -2px;
    animation: mail-btn-spin 0.7s linear infinite;
}

@keyframes mail-btn-spin {
    to { transform: rotate(360deg); }
}

.scheda-dettaglio,
.scheda-firma-section,
.scheda-editable-block,
.scheda-mail-block {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border-light);
}

.scheda-dettaglio-list {
    margin: 12px 0 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 20px;
}

.scheda-dettaglio-row {
    margin: 0;
    min-width: 0;
}

.scheda-dettaglio-row-full {
    grid-column: 1 / -1;
}

.scheda-dettaglio-row dt {
    margin: 0 0 4px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.scheda-dettaglio-row dd {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    word-break: break-word;
}

.scheda-firmatario-nome {
    margin: 0 0 10px;
}

.scheda-empty-inline {
    margin: 8px 0 0;
    font-size: 0.9rem;
}

.scheda-mail-target {
    margin: 0 0 12px;
    font-size: 0.95rem;
}

.scheda-mail-warning {
    margin: 0 0 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--danger);
}

.scheda-mail-form {
    margin-bottom: 8px;
}

.scheda-invii-details {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border-light);
}

.scheda-invii-summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    list-style: none;
}

.scheda-invii-summary::-webkit-details-marker {
    display: none;
}

.scheda-invii-summary::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.15s ease;
}

.scheda-invii-details[open] .scheda-invii-summary::before {
    transform: rotate(90deg);
}

.scheda-invii-body {
    margin-top: 14px;
}

.scheda-section-title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.scheda-section-hint {
    margin: 0 0 16px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.scheda-gestionale-hint {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.scheda-gestione-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 640px;
}

.bozza-step-hint {
    margin: 0 0 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.scheda-fatturato-field {
    margin: 0;
}

.scheda-fatturato-label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.fatturato-stato-picker {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fatturato-stato-picker--tre {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.fatturato-stato-avviso {
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.45;
}

.fatturato-stato-avviso--nulla {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.fatturato-stato-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.fatturato-stato-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.fatturato-stato-btn:hover:not(:disabled):not(.active) {
    border-color: var(--primary);
    background: var(--bg-muted);
}

.fatturato-stato-btn.active.fatturato-stato-btn--no {
    border-color: #dc2626;
    background: #fef2f2;
    color: #b91c1c;
    box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.15);
}

.fatturato-stato-btn.active.fatturato-stato-btn--si {
    border-color: #16a34a;
    background: #f0fdf4;
    color: #15803d;
    box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.15);
}

.fatturato-stato-btn.active.fatturato-stato-btn--skip {
    border-color: #64748b;
    background: #f1f5f9;
    color: #334155;
    box-shadow: 0 0 0 1px rgba(100, 116, 139, 0.2);
}

.fattura-riferimento {
    margin-top: 12px;
}

.fattura-riferimento-fields {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 8px;
}

.scheda-cronologia {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.scheda-cronologia-title {
    margin: 0 0 10px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary);
}

.scheda-cronologia-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.scheda-cronologia-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.scheda-cronologia-list li:last-child {
    border-bottom: 0;
}

.scheda-cronologia-meta,
.scheda-cronologia-cambio {
    margin: 0;
    font-size: 0.9rem;
}

.scheda-cronologia-meta {
    color: var(--text-secondary);
}

.scheda-cronologia-cambio {
    margin-top: 4px;
    color: var(--text-primary);
}

.fatturato-stato-btn.is-disabled,
.fatturato-stato-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .fatturato-stato-picker,
    .fatturato-stato-picker--tre,
    .fattura-riferimento-fields {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    body.has-mobile-back .mobile-topbar {
        padding-top: calc(0px + env(safe-area-inset-top, 0px));
    }

    body.has-mobile-back .mobile-topbar-back {
        font-size: 0.62rem;
        min-height: 28px;
    }

    body.has-mobile-back .mobile-topbar-btn {
        min-height: 28px;
        min-width: 28px;
        font-size: 0.58rem;
        padding: 2px 4px;
    }

    body.has-mobile-back .mobile-topbar-btn--compact {
        padding: 2px 3px;
    }

    body.has-mobile-back .scheda-page .scheda-sticky-head .scheda-tab-btn {
        font-size: 0.6rem;
        padding: 4px 3px;
    }
}

@media (max-width: 380px) {
    body.has-mobile-back .mobile-topbar {
        min-height: 26px !important;
    }

    body.has-mobile-back .mobile-topbar-back {
        min-height: 24px !important;
        font-size: 0.6rem !important;
        padding: 1px 3px !important;
    }

    body.has-mobile-back .mobile-topbar-btn {
        min-height: 24px !important;
        min-width: 24px !important;
        font-size: 0.55rem !important;
        padding: 1px 3px !important;
    }

    body.has-mobile-back .mobile-topbar-actions {
        margin-left: auto !important;
        justify-content: flex-end !important;
    }
}

.scheda-gestione-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(160px, 0.6fr);
    gap: 16px 20px;
    align-items: start;
}

.scheda-gestione-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.scheda-gestione-actions:has([data-gestione-save][hidden]) {
    display: none;
}

.fatturato-toggle {
    display: flex;
    gap: 8px;
}

.bozza-mail-choice {
    border: none;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.bozza-mail-choice-question {
    margin: 0 0 12px;
    padding: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.45;
}

.bozza-mail-hint {
    margin: 10px 0 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--danger);
    line-height: 1.4;
}

.choice-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-radio {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-surface);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.choice-radio:hover {
    border-color: var(--border);
    background: var(--bg-muted);
}

.choice-radio:has(input:checked) {
    border-color: var(--bg-sidebar-active);
    background: #eff6ff;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.choice-radio input[type="radio"] {
    margin: 2px 0 0;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--bg-sidebar-active);
    cursor: pointer;
}

.choice-radio-label-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    flex: 1;
    min-width: 0;
}

.choice-radio-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
}

.choice-radio-mail {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.35;
    word-break: break-all;
}

.fatturato-btn {
    flex: 1;
    min-width: 72px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.fatturato-btn.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.fatturato-toggle--stato {
    flex-wrap: wrap;
    gap: 0.35rem;
}

.fatturato-btn--nulla {
    flex: 1 1 100%;
    font-size: 0.9rem;
}

.fatturato-btn.is-disabled,
.fatturato-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.fatturato-btn:hover:not(.active):not(:disabled) {
    background: var(--bg-muted);
}

.scheda-invii-empty {
    margin: 0;
}

.invii-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.invii-item {
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-muted);
}

.invii-item-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}

.invii-email {
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.invii-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.invii-error {
    color: var(--danger);
}

.riepilogo-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.riepilogo-meta-item {
    font-size: 0.9rem;
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .scheda-tabs {
        gap: 4px;
        padding: 5px 6px;
    }

    .scheda-tab-btn {
        font-size: 0.76rem;
        padding: 10px 5px;
        border-radius: 7px;
    }

    .scheda-tab-btn[aria-selected="true"] {
        box-shadow: 0 1px 6px rgba(37, 99, 235, 0.3);
    }

    .scheda-intervento-sections {
        gap: 12px;
    }

    .scheda-intervento-parti-row,
    .scheda-intervento-head-row {
        grid-template-columns: 1fr;
    }

    .scheda-dettaglio-list,
    .scheda-gestione-grid {
        grid-template-columns: 1fr;
    }

    .riepilogo-list {
        grid-template-columns: 1fr;
    }

    .signature-canvas {
        min-height: 200px;
    }
}

.signature-preview {
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    display: inline-block;
    max-width: 100%;
}

.signature-preview img {
    display: block;
    width: auto;
    height: auto;
    max-width: min(100%, 320px);
    max-height: 72px;
    object-fit: contain;
}

.signature-preview.signature-preview--scheda {
    padding: 0;
    border: none;
    background: transparent;
    display: inline-block;
    max-width: 100%;
    vertical-align: top;
}

.scheda-firma-viewport {
    display: inline-block;
    position: relative;
    line-height: 0;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: #fff;
    padding: 2px;
    box-sizing: content-box;
    vertical-align: top;
}

.signature-preview--scheda img {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
}

.signature-preview--scheda img.scheda-firma-img--rotate {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
}

/* Login */
.page-login {
    background: var(--bg-page, #f3f4f6);
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.login-card {
    width: min(100%, 420px);
    padding: 28px 24px;
}

.login-title {
    margin: 0 0 6px;
    font-size: 1.35rem;
}

.login-subtitle {
    margin: 0 0 20px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.login-alert {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.login-alert-error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.login-alert-info,
.login-alert-success {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.login-lock-message {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.92rem;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form .btn-block {
    margin-top: 8px;
}

.login-form [data-lock-too-soon] {
    margin: 12px 0 0;
}

.btn-block {
    width: 100%;
}

.login-extra {
    margin: 14px 0 0;
    text-align: center;
    font-size: 0.9rem;
}

.login-extra + .login-extra {
    margin-top: 8px;
}

.login-extra a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.login-extra a:hover {
    text-decoration: underline;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-nav .nav-btn-logout {
    margin-top: auto;
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.app-nav .nav-btn-logout:hover {
    color: #fff;
    background: #b91c1c;
    border-color: #b91c1c;
}

/* Account */
.page-title {
    margin: 0;
    font-size: 1.2rem;
}

.page-subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.account-card {
    max-width: 480px;
}

.account-form {
    display: flex;
    flex-direction: column;
}

.account-form .form-group {
    gap: 8px;
    margin-bottom: 20px;
}

.account-form .form-group:last-of-type {
    margin-bottom: 24px;
}

.account-form label {
    font-size: 0.92rem;
    line-height: 1.45;
}

.account-label-note {
    font-weight: 500;
    color: var(--text-muted);
}

.account-form .btn-primary {
    align-self: flex-start;
}

@media (max-width: 768px) {
    body.filters-mobile-open {
        overflow: hidden;
    }

    .list-filters-panel.list-filters-panel-mobile-open {
        position: fixed !important;
        top: calc(var(--scheda-mobile-chrome-top, 0px) + 8px);
        left: 10px;
        right: 10px;
        z-index: 380;
        max-height: calc(100dvh - var(--scheda-mobile-chrome-top, 0px) - 18px);
        overflow-y: auto;
        margin: 0;
        padding: 12px;
        background: var(--bg-surface);
        border: 1px solid var(--border-light);
        border-radius: 12px;
        box-shadow: 0 14px 34px rgba(15, 23, 42, 0.24);
    }

    .list-filters-mobile-actions {
        display: flex;
        gap: 8px;
        margin-top: 6px;
        padding-top: 8px;
        border-top: 1px solid var(--border-light);
    }

    .list-filters-mobile-actions .btn {
        flex: 1 1 0;
        min-height: 40px;
    }
}

/* FINAL CLEANUP schede mobile: no doppioni, barra compatta uniforme */
@media (max-width: 768px) {
    /* Usa solo la topbar mobile: nasconde la toolbar interna duplicata */
    body.has-mobile-back .scheda-page .scheda-sticky-head .scheda-toolbar-desktop,
    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head .page-toolbar,
    body.has-mobile-back .scheda-page[data-cliente-scheda] .scheda-sticky-head .page-toolbar,
    body.has-mobile-back .scheda-page[data-utente-scheda] .scheda-sticky-head .page-toolbar {
        display: none !important;
    }

    /* Cliente/utente: nessuna sticky head interna */
    body.has-mobile-back .scheda-page[data-cliente-scheda] .scheda-sticky-head,
    body.has-mobile-back .scheda-page[data-utente-scheda] .scheda-sticky-head {
        display: none !important;
    }

    /* Rapporto: resta solo la riga tab, compatta e full width */
    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head {
        display: block !important;
        position: sticky !important;
        top: 0 !important;
        left: auto !important;
        right: auto !important;
        width: auto !important;
        max-width: none !important;
        margin: 0 calc(-1 * var(--content-pad-x)) 8px !important;
        padding: 0 var(--content-pad-x) !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
        border-bottom: 1px solid var(--border-light) !important;
        box-shadow: none !important;
        z-index: 295 !important;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] {
        padding-top: 0 !important;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head .scheda-tabs {
        display: flex !important;
        margin: 0 !important;
        padding: 2px !important;
        gap: 2px !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
        box-shadow: none !important;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head .scheda-tab-btn {
        min-height: 30px !important;
        padding: 3px 4px !important;
        font-size: 0.66rem !important;
        line-height: 1.05 !important;
        border-radius: 4px !important;
    }

    /* Topbar stessa altezza "liste con filtri non espansi" */
    body.has-mobile-back .mobile-topbar {
        min-height: 36px !important;
    }

    body.has-mobile-back .mobile-topbar-back,
    body.has-mobile-back .mobile-topbar-btn {
        min-height: 30px !important;
        font-size: 0.72rem !important;
    }
}

/* Schede mobile: stesso ritmo visivo delle liste (padding, card, pulsanti) */
@media (max-width: 768px) {
    body.has-mobile-back main.content:has(.scheda-page) {
        --content-pad-x: 14px;
        padding-top: 0 !important;
        padding-left: var(--content-pad-x) !important;
        padding-right: var(--content-pad-x) !important;
        padding-bottom: 20px !important;
    }

    body.has-mobile-back .mobile-topbar {
        min-height: 48px !important;
        padding: 6px 14px !important;
        padding-top: calc(6px + env(safe-area-inset-top, 0px)) !important;
    }

    body.has-mobile-back .mobile-topbar--has-back .mobile-menu-toggle {
        display: none !important;
    }

    body.has-mobile-back .mobile-topbar--has-back {
        gap: 8px !important;
    }

    body.has-mobile-back .mobile-topbar-back {
        flex: 1 1 auto;
        min-height: 36px !important;
        margin-left: 0 !important;
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
        border-radius: var(--radius) !important;
    }

    body.has-mobile-back .mobile-topbar-actions {
        gap: 8px !important;
    }

    body.has-mobile-back .mobile-topbar-btn {
        min-height: 36px !important;
        min-width: 36px !important;
        padding: 8px 12px !important;
        font-size: 0.82rem !important;
        border-radius: var(--radius) !important;
    }

    body.has-mobile-back .scheda-page {
        margin: 0 !important;
    }

    body.has-mobile-back .scheda-page[data-cliente-scheda],
    body.has-mobile-back .scheda-page[data-utente-scheda] {
        padding-top: 0 !important;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] {
        padding-top: 0 !important;
    }

    body.has-mobile-back .scheda-page > .card,
    body.has-mobile-back .scheda-page .card.rapporto-scheda {
        margin: 0 !important;
        padding: 16px 14px !important;
        border: 1px solid var(--border-light) !important;
        border-top: 3px solid var(--bg-sidebar-active) !important;
        border-radius: var(--radius) !important;
        box-shadow: var(--shadow-sm) !important;
    }

    body.has-mobile-back .scheda-page .card .scheda-detail-block {
        padding: 12px 14px !important;
    }

    body.has-mobile-back .scheda-page .card .scheda-invii-block {
        gap: 14px !important;
    }

    body.has-mobile-back .scheda-page .card .scheda-invii-block .scheda-mail-block {
        padding: 12px 14px !important;
    }

    body.has-mobile-back .scheda-page .card .scheda-invii-block .invii-item {
        padding: 12px 14px !important;
    }

    body.has-mobile-back .scheda-page .card .scheda-gestione-stack {
        padding: 0 2px !important;
        gap: 16px !important;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head {
        left: auto !important;
        right: auto !important;
        width: auto !important;
        max-width: none !important;
        margin-left: calc(-1 * var(--content-pad-x)) !important;
        margin-right: calc(-1 * var(--content-pad-x)) !important;
        padding: 0 var(--content-pad-x) 8px !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head .scheda-tabs {
        margin: 0 calc(-1 * var(--content-pad-x)) !important;
        padding: 6px var(--content-pad-x) !important;
        gap: 6px !important;
        background: var(--bg-muted) !important;
        border: 1px solid var(--border-light) !important;
        border-left: 0 !important;
        border-right: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head .scheda-tab-btn {
        min-height: 36px !important;
        padding: 8px 8px !important;
        font-size: 0.82rem !important;
        line-height: 1.2 !important;
        border-radius: 8px !important;
    }

    body.has-mobile-back .scheda-page .card .btn,
    body.has-mobile-back .scheda-page .fatturato-btn {
        min-height: 42px !important;
        padding: 10px 14px !important;
        font-size: 0.9rem !important;
    }

    body.has-mobile-back .scheda-page .card input:not([type="hidden"]),
    body.has-mobile-back .scheda-page .card select,
    body.has-mobile-back .scheda-page .card textarea {
        min-height: 42px;
    }

    body.has-mobile-back .scheda-page .scheda-tab-panels {
        padding-top: 12px;
    }

    body.has-mobile-back .scheda-page .scheda-tab-panels > .card {
        margin-top: 0;
    }
}

.admin-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.admin-subnav a {
    padding: 8px 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-subnav a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.admin-home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.admin-home-link {
    display: block;
    padding: 18px 14px;
    background: var(--bg-muted);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    text-align: center;
}

.login-logo,
.scheda-org-logo,
.org-logo-preview {
    max-height: 72px;
    max-width: 220px;
    display: block;
    margin: 0 auto 12px;
    object-fit: contain;
}

.scheda-logo-wrap {
    margin-bottom: 12px;
}

.clienti-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.clienti-select-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

.clienti-import-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.import-modal-panel {
    width: min(560px, 96vw);
}

.import-modal-backdrop.is-running .import-modal-panel {
    border-left: 4px solid #d97706;
}

.import-modal-backdrop.is-ready .import-modal-panel {
    border-left: 4px solid var(--success);
}

.import-modal-backdrop.is-error .import-modal-panel {
    border-left: 4px solid var(--danger, #b91c1c);
}

.import-file-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-banner-errors {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.import-banner-errors p {
    margin: 0 0 8px;
    color: var(--text-secondary);
}

.import-banner-errors ul {
    margin: 0;
    padding-left: 18px;
    color: var(--danger, #b91c1c);
    font-size: 0.9rem;
}

.import-banner-errors li + li {
    margin-top: 4px;
}

.import-banner-top {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: center;
    justify-content: space-between;
}

.import-banner-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.import-banner-status {
    margin: 2px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.import-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.import-file-btn {
    position: relative;
    cursor: pointer;
    margin: 0;
}

.import-file-btn input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.import-banner-ready {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.import-banner-ready p {
    margin: 0 0 10px;
    color: var(--text-secondary);
}

.analisi-totals {
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    text-align: left;
}

.analisi-totals-row {
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    gap: 8px;
    margin: 0;
    font-size: 0.92rem;
    color: var(--text-secondary);
    text-align: left;
}

.analisi-totals-row + .analisi-totals-row {
    margin-top: 2px;
}

.analisi-totals-row strong {
    color: var(--text-primary);
    font-weight: 700;
}

.import-banner-confirm {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.list-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin: 12px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.list-infinite-sentinel {
    height: 1px;
    margin: 0;
    padding: 0;
}

.list-pager-status {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.list-pager-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.list-pager-page {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
}

.list-pager-page.is-current {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--text-inverse);
}

.list-pager-ellipsis {
    color: var(--text-muted);
}

.list-pager-nav .btn[aria-disabled="true"] {
    opacity: 0.45;
    pointer-events: none;
}

@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="file"]):not([type="image"]):not([type="range"]):not([type="color"]),
    select,
    textarea,
    .time-text-input,
    .ore-duration-input,
    .ore-hm-input {
        font-size: 16px !important;
        touch-action: manipulation;
    }
}

.mobile-topbar--has-back .mobile-menu-toggle,
body.has-mobile-back .mobile-topbar .mobile-menu-toggle {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-topbar,
    body.has-mobile-back .mobile-topbar {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
    }

    .scheda-page .scheda-sticky-head,
    .scheda-page .scheda-sticky-head .page-toolbar,
    .scheda-page .scheda-sticky-head .scheda-tabs,
    .scheda-page[data-rapporto-scheda] .scheda-sticky-head,
    .scheda-page[data-cliente-scheda] .scheda-sticky-head,
    .scheda-page[data-utente-scheda] .scheda-sticky-head,
    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head,
    body.has-mobile-back .scheda-page[data-rapporto-scheda] .scheda-sticky-head .scheda-tabs,
    .list-page-head {
        background: #ffffff !important;
        background-color: #ffffff !important;
    }

    .scheda-page .scheda-sticky-head {
        top: 0 !important;
        margin-top: 0 !important;
        margin-left: calc(-1 * var(--content-pad-x, 14px)) !important;
        margin-right: calc(-1 * var(--content-pad-x, 14px)) !important;
        padding-top: 14px !important;
        padding-left: var(--content-pad-x, 14px) !important;
        padding-right: var(--content-pad-x, 14px) !important;
    }

    .list-page-head {
        top: 0 !important;
        margin-top: 0 !important;
        margin-left: calc(-1 * var(--content-pad-x, 14px)) !important;
        margin-right: calc(-1 * var(--content-pad-x, 14px)) !important;
        padding-top: 14px !important;
        padding-left: var(--content-pad-x, 14px) !important;
        padding-right: var(--content-pad-x, 14px) !important;
    }
}
