/* 1. Variabili */
:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #1f2937;
    --muted: #667085;
    --border: #d7dde5;
    --navy: #101b31;
    --navy-2: #17243d;
    --navy-3: #24324e;
    --primary: #1f6feb;
    --primary-dark: #185abc;
    --success: #1f8a4c;
    --success-dark: #176b3b;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --danger: #b42318;
    --danger-dark: #8f1d14;
    --info: #0284c7;
    --info-dark: #0369a1;
    --purple: #7c3aed;
    --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.06);
    --radius: 8px;
    --sidebar-width: 244px;
}

/* 2. Reset/base */
* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 30px;
    line-height: 1.18;
}

h2 {
    margin: 0 0 16px;
    font-size: 20px;
}

h3 {
    margin-bottom: 12px;
    font-size: 17px;
}

img {
    max-width: 100%;
}

label,
.form-label,
.checkbox-label {
    color: #344054;
    font-size: 14px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    background: #fff;
    font: inherit;
}

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

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    min-height: 0;
}

input[type="date"] {
    min-width: 170px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(31, 111, 235, 0.14);
}

input:disabled {
    color: #4b5563;
    background: #f3f4f6;
}

.muted {
    color: var(--muted);
}

.mono,
.path-note,
.technical-id {
    font-family: Consolas, Monaco, "Courier New", monospace;
}

.technical-id,
.count-note,
.path-note,
.form-note,
.current-file {
    color: var(--muted);
    font-size: 13px;
    word-break: break-word;
}

.nowrap {
    white-space: nowrap;
}

.null-value {
    color: var(--muted);
}

.logo {
    display: block;
    max-width: 180px;
    height: auto;
}

.page-logo {
    max-width: 96px;
}

/* 3. Layout app */
.app-shell {
    min-height: 100vh;
}

.main-content,
.app-main {
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 30px;
}

.page-container,
.container {
    width: min(1180px, 100%);
    margin: 0 auto;
}

.page-container-wide,
.giri-container {
    width: min(1420px, 100%);
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-box,
.login-card,
.panel,
.card,
.filter-card,
.content-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-soft);
}

.login-box,
.login-card {
    width: min(430px, 100%);
    padding: 30px;
}

.login-box .logo {
    margin: 0 auto 22px;
}

.login-box h1 {
    text-align: center;
}

.panel,
.card,
.filter-card,
.content-card {
    margin-bottom: 22px;
    padding: 22px;
}

.card-header,
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -22px -22px 18px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.card-footer {
    margin: 18px -22px -22px;
    border-top: 1px solid var(--border);
    border-bottom: 0;
}

.card-body {
    padding: 0;
}

/* 4. Sidebar */
.sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    color: #fff;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
    box-shadow: 10px 0 30px rgba(15, 23, 42, 0.12);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    padding: 20px 16px;
}

.sidebar-mobile-head {
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 66px;
    margin-bottom: 18px;
    padding: 8px 6px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.16);
}

.brand img {
    width: 46px;
    height: 46px;
    object-fit: contain;
}

.brand-copy {
    display: grid;
    gap: 2px;
}

.brand-copy strong {
    font-size: 18px;
    letter-spacing: 0;
}

