:root {

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --dark: #0f172a;

    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #fb923c;

    --success: #16a34a;
    --success-dark: #15803d;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning: #d97706;
    --warning-dark: #b45309;
    --info: #0284c7;
    --info-dark: #0369a1;

    --border-radius: 10px;
    --border-radius-lg: 14px;
    --box-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --box-shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
    --box-shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
    --box-shadow-xl: 0 24px 56px rgba(15, 23, 42, 0.16);

    --sidebar-bg: linear-gradient(180deg, #111827 0%, #1f2937 100%);

    --cat-vendita: #ec4899;
    --cat-titoli: #22c55e;
    --cat-rilievi: #06b6d4;
    --cat-progettazione: #a855f7;
    --cat-sicurezza: #ef4444;
    --cat-catasto: #3b82f6;
    --cat-documenti: #64748b;
    --cat-perizie: #d97706;
    --cat-altro: #94a3b8;

}

[data-theme="dark"] {
    --gray-50: #1a2231;
    --gray-100: #212b3d;
    --gray-200: #2b3648;
    --gray-300: #3b4a63;
    --gray-400: #64748b;
    --gray-500: #8ea0b8;
    --gray-600: #b3c1d4;
    --gray-700: #cdd7e4;
    --gray-800: #e2e8f0;
    --gray-900: #f1f5f9;
    --dark: #f1f5f9;
    --white: #101826;
}

body { background: var(--gray-100); }

.bento-card,
.bento-header,
.list-panel,
.card,
.dashboard-card,
.calendar-container,
.bento-kpi {
    border: 1px solid var(--gray-200);
    box-shadow: var(--box-shadow-sm);
}

.menu-section { flex-direction: column; }
.menu-section-title { display: none; }

.menu-link { color: rgba(255, 255, 255, 0.62); }
.menu-link:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.page-title {
    font-size: 21px;
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.02em;
    color: var(--gray-900);
}

.bento-nome {
    font-size: 17px;
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.01em;
}

.bento-card-head {
    height: 40px;
    padding-top: 0;
    padding-bottom: 0;
    color: var(--gray-500);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.4px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
}

.bento-kpi-label {
    font-size: 10px;
    letter-spacing: 0.8px;
    color: var(--gray-400);
    font-weight: var(--font-weight-semibold);
}

.bento-kpi-value {
    font-size: 20px;
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.02em;
}

.bento-fin-total {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
}
.bento-detail-row:has(+ .bento-fin-total) { border-bottom: none; }

.table th {
    font-size: 10px;
    letter-spacing: 0.6px;
    color: var(--gray-400);
    font-weight: var(--font-weight-semibold);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 10px var(--spacing-sm);
}

.table td { border-bottom: none; }

.filter-tab,
.status-filter-tab {
    border-radius: var(--border-radius-full);
    border: 1px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-500);
    font-weight: var(--font-weight-medium);
}
.filter-tab:hover,
.status-filter-tab:hover { border-color: var(--gray-300); color: var(--gray-700); }
.filter-tab.active,
.status-filter-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.bento-card-body--contacts .cliente-item .cliente-nome,
.bento-card-body--contacts .cliente-item .cliente-subtitle {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
.bento-card-body:empty,
.bento-card-body:has(> .list:empty) { padding: 0; }
.bento-card-body--contacts .list-row {
    height: 52px;
    overflow: hidden;
}
.bento-card-body--contacts .cliente-subtitle {
    display: flex;
    align-items: center;
    gap: 5px;
}
.bento-card-body--contacts .cliente-subtitle i { color: var(--gray-400); width: 14px; text-align: center; }
.cliente-row-remove .cliente-row-info { flex: 1; min-width: 0; }
.cliente-row-remove .cliente-row-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.bento-card-body--contacts .cliente-item,
.cliente-row-remove .cliente-item { min-width: 0; flex: 1; }
.bento-card-body--contacts .cliente-item .cliente-info,
.cliente-row-remove .cliente-item .cliente-info { min-width: 0; overflow: hidden; }

.ruolo-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: none;
    background: none;
    color: var(--gray-500);
    font-size: var(--font-size-xs);
    font-family: inherit;
    line-height: 1.25;
    cursor: pointer;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
}
.ruolo-chip:hover { color: var(--primary); }
.ruolo-chip i:first-child { width: 14px; text-align: center; color: var(--gray-400); }
.ruolo-chip:hover i:first-child { color: var(--primary); }
.cliente-item[data-codice-cliente]:hover .cliente-nome { color: inherit; }
.cliente-item[data-codice-maestranza] { cursor: pointer; }
.ruolo-chip .ruolo-chip-label { overflow: hidden; text-overflow: ellipsis; }
.ruolo-chip .ruolo-chip-caret {
    font-size: 8px;
    opacity: 0.6;
    transition: transform 0.15s ease;
}
.ruolo-chip.aperto { color: var(--primary); }
.ruolo-chip.aperto i:first-child { color: var(--primary); }
.ruolo-chip.aperto .ruolo-chip-caret { transform: rotate(180deg); opacity: 1; }

body > .search-dropdown { z-index: 2100; }

select.select-custom-native {
    position: absolute;
    width: 0;
    height: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
.select-custom-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.select-custom-trigger .select-custom-valore {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.select-custom-trigger > i {
    font-size: 9px;
    color: var(--gray-400);
    flex-shrink: 0;
    transition: transform 0.15s ease;
}
.select-custom-trigger.aperto > i { transform: rotate(180deg); color: var(--primary); }
.select-custom-trigger.select-custom-vuoto .select-custom-valore { color: var(--gray-400); }
.select-dropdown .ruolo-option { padding: 8px 12px; }

.ruolo-dropdown { padding: 4px; }
.ruolo-dropdown .ruolo-option,
.ruolo-picker .ruolo-option {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    color: var(--gray-700);
    cursor: pointer;
    white-space: nowrap;
}
.ruolo-dropdown .ruolo-option i,
.ruolo-picker .ruolo-option i { width: 18px; text-align: center; color: var(--gray-400); }
.ruolo-dropdown .ruolo-option:hover,
.ruolo-picker .ruolo-option:hover { background: var(--gray-50); }
.ruolo-dropdown .ruolo-option.active,
.ruolo-picker .ruolo-option.active {
    background: var(--gray-100);
    color: var(--gray-900);
    font-weight: var(--font-weight-semibold);
}
.ruolo-dropdown .ruolo-option.active i,
.ruolo-picker .ruolo-option.active i { color: var(--primary); }
.ruolo-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}
.ruolo-picker .ruolo-option { border: 1px solid var(--gray-200); }
.ruolo-picker .ruolo-option.active { border-color: var(--primary); }

.modal-container .form-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    background: var(--white);
    box-shadow: var(--box-shadow-sm);
    overflow: hidden;
}
.modal-container .form-section > h6 {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    margin: 0;
    padding: 0 var(--spacing-md);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-500);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.modal-container .form-section > :not(h6) {
    margin-left: var(--spacing-md);
    margin-right: var(--spacing-md);
}
.modal-container .form-section > h6 + * { margin-top: var(--spacing-sm); }
.modal-container .form-section > :last-child { margin-bottom: var(--spacing-sm); }
.modal-container .g-cell { display: flex; flex-direction: column; gap: var(--spacing-md); }
.modal-viste { justify-content: center; margin-bottom: var(--spacing-md); }