.brand-copy small {
    color: #b8c2d6;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 7px;
    color: #e7edf8;
    font-weight: 800;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-badge {
    flex: 0 0 auto;
    padding: 3px 7px;
    border-radius: 999px;
    color: #dbeafe;
    background: rgba(31, 111, 235, 0.28);
    font-size: 11px;
    font-weight: 800;
}

.sidebar-footer {
    display: grid;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user {
    display: grid;
    gap: 2px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-label,
.sidebar-user span:last-child {
    color: #b8c2d6;
    font-size: 12px;
    font-weight: 800;
}

.sidebar-user strong {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 5. Mobile sidebar */
.mobile-menu-button,
.sidebar-overlay {
    display: none;
}

.sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 7px;
}

/* 6. Header pagina */
.page-header,
.app-header,
.topbar,
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.page-header {
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.page-header h1,
.app-header h1 {
    margin: 0 0 8px;
}

.page-header p {
    max-width: 720px;
    margin-bottom: 0;
    color: var(--muted);
}

.page-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.page-brand img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.eyebrow,
.module-kicker,
.app-name {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.page-name {
    font-size: 22px;
    font-weight: 900;
}

.user-menu,
.header-actions,
.nav-actions,
.actions,
.actions-inline,
.table-actions,
.page-actions,
.filter-actions,
.filters-actions,
.toolbar,
.view-switch,
.status-row,
.summary-strip,
.movement-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar {
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-soft);
}

/* 7. Card */
.card-grid,
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
    gap: 18px;
}

.module-card {
    position: relative;
    display: grid;
    gap: 10px;
    align-content: start;
    min-height: 214px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--panel);
    box-shadow: var(--shadow-soft);
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.module-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.module-card strong {
    font-size: 22px;
    line-height: 1.2;
}

.module-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    font-size: 20px;
    font-weight: 900;
}

.module-card .btn,
.module-card .button {
    align-self: end;
    margin-top: 6px;
}

.utility-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.utility-panel p {
    margin: 4px 0 0;
}

/* 8. Module cards */
.module-card-maintenance {
    border-top: 4px solid var(--primary);
}

.module-card-routes {
    border-top: 4px solid var(--success);
}

.module-card-comms {
    border-top: 4px solid var(--purple);
}

.module-card-users {
    border-top: 4px solid var(--warning);
}

.module-card-logs {
    border-top: 4px solid var(--navy-3);
}

.module-card-maintenance .module-icon {
    background: var(--primary);
}

.module-card-routes .module-icon {
    background: var(--success);
}

.module-card-comms .module-icon {
    background: var(--purple);
}

.module-card-users .module-icon {
    background: var(--warning);
}

.module-card-logs .module-icon {
    background: var(--navy-3);
}

/* 9. Bottoni */
button,
.button,
.btn,
.action-button,
.logout-button,
.secondary-button,
.small-button,
.danger-button,
.warning-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

button,
.button,
.btn,
.button-primary,
.btn-primary,
.action-button {
    color: #fff;
    background: var(--primary);
}

button:hover,
.button:hover,
.btn:hover,
.button-primary:hover,
.btn-primary:hover,
.action-button:hover {
    background: var(--primary-dark);
}

.btn-secondary,
.button-light,
.btn-light,
.secondary-button {
    color: #344054;
    background: #fff;
    border-color: var(--border);
}

.btn-secondary:hover,
.button-light:hover,
.btn-light:hover,
.secondary-button:hover {
    background: #f7f9fb;
}

.btn-success {
    color: #fff;
    background: var(--success);
}

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

.btn-warning,
.warning-button {
    color: #1f2937;
    background: #facc15;
}

.btn-warning:hover,
.warning-button:hover {
    background: #eab308;
}

.btn-danger,
.button-danger,
.danger-button,
.logout-button {
    color: #fff;
    background: var(--danger);
}

.btn-danger:hover,
.button-danger:hover,
.danger-button:hover,
.logout-button:hover {
    background: var(--danger-dark);
}

.btn-info,
.small-button {
    color: #fff;
    background: var(--info);
}

.btn-info:hover,
.small-button:hover {
    background: var(--info-dark);
}

.btn-dark {
    color: #fff;
    background: var(--navy-3);
}

.btn-dark:hover {
    background: var(--navy);
}

.btn-block {
    width: 100%;
}

.button-small,
.small-button,
.btn-sm {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

.button-small.button-light,
.small-button.button-light {
    color: #344054;
    background: #fff;
    border-color: var(--border);
}

.button-small.button-danger,
.small-button.danger-button {
    color: #fff;
    background: var(--danger);
}

.button-outline-danger {
    color: var(--danger);
    background: #fff;
    border-color: #fecdca;
}

.button-outline-danger:hover {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.small-button.warning-button {
    color: #1f2937;
    background: #facc15;
}

.small-button.warning-button:hover {
    background: #eab308;
}

.small-button.danger-button:hover {
    background: var(--danger-dark);
}

.button-disabled {
    color: #98a2b3;
    background: #eef1f5;
    border-color: #e3e7ed;
    cursor: not-allowed;
}

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

td .inline-form {
    margin-left: 6px;
}

/* 10. Form */
.login-form,
.form,
.user-form,
.machine-form,
.parts-form,
.maintenance-form,
.filters-form,
.filters {
    display: grid;
    gap: 12px;
}

.form-section {
    margin-bottom: 18px;
}

.form-section-title {
    margin-bottom: 16px;
}

.form-grid,
.form-row,
.external-tech-grid,
.detail-grid,
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

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

.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-group {
    display: grid;
    gap: 6px;
}

.form-control {
    width: 100%;
}

.form-check,
.check-card,
.checkbox-option,
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--panel-soft);
}

.check-card {
    cursor: pointer;
}

.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.route-move-dialog {
    width: min(620px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.route-move-dialog::backdrop {
    background: rgba(15, 23, 42, 0.42);
}

.route-move-form {
    padding: 20px;
}

.dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
    margin: 0;
}

.form-wide {
    max-width: 840px;
}

.form-note,
.current-file {
    margin: 4px 0 0;
}

.checkbox-list,
.person-hours-list {
    display: grid;
    gap: 10px;
}

.checkbox-list-compact {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

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

.person-checkbox {
    justify-content: flex-start;
}

.toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.conditional-panel,
.external-tech-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.external-tech-list {
    display: grid;
    gap: 14px;
}

.external-tech-header,
.giro-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.person-hours-section {
    margin-top: 18px;
}

.person-hour-row {
    max-width: 420px;
}

.signature-line {
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.machine-form,
.parts-form,
.user-form,
.filters-form,
.maintenance-form .external-tech-grid {
    grid-template-columns: 1fr;
}

.maintenance-form .form-grid:not(.form-grid-2):not(.form-grid-3) {
    grid-template-columns: 1fr;
}

/* 11. Tabelle responsive */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.table-wrap-wide {
    max-height: 70vh;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: #344054;
    background: #eef2f6;
    font-size: 13px;
    font-weight: 900;
}

tr:last-child td {
    border-bottom: 0;
}

.data-table,
.history-table,
.machines-table,
.users-table,
.detail-table,
.materials-table,
.parts-table,
.movements-table {
    min-width: 840px;
}

.editable-materials-table input,
.editable-materials-table select {
    min-width: 150px;
}

.actions-col,
.technical-col {
    white-space: nowrap;
}

/* 12. Badge */
.status-badge,
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    background: #eef2f6;
}

.badge-success,
.status-ok {
    color: var(--success);
    background: #edfdf4;
}

.badge-warning,
.status-low,
.badge-extra {
    color: #9a5b00;
    background: #fff7e6;
}

.badge-danger,
.status-empty,
.status-error,
.badge-chiuso {
    color: var(--danger);
    background: #fef3f2;
}

.badge-info,
.badge-attuale {
    color: var(--info);
    background: rgba(2, 132, 199, 0.1);
}

.badge-muted {
    color: var(--muted);
}

.badge-bozza,
.badge-programmata {
    color: var(--primary);
    background: rgba(31, 111, 235, 0.1);
}

/* 13. Alert */
.form-error,
.message-error {
    color: var(--danger);
}

.alert-success,
.alert-warning,
.alert-danger,
.alert-info,
.message {
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-weight: 800;
}

.alert-success,
.message-success {
    color: var(--success);
    background: #edfdf4;
    border-color: #b7ebc6;
}

.alert-warning,
.message-warning {
    color: #9a5b00;
    background: #fff7e6;
    border-color: #f6d49b;
}

.alert-danger,
.message-error {
    color: var(--danger);
    background: #fef3f2;
    border-color: #f2b8b5;
}

.alert-info {
    color: var(--info);
    background: rgba(2, 132, 199, 0.09);
    border-color: rgba(2, 132, 199, 0.25);
}

/* 14. Filtri */
.filter-card {
    padding: 18px;
}

.filter-wide {
    grid-column: span 2;
}

.filters-actions,
.filter-actions {
    align-self: end;
}

/* 15. Modali */
.empty-state {
    padding: 22px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    background: var(--panel-soft);
    text-align: center;
}

/* 16. Utilities */
.pdf-link {
    color: var(--primary);
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.readonly-note {
    margin: 14px 0;
    padding: 12px 14px;
    border-left: 4px solid var(--success);
    border-radius: 6px;
    background: rgba(31, 138, 76, 0.09);
}

.giri-dashboard {
    display: grid;
    gap: 18px;
}

.giri-dashboard .section-head {
    margin-bottom: 4px;
}

.giri-dashboard-sections {
    display: grid;
    gap: 18px;
}

.giri-dashboard-section {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.giri-dashboard-section h2 {
    margin-bottom: 4px;
}

.giri-section-head,
.giri-date-section,
.giri-utility-section {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.giri-date-section .date-toolbar {
    flex: 0 1 520px;
    justify-content: flex-end;
}

.giri-view-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
}

.status-dot.status-ok {
    background: var(--success);
}

.status-dot.status-error {
    background: var(--danger);
}

.summary-strip {
    margin: 16px 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.view-link {
    display: grid;
    gap: 6px;
    min-width: 220px;
    min-height: 138px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

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

.view-link-disabled {
    color: var(--muted);
    background: #eef1f5;
    cursor: not-allowed;
}

.view-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}

.filters-collapsible {
    margin: 12px 0 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.filters-collapsible[hidden] {
    display: none !important;
}

.week-grid {
    display: grid;
    gap: 18px;
}

.day-section,
.fascia-section,
.giro-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.day-section {
    overflow: hidden;
}

.day-title {
    padding: 14px 16px;
    background: #eef2f6;
}

.day-title h2 {
    margin: 0;
}

.fascia-section {
    margin: 14px;
    padding: 14px;
}

.giro-card {
    padding: 14px;
    margin-top: 12px;
}

.giro-card h4 {
    margin: 0 0 8px;
    font-size: 17px;
}

.giro-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    color: var(--muted);
    font-size: 13px;
}

.giro-note {
    margin-top: 10px;
    padding: 10px;
    border-radius: 6px;
    background: var(--panel-soft);
}

.route-code,
.client-code {
    font-weight: 900;
}

.technical-details {
    min-width: 190px;
    color: var(--muted);
    font-size: 13px;
}

.technical-details summary {
    cursor: pointer;
    color: #344054;
    font-weight: 900;
}

.technical-details div {
    margin-top: 4px;
}

.variation-detail {
    display: grid;
    gap: 4px;
    min-width: 260px;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-soft);
}

.print-panel {
    background: #fff;
}

.print-day {
    margin: 22px 0;
    break-inside: avoid;
}

.print-day h2 {
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

.print-table {
    min-width: 0;
}

.route-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    align-items: start;
}

.print-route {
    min-height: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    break-inside: avoid;
}

.print-route h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.print-route ol {
    margin: 10px 0 0;
    padding-left: 22px;
}

.print-route li {
    margin-bottom: 5px;
}

.print-route li span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.maintenance-sheet {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.print-title {
    text-align: center;
}

.sintesi-giri-page {
    background: #fff;
}

.sintesi-print-header {
    margin: 4px 0 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e1e7ef;
}

.sintesi-print-header h1 {
    margin-bottom: 6px;
    color: var(--text);
    font-size: 26px;
    font-weight: 900;
}

.sintesi-print-header p {
    margin: 0;
}

.sintesi-print-subtitle {
    color: var(--text);
    font-size: 16px;
    font-weight: 800;
}

.sintesi-print-range {
    margin-top: 4px !important;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.print-range {
    display: none;
}

.sintesi-day-block {
    margin: 0 0 28px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-soft);
    break-inside: avoid;
    page-break-inside: avoid;
}

.sintesi-day-block + .sintesi-day-block {
    margin-top: 26px;
}

.sintesi-day-title {
    margin: 0 0 13px;
    padding: 0 0 10px;
    border-bottom: 1px solid #e1e7ef;
    color: var(--navy-2);
    font-size: 20px;
    font-weight: 900;
    line-height: 1.2;
}

.sintesi-table-wrap {
    overflow: hidden;
    border-radius: 7px;
}

.sintesi-table {
    min-width: 0;
    table-layout: fixed;
}

.sintesi-table th,
.sintesi-table td {
    padding: 12px 14px;
    border: 1px solid #d8dee6;
    vertical-align: middle;
}

.sintesi-table th {
    background: #eef2f6;
    color: #344054;
    font-weight: 900;
}

.sintesi-table th:first-child,
.sintesi-table td:first-child {
    width: 24%;
}

.sintesi-table th:nth-child(2),
.sintesi-table td:nth-child(2),
.sintesi-table th:nth-child(3),
.sintesi-table td:nth-child(3) {
    width: 38%;
}

.mode-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 18px;
}

.mode-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #344054;
    background: #fff;
    font-weight: 800;
}

.mode-tab.active {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
}

.client-search-form,
.variazioni-filters {
    margin: 14px 0 18px;
}

.client-management-form {
    max-width: none;
}

.dettaglio-print-title {
    margin: 4px 0 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e1e7ef;
}

.dettaglio-day-page {
    margin: 0 0 24px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.dettaglio-day-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.dettaglio-day-header p {
    margin: 0;
    color: var(--muted);
    font-weight: 800;
}

.dettaglio-day-title {
    margin: 0;
    color: var(--navy-2);
    font-size: 22px;
    font-weight: 900;
}

.dettaglio-period-section {
    margin: 18px 0 0;
}

.dettaglio-period-title {
    margin: 0 0 10px;
    color: #344054;
    font-size: 17px;
    font-weight: 900;
}

.period-routes-grid,
.dettaglio-route-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    align-items: start;
    width: 100%;
}

.route-card,
.dettaglio-route-card {
    min-width: 0;
    padding: 10px;
    border: 1px solid #d9e2ef;
    border-radius: 8px;
    background: #fff;
    break-inside: avoid;
    page-break-inside: avoid;
}

.route-card-header,
.dettaglio-route-head {
    display: grid;
    gap: 3px;
    margin-bottom: 9px;
    padding-bottom: 8px;
    border-bottom: 1px solid #d8dee6;
}

.route-card-header strong,
.dettaglio-route-head strong {
    color: var(--navy-2);
}

.route-card-header span,
.dettaglio-route-head span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.route-clients,
.dettaglio-client-list {
    margin: 0;
    padding-left: 20px;
}

.route-clients li,
.dettaglio-client-list li {
    margin-bottom: 4px;
    font-weight: 800;
}

.sheet-section {
    margin: 22px 0;
}

.text-block {
    white-space: pre-wrap;
}

.signature-section {
    margin-top: 34px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.movement-nav a.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

/* COMUNICAZIONI */
.sidebar-group {
    display: grid;
    gap: 6px;
}

.sidebar-subnav {
    display: grid;
    gap: 4px;
    margin: -2px 0 4px 14px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.sidebar-nav .sidebar-subnav a {
    min-height: 34px;
    padding: 7px 10px;
    color: #c9d4e8;
    font-size: 13px;
    font-weight: 800;
}

.sidebar-nav .sidebar-subnav a.active,
.sidebar-nav .sidebar-subnav a:hover {
    color: #fff;
    background: rgba(31, 111, 235, 0.38);
}

.comunicazioni-page .page-container {
    width: min(1320px, 100%);
}

.comm-stats-grid,
.comm-quick-grid,
.comm-choice-grid,
.comm-channel-grid,
.comm-detail-grid,
.comm-settings-grid {
    display: grid;
    gap: 16px;
}

.comm-stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 22px;
}

.comm-stat-card,
.comm-quick-card,
.comm-choice-card,
.comm-channel-card,
.comm-recipient-box,
.comm-template-option,
.comm-send-note,
.comm-disabled-channel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.comm-stat-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-height: 132px;
    padding: 18px;
}

.comm-stat-card strong {
    display: block;
    margin-bottom: 2px;
    color: var(--navy);
    font-size: 34px;
    line-height: 1;
}

.comm-stat-card span:not(.comm-icon) {
    display: block;
    margin-bottom: 4px;
    font-weight: 900;
}

.comm-stat-card p,
.comm-quick-card small,
.comm-choice-card small,
.comm-channel-card small,
.comm-send-note span,
.comm-template-option small,
.comm-disabled-channel p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.comm-icon {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    font-weight: 900;
}

.comm-stat-draft .comm-icon {
    background: var(--muted);
}

.comm-stat-scheduled .comm-icon {
    color: #1f2937;
    background: #facc15;
}

.comm-stat-sent .comm-icon,
.dot-success {
    background: var(--success);
}

.comm-stat-error .comm-icon,
.dot-danger {
    background: var(--danger);
}

.comm-quick-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.comm-quick-card {
    display: grid;
    gap: 8px;
    min-height: 142px;
    padding: 16px;
}

.comm-quick-card:hover,
.comm-choice-card:hover,
.comm-template-option:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.comm-quick-card strong {
    font-size: 16px;
}

.comm-wizard-form {
    display: grid;
    gap: 18px;
}

.comm-wizard-steps {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 0;
    overflow-x: auto;
    padding: 6px 0 2px;
}

.comm-step {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 7px;
    min-width: 132px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}

.comm-step::before {
    content: "";
    position: absolute;
    top: 17px;
    left: 0;
    right: 0;
    height: 2px;
    background: #dbe2ea;
}

.comm-step:first-child::before {
    left: 50%;
}

.comm-step:last-child::before {
    right: 50%;
}

.comm-step strong {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--muted);
    background: #e8edf3;
}

.comm-step.is-active {
    color: var(--primary);
}

.comm-step.is-active strong {
    color: #fff;
    background: var(--primary);
}

.comm-step.is-complete {
    color: var(--success);
}

.comm-step.is-complete strong {
    color: #fff;
    background: var(--success);
}

.comm-choice-grid {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.comm-choice-card,
.comm-channel-card {
    display: grid;
    gap: 8px;
    min-height: 150px;
    padding: 16px;
    cursor: pointer;
}

.comm-choice-card input,
.comm-channel-card input,
.comm-template-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.comm-choice-card:has(input:checked),
.comm-channel-card:has(input:checked),
.comm-template-option:has(input:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.14), var(--shadow-soft);
}

.comm-channel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.comm-channel-card.is-disabled {
    color: var(--muted);
    background: #f4f6f9;
    cursor: not-allowed;
}

.comm-channel-card.is-disabled .comm-icon,
.dot-warning {
    background: var(--warning);
}

.comm-recipient-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.comm-recipient-box {
    padding: 16px;
}

.comm-recipient-box h3,
.comm-variable-panel h3,
.comm-members-panel h3,
.comm-template-preview h3 {
    margin-bottom: 10px;
}

.comm-check-list {
    max-height: 270px;
    overflow: auto;
    padding-right: 4px;
}

.comm-check-list small,
.checkbox-option small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.comm-disabled-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.communication-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.communication-card {
    display: grid;
    gap: 8px;
    min-height: 132px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.communication-card strong {
    color: var(--navy);
    font-size: 30px;
    line-height: 1;
}

.communication-card small {
    color: var(--muted);
    font-weight: 800;
}

.whatsapp-status-badge {
    white-space: nowrap;
}

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

.conversation-list {
    max-height: calc(100vh - 150px);
    overflow: auto;
}

.conversation-items {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.conversation-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: inherit;
}

.conversation-item:hover,
.conversation-item.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.conversation-item strong,
.conversation-item small,
.conversation-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item small,
.conversation-preview {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.conversation-preview {
    grid-column: 1 / -1;
}

.conversation-meta {
    display: grid;
    gap: 4px;
    justify-items: end;
}

.message-list {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 320px);
    min-height: 320px;
    overflow: auto;
    padding: 4px;
}

.message-row {
    display: flex;
}

.message-row.is-outbound {
    justify-content: flex-end;
}

.message-row.is-inbound {
    justify-content: flex-start;
}

.message-bubble {
    width: fit-content;
    max-width: min(680px, 82%);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.message-bubble p {
    margin: 0 0 6px;
}

.message-bubble small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.message-bubble-inbound {
    background: #fff;
}

.message-bubble-outbound {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.log-json-box {
    max-height: 360px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.config-secret-field {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.badge-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.badge-ref-email {
    color: #075985;
    background: #e0f2fe;
}

.badge-ref-phone {
    color: #155e75;
    background: #cffafe;
}

.badge-ref-whatsapp {
    color: #166534;
    background: #dcfce7;
}

.badge-ref-pec {
    color: #7c2d12;
    background: #ffedd5;
}

.badge-preferred {
    color: #854d0e;
    background: #fef9c3;
}

.badge-secondary-ref {
    color: #334155;
    background: #e2e8f0;
}

.badge-alternate-ref {
    color: #6d28d9;
    background: #ede9fe;
}

.badge-origin-mistral {
    color: #1d4ed8;
    background: #dbeafe;
}

.badge-origin-manuale {
    color: #047857;
    background: #d1fae5;
}

.badge-valid {
    color: var(--success);
    background: #edfdf4;
}

.badge-invalid {
    color: var(--danger);
    background: #fef3f2;
}

.preview-nuovo,
.preview-row-nuovo .badge {
    color: #047857;
    background: #d1fae5;
}

.preview-aggiornato,
.preview-row-aggiornato .badge {
    color: #075985;
    background: #e0f2fe;
}

.preview-errore,
.preview-row-errore .badge {
    color: var(--danger);
    background: #fef3f2;
}

.preview-duplicato,
.preview-row-duplicato .badge {
    color: #92400e;
    background: #fef3c7;
}

.preview-obsoleto,
.preview-row-obsoleto .badge {
    color: #475569;
    background: #e2e8f0;
}

.preview-row {
    background: #fff;
}

.preview-row-errore,
.preview-row-duplicato,
.preview-row-obsoleto {
    background: #fffaf5;
}

.comm-member-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.comm-final-confirm {
    margin-top: 14px;
}

.comm-template-picker,
.comm-template-form-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
    gap: 16px;
    align-items: start;
}

.alert-warning,
.alert-success,
.alert-error {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 800;
}

.alert-warning {
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
}

.alert-success {
    color: var(--success);
    background: #edfdf4;
    border: 1px solid #bbf7d0;
}

.alert-error {
    color: var(--danger);
    background: #fef3f2;
    border: 1px solid #fecaca;
}

.comm-template-list {
    display: grid;
    gap: 10px;
}

.comm-template-option {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 13px;
    cursor: pointer;
}

.comm-template-preview,
.comm-variable-panel,
.comm-members-panel {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
}

.comm-preview-subject {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    font-weight: 900;
}

.comm-email-preview {
    min-height: 160px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: #344054;
}

.comm-email-preview p:last-child {
    margin-bottom: 0;
}

.comm-send-note {
    display: grid;
    gap: 4px;
    align-content: center;
    min-height: 72px;
    padding: 12px 14px;
    background: #f8fafc;
}

.comm-preview-recipients {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.comm-preview-recipients > div {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
}

.comm-preview-recipients ul {
    display: grid;
    gap: 6px;
    max-height: 180px;
    margin: 0;
    padding-left: 18px;
    overflow: auto;
}

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

.comm-variable-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.comm-variable-list code {
    padding: 6px 8px;
    border: 1px solid #dbe2ea;
    border-radius: 6px;
    color: var(--primary);
    background: #fff;
    font-size: 12px;
    font-weight: 900;
}

.comm-template-form-main {
    display: grid;
    gap: 12px;
}

.comm-table .table-link {
    color: var(--primary);
    font-weight: 900;
}

.comm-table .empty-row,
.empty-row {
    padding: 22px;
    color: var(--muted);
    text-align: center;
}

.comm-detail-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.7fr);
    align-items: stretch;
}

.comm-detail-card,
.comm-status-card {
    min-height: 100%;
}

.comm-definition-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.comm-definition-grid div {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
}

.comm-definition-grid dt {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.comm-definition-grid dd {
    margin: 0;
    font-weight: 800;
}

.comm-status-card {
    display: grid;
    justify-items: center;
    gap: 16px;
    text-align: center;
}

.comm-status-ring {
    display: grid;
    place-items: center;
    align-content: center;
    width: 156px;
    height: 156px;
    border: 14px solid #dbeafe;
    border-top-color: var(--success);
    border-right-color: var(--warning);
    border-bottom-color: var(--danger);
    border-radius: 50%;
    background: #fff;
}

.comm-status-ring strong {
    font-size: 34px;
    line-height: 1;
}

.comm-status-ring span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.comm-status-summary {
    display: grid;
    gap: 8px;
    justify-items: start;
}

.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 7px;
    border-radius: 50%;
}

.comm-settings-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
    align-items: start;
}

.comm-test-form {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.comm-disabled-channel {
    display: grid;
    gap: 10px;
    justify-items: center;
    padding: 28px;
    text-align: center;
    background: var(--panel-soft);
}

.comm-disabled-channel .comm-icon {
    background: var(--muted);
}

/* 17. Responsive */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 232px;
    }

    .main-content,
    .app-main {
        padding: 24px;
    }

    .comm-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .comm-settings-grid,
    .comm-detail-grid,
    .comm-template-picker,
    .comm-template-form-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    h1 {
        font-size: 25px;
    }

    .mobile-menu-button {
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 70;
        display: inline-flex;
        flex-direction: column;
        gap: 4px;
        width: 42px;
        height: 42px;
        min-height: 42px;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: #fff;
        box-shadow: var(--shadow);
    }

    .mobile-menu-button span {
        display: block;
        width: 100%;
        height: 2px;
        background: var(--text);
    }

    .sidebar-overlay {
        position: fixed;
        z-index: 45;
        inset: 0;
        background: rgba(15, 23, 42, 0.46);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .sidebar {
        width: min(84vw, 310px);
        max-width: 310px;
        transform: translateX(-105%);
        transition: transform 180ms ease;
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-mobile-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 8px;
        color: #d8e0ef;
        font-weight: 900;
    }

    .main-content,
    .app-main {
        margin-left: 0;
        padding: 70px 14px 20px;
    }

    .page-container,
    .container,
    .page-container-wide,
    .giri-container {
        width: 100%;
    }

    .page-header,
    .app-header,
    .topbar,
    .section-head,
    .giri-section-head,
    .giri-date-section,
    .giri-utility-section,
    .utility-panel,
    .giro-card-header {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .page-actions,
    .header-actions,
    .actions,
    .actions-inline,
    .nav-actions,
    .view-toolbar,
    .filter-actions,
    .filters-actions,
    .form-actions,
    .toolbar {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .page-actions > *,
    .header-actions > *,
    .actions > *,
    .actions-inline > *,
    .nav-actions > *,
    .view-toolbar > *,
    .filter-actions > *,
    .filters-actions > *,
    .form-actions > *,
    .toolbar > *,
    .table-actions > *,
    button,
    .button,
    .btn,
    .action-button,
    .secondary-button,
    .small-button {
        width: 100%;
    }

    .panel,
    .card,
    .filter-card,
    .content-card,
    .login-card,
    .login-box {
        padding: 16px;
    }

    .card-header,
    .card-footer {
        margin-right: -16px;
        margin-left: -16px;
    }

    .module-grid,
    .card-grid,
    .comm-stats-grid,
    .communication-grid,
    .comm-choice-grid,
    .comm-channel-grid,
    .comm-recipient-layout,
    .comm-member-layout,
    .whatsapp-inbox-layout,
    .comm-preview-recipients,
    .comm-quick-grid,
    .giri-view-switch,
    .filter-grid,
    .form-grid,
    .form-row,
    .external-tech-grid,
    .detail-grid,
    .checkbox-list-compact,
    .permissions-grid,
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    .comm-wizard-steps {
        grid-template-columns: repeat(5, 150px);
    }

    .comm-stat-card,
    .comm-quick-card,
    .comm-choice-card,
    .comm-channel-card {
        min-height: auto;
    }

    .comm-definition-grid {
        grid-template-columns: 1fr;
    }

    .filter-wide {
        grid-column: auto;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
    }

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

    table.responsive-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

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

    table.responsive-table tr {
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: #fff;
        box-shadow: var(--shadow-soft);
    }

    table.responsive-table td {
        display: grid;
        grid-template-columns: minmax(112px, 38%) 1fr;
        gap: 10px;
        padding: 9px 0;
        border-bottom: 1px solid #eef2f6;
    }

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

    table.responsive-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 900;
    }

    table.responsive-table td[colspan] {
        display: block;
    }

    table.responsive-table td[colspan]::before {
        content: "";
        display: none;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 23px;
    }

    h2 {
        font-size: 18px;
    }

    .module-card {
        min-height: 160px;
        padding: 18px;
    }

    table.responsive-table td {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* COMUNICAZIONI MODERNE */
.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;
}

.ui-icon,
.sidebar-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
}

.sidebar-toggle-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 0;
    border-radius: 7px;
    color: #e7edf8;
    background: transparent;
    font: inherit;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
}

.sidebar-toggle-link:hover,
.sidebar-toggle-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-link-copy,
.sidebar-subnav a {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.sidebar-chevron {
    color: #b8c2d6;
    font-size: 12px;
    transition: transform 160ms ease;
}

.sidebar-group.is-open .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-group:not(.is-open) .sidebar-subnav {
    display: none;
}

.sidebar-nav .sidebar-subnav a {
    justify-content: flex-start;
}

.sidebar-nav .sidebar-subnav .sidebar-icon {
    width: 16px;
    height: 16px;
}

.comms-modern-page {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: #f5f7fb;
}

.comms-modern-page .page-container {
    width: min(1440px, 100%);
}

.comm-module {
    display: grid;
    gap: 18px;
    color: #0f172a;
}

.comm-page-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 2px;
}

.comm-page-top h1 {
    margin: 0 0 7px;
    color: #0f172a;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0;
}

.comm-page-top p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

.comm-breadcrumb {
    margin-bottom: 8px !important;
    color: #2563eb !important;
    font-size: 12px !important;
    font-weight: 700;
}

.comm-top-actions,
.comm-inline-actions,
.comm-form-actions,
.comm-table-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.comm-top-actions {
    justify-content: flex-end;
}

.comm-top-actions select,
.comm-top-actions input,
.comm-date-pill {
    width: auto;
    min-width: 150px;
    min-height: 40px;
    border-radius: 10px;
    border-color: #dbe3ef;
    background: #fff;
    font-size: 13px;
    font-weight: 700;
}

.comm-date-pill {
    display: inline-flex;
    align-items: center;
    padding: 0 13px;
    color: #334155;
}

.comm-icon-button {
    gap: 8px;
    border-radius: 999px;
}

.comm-panel,
.comm-kpi-card {
    border: 1px solid #dfe7f2;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.045);
}

.comm-panel {
    padding: 18px;
}

.comm-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.comm-panel-head h2 {
    margin: 0;
    color: #0f172a;
    font-size: 16px;
    font-weight: 800;
}

.comm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.comm-kpi-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    min-height: 128px;
    padding: 18px;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.comm-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.comm-kpi-label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 800;
}

.comm-kpi-card strong {
    display: block;
    color: #0f172a;
    font-size: 34px;
    line-height: 1;
}

.comm-kpi-card small {
    display: block;
    margin-top: 10px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.comm-kpi-card small[data-direction="up"] {
    color: #16a34a;
}

.comm-kpi-card small[data-direction="down"] {
    color: #ef4444;
}

.comm-kpi-icon,
.comm-activity-icon,
.comm-mini-icon,
.comm-send-round {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
}

.comm-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
}

.comm-kpi-card.is-mail .comm-kpi-label,
.comm-kpi-card.is-mail .comm-kpi-icon {
    color: #2563eb;
}

.comm-kpi-card.is-mail .comm-kpi-icon {
    background: #eff6ff;
}

.comm-kpi-card.is-whatsapp .comm-kpi-label,
.comm-kpi-card.is-whatsapp .comm-kpi-icon {
    color: #22c55e;
}

.comm-kpi-card.is-whatsapp .comm-kpi-icon {
    background: #f0fdf4;
}

.comm-kpi-card.is-danger .comm-kpi-label,
.comm-kpi-card.is-danger .comm-kpi-icon {
    color: #ef4444;
}

.comm-kpi-card.is-danger .comm-kpi-icon {
    background: #fef2f2;
}

.comm-kpi-card.is-purple .comm-kpi-label,
.comm-kpi-card.is-purple .comm-kpi-icon {
    color: #8b5cf6;
}

.comm-kpi-card.is-purple .comm-kpi-icon {
    background: #f5f3ff;
}

.comm-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: 16px;
}

.comm-chart-wrap {
    width: min(240px, 100%);
    margin: 0 auto;
}

.comm-donut-layout {
    display: grid;
    grid-template-columns: minmax(170px, 240px) minmax(160px, 1fr);
    gap: 16px;
    align-items: center;
}

.comm-chart-legend {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.comm-chart-legend li {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.comm-chart-legend span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dot-color, #2563eb);
}

.comm-chart-legend em {
    font-style: normal;
}

.comm-chart-legend strong {
    color: #0f172a;
}

.comm-chart-legend .is-total {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-top: 7px;
    border-top: 1px solid #eef2f7;
}

.comm-line-chart-wrap {
    height: 260px;
}

.comm-activity-list {
    display: grid;
    gap: 10px;
}

.comm-activity-item {
    display: grid;
    grid-template-columns: 46px 34px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eef2f7;
}

.comm-activity-item:last-child {
    border-bottom: 0;
}

.comm-activity-item time {
    color: #475569;
    font-size: 12px;
    font-weight: 800;
}

.comm-activity-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
}

.comm-activity-icon.is-mail {
    color: #2563eb;
    background: #eff6ff;
}

.comm-activity-icon.is-whatsapp {
    color: #22c55e;
    background: #f0fdf4;
}

.comm-activity-item strong,
.comm-activity-item small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comm-activity-item strong {
    font-size: 13px;
}

.comm-activity-item small {
    color: #64748b;
    font-size: 12px;
}

.comm-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.comm-status-pill.is-ok {
    color: #15803d;
    background: #dcfce7;
}

.comm-status-pill.is-failed {
    color: #dc2626;
    background: #fee2e2;
}

.comm-status-pill.is-received {
    color: #2563eb;
    background: #dbeafe;
}

.comm-status-pill.is-read {
    color: #7c3aed;
    background: #ede9fe;
}

.comm-status-pill.is-pending {
    color: #64748b;
    background: #f1f5f9;
}

.comm-table-scroll {
    width: 100%;
    overflow-x: auto;
}

.comm-modern-table {
    min-width: 680px;
    border-collapse: separate;
    border-spacing: 0;
}

.comm-modern-table th,
.comm-modern-table td {
    padding: 13px 12px;
    border-bottom: 1px solid #eef2f7;
    background: #fff;
    vertical-align: middle;
}

.comm-modern-table th {
    color: #64748b;
    background: #fff;
    font-size: 12px;
    font-weight: 800;
}

.comm-modern-table tr:hover td {
    background: #f8fafc;
}

.comm-modern-table td small {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
}

.comm-channel-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.comm-channel-name.is-mail {
    color: #2563eb;
}

.comm-channel-name.is-whatsapp {
    color: #16a34a;
}

.comm-empty {
    margin: 0;
    padding: 18px;
    color: #64748b;
    text-align: center;
}

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

.comm-mail-main {
    display: grid;
    gap: 16px;
}

.comm-recipient-search,
.comm-filter-row,
.comm-form-grid {
    display: grid;
    gap: 12px;
    align-items: end;
}

.comm-recipient-search {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 10px;
}

.comm-form-grid.two {
    grid-template-columns: minmax(0, 1fr) auto;
}

.comm-form-grid.three,
.comm-filter-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

.comm-filter-row .wide {
    grid-column: span 2;
}

.comm-form-end {
    display: flex;
    justify-content: flex-end;
    align-items: end;
}

.comm-inline-actions {
    margin: 10px 0;
}

.comm-selected-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 34px;
    margin-top: 10px;
}

.comm-selected-pills span {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 999px;
    color: #334155;
    background: #f1f5f9;
    font-size: 12px;
    font-weight: 800;
}

.comm-recipient-results {
    display: grid;
    gap: 8px;
    max-height: 230px;
    margin-top: 12px;
    overflow: auto;
}

.comm-recipient-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
}

.comm-recipient-option:hover {
    border-color: #bfdbfe;
    background: #f8fafc;
}

.comm-recipient-option strong,
.comm-recipient-option small {
    display: block;
}

.comm-recipient-option small {
    color: #64748b;
    font-size: 12px;
}

.comm-collapsible-panel {
    margin-top: 10px;
}

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

.comm-editor {
    overflow: hidden;
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    background: #fff;
}

.comm-editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    min-height: 40px;
    padding: 6px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.comm-editor-toolbar button {
    width: auto;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #334155;
    background: transparent;
    font-size: 12px;
}

.comm-mini-icon {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #334155;
    background: transparent;
    font-size: 12px;
}

.comm-editor-toolbar button:hover,
.comm-mini-icon:hover {
    color: #2563eb;
    background: #eff6ff;
}

.comm-editor-area {
    min-height: 210px;
    padding: 14px;
    color: #0f172a;
    outline: none;
}

.comm-check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.comm-options-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.comm-mail-preview {
    position: sticky;
    top: 24px;
    min-height: 520px;
}

.comm-preview-meta {
    display: grid;
    gap: 4px;
    margin-bottom: 16px;
    color: #334155;
    font-size: 13px;
}

.comm-preview-meta strong {
    color: #0f172a;
}

.comm-preview-body {
    color: #0f172a;
    font-size: 14px;
    line-height: 1.65;
}

.comm-wa-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 310px;
    gap: 16px;
    align-items: stretch;
    min-height: calc(100vh - 150px);
}

.comm-wa-conversations,
.comm-wa-chat,
.comm-wa-detail {
    min-height: 620px;
}

.comm-wa-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 8px;
    margin-bottom: 12px;
}