.modal-container .form-section[data-categoria] { border-left: 3px solid var(--cat-color); }
.modal-container .form-section[data-categoria] > h6 {
    background: color-mix(in srgb, var(--cat-color) 8%, transparent);
    border-bottom-color: color-mix(in srgb, var(--cat-color) 25%, transparent);
}
.modal-container .form-section[data-categoria] > h6 > i { color: var(--cat-color); }
.form-section[data-categoria] .passo-scelta:not(.passo-scelta--bloccato) .list-row-icon { color: var(--cat-color); }
.modal-container .list-row { min-height: 34px; }
.modal-container .list-row-label { color: var(--gray-500); font-weight: var(--font-weight-medium); }

.modal-body .g-grid { --col-w: minmax(0, 1fr); }

@media (max-width: 900px) {
    .modal-body .g-grid,
    .modal-body .g-grid.cols-2,
    .modal-body .g-grid.cols-3,
    .modal-body .g-grid.cols-4 { --cols: 1; }
}

@media (max-width: 768px) {

    .ruolo-dropdown .ruolo-option { height: 44px; }

    html, body { overflow-x: hidden; height: auto; min-height: 100%; }
    .main-content { overflow-x: hidden; margin-left: 0; }

    .sidebar { box-shadow: none; }
    .sidebar.show { box-shadow: var(--box-shadow-lg); }

    .bento-nome { overflow-wrap: anywhere; }

    .dashboard-wrapper { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
    .main-content { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
    .content-area { height: auto; overflow: visible; }
    .progetto-bento,
.cliente-bento { flex: none; min-height: auto; overflow: visible; }
    .progetto-bento-col,
.cliente-bento-col { overflow: visible; min-height: auto; }
    .bento-card--fill { flex: none; }
    .bento-card-body--scroll { overflow: visible; max-height: none; }

    .menu-section-title {
        display: block;
        width: auto;
        height: auto;
        margin: 0;
        padding: var(--spacing-md) var(--spacing-md) 4px;
        background: none;
        color: rgba(255, 255, 255, 0.4);
        font-size: 10px;
        letter-spacing: 1.2px;
        text-align: left;
    }

    .bento-header { flex-wrap: wrap; padding: var(--spacing-md); }
    .bento-avatar { width: 40px; height: 40px; font-size: var(--font-size-sm); }
    .bento-header-info { flex: 1 1 60%; min-width: 0; }
    .bento-header-title { flex-wrap: wrap; }
    .bento-header-meta { flex-wrap: wrap; row-gap: 2px; }
    .bento-header-actions {
        margin-left: 0;
        width: 100%;
        order: 10;
        padding-top: var(--spacing-sm);
        border-top: 1px solid var(--gray-100);
    }
    .bento-header-actions .btn-icon-only { min-width: 44px; min-height: 40px; }
    .bento-header-actions .btn-primary { flex: 1; min-height: 40px; }

    

    .bento-kpi-row { gap: var(--spacing-sm); grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .progetto-bento,
.cliente-bento { grid-template-columns: minmax(0, 1fr); }
    .progetto-bento-col,
.cliente-bento-col,
.bento-kpi { min-width: 0; }
    .bento-kpi-value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 540px) {
    .bento-kpi-value { font-size: 16px; }
    .page-title { font-size: 18px; }
    .bento-header-meta span { font-size: var(--font-size-xs); }
}

.cad-topbar { background: #26282c !important; border-bottom: 1px solid #35383d; }
.cad-statusbar { background: #1c1e21 !important; }

.cad-cmdbar {
    background: #1f2124;
    border-top: 1px solid #35383d;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 12px;
    flex-shrink: 0;
}

.cad-cmd-history {
    max-height: 54px;
    overflow-y: auto;
    padding: 3px 10px 0;
    color: #9aa3ad;
    line-height: 1.5;
    scrollbar-width: thin;
}

.cad-cmd-history .cad-cmd-name { color: #e8a84c; font-weight: 600; }
.cad-cmd-history .cad-cmd-err { color: #e06c60; }

.cad-cmd-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 6px;
}

.cad-cmd-prompt { color: #e8a84c; font-weight: 600; user-select: none; }

#cadCmdInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e6e9ec;
    font: inherit;
    caret-color: #e8a84c;
}

#cadCmdInput::placeholder { color: #565d66; }

.cat-deep_work   { background: #a855f7; color: #fff; }
.cat-sopralluogo { background: var(--primary); color: #fff; }
.cat-cliente     { background: #3b82f6; color: #fff; }
.cat-admin       { background: #64748b; color: #fff; }

.upcoming-icon.progetto { --ico: var(--primary); }
.upcoming-icon.ape      { --ico: #22c55e; }
.upcoming-icon.enea     { --ico: #d97706; }
.upcoming-icon.pregeo   { --ico: #06b6d4; }
.upcoming-icon.docfa    { --ico: #3b82f6; }
.upcoming-icon.progetto, .upcoming-icon.ape, .upcoming-icon.enea,
.upcoming-icon.pregeo, .upcoming-icon.docfa {
    background: color-mix(in srgb, var(--ico) 14%, transparent);
    color: var(--ico);
}

.dashboard-stats { gap: 12px; margin-bottom: var(--spacing-md); }
.stat-card { padding: 14px 16px; gap: 12px; }
.stat-card .stat-icon { width: 44px; height: 44px; font-size: 18px; border-radius: 10px; }
.stat-value { font-size: 22px; letter-spacing: -0.02em; }
.stat-label { font-size: var(--font-size-xs); }
.stat-detail { font-size: 11px; color: var(--gray-400); }

.page-subtitle { font-size: var(--font-size-sm); color: var(--gray-400); margin-top: 2px; }

.servizio-stat-bar {
    height: 6px;
    width: 100%;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 5px;
}
.servizio-stat-bar-fill { background: var(--primary); }
.servizio-stat-active { color: var(--primary); }
.servizio-stat-row { display: block; padding: 7px 0; }

.progetto-item { border-radius: var(--border-radius); transition: var(--transition-fast); }
.progetto-item:hover { background: var(--gray-50); }

.quick-action {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-full);
    background: var(--white);
    color: var(--gray-600);
    font-weight: var(--font-weight-medium);
    transition: var(--transition-fast);
}
.quick-action:hover { border-color: var(--primary); color: var(--primary); }

.card-header,
.dashboard-card .card-header {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 10px 14px;
}
.card-header h3, .card-header h5 {
    font-size: 12px;
    font-weight: var(--font-weight-semibold);
    color: var(--gray-500);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
}
.card-header h3 i, .card-header h5 i { color: var(--primary); font-size: 11px; }

.calendar-container { padding: var(--spacing-md); }
.calendar-days {
    gap: 0;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--white);
}
.calendar-day {
    border: none;
    border-right: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
    border-radius: 0;
    background: var(--white);
    min-height: 84px;
    padding: 6px 8px;
    overflow: hidden;
}
.calendar-day:nth-child(7n) { border-right: none; }
.calendar-days .calendar-day:nth-last-child(-n+7) { border-bottom: none; }
.calendar-day.weekend { background: var(--gray-50); }
.calendar-day.other-month { background: var(--gray-50); }
.calendar-day.other-month .day-number { color: var(--gray-300); }
.calendar-day.has-events:hover { background: var(--gray-50); }
.calendar-day.today {
    background: color-mix(in srgb, var(--primary) 6%, var(--white));
}
.calendar-day.today .day-number {
    background: var(--primary);
    color: #fff;
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: 12px;
}
.calendar-day.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.calendar-day .day-number { font-size: 13px; font-weight: 600; color: var(--gray-500); }
.calendar-day:hover { background: color-mix(in srgb, var(--primary) 4%, var(--white)); }
.day-event-dot { width: 7px; height: 7px; border-radius: 50%; }
.day-events { gap: 3px; margin-top: 4px; }
.calendar-weekdays > div { text-align: left; padding-left: 9px; }

.calendario-main, .calendario-sidebar { min-width: 0; }

.bento-kpi-row--scheda {
    grid-template-columns: auto minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) auto;
    align-items: stretch;
}
.kpi-break { display: none; }

.bento-card-head .head-actions .btn-action i { color: inherit; }
.bento-card--toggle > .bento-card-head { cursor: pointer; user-select: none; }

.bento-card--toggle.collapsed > .bento-card-body { display: none; }
.bento-card--toggle.collapsed > .bento-card-head { border-bottom: none; }

.progetto-bento-col--finanze { overflow: hidden; }
.progetto-bento-col--finanze > .bento-card { flex: 0 1 auto; min-height: 0; }
.progetto-bento-col--finanze > .bento-card:not(.bento-card--intero) { min-height: 90px; }
.progetto-bento-col--finanze > .bento-card--intero { flex: 0 0 auto; }
.progetto-bento-col--finanze > .bento-card > .bento-card-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
@media (max-width: 768px) {
    .progetto-bento-col--finanze { overflow: visible; min-height: auto; }
    .progetto-bento-col--finanze > .bento-card { flex: 0 0 auto; }
    .progetto-bento-col--finanze > .bento-card > .bento-card-body { overflow: visible; }
}

.progetto-bento-col--documenti { overflow: hidden; }
.progetto-bento-col--documenti > .bento-card { flex: 0 1 auto; min-height: 90px; }
.progetto-bento-col--documenti > .bento-card > .bento-card-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; }

.progetto-bento--merged { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); }
.bento-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: var(--spacing-md);
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}
.bg3-mappa { grid-column: 1 / 3; grid-row: 1; }
.bg3-ubicazione { grid-column: 1 / 3; grid-row: 2; }
.bg3-clienti { grid-column: 1; grid-row: 3; }
.bg3-maestranze { grid-column: 2; grid-row: 3; }
.bg3-clienti, .bg3-maestranze { align-self: start; max-height: 100%; min-height: 0; }
.bg3-clienti > .bento-card-body,
.bg3-maestranze > .bento-card-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.bento-card--testo .bento-card-body,
.progetto-bento-col--documenti > .bento-card--testo > .bento-card-body { min-height: 103px; }
.progetto-bento-col--documenti > .bento-card--testo { flex: 0 0 auto; min-height: 0; }
.bg3-right {
    grid-column: 3;
    grid-row: 1 / 4;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    min-height: 0;
    min-width: 0;
}
.bg3-right > .bento-card { flex: 0 0 auto; }
.bg3-timeline { display: contents; }
.bg3-right .timeline-card { flex: 0 1 auto; min-height: 0; }

.progetto-bento .list-row-label {
    color: var(--gray-500);
    font-weight: var(--font-weight-medium);
}
.input-inline {
    field-sizing: content;
    min-width: 3ch;
    max-width: 100%;
    padding: 0 0.25em;
    font: inherit;
    color: inherit;
    border: 1px solid transparent;
    border-radius: 0.3em;
    background: transparent;
    vertical-align: bottom;
    line-height: 1.4;
}
.input-inline:hover { border-color: var(--gray-300); }
.input-inline:focus { outline: none; border-color: var(--primary); background: var(--white); }
.bento-card .indirizzo-riga1,
.bento-card .indirizzo-riga2 { line-height: calc(1.4em + 2px); padding-block: 0; text-transform: uppercase; }
.bento-card .indirizzo-riga1 .val-inline,
.bento-card .indirizzo-riga2 .val-inline {
    display: inline-block;
    padding: 0 0.25em;
    border: 1px solid transparent;
    line-height: 1.4;
    vertical-align: bottom;
}
.bento-card--testo .form-control {
    border-color: transparent;
    background: transparent;
    resize: none;
}
.bento-card--testo .form-control:hover { border-color: var(--gray-300); }
.bento-card--testo .form-control:focus { border-color: var(--primary); background: var(--white); }
.input-inline[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.input-inline[type="number"]::-webkit-inner-spin-button,
.input-inline[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.list-row--pagamento { height: 34px; }
.list-row--pagamento:has(.pagamento-row-sub) { height: 52px; }
.pagamento-row-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.pagamento-row-main,
.pagamento-row-sub { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pagamento-row-sub { font-size: 11px; color: var(--gray-500); }

.bento-card-body--contacts .clienti-selezionati { gap: 6px; }
.bento-card--testo .bento-card-body p {
    margin: 0;
    padding: 10px 14px;
    border: 1px solid transparent;
    font-size: var(--font-size-base);
    line-height: 1.5;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .progetto-bento--merged { grid-template-columns: minmax(0, 1fr); }
    .bento-grid-3col { overflow: visible; grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
    .bg3-mappa, .bg3-ubicazione, .bg3-clienti, .bg3-maestranze { grid-column: auto; grid-row: auto; }
    .bg3-right { display: contents; }
    .bg3-mappa { order: 0; }
    .bg3-ubicazione { order: 1; }
    .bg3-clienti { order: 2; }
    .bg3-maestranze { order: 3; }
    .bg3-right > .bento-card { order: 4; min-height: 0; }
    .timeline-card { order: 4; }
    .timeline-body { overflow: visible; }
}

.bento-kpi--identita {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
}
.kpi-identita-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kpi-codice { font-size: 20px; font-weight: var(--font-weight-bold); letter-spacing: 0.3px; color: var(--gray-800); }
.kpi-identita-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    color: var(--gray-500);
    font-size: var(--font-size-sm);
    min-width: 0;
}
.kpi-identita-sub span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.kpi-identita-sub i { color: var(--gray-300); font-size: 11px; }
.kpi-actions { --kpi-btn: 35px; --kpi-gap: 6px; display: flex; align-items: stretch; gap: var(--kpi-gap); }

.kpi-actions-elle {
    display: grid;
    grid-template-columns: repeat(2, var(--kpi-btn));
    grid-template-rows: repeat(2, var(--kpi-btn));
    gap: var(--kpi-gap);
}
.kpi-slot-salva     { grid-area: 1 / 1; }
.kpi-slot-elimina   { grid-area: 1 / 2; }
.kpi-slot-prezzi    { grid-area: 2 / 1; }
.kpi-slot-trasforma { grid-area: 2 / 2; }
.kpi-back,
.kpi-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: auto;
    width: auto;
    aspect-ratio: 1;
    padding: 0;
    border-radius: var(--border-radius);
}
.kpi-back { align-self: stretch; }
.kpi-actions .btn { flex: 0 0 auto; width: var(--kpi-btn); height: var(--kpi-btn); aspect-ratio: auto; align-self: center; }
.kpi-actions-elle .btn { align-self: stretch; }

.kpi-btn-label { display: none; }

.profilo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-md);
    align-items: start;
    max-width: 60rem;
}
.profilo-user { display: flex; align-items: center; gap: 14px; }
.profilo-nome { font-size: 17px; font-weight: var(--font-weight-bold); letter-spacing: -0.01em; }
.profilo-email { color: var(--gray-500); font-size: var(--font-size-sm); overflow-wrap: anywhere; }
.switch-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.profilo-sessione-hint { margin-bottom: 10px; }

.indirizzo-item .indirizzo-riga1 { min-height: 1.4em; }
.indirizzo-item .indirizzo-riga2 { min-height: 1.4em; }

.upcoming-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: var(--spacing-md);
    row-gap: 2px;
    align-items: baseline;
    padding: 10px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.upcoming-item:hover {
    background: var(--white);
    border-color: var(--gray-300);
    box-shadow: var(--box-shadow);
    transform: translateY(-1px);
}
.upcoming-item + .upcoming-item { margin-top: 8px; }
.upcoming-icon { --ico: var(--primary); width: 36px; height: 36px; border-radius: 10px; grid-row: 1 / span 2; align-self: center; }
.upcoming-content, .upcoming-date { display: contents; }
.upcoming-title { grid-column: 2; grid-row: 1; font-weight: 600; font-size: var(--font-size-base); color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.upcoming-desc { grid-column: 2; grid-row: 2; color: var(--gray-500); font-size: var(--font-size-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.upcoming-date-value { grid-column: 3; grid-row: 1; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--gray-700); text-align: right; white-space: nowrap; }
.upcoming-date-diff { grid-column: 3; grid-row: 2; font-size: 11px; color: var(--gray-400); text-align: right; white-space: nowrap; }
.btn-mail-back { display: none; }

#toast-container { pointer-events: none; }
#toast-container .toast { pointer-events: auto; }

.mail-detail-header { flex-wrap: wrap; }
.mail-detail-actions { flex-wrap: wrap; min-width: 0; }
.mail-body-frame {
    display: block;
    width: 100%;
    min-height: 12rem;
    border: 0;
}

* { scrollbar-width: thin; scrollbar-color: var(--gray-300) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
*::-webkit-scrollbar-track { background: transparent; }

.smart-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.smart-row {
    display: grid;
    grid-template-columns: max-content minmax(170px, 1.15fr) minmax(0, 1.3fr) minmax(150px, 1fr) minmax(120px, auto) auto;
    grid-template-areas:
        "code where tags id status actions"
        "code detail detail detail detail actions";
    align-items: center;
    column-gap: 14px;
    row-gap: 2px;
    padding: 10px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.smart-row:hover {
    border-color: var(--gray-300);
    box-shadow: var(--box-shadow);
    transform: translateY(-1px);
}

@supports (grid-template-columns: subgrid) {
    @media (min-width: 1081px) {
        .smart-list:not(.smart-list--flat) {
            display: grid;
            grid-template-columns: max-content minmax(170px, 1fr) minmax(160px, 1fr) minmax(150px, 0.9fr) max-content;
            column-gap: 14px;
            align-content: start;
        }
        .smart-list:not(.smart-list--flat) > .smart-row {
            grid-column: 1 / -1;
            grid-template-columns: subgrid;
        }
    }
}

.sr-code {
    grid-area: code;
    justify-self: start;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 1px;
    background: var(--gray-100);
    border-radius: 8px;
    padding: 6px 10px;
    white-space: nowrap;
}
.sr-code strong { font-size: var(--font-size-sm); color: var(--gray-700); letter-spacing: 0.3px; }
.sr-code span { font-size: 12px; color: var(--gray-500); font-weight: var(--font-weight-medium); }
.sr-code-link {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 1px;
    color: inherit;
    text-decoration: none;
}
.sr-code-link:hover strong { text-decoration: underline; }

.sr-id { grid-area: id; min-width: 0; }
.sr-where { grid-area: where; min-width: 0; }
.sr-tags { grid-area: tags; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }

.sr-meta .sr-contact {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    margin-right: 10px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sr-meta .sr-contact i { color: var(--gray-300); font-size: 10px; }

.sr-status {
    grid-area: status;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    justify-self: end;
}
.sr-mono { font-size: 11px; color: var(--gray-500); font-variant-numeric: tabular-nums; letter-spacing: 0.3px; }
.sr-amount { font-size: var(--font-size-base); font-weight: var(--font-weight-bold); color: var(--gray-800); }

.sr-pay { width: 116px; }
.sr-pay-bar {
    height: 5px;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
}
.sr-pay-bar span { display: block; height: 100%; border-radius: 3px; }
.sr-pay-bar span.ok  { background: var(--success); }
.sr-pay-bar span.mid { background: var(--primary); }
.sr-pay-label { display: block; margin-top: 2px; font-size: 10px; color: var(--gray-400); text-align: right; white-space: nowrap; }
.bento-prog-fill--primary { background: var(--primary); }

.sr-actions { grid-area: actions; display: flex; gap: 2px; opacity: 0.35; transition: opacity 0.15s ease; }
.smart-row:hover .sr-actions, .sr-actions:focus-within { opacity: 1; }
.sr-actions .btn-action {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: none;
    border-radius: 8px;
    color: var(--gray-400);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}
.sr-actions .btn-action:hover { background: var(--gray-100); color: var(--gray-700); }
.sr-actions .btn-action--danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }

.sr-detail {
    grid-area: detail;
    display: flex;
    gap: 14px;
    min-width: 0;
}
.sr-detail .sr-desc, .sr-detail .sr-note { flex: 1 1 50%; }
.sr-desc {
    grid-area: detail;
    font-size: 11px;
    color: var(--gray-400);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.sr-note {
    grid-area: detail;
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.badge { gap: 5px; }
.badge-tipologia { background: color-mix(in srgb, var(--tip-color) 15%, transparent); color: var(--tip-color); }

.progetto-bento-col--documenti > .bento-card--intero { flex: 0 0 auto; }

.empty-state--compatto { padding: 20px 12px; gap: 8px; }
.empty-state--compatto i { font-size: 22px; }
.empty-state--compatto p { font-size: var(--font-size-sm); }

.badge i { font-size: 0.9em; }
.badge.vendita        { background: color-mix(in srgb, var(--cat-vendita) 15%, transparent); color: var(--cat-vendita); }
.badge.titoli_permessi{ background: color-mix(in srgb, var(--cat-titoli) 15%, transparent); color: var(--cat-titoli); }
.badge.rilievi        { background: color-mix(in srgb, var(--cat-rilievi) 15%, transparent); color: var(--cat-rilievi); }
.badge.progettazione  { background: color-mix(in srgb, var(--cat-progettazione) 15%, transparent); color: var(--cat-progettazione); }
.badge.sicurezza      { background: color-mix(in srgb, var(--cat-sicurezza) 15%, transparent); color: var(--cat-sicurezza); }
.badge.catasto        { background: color-mix(in srgb, var(--cat-catasto) 15%, transparent); color: var(--cat-catasto); }
.badge.documenti      { background: color-mix(in srgb, var(--cat-documenti) 15%, transparent); color: var(--cat-documenti); }
.badge.perizie        { background: color-mix(in srgb, var(--cat-perizie) 15%, transparent); color: var(--cat-perizie); }
.badge.altro          { background: color-mix(in srgb, var(--cat-altro) 15%, transparent); color: var(--gray-500); }

.bottom-nav { display: none; }
.bnav-set { display: contents; }
.bnav-set[hidden] { display: none; }

@media (max-width: 768px) {
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 800;
        display: flex;
        background: var(--white);
        border-top: 1px solid var(--gray-200);
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
    }
    .bnav-link {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 54px;
        padding: 7px 0 6px;
        border: none;
        background: none;
        font-family: inherit;
        font-size: 10px;
        font-weight: 600;
        color: var(--gray-400);
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .bnav-link i { font-size: 17px; }
    .bnav-link.active { color: var(--primary); }
    .content-area { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
    .sidebar { padding-bottom: env(safe-area-inset-bottom); }

    .dashboard-wrapper, .main-content, .content-area { min-width: 0; max-width: 100vw; }

    .mobile-header { display: none; }
    .content-area { padding-top: calc(12px + env(safe-area-inset-top)); }

    .sidebar-header {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 4%;
        padding: 4% 5%;
    }
    .sidebar-brand { flex-direction: row; }
    .sidebar-header .user-info { width: auto; }

    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        flex-wrap: wrap;
    }
    .page-title { font-size: 18px; }
    .page-header .btn { padding: 9px 14px; font-size: 13px; flex-shrink: 0; }

    .btn-action { width: 40px; height: 40px; }
    .filter-tab, .status-filter-tab { padding: 8px 14px; }
    .content-area input:not([type="checkbox"]):not([type="radio"]),
    .content-area select,
    .content-area textarea,
    .modal-container input:not([type="checkbox"]):not([type="radio"]),
    .modal-container select,
    .modal-container textarea { font-size: 16px; }

    .smart-list { padding: 10px; flex: none; min-height: auto; overflow: visible; }
    .smart-row {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "where where"
            "tags status"
            "detail detail"
            "id id"
            "footer footer";
        row-gap: 6px;
        padding: 10px 12px;
    }
    .sr-where { justify-self: stretch; text-align: left; }
    .sr-id { justify-self: start; text-align: left; }
    .smart-row .sr-code {
        grid-area: footer;
        justify-self: start;
        margin-top: 2px;
    }
    #clientiList .smart-row, #maestranzeList .smart-row {
        grid-template-areas:
            "id id"
            "tags tags"
            "status status"
            "detail detail"
            "where where"
            "footer footer";
    }
    #clientiList .sr-id, #maestranzeList .sr-id { justify-self: start; text-align: left; }
    #clientiList .sr-where, #maestranzeList .sr-where { justify-self: start; text-align: left; }
    #clientiList .sr-status, #maestranzeList .sr-status {
        justify-self: start;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    .smart-row .cliente-nome { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; line-height: 1.2; font-size: 14px; }
    .sr-tags { align-self: center; }
    .sr-status { align-items: flex-end; justify-self: end; align-self: center; max-width: 100%; }
    .sr-pay { width: 130px; max-width: 100%; }
    .sr-pay-label { font-size: 10px; white-space: nowrap; }
    .sr-actions {
        display: flex;
        opacity: 1;
        grid-area: footer;
        justify-self: end;
        align-self: center;
        gap: 4px;
    }
    .sr-detail { flex-direction: column; gap: 4px; }
    .sr-desc, .sr-note {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
        overflow: hidden;
        border: none;
        padding-top: 0;
    }

    

    .bento-kpi-row--scheda { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-back { display: none; }
    .bento-kpi--identita { grid-column: 1 / -1; }
    .kpi-actions { grid-column: 1 / -1; flex-direction: row; }
    .kpi-actions .btn { min-height: 44px; flex: 1 1 auto; aspect-ratio: auto; width: auto; padding: 0 var(--spacing-md); }
    .kpi-btn-label { display: inline; margin-left: 7px; font-weight: var(--font-weight-medium); }

    .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-card, .stat-card > * { min-width: 0; }
    .stat-card .stat-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .progetto-item {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "codice cliente stato"
            "indirizzo indirizzo indirizzo"
            "servizi servizi servizi";
        row-gap: 4px;
        column-gap: 10px;
        align-items: center;
    }
    .progetto-item .progetto-codice { grid-area: codice; }
    .progetto-item .progetto-cliente { grid-area: cliente; min-width: 0; }
    .progetto-item > .badge { grid-area: stato; justify-self: end; }
    .progetto-item .indirizzo-item { grid-area: indirizzo; }
    .progetto-item .progetto-servizi { grid-area: servizi; }
    .progetto-item .cliente-nome { white-space: normal; overflow-wrap: break-word; }
    .indirizzo-item .indirizzo-riga1, .indirizzo-item .indirizzo-riga2 { white-space: normal; }

    .mail-layout {
        display: flex;
        flex-direction: column;
        min-height: 0;
        flex: 1;
    }
    .mail-sidebar {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        padding: 8px 10px;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
        overflow-x: auto;
        scrollbar-width: none;
    }
    .mail-sidebar::-webkit-scrollbar { display: none; }
    .mail-sidebar-header { padding: 0; flex-shrink: 0; }
    .mail-sidebar-header .btn { padding: 8px 12px; border-radius: 999px; }
    .mail-folders {
        display: flex;
        flex-direction: row;
        flex: 1;
        gap: 4px;
        overflow: visible;
    }
    .mail-folder { flex-shrink: 0; border-radius: 999px; padding: 7px 12px; }
    .mail-list-panel {
        flex: 1;
        min-height: 0;
        max-height: none;
        border-right: none;
        border-bottom: none;
    }
    .mail-content-panel { display: none; }
    .mail-layout.mail-viewing .mail-sidebar,
    .mail-layout.mail-viewing .mail-list-panel { display: none; }
    .mail-layout.mail-viewing .mail-content-panel {
        display: flex;
        flex: 1;
        min-height: 0;
    }
    .mail-detail-header { align-items: center; flex-wrap: wrap; row-gap: 8px; }
    .mail-detail-subject { flex: 1; min-width: 0; font-size: 16px; }
    .mail-detail-actions {
        flex-basis: 100%;
        display: flex;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .mail-detail-actions::-webkit-scrollbar { display: none; }
    .mail-detail-actions .btn { flex-shrink: 0; }
    .btn-mail-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        flex-shrink: 0;
        border-radius: 10px;
        background: var(--gray-100);
        color: var(--gray-600);
        font-size: 15px;
    }

    .calendar-day { min-height: 44px; padding: 3px 4px; }
    .calendar-weekdays > div { padding-left: 5px; }
    .calendar-header {
        grid-template-columns: auto minmax(0, 1fr);
        row-gap: 8px;
        margin-bottom: var(--spacing-sm);
    }
    .calendar-header > .btn { grid-column: 1; grid-row: 1; }
    .calendar-nav { grid-column: 2; grid-row: 1; min-width: 0; }
    .calendar-title { font-size: var(--font-size-base); white-space: nowrap; min-width: 0; }
    .calendar-summary {
        grid-column: 1 / -1;
        grid-row: 2;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
        min-width: 0;
    }
    .calendar-summary .calendar-summary-pill,
    .calendar-summary > span { white-space: nowrap; }
    .calendario-main { gap: 0; }
    .day-event-chip {
        width: 8px;
        height: 8px;
        padding: 0;
        border-radius: 50%;
        font-size: 0;
        overflow: hidden;
    }
    .calendar-keyboard-hint { display: none; }
}

@media (min-width: 769px) and (max-width: 1080px) {
    .content-area { padding: 14px; }
    .bento-kpi-row--scheda { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--spacing-sm); }
    .bento-kpi-row--scheda .kpi-back { order: 1; }
    .bento-kpi-row--scheda .bento-kpi--identita { order: 2; flex: 1 1 auto; }
    .bento-kpi-row--scheda .kpi-actions { order: 3; flex-direction: row; }
    .bento-kpi-row--scheda .kpi-break { display: block; order: 4; flex-basis: 100%; height: 0; }
    .bento-kpi-row--scheda > .bento-kpi:not(.bento-kpi--identita) { order: 5; flex: 1 1 0; min-width: 0; }
    .bento-kpi-row--scheda .bento-kpi-value { white-space: nowrap; }
    .smart-row {
        column-gap: 12px;
        grid-template-columns: max-content minmax(0, 1.1fr) minmax(0, 1fr) max-content auto;
        grid-template-areas:
            "code where id status actions"
            "code tags tags tags actions"
            "code detail detail detail actions";
    }
    .sr-actions { opacity: 1; }
}

@media (min-width: 769px) {
    .smart-row .sr-where .indirizzo-riga1 { font-weight: 600; color: var(--gray-800); }
    .smart-row .sr-id .cliente-nome { font-weight: var(--font-weight-medium); color: var(--gray-600); font-size: 13px; }
    .smart-row .sr-id .avatar { width: 30px; height: 30px; font-size: 11px; }

    #clientiList .smart-row, #maestranzeList .smart-row {
        grid-template-areas:
            "code id where tags status actions"
            "code detail detail detail detail actions";
    }
    #clientiList .sr-id .cliente-nome, #maestranzeList .sr-id .cliente-nome {
        font-weight: var(--font-weight-semibold);
        color: var(--gray-800);
        font-size: var(--font-size-sm);
    }
    #clientiList .sr-id .avatar, #maestranzeList .sr-id .avatar {
        width: var(--spacing-xl);
        height: var(--spacing-xl);
        font-size: var(--font-size-sm);
    }
    #clientiList .sr-where .indirizzo-riga1, #maestranzeList .sr-where .indirizzo-riga1 {
        font-weight: var(--font-weight-normal);
        color: var(--gray-700);
    }
}

@media (min-width: 1025px) {
    body:has(.calendario-layout) .content-area { overflow-y: auto; }
    .calendario-layout {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1.15fr);
        grid-template-rows: auto minmax(0, 1fr);
    }
    .calendario-main { display: contents; }
    .calendario-main .calendar-container {
        grid-column: 1;
        grid-row: 1 / -1;
    }
    .calendario-main .calendar-day { aspect-ratio: 1 / 1; min-height: 0; }
    .calendario-main > .card {
        grid-column: 2;
        grid-row: 2;
        margin-top: 0;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .calendario-main > .card .card-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }
    .calendario-sidebar {
        grid-column: 2;
        grid-row: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .calendario-sidebar .card {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .calendario-sidebar .card .card-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }
}

.g-grid.cols-2 { --cols: 2; }
.g-grid.cols-3 { --cols: 3; }
.g-grid.cols-4 { --cols: 4; }

@media (max-width: 768px) {
    body:has(.list-panel) {
        height: 100dvh;
        overflow: hidden;
    }
    body:has(.list-panel) #app,
    body:has(.list-panel) .dashboard-wrapper {
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }
    body:has(.list-panel) .main-content {
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    body:has(.list-panel) .content-area {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    body:has(.list-panel) .list-panel {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    body:has(.list-panel) .list-body {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    body:has(.list-panel) .smart-list {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

.smart-list--flat {
    padding: 0;
    flex: none;
    min-height: auto;
    overflow: visible;
}

.smart-row--mini {
    grid-template-columns: max-content minmax(0, 1.1fr) minmax(0, 1fr) max-content auto;
    grid-template-areas:
        "code where id status actions"
        "code tags tags tags actions";
    row-gap: 6px;
}

@media (max-width: 768px) {
    .smart-list--flat { padding: 0; }
    .smart-row--mini {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "where where"
            "tags status"
            "id id"
            "footer footer";
    }
}

@media (min-width: 1081px) {
    .smart-row {
        grid-template-columns: max-content minmax(170px, 1fr) minmax(160px, 1fr) minmax(150px, 0.9fr) auto;
        grid-template-areas:
            "code where id tags actions"
            "code desc note status actions";
        row-gap: 5px;
    }
    .sr-detail { display: contents; }
    .sr-desc { grid-area: desc; }
    .sr-note { grid-area: note; }
    .sr-tags, .sr-status { align-self: center; }
    .sr-status { flex-direction: row; align-items: center; gap: 8px; justify-self: start; }

    #clientiList .smart-row, #maestranzeList .smart-row {
        grid-template-areas:
            "code id where tags actions"
            "code desc note status actions";
    }

    .smart-row--mini {
        grid-template-columns: max-content minmax(170px, 1fr) minmax(160px, 1fr) minmax(150px, auto) auto;
        grid-template-areas:
            "code where id tags actions"
            "code where id status actions";
    }
    .smart-row--mini .sr-where, .smart-row--mini .sr-id { align-self: center; }
}

@supports (grid-template-columns: subgrid) {
    @media (min-width: 1081px) {
        .smart-list--flat {
            display: grid;
            grid-template-columns: max-content minmax(170px, 1fr) minmax(160px, 1fr) minmax(150px, auto) max-content;
            column-gap: 14px;
            align-content: start;
        }
        .smart-list--flat > .smart-row--mini {
            grid-column: 1 / -1;
            grid-template-columns: subgrid;
        }
    }
}

@media (min-width: 1920px) {
    .content-area {
        max-width: 105rem;
        margin-inline: auto;
    }
}

@media (max-width: 768px) {
    .sidebar-menu {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 6px;
        padding: 10px;
        align-content: start;
    }
    .sidebar-menu > .menu-item { display: none; }
    .sidebar-menu > .menu-section {
        grid-column: 1 / -1;
        display: block;
        margin-top: 4px;
        padding-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }
    .sidebar-menu > .menu-item + .menu-section {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }
    .menu-section-title { padding: 2px 4px 8px; }
    .menu-section-items {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }
    .menu-link {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 13px 6px;
        background: rgba(255, 255, 255, 0.04);
    }
    .menu-icon { font-size: 19px; width: auto; text-align: center; }
    .menu-text,
    .sidebar-menu > .menu-item .menu-text {
        font-size: 11px;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .sidebar-footer .menu-link { flex-direction: row; justify-content: center; background: none; }
}

.timeline-card { min-height: 0; }
.timeline-body { padding: 0; overflow-y: auto; }
.timeline-prossimo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: color-mix(in srgb, var(--primary) 6%, transparent);
    border-bottom: 1px solid var(--gray-200);
    font-size: 11px;
    color: var(--gray-600);
    flex-shrink: 0;
}
.timeline-prossimo i { color: var(--primary); font-size: 10px; }
.timeline-prossimo b { color: var(--gray-900); font-weight: var(--font-weight-semibold); }

.timeline-gruppo-head {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 12px 0 10px;
    margin-top: 6px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--gray-400);
    font-weight: var(--font-weight-semibold);
}
.timeline-gruppo:first-child .timeline-gruppo-head { margin-top: 2px; }
.timeline-gruppo-head::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }
.timeline-gruppo[style*="--cat-color"] .timeline-gruppo-head { color: var(--cat-color); }
.timeline-gruppo[style*="--cat-color"] .timeline-gruppo-head::after { background: color-mix(in srgb, var(--cat-color) 30%, transparent); }
.timeline-gruppo { position: relative; }
.timeline-gruppo::before {
    content: '';
    position: absolute;
    left: calc(var(--passo-asse) - 1px);
    top: 39px;
    bottom: 17px;
    width: 2px;
    background: var(--gray-200);
}

.timeline-card { --passo-asse: 20px; }
.timeline-passo {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px 0 10px;
    cursor: pointer;
}
.timeline-passo:hover { background: var(--gray-50); }
.passo-punto {
    width: 10px;
    height: 10px;
    margin-left: 5px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    background: var(--white);
    box-shadow: 0 0 0 3px var(--white);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.timeline-passo:hover .passo-punto { box-shadow: 0 0 0 3px var(--gray-50); }
.passo-icona { font-size: 10px; color: var(--gray-400); width: 14px; text-align: center; flex-shrink: 0; }
.passo-nome {
    flex: 1;
    min-width: 0;
    font-size: var(--font-size-sm);
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.passo-meta { font-size: 10px; color: var(--gray-400); flex-shrink: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-passo:not(:has(.passo-remove))::after { content: ''; width: 20px; margin-right: -4px; flex-shrink: 0; }

.passo--svolto .passo-punto { background: var(--success); border-color: var(--success); }
.passo--svolto .passo-icona { color: var(--success); }
.passo--corso .passo-punto { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 3px var(--white), 0 0 0 5px color-mix(in srgb, var(--primary) 18%, transparent); }
.passo--corso .passo-nome { color: var(--gray-900); font-weight: var(--font-weight-semibold); }
.passo--corso .passo-icona { color: var(--primary); }
.passo--pronto { cursor: pointer; }
.passo--pronto .passo-punto { border-style: dashed; border-color: var(--gray-300); }
.passo--pronto .passo-nome,
.passo--bloccato .passo-nome { color: var(--gray-400); }
.passo--pronto .passo-icona { color: var(--gray-300); }
.passo--bloccato { cursor: default; }
.passo--bloccato .passo-punto { border-color: var(--gray-200); }
.passo--bloccato .passo-icona { color: var(--gray-300); }
.timeline-gruppo[style*="--cat-color"] .passo--svolto .passo-punto,
.timeline-gruppo[style*="--cat-color"] .passo--corso .passo-punto { background: var(--cat-color); border-color: var(--cat-color); }
.timeline-gruppo[style*="--cat-color"] .passo--corso .passo-punto { box-shadow: 0 0 0 3px var(--white), 0 0 0 5px color-mix(in srgb, var(--cat-color) 18%, transparent); }
.timeline-gruppo[style*="--cat-color"] .passo--svolto .passo-icona,
.timeline-gruppo[style*="--cat-color"] .passo--corso .passo-icona { color: var(--cat-color); }

.timeline-istanza {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 0 12px 0 4px;
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    cursor: pointer;
}
.timeline-istanza:hover { background: var(--gray-50); color: var(--gray-800); }
.istanza-nome { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timeline-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    margin: 8px 12px;
    border: 1px dashed var(--gray-300);
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--gray-400);
    font-size: var(--font-size-xs);
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
}
.timeline-add:hover { border-color: var(--primary); color: var(--primary); }

.passo-scelta { cursor: pointer; }
.passo-scelta:hover { background: var(--gray-50); }
.passo-scelta--bloccato .list-row-label { color: var(--gray-400); flex: 1 1 auto; }
.passo-scelta--bloccato .list-row-icon { color: var(--gray-300); }
.passo-motivo {
    font-size: 11px;
    color: var(--gray-400);
    flex: 0 1 auto;
    min-width: 0;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .timeline-body { max-height: none; }
}

.passo-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: -4px;
    border: none;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--gray-300);
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0;
}
.timeline-passo:hover .passo-remove { opacity: 1; }
.passo-remove:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

.passo-chevron { font-size: 9px; color: var(--gray-300); transition: transform 0.15s ease; flex-shrink: 0; }
.timeline-passo.passo--aperto .passo-chevron { transform: rotate(180deg); color: var(--primary); }
.timeline-passo.passo--aperto { background: var(--gray-50); }

.timeline-dettagli {
    position: relative;
    margin: 2px 0 6px calc(var(--passo-asse) - 1px);
    padding: 4px 12px;
    background: var(--white);
}
.timeline-dettagli::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-left: 2px dashed var(--gray-300);
}
.timeline-dettagli[hidden] { display: none; }
.timeline-dettagli .list-row { min-height: 34px; height: auto; }
.timeline-dettagli .list-row-label { color: var(--gray-500); }
.timeline-dettagli .form-group { margin: 6px 0; }
.timeline-dettagli .form-group > label { font-size: var(--font-size-xs); color: var(--gray-500); }

.timeline-istanze { display: flex; flex-direction: column; }
.timeline-istanza {
    display: flex;
    align-items: center;
    min-height: 34px;
    padding: 0 6px;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
    color: var(--gray-600);
    cursor: pointer;
}
.timeline-istanza:hover { background: var(--gray-50); color: var(--gray-900); }
.istanza-nome { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timeline-add-istanza {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    margin-top: 4px;
    padding: 0 8px;
    border: 1px dashed var(--gray-300);
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--gray-400);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
}
.timeline-add-istanza:hover { border-color: var(--primary); color: var(--primary); }
.modal-footer [data-action="delete"] { margin-right: auto; }

#formProgetto :disabled {
    background: transparent;
    border-color: transparent;
    color: var(--gray-800);
    -webkit-text-fill-color: var(--gray-800);
    opacity: 1;
    cursor: default;
}
#formProgetto .switch-label:has(:disabled) { cursor: default; }
#formProgetto :disabled::-webkit-calendar-picker-indicator { display: none; }
#formProgetto .select-custom-trigger:disabled .fa-chevron-down { display: none; }

.lavorazione-row { gap: 8px; cursor: default; }
.lavorazione-row > * { flex: 0 0 auto; min-width: 0; }
.lavorazione-row .lav-data { width: 108px; }
.lavorazione-row .lav-descrizione { flex: 1 1 auto; min-width: 60px; }
.list-row.lavorazione-row input.lav-descrizione { text-align: left; }
.lavorazione-row .lav-num {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    width: 96px;
    color: var(--gray-400);
}
.lavorazione-row .lav-num--ore { width: 56px; }
.lavorazione-row .lav-num .input-inline { flex: 1 1 auto; width: auto; min-width: 0; text-align: right; }
.lavorazione-row .lav-num--ore .input-inline { width: 40px; }
.lavorazione-row .lav-ft { width: 66px; text-align: right; }
.lavorazione-row input:not(.input-inline) {
    border: none;
    background: transparent;
    font: inherit;
    color: inherit;
    padding: 0;
}
.lavorazione-row input:not(.input-inline):focus { outline: none; color: var(--primary); }
.lavorazione-head {
    color: var(--gray-400);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    height: 24px;
    font-weight: var(--font-weight-semibold);
}
.lavorazione-head .lav-descrizione { text-align: left; }
.lavorazione-head .lav-num,
.lavorazione-head .lav-ft { text-align: right; display: block; }

@media (max-width: 900px) {
    .lavorazione-head { display: none; }
    .lavorazione-row { flex-wrap: wrap; height: auto; padding: 6px var(--spacing-xs); }
    .lavorazione-row .lav-descrizione { flex: 1 1 100%; order: -1; }
    .lavorazione-row .lav-data { width: auto; flex: 1 1 auto; }
}

.ordine-lavoro {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    height: min(calc(90vh - 200px), 620px);
}
.ordine-lavoro > .bento-card { min-height: 0; }
.ordine-lavoro > .bento-card--lavorazioni { flex: 1 1 50%; }
.ordine-lavoro > .bento-card--voci { flex: 1 1 auto; }
.ordine-lavoro > .bento-card--descrizione { flex: 1 1 auto; min-height: 148px; }
.ordine-lavoro > .bento-card--importi { flex: 0 0 auto; }
.ordine-lavoro > .bento-card > .bento-card-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; }

@media (max-width: 900px) {
    .ordine-lavoro { height: auto; }
    .ordine-lavoro > .bento-card--lavorazioni,
    .ordine-lavoro > .bento-card--voci,
    .ordine-lavoro > .bento-card--descrizione { flex: 0 0 auto; }
    .ordine-lavoro > .bento-card > .bento-card-body { max-height: 40vh; }
}

.prev-totale { white-space: nowrap; min-width: 0; }
.prev-delta {
    margin-left: 6px;
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
}
.prev-delta.su { color: var(--danger); }
.prev-delta.giu { color: var(--success); }


.menu-contestuale a.pericolo,
.menu-contestuale a.pericolo i { color: var(--danger); }
.menu-contestuale a.pericolo:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }

.bento-card-body > .timeline-add { width: calc(100% - 24px); }

@media (max-width: 768px) and (pointer: coarse) {
    .swipe-righe .smart-row {
        position: relative;
        clip-path: inset(0 round var(--border-radius));
        touch-action: pan-y pinch-zoom;
    }
    .swipe-righe .smart-row > *:not(.sr-actions) {
        transform: translateX(calc(-1 * var(--swipe, 0px)));
        transition: transform 0.22s ease;
    }
    .swipe-righe .smart-row > .sr-actions {
        position: absolute;
        grid-area: auto;
        align-self: stretch;
        justify-self: stretch;
        right: -1px;
        top: 0;
        bottom: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: safe center;
        gap: 4px;
        padding: 8px;
        overflow-y: auto;
        scrollbar-width: none;
        background: var(--gray-100);
        border-left: 1px solid var(--gray-200);
        transform: translateX(calc(100% - var(--swipe, 0px)));
        transition: transform 0.22s ease;
    }
    .swipe-righe .smart-row > .sr-actions .btn-action {
        width: 36px;
        flex: 0 1 36px;
        min-height: 26px;
        background: var(--white);
        border-radius: 10px;
        color: var(--gray-500);
        font-size: 14px;
    }
    .swipe-righe .smart-row > .sr-actions .btn-action--danger { color: var(--danger); }
    .swipe-righe .smart-row.swipe-trascina > *,
    .swipe-righe .smart-row.swipe-trascina > .sr-actions { transition: none; }
    .swipe-righe .smart-row.swipe-aperta { border-color: var(--gray-300); }
}