.comm-segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: #f1f5f9;
}

.comm-segmented a {
    display: inline-flex;
    justify-content: center;
    min-height: 30px;
    padding: 7px 8px;
    border-radius: 999px;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.comm-segmented a.is-active {
    color: #0f172a;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.comm-wa-thread-list {
    display: grid;
    gap: 8px;
    max-height: calc(100vh - 270px);
    margin-top: 14px;
    overflow: auto;
}

.comm-wa-conversation {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 14px;
}

.comm-wa-conversation:hover,
.comm-wa-conversation.is-active {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.comm-avatar {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: #0f766e;
    background: #ccfbf1;
    font-size: 12px;
    font-weight: 900;
}

.comm-avatar.large {
    width: 62px;
    height: 62px;
    margin-bottom: 10px;
    font-size: 16px;
}

.comm-wa-copy {
    min-width: 0;
}

.comm-wa-copy strong,
.comm-wa-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comm-wa-copy small,
.comm-wa-meta time {
    color: #64748b;
    font-size: 12px;
}

.comm-wa-meta {
    display: grid;
    justify-items: end;
    gap: 5px;
}

.comm-wa-meta em {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    color: #fff;
    background: #22c55e;
    font-style: normal;
    font-size: 11px;
    font-weight: 900;
}

.comm-wa-chat {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 0;
    overflow: hidden;
}

.comm-wa-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.comm-wa-chat-head h2 {
    margin: 0 0 3px;
    font-size: 16px;
}

.comm-wa-chat-head p {
    margin: 0;
    color: #64748b;
    font-size: 12px;
}

.comm-wa-chat-actions {
    display: flex;
    gap: 6px;
}

.comm-mobile-back {
    display: none;
}

.comm-wa-messages {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 18px;
    overflow: auto;
    background: #f8fafc;
}

.comm-wa-message {
    display: flex;
}

.comm-wa-message.is-outbound {
    justify-content: flex-end;
}

.comm-wa-message.is-inbound {
    justify-content: flex-start;
}

.comm-wa-message > div {
    max-width: min(560px, 78%);
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.035);
}

.comm-wa-message.is-outbound > div {
    border-color: #bbf7d0;
    background: #dcfce7;
}

.comm-wa-message p {
    margin: 0 0 5px;
}

.comm-wa-message small {
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
}

.comm-wa-input {
    display: grid;
    grid-template-columns: 34px 34px minmax(0, 1fr) 40px;
    gap: 8px;
    align-items: center;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.comm-wa-input textarea {
    min-height: 40px;
    max-height: 120px;
    border-radius: 999px;
    resize: none;
}

.comm-send-round {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 50%;
    color: #fff;
    background: #22c55e;
}

.comm-client-card {
    display: grid;
    justify-items: center;
    margin-bottom: 16px;
    text-align: center;
}

.comm-client-card strong,
.comm-client-card small {
    display: block;
}

.comm-client-card small {
    color: #64748b;
    font-size: 12px;
}

.comm-detail-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.comm-detail-list div,
.comm-history-mini div {
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
}

.comm-detail-list dt {
    margin-bottom: 3px;
    color: #64748b;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.comm-detail-list dd {
    margin: 0;
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    word-break: break-word;
}

.comm-history-mini {
    display: grid;
    gap: 9px;
    margin-top: 18px;
}

.comm-history-mini h3 {
    margin: 0 0 2px;
    font-size: 14px;
}

.comm-history-mini div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.comm-history-mini strong {
    color: #0f172a;
}

.comm-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid #e2e8f0;
}

.comm-tabs a {
    padding: 10px 12px;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-weight: 800;
}

.comm-tabs a.is-active {
    border-color: #2563eb;
    color: #2563eb;
}

.comm-template-edit {
    display: grid;
    gap: 14px;
}

.comm-log-drawer {
    position: fixed;
    z-index: 85;
    top: 0;
    right: 0;
    width: min(520px, 92vw);
    height: 100vh;
    padding: 18px;
    border-left: 1px solid #dbe3ef;
    background: #fff;
    box-shadow: -18px 0 40px rgba(15, 23, 42, 0.16);
}

.comm-log-drawer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.comm-log-drawer-head strong,
.comm-log-drawer-head small {
    display: block;
}

.comm-log-drawer-head small {
    margin-top: 3px;
    color: #64748b;
}

.comm-log-drawer pre {
    max-height: calc(100vh - 100px);
    margin: 0;
    overflow: auto;
    padding: 14px;
    border-radius: 12px;
    color: #e2e8f0;
    background: #0f172a;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.comm-drawer-backdrop {
    position: fixed;
    z-index: 80;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
}

@media (max-width: 1180px) {
    .comm-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .comm-dashboard-grid,
    .comm-mail-layout {
        grid-template-columns: 1fr;
    }

    .comm-mail-preview {
        position: static;
        min-height: 300px;
    }

    .comm-wa-layout {
        grid-template-columns: 300px minmax(0, 1fr);
    }

    .comm-wa-detail {
        display: none;
    }
}

@media (max-width: 768px) {
    .comms-modern-page .main-content,
    .comms-modern-page .app-main,
    .comms-modern-page .page-container {
        max-width: 100%;
        overflow-x: hidden;
    }

    .comm-module,
    .comm-panel,
    .comm-page-top,
    .comm-top-actions {
        min-width: 0;
        width: 100%;
    }

    .comm-page-top,
    .comm-top-actions,
    .comm-options-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .comm-page-top h1 {
        font-size: 24px;
    }

    .comm-page-top p {
        overflow-wrap: anywhere;
    }

    .comm-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .comm-kpi-card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 34px;
        min-height: 116px;
        min-width: 0;
        padding: 12px;
    }

    .comm-kpi-card strong {
        font-size: 28px;
    }

    .comm-kpi-icon {
        width: 34px;
        height: 34px;
    }

    .comm-kpi-label {
        overflow-wrap: anywhere;
    }

    .comm-donut-layout,
    .comm-recipient-search,
    .comm-form-grid.two,
    .comm-form-grid.three,
    .comm-filter-row {
        grid-template-columns: 1fr;
    }

    .comm-filter-row .wide {
        grid-column: auto;
    }

    .comm-form-end {
        justify-content: stretch;
    }

    .comm-form-end > *,
    .comm-top-actions > *,
    .comm-form-actions > * {
        width: 100%;
    }

    .comm-activity-item {
        grid-template-columns: 42px 30px minmax(0, 1fr);
    }

    .comm-activity-item .comm-status-pill {
        grid-column: 3;
        justify-self: start;
    }

    .comm-modern-table {
        min-width: 720px;
    }

    .comm-wa-layout {
        display: block;
        min-height: calc(100vh - 98px);
    }

    .comm-wa-conversations {
        min-height: calc(100vh - 120px);
    }

    .comm-wa-chat {
        display: none;
        min-height: calc(100vh - 96px);
    }

    .comm-whatsapp-shell.is-chat-open .comm-wa-conversations {
        display: none;
    }

    .comm-whatsapp-shell.is-chat-open .comm-wa-chat {
        display: grid;
    }

    .comm-mobile-back {
        display: inline-flex;
        width: auto;
        min-height: 34px;
        padding: 7px 10px;
        border-radius: 999px;
        color: #2563eb;
        background: #eff6ff;
    }

    .comm-wa-chat-head {
        position: sticky;
        top: 0;
        z-index: 2;
        background: #fff;
    }

    .comm-wa-input {
        position: sticky;
        bottom: 0;
    }
}

@media (max-width: 480px) {
    .comm-kpi-card {
        gap: 8px;
    }

    .comm-kpi-label {
        margin-bottom: 8px;
        font-size: 12px;
    }

    .comm-kpi-card small {
        font-size: 11px;
    }

    .comm-wa-message > div {
        max-width: 88%;
    }
}

@media print {
    @page {
        size: A4 portrait;
        margin: 8mm;
    }

    @page sintesi-giri-portrait {
        size: A4 portrait;
        margin: 8mm 10mm;
    }

    @page dettaglio-giri-landscape {
        size: A4 landscape;
        margin: 6mm;
    }

    body {
        background: #fff;
    }

    .no-print,
    .page-header,
    .topbar,
    .sidebar,
    .mobile-menu-button,
    .sidebar-overlay,
    .view-toolbar,
    .filters,
    .filters-form,
    .filter-card,
    .readonly-note,
    button,
    .button,
    .btn {
        display: none !important;
    }

    .main-content,
    .app-main,
    .page-container,
    .page-container-wide,
    .giri-container {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .panel,
    .card,
    .content-card,
    .giri-print-view {
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .section-head {
        margin-bottom: 10px;
        padding-bottom: 8px;
        border-bottom: 1px solid #9ca3af;
    }

    .summary-strip {
        margin: 8px 0 12px;
        padding: 8px 0;
        border: 0;
        border-bottom: 1px solid #d1d5db;
        border-radius: 0;
        background: #fff;
    }

    .day-section,
    .fascia-section,
    .giro-card,
    .print-day,
    .print-route {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .day-section,
    .fascia-section,
    .giro-card {
        border-color: #d1d5db;
        box-shadow: none;
    }

    .day-title {
        padding: 8px 0;
        background: #fff;
        border-bottom: 1px solid #d1d5db;
    }

    .day-title .technical-id,
    .technical-details,
    .technical-col {
        display: none !important;
    }

    .fascia-section {
        margin: 10px 0;
        padding: 8px 0;
        border: 0;
    }

    .giro-card {
        margin-top: 8px;
        padding: 8px 0;
        border-width: 0 0 1px;
        border-radius: 0;
    }

    .giro-card-header {
        break-after: avoid;
        page-break-after: avoid;
        margin-bottom: 6px;
    }

    .giro-meta {
        gap: 4px 10px;
        font-size: 11px;
    }

    .table-wrap,
    .print-panel .table-wrap {
        overflow: visible;
        border: 0;
    }

    .data-table,
    .client-list,
    .print-table {
        min-width: 0;
        font-size: 10px;
    }

    th,
    td {
        padding: 5px 6px;
        border-bottom-color: #d1d5db;
    }

    th {
        background: #f3f4f6;
        color: #111827;
        font-size: 10px;
    }

    .maintenance-sheet {
        border: 0;
        box-shadow: none;
    }

    .print-panel,
    .print-route {
        border: 0;
        box-shadow: none;
    }

    .print-panel {
        padding: 0;
    }

    .print-panel .table-wrap {
        overflow: visible;
        border: 0;
    }

    .route-columns {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    body:has(.dettaglio-giri-page) {
        background: #fff !important;
        width: 297mm;
        min-height: 210mm;
        font-size: 8.5px;
    }

    body:has(.dettaglio-giri-page) .sidebar,
    body:has(.dettaglio-giri-page) .btn,
    body:has(.dettaglio-giri-page) .no-print,
    body:has(.dettaglio-giri-page) .page-actions,
    body:has(.dettaglio-giri-page) .top-actions,
    body:has(.dettaglio-giri-page) nav,
    body:has(.dettaglio-giri-page) aside,
    body:has(.dettaglio-giri-page) button,
    body:has(.dettaglio-giri-page) .button {
        display: none !important;
    }

    body:has(.dettaglio-giri-page) .main-content,
    body:has(.dettaglio-giri-page) .app-main,
    body:has(.dettaglio-giri-page) .content,
    body:has(.dettaglio-giri-page) .page-wrapper,
    body:has(.dettaglio-giri-page) .page-container,
    body:has(.dettaglio-giri-page) .page-container-wide,
    body:has(.dettaglio-giri-page) .giri-container,
    body:has(.dettaglio-giri-page) .card,
    body:has(.dettaglio-giri-page) .print-container,
    body:has(.dettaglio-giri-page) .detail-print-container,
    body:has(.dettaglio-giri-page) .panel {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
        box-shadow: none !important;
        border: none !important;
        background: #fff !important;
    }

    .dettaglio-print-title {
        display: none !important;
    }

    .dettaglio-giri-page {
        page: dettaglio-giri-landscape;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
    }

    .day-print-page {
        page: dettaglio-giri-landscape;
        page-break-after: always;
        break-after: page;
        page-break-inside: avoid;
        break-inside: avoid;
        width: 100% !important;
        min-height: 198mm;
        box-sizing: border-box;
    }

    .day-print-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    .dettaglio-day-page {
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
    }

    .dettaglio-day-header {
        align-items: flex-start !important;
        margin: 0 0 3mm !important;
        padding: 0 0 2mm !important;
        border-bottom: 1px solid #cfd6df !important;
    }

    .dettaglio-day-title {
        margin: 0 !important;
        color: #111827 !important;
        font-size: 14px !important;
        font-weight: 900 !important;
        line-height: 1.1 !important;
    }

    .dettaglio-day-header p {
        margin: 0 !important;
        color: #374151 !important;
        font-size: 8px !important;
        line-height: 1.1 !important;
    }

    .dettaglio-period-section {
        margin: 0 0 6px !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .dettaglio-period-title {
        margin: 4px 0 !important;
        color: #111827 !important;
        font-size: 11px !important;
        font-weight: 900 !important;
        line-height: 1.1 !important;
    }

    .period-routes-grid,
    .dettaglio-route-grid {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(48mm, 1fr)) !important;
        gap: 4mm !important;
        align-items: start !important;
        width: 100% !important;
    }

    .route-card,
    .dettaglio-route-card {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 3mm !important;
        border: 1px solid #000 !important;
        border-radius: 3px !important;
        background: #fff !important;
        font-size: 8px !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .route-card-header,
    .dettaglio-route-head {
        gap: 0.4mm !important;
        margin: 0 0 1mm !important;
        padding: 0 0 1mm !important;
        border-bottom: 1px solid #d8dee6 !important;
    }

    .route-card-header strong,
    .route-title,
    .dettaglio-route-head strong {
        color: #111827 !important;
        font-size: 8.5px !important;
        line-height: 1.1 !important;
        margin: 0 0 2px 0 !important;
    }

    .route-card-header span,
    .dettaglio-route-head span {
        color: #374151 !important;
        font-size: 7.5px !important;
        font-weight: 700 !important;
        line-height: 1.1 !important;
        margin-bottom: 2px !important;
    }

    .route-clients,
    .dettaglio-client-list {
        margin: 0 !important;
        padding-left: 12px !important;
        font-size: 8px !important;
        line-height: 1.12 !important;
    }

    .route-clients li,
    .dettaglio-client-list li {
        margin: 0 !important;
        font-weight: 700 !important;
    }

    .dettaglio-empty {
        padding: 1.5mm !important;
        font-size: 7px !important;
        line-height: 1.1 !important;
    }

    /* Stampa Sintesi Giri: mantiene la struttura web in una singola facciata A4 verticale. */
    html:has(.summary-print-page),
    body:has(.summary-print-page),
    body:has(.sintesi-giri-page) {
        background: #fff !important;
        width: 100% !important;
        height: 281mm;
        min-height: 281mm;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        color: #000 !important;
        font-size: 10.5pt !important;
        line-height: 1.25 !important;
    }

    body:has(.summary-print-page) .main-content,
    body:has(.summary-print-page) .app-main,
    body:has(.summary-print-page) .content,
    body:has(.summary-print-page) .page-wrapper,
    body:has(.summary-print-page) .page-container,
    body:has(.summary-print-page) .page-container-wide,
    body:has(.summary-print-page) .giri-container,
    body:has(.summary-print-page) .card,
    body:has(.summary-print-page) .print-container,
    body:has(.summary-print-page) .summary-print-page,
    body:has(.summary-print-page) .panel,
    body:has(.sintesi-giri-page) .main-content,
    body:has(.sintesi-giri-page) .app-main,
    body:has(.sintesi-giri-page) .content,
    body:has(.sintesi-giri-page) .page-wrapper,
    body:has(.sintesi-giri-page) .page-container,
    body:has(.sintesi-giri-page) .page-container-wide,
    body:has(.sintesi-giri-page) .giri-container,
    body:has(.sintesi-giri-page) .card,
    body:has(.sintesi-giri-page) .print-container,
    body:has(.sintesi-giri-page) .panel,
    body:has(.sintesi-giri-page) .container {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
        box-shadow: none !important;
        border: none !important;
        background: #fff !important;
    }

    body:has(.summary-print-page) .sidebar,
    body:has(.summary-print-page) .sidebar-overlay,
    body:has(.summary-print-page) .topbar,
    body:has(.summary-print-page) .page-header,
    body:has(.summary-print-page) .section-head,
    body:has(.summary-print-page) .no-print,
    body:has(.summary-print-page) .top-actions,
    body:has(.summary-print-page) .page-actions,
    body:has(.summary-print-page) .actions-inline,
    body:has(.summary-print-page) .toolbar,
    body:has(.summary-print-page) .btn,
    body:has(.summary-print-page) .button,
    body:has(.summary-print-page) nav,
    body:has(.summary-print-page) aside,
    body:has(.summary-print-page) header:not(.print-header),
    body:has(.summary-print-page) button,
    body:has(.sintesi-giri-page) .sidebar,
    body:has(.sintesi-giri-page) .sidebar-overlay,
    body:has(.sintesi-giri-page) .topbar,
    body:has(.sintesi-giri-page) .page-header,
    body:has(.sintesi-giri-page) .section-head,
    body:has(.sintesi-giri-page) .no-print,
    body:has(.sintesi-giri-page) .top-actions,
    body:has(.sintesi-giri-page) .page-actions,
    body:has(.sintesi-giri-page) .actions-inline,
    body:has(.sintesi-giri-page) .toolbar,
    body:has(.sintesi-giri-page) .btn,
    body:has(.sintesi-giri-page) .button,
    body:has(.sintesi-giri-page) nav,
    body:has(.sintesi-giri-page) aside,
    body:has(.sintesi-giri-page) button {
        display: none !important;
    }

    .summary-print-page,
    .sintesi-giri-page {
        page: sintesi-giri-portrait;
        width: 100% !important;
        height: 281mm !important;
        max-height: 281mm !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        transform: none !important;
        zoom: 1 !important;
    }

    .summary-header,
    .sintesi-print-header {
        margin: 0 0 4mm !important;
        padding: 0 !important;
        border-bottom: 0 !important;
        text-align: center !important;
        flex: 0 0 auto !important;
    }

    .summary-title,
    .sintesi-print-header h1 {
        margin: 0 0 2mm 0 !important;
        padding: 0 !important;
        color: #000 !important;
        font-size: 18pt !important;
        font-weight: 700 !important;
        line-height: 1.1 !important;
        text-align: center !important;
    }

    .sintesi-print-header p {
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.1 !important;
    }

    .summary-subtitle,
    .summary-date-range,
    .sintesi-print-subtitle {
        display: none !important;
    }

    .print-range {
        display: block !important;
        margin: 0 0 4mm 0 !important;
        color: #000 !important;
        font-size: 10.5pt !important;
        font-weight: 600 !important;
        line-height: 1.2 !important;
        text-align: center !important;
    }

    .sintesi-print-range {
        display: none !important;
    }

    .sintesi-print-wrapper {
        width: 100% !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
        transform: none !important;
        zoom: 1 !important;
    }

    .summary-day,
    .sintesi-day-block,
    .print-day.sintesi-day-block {
        margin: 0 0 3.4mm 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .sintesi-day-block + .sintesi-day-block {
        margin-top: 0 !important;
    }

    .summary-day-title,
    .sintesi-day-title {
        margin: 0 0 1.2mm 0 !important;
        padding: 0 !important;
        border: 0 !important;
        color: #000 !important;
        font-size: 11pt !important;
        font-weight: 700 !important;
        line-height: 1.15 !important;
        break-after: avoid !important;
        page-break-after: avoid !important;
    }

    .sintesi-table-wrap,
    .print-panel .sintesi-table-wrap {
        overflow: visible !important;
        border: 0 !important;
        border-radius: 0 !important;
    }

    .summary-table,
    .sintesi-table,
    .data-table.sintesi-table,
    .print-table.sintesi-table,
    .print-summary-table {
        display: table !important;
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        border-spacing: 0 !important;
        font-size: 9pt !important;
    }

    .sintesi-table thead,
    .summary-table thead {
        position: static !important;
        display: table-header-group !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        clip: auto !important;
        white-space: normal !important;
    }

    .sintesi-table tbody,
    .summary-table tbody {
        display: table-row-group !important;
        width: auto !important;
    }

    .sintesi-table tr,
    .summary-table tr {
        display: table-row !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .summary-table th,
    .summary-table td,
    .sintesi-table th,
    .sintesi-table td {
        display: table-cell !important;
        padding: 1.35mm 1.8mm !important;
        border: 1px solid #000 !important;
        color: #000 !important;
        font-size: 9pt !important;
        line-height: 1.2 !important;
        vertical-align: middle !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    .summary-table td::before,
    .sintesi-table td::before {
        content: none !important;
        display: none !important;
    }

    .summary-table th,
    .sintesi-table th {
        background: #f2f2f2 !important;
        color: #000 !important;
        font-size: 9pt !important;
        font-weight: 700 !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    .summary-table th:first-child,
    .summary-table td:first-child,
    .sintesi-table th:first-child,
    .sintesi-table td:first-child {
        width: 32% !important;
    }

    .summary-table th:nth-child(2),
    .summary-table td:nth-child(2),
    .summary-table th:nth-child(3),
    .summary-table td:nth-child(3),
    .sintesi-table th:nth-child(2),
    .sintesi-table td:nth-child(2),
    .sintesi-table th:nth-child(3),
    .sintesi-table td:nth-child(3) {
        width: 34% !important;
    }
}
