/* ---------------------------
   MODERN MODAL STYLE (tutta l'app)
   --------------------------- */
.modal-content {
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 18px 40px rgba(12, 17, 43, 0.18);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.modal-header,
.modal-header.invoice-titlebar,
.modal-header.modern-titlebar {
	padding: 14px 20px;
	background: linear-gradient(90deg, #667eea, #764ba2);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header .modal-title,
.modal-header.invoice-titlebar .modal-title,
.modal-header.modern-titlebar .modal-title {
	font-weight: 700;
	font-size: 16px;
}

.modal-header .btn-close {
	filter: invert(1) grayscale(100%);
	opacity: 0.9;
}

.modal-header .btn-close:hover {
	opacity: 1;
}

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	border: 0;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
}

.icon-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

.modal-body,
.invoice-content,
.modern-modal-content {
	padding: 18px 22px;
	overflow: auto;
	flex: 1;
	min-height: 0;
}

.modal-footer,
.invoice-footer,
.modern-modal-footer {
	border-top: 1px solid #e6e9ee;
	padding: 12px 22px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.95));
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	align-items: center;
	flex-shrink: 0;
}

.btn-ghost {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #e6e9ee;
}

.modal-content .btn-primary,
.modal-content.invoice-window .btn-primary,
.modal-content.modern-modal .btn-primary {
	background: #0b63ff;
	border: 0;
}

.modal-content .btn-primary:hover,
.modal-content.invoice-window .btn-primary:hover,
.modal-content.modern-modal .btn-primary:hover {
	background: #0853d6;
}

#modalCountryCode {
	--inv-bg-start: #667eea;
	--inv-bg-end: #764ba2;
	--inv-card-bg: #ffffff;
	--inv-muted: #6b7280;
	--inv-border: #e6e9ee;
	--inv-accent: #0b63ff;
	--inv-accent-dark: #0853d6;
}

#modalCountryCode .modal-dialog {
	height: calc(100vh - 2rem);
}

@supports (height: 100dvh) {
	#modalCountryCode .modal-dialog {
		height: calc(100dvh - 2rem);
	}
}

#modalCountryCode .invoice-window {
	border-radius: 12px;
	background: var(--inv-card-bg);
	box-shadow: 0 18px 40px rgba(12, 17, 43, 0.18);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	height: 100%;
	max-height: 100%;
}

#modalCountryCode .invoice-titlebar {
	padding: 14px 20px;
	background: linear-gradient(90deg, var(--inv-bg-start), var(--inv-bg-end));
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#modalCountryCode .invoice-titlebar .modal-title {
	font-weight: 700;
	font-size: 16px;
}

#modalCountryCode .icon-btn {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #ffffff;
	border: 0;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
}

#modalCountryCode .icon-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

#modalCountryCode .invoice-content {
	padding: 18px 22px;
	overflow: auto;
	flex: 1;
	min-height: 0;
}

#modalCountryCode .form-label {
	font-weight: 600;
	margin-bottom: 8px;
}

#modalCountryCode .form-text {
	color: var(--inv-muted) !important;
}

#modalCountryCode .form-control,
#modalCountryCode textarea {
	border-radius: 8px;
	border: 1px solid var(--inv-border);
	background: #ffffff;
	font-size: 14px;
	padding: 10px 12px;
	box-shadow: none;
}

#modalCountryCode .form-control:focus,
#modalCountryCode textarea:focus {
	box-shadow: 0 4px 12px rgba(11, 99, 255, 0.12);
	border-color: var(--inv-accent);
}

#modalCountryCode .btn-primary {
	background: var(--inv-accent);
	border: 0;
}

#modalCountryCode .btn-primary:hover {
	background: var(--inv-accent-dark);
}

#modalCountryCode .btn-ghost {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #e6e9ee;
}

#modalCountryCode .invoice-footer {
	border-top: 1px solid var(--inv-border);
	padding: 12px 22px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.95));
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	align-items: center;
	flex-shrink: 0;
}

#modalCompany {
	--inv-bg-start: #667eea;
	--inv-bg-end: #764ba2;
	--inv-card-bg: #ffffff;
	--inv-muted: #6b7280;
	--inv-border: #e6e9ee;
	--inv-accent: #0b63ff;
	--inv-accent-dark: #0853d6;
}

#modalCompany .modal-dialog {
	height: calc(100vh - 2rem);
}

@supports (height: 100dvh) {
	#modalCompany .modal-dialog {
		height: calc(100dvh - 2rem);
	}
}

#modalCompany .invoice-window {
	border-radius: 12px;
	background: var(--inv-card-bg);
	box-shadow: 0 18px 40px rgba(12, 17, 43, 0.18);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	height: 100%;
	max-height: 100%;
}

#modalCompany .invoice-titlebar {
	padding: 14px 20px;
	background: linear-gradient(90deg, var(--inv-bg-start), var(--inv-bg-end));
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#modalCompany .invoice-titlebar .modal-title {
	font-weight: 700;
	font-size: 16px;
}

#modalCompany .icon-btn {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #ffffff;
	border: 0;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
}

#modalCompany .icon-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

#modalCompany .invoice-content {
	padding: 18px 22px;
	overflow: auto;
	flex: 1;
	min-height: 0;
}

#modalCompany .form-label {
	font-weight: 600;
	margin-bottom: 8px;
}

#modalCompany .form-text {
	color: var(--inv-muted) !important;
}

#modalCompany .form-control,
#modalCompany textarea {
	border-radius: 8px;
	border: 1px solid var(--inv-border);
	background: #ffffff;
	font-size: 14px;
	padding: 10px 12px;
	box-shadow: none;
}

#modalCompany .form-control:focus,
#modalCompany textarea:focus {
	box-shadow: 0 4px 12px rgba(11, 99, 255, 0.12);
	border-color: var(--inv-accent);
}

#modalCompany .btn-primary {
	background: var(--inv-accent);
	border: 0;
}

#modalCompany .btn-primary:hover {
	background: var(--inv-accent-dark);
}

#modalCompany .btn-ghost {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #e6e9ee;
}

#modalCompany .invoice-footer {
	border-top: 1px solid var(--inv-border);
	padding: 12px 22px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.95));
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	align-items: center;
	flex-shrink: 0;
}

/* X interna all'input filtro mobile fatture */
#invoicesMobileFilterClear {
	color: #888;
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
	border: none;
	background: transparent;
	outline: none;
}

#invoicesMobileFilterClear:active {
	color: #333;
}

#invoicesMobileFilterQuery.pe-4 {
	padding-right: 2.1rem !important;
}

/* X interna all'input filtro mobile clienti */
#clientsMobileFilterClear {
	color: #888;
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
	border: none;
	background: transparent;
	outline: none;
}

#clientsMobileFilterClear:active {
	color: #333;
}

#clientsMobileFilterQuery.pe-4 {
	padding-right: 2.1rem !important;
}

/* X interna all'input filtro mobile aziende */
#companiesMobileFilterClear {
	color: #888;
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
	border: none;
	background: transparent;
	outline: none;
}

#companiesMobileFilterClear:active {
	color: #333;
}

#companiesMobileFilterQuery.pe-4 {
	padding-right: 2.1rem !important;
}

/* X interna all'input filtro mobile prestazioni */
#prestazioniMobileFilterClear {
	color: #888;
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
	border: none;
	background: transparent;
	outline: none;
}

#prestazioniMobileFilterClear:active {
	color: #333;
}

#prestazioniMobileFilterQuery.pe-4 {
	padding-right: 2.1rem !important;
}

#countryCodesMobileFilterClear {
	color: #999;
	text-decoration: none;
	border: none;
	background: transparent;
	outline: none;
}

#countryCodesMobileFilterClear:active {
	color: #333;
}

#countryCodesMobileFilterQuery.pe-4 {
	padding-right: 2.1rem !important;
}

#clientsTable thead th {
	position: sticky;
	background: var(--bs-body-bg);
}

#clientsHeaderRowLabels th {
	top: 0;
	z-index: 4;
}

#clientsHeaderRowFilters th {
	top: var(--clients-thead-row1-h, 2.25rem);
	z-index: 3;
}

#companiesTable thead th {
	position: sticky;
	background: var(--bs-body-bg);
}

#companiesHeaderRowLabels th {
	top: 0;
	z-index: 4;
}

#companiesHeaderRowFilters th {
	top: var(--companies-thead-row1-h, 2.25rem);
	z-index: 3;
}

#prestazioniTable thead th {
	position: sticky;
	background: var(--bs-body-bg);
}

#prestazioniHeaderRowLabels th {
	top: 0;
	z-index: 4;
}

#prestazioniHeaderRowFilters th {
	top: var(--prestazioni-thead-row1-h, 2.25rem);
	z-index: 3;
}

#countryCodesTable thead th {
	position: sticky;
	background: var(--bs-body-bg);
}

#countryCodesHeaderRowLabels th {
	top: 0;
	z-index: 4;
}

#countryCodesHeaderRowFilters th {
	top: var(--countryCodes-thead-row1-h, 2.25rem);
	z-index: 3;
}

#postalCodesTable thead th {
	position: sticky;
	background: var(--bs-body-bg);
}

#postalCodesHeaderRowLabels th {
	top: 0;
	z-index: 4;
}

#postalCodesHeaderRowFilters th {
	top: var(--postalCodes-thead-row1-h, 2.25rem);
	z-index: 3;
}

#clientsTable th.app-select-col,
#clientsTable td.app-select-col {
	width: 40px;
}

#clientsTable td.app-select-col {
	vertical-align: top;
}

#companiesTable th.app-select-col,
#companiesTable td.app-select-col {
	width: 40px;
}

#companiesTable td.app-select-col {
	vertical-align: top;
}

#prestazioniTable th.app-select-col,
#prestazioniTable td.app-select-col {
	width: 40px;
}

#prestazioniTable td.app-select-col {
	vertical-align: top;
}

#countryCodesTable th.app-select-col,
#countryCodesTable td.app-select-col {
	width: 40px;
}

#countryCodesTable td.app-select-col {
	vertical-align: top;
}

#postalCodesTable th.app-select-col,
#postalCodesTable td.app-select-col {
	width: 40px;
}

#postalCodesTable td.app-select-col {
	vertical-align: top;
}

#postalCodesMobileFilterQuery {
	padding-right: 2rem;
}

#postalCodesMobileFilterClear {
	color: var(--bs-secondary-color);
}

#postalCodesMobileFilterClear:hover {
	color: var(--bs-body-color);
}

/* ---------------------------
   Nuova fattura (Fatt.XML) - finestra grafica
   --------------------------- */
#modalInvoice {
	--inv-bg-start: #667eea;
	--inv-bg-end: #764ba2;
	--inv-card-bg: #ffffff;
	--inv-muted: #6b7280;
	--inv-border: #e6e9ee;
	--inv-accent: #0b63ff;
	--inv-accent-dark: #0853d6;
}

#modalInvoice .modal-dialog {
	height: calc(100vh - 2rem);
}

@supports (height: 100dvh) {
	#modalInvoice .modal-dialog {
		height: calc(100dvh - 2rem);
	}
}

#modalInvoice .invoice-window {
	border-radius: 12px;
	background: var(--inv-card-bg);
	box-shadow: 0 18px 40px rgba(12, 17, 43, 0.18);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	height: 100%;
	max-height: 100%;
}

#modalInvoice .invoice-titlebar {
	padding: 14px 20px;
	background: linear-gradient(90deg, var(--inv-bg-start), var(--inv-bg-end));
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#modalInvoice .invoice-titlebar .modal-title {
	font-weight: 700;
	font-size: 16px;
}

#modalInvoice .icon-btn {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #ffffff;
	border: 0;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
}

#modalInvoice .icon-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

#modalInvoice .invoice-content {
	padding: 18px 22px;
	overflow: auto;
	flex: 1;
	min-height: 0;
	padding-bottom: 24px;
}

#modalInvoice .invoice-section-title {
	margin: 0 0 8px 0;
	font-size: 15px;
	color: #111827;
	font-weight: 700;
}

#modalInvoice .invoice-subtitle {
	font-weight: 600;
	color: #111827;
}

#modalInvoice .form-label {
	font-weight: 600;
	margin-bottom: 8px;
}

#modalInvoice .form-text,
#modalInvoice .text-body-secondary {
	color: var(--inv-muted) !important;
}

#modalInvoice .form-control,
#modalInvoice textarea {
	border-radius: 8px;
	border: 1px solid var(--inv-border);
	background: #ffffff;
	font-size: 14px;
	padding: 10px 12px;
	box-shadow: none;
}

#modalInvoice .form-control:focus,
#modalInvoice textarea:focus {
	box-shadow: 0 4px 12px rgba(11, 99, 255, 0.12);
	border-color: var(--inv-accent);
}

#modalInvoice details>summary {
	color: var(--inv-accent);
	cursor: pointer;
	list-style: none;
}

#modalInvoice details>summary::-webkit-details-marker {
	display: none;
}

#modalInvoice .table-responsive {
	border-top: 1px solid var(--inv-border);
	padding-top: 12px;
}

#modalInvoice table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

#modalInvoice thead th {
	padding: 10px 12px;
	text-align: left;
	color: #111827;
	font-weight: 700;
	border-bottom: 1px solid var(--inv-border);
}

#modalInvoice tbody td {
	padding: 10px 12px;
	border-bottom: 1px solid #f3f4f6;
	vertical-align: middle;
}

#modalInvoice #btnAddLine {
	background: #ffffff;
	border: 1px solid var(--inv-accent);
	color: var(--inv-accent);
	padding: 8px 12px;
	border-radius: 8px;
}

#modalInvoice #btnAddLine:hover {
	background: rgba(11, 99, 255, 0.06);
}

#modalInvoice .btn-primary {
	background: var(--inv-accent);
	border: 0;
}

#modalInvoice .btn-primary:hover {
	background: var(--inv-accent-dark);
}

#modalInvoice .btn-ghost {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #e6e9ee;
}

#modalInvoice .invoice-footer {
	border-top: 1px solid var(--inv-border);
	padding: 12px 22px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.95));
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	align-items: center;
	flex-shrink: 0;
}

#modalInvoice .form-check-label {
	color: #111827;
}

#modalInvoice input[name="line_qty"] {
	text-align: center;
}

#modalInvoice input[name="line_unit_price"],
#modalInvoice input[name="line_vat_rate"] {
	text-align: right;
}

#modalInvoice .btn-outline-danger {
	border-radius: 6px;
	border: 1px solid var(--inv-border);
	background: #ffffff;
	color: #b91c1c;
}

/* ---------------------------
   Nuova prestazione - finestra grafica
   --------------------------- */
#modalPrestazione {
	--inv-bg-start: #667eea;
	--inv-bg-end: #764ba2;
	--inv-card-bg: #ffffff;
	--inv-muted: #6b7280;
	--inv-border: #e6e9ee;
	--inv-accent: #0b63ff;
	--inv-accent-dark: #0853d6;
}

#modalPrestazione .modal-dialog {
	height: calc(100vh - 2rem);
}

@supports (height: 100dvh) {
	#modalPrestazione .modal-dialog {
		height: calc(100dvh - 2rem);
	}
}

#modalPrestazione .invoice-window {
	border-radius: 12px;
	background: var(--inv-card-bg);
	box-shadow: 0 18px 40px rgba(12, 17, 43, 0.18);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	height: 100%;
	max-height: 100%;
}

#modalPrestazione .invoice-titlebar {
	padding: 14px 20px;
	background: linear-gradient(90deg, var(--inv-bg-start), var(--inv-bg-end));
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#modalPrestazione .invoice-titlebar .modal-title {
	font-weight: 700;
	font-size: 16px;
}

#modalPrestazione .icon-btn {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #ffffff;
	border: 0;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
}

#modalPrestazione .icon-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

#modalPrestazione .invoice-content {
	padding: 18px 22px;
	overflow: auto;
	flex: 1;
	min-height: 0;
}

#modalPrestazione .form-label {
	font-weight: 600;
	margin-bottom: 8px;
}

#modalPrestazione .form-text {
	color: var(--inv-muted) !important;
}

#modalPrestazione .form-control,
#modalPrestazione textarea {
	border-radius: 8px;
	border: 1px solid var(--inv-border);
	background: #ffffff;
	font-size: 14px;
	padding: 10px 12px;
	box-shadow: none;
}

#modalPrestazione .form-control:focus,
#modalPrestazione textarea:focus {
	box-shadow: 0 4px 12px rgba(11, 99, 255, 0.12);
	border-color: var(--inv-accent);
}

#modalPrestazione .btn-primary {
	background: var(--inv-accent);
	border: 0;
}

#modalPrestazione .btn-primary:hover {
	background: var(--inv-accent-dark);
}

#modalPrestazione .btn-ghost {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #e6e9ee;
}

#modalPrestazione .invoice-footer {
	border-top: 1px solid var(--inv-border);
	padding: 12px 22px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.95));
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	align-items: center;
	flex-shrink: 0;
}

/* ---------------------------
   Nuovo cliente - finestra grafica
   --------------------------- */
#modalClient {
	--inv-bg-start: #667eea;
	--inv-bg-end: #764ba2;
	--inv-card-bg: #ffffff;
	--inv-muted: #6b7280;
	--inv-border: #e6e9ee;
	--inv-accent: #0b63ff;
	--inv-accent-dark: #0853d6;
}

#modalClient .modal-dialog {
	height: calc(100vh - 2rem);
}

@supports (height: 100dvh) {
	#modalClient .modal-dialog {
		height: calc(100dvh - 2rem);
	}
}

#modalClient .invoice-window {
	border-radius: 12px;
	background: var(--inv-card-bg);
	box-shadow: 0 18px 40px rgba(12, 17, 43, 0.18);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	height: 100%;
	max-height: 100%;
}

#modalClient .invoice-titlebar {
	padding: 14px 20px;
	background: linear-gradient(90deg, var(--inv-bg-start), var(--inv-bg-end));
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#modalClient .invoice-titlebar .modal-title {
	font-weight: 700;
	font-size: 16px;
}

#modalClient .icon-btn {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #ffffff;
	border: 0;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
}

#modalClient .icon-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

#modalClient .invoice-content {
	padding: 18px 22px;
	overflow: auto;
	flex: 1;
	min-height: 0;
}

#modalClient .form-label {
	font-weight: 600;
	margin-bottom: 8px;
}

#modalClient .form-text {
	color: var(--inv-muted) !important;
}

#modalClient .form-control,
#modalClient textarea {
	border-radius: 8px;
	border: 1px solid var(--inv-border);
	background: #ffffff;
	font-size: 14px;
	padding: 10px 12px;
	box-shadow: none;
}

#modalClient .form-control:focus,
#modalClient textarea:focus {
	box-shadow: 0 4px 12px rgba(11, 99, 255, 0.12);
	border-color: var(--inv-accent);
}

#modalClient .btn-primary {
	background: var(--inv-accent);
	border: 0;
}

#modalClient .btn-primary:hover {
	background: var(--inv-accent-dark);
}

#modalClient .btn-ghost {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #e6e9ee;
}

#modalClient .invoice-footer {
	border-top: 1px solid var(--inv-border);
	padding: 12px 22px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.95));
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	align-items: center;
	flex-shrink: 0;
}

/* ---------------------------
   App header gradient
   --------------------------- */
.navbar.bg-dark {
	background: linear-gradient(90deg, #667eea, #764ba2) !important;
}

.navbar.bg-dark .navbar-brand,
.navbar.bg-dark .nav-link,
.navbar.bg-dark .navbar-text,
.navbar.bg-dark .btn,
.navbar.bg-dark .navbar-toggler {
	color: #ffffff !important;
}

.navbar.bg-dark .btn-outline-light {
	border-color: rgba(255, 255, 255, 0.6) !important;
}

@media (max-width: 900px) {
	#modalInvoice .invoice-window {
		max-height: 100%;
		height: 100%;
	}
}

/* Allinea verticalmente i pulsanti Modifica/Elimina nella btn-group */
#invoicesBulkActions,
#invoicesBulkActionsMobile {
	align-items: center !important;
}

#invoicesBulkActions>a,
#invoicesBulkActions>form,
#invoicesBulkActionsMobile>a,
#invoicesBulkActionsMobile>form {
	display: flex;
	align-items: center;
	margin-bottom: 0 !important;
}

/* Mobile-first tweaks */
.table-responsive {
	-webkit-overflow-scrolling: touch;
}

/* Invoices table: scroll rows while keeping header/filters visible */
.app-table-scroll {
	max-height: calc(100vh - 280px);
	overflow: auto;
}

@supports (height: 100dvh) {
	.app-table-scroll {
		max-height: calc(100dvh - 280px);
	}
}

#invoicesTable thead th {
	position: sticky;
	background: var(--bs-body-bg);
}

#invoicesHeaderRowLabels th {
	top: 0;
	z-index: 4;
}

#invoicesHeaderRowFilters th {
	top: var(--invoices-thead-row1-h, 2.25rem);
	z-index: 3;
}

#invoicesTable th.app-select-col,
#invoicesTable td.app-select-col {
	width: 40px;
}

#invoicesTable td.app-select-col {
	vertical-align: top;
}

/* Make modal usable on mobile */
.modal-fullscreen-sm-down .modal-body {
	padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
}

/* iOS Safari: keep footer above the bottom bar */
.modal-footer {
	padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* iOS Safari: prevent background scrolling when modal is open */
body.modal-open {
	overflow: hidden !important;
}

/* iOS Safari: make the modal itself scroll (more reliable than nested flex scroll) */
.modal {
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* Fullscreen modals on mobile: let container scroll, keep header/footer visible */
.modal-dialog.modal-fullscreen-sm-down {
	margin: 0;
	height: auto !important;
	min-height: 100%;
}

.modal-dialog.modal-fullscreen-sm-down .modal-content {
	height: auto !important;
	min-height: 100%;
	border: 0;
	border-radius: 0;
	display: block !important;
}

.modal-dialog.modal-fullscreen-sm-down .modal-body {
	overflow: visible !important;
	padding-bottom: calc(7rem + env(safe-area-inset-bottom, 0px));
}

.modal-dialog.modal-fullscreen-sm-down .modal-header {
	position: sticky;
	top: 0;
	z-index: 2;
	background: linear-gradient(90deg, #667eea, #764ba2);
}

.modal-dialog.modal-fullscreen-sm-down .modal-footer {
	position: sticky;
	bottom: 0;
	z-index: 2;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.95));
}

/* Prefer dynamic viewport units when available */
@supports (height: 100dvh) {

	.modal-fullscreen-sm-down .modal-dialog,
	.modal-fullscreen-sm-down .modal-content {
		height: 100dvh;
	}
}

/* Visual consistency: make buttons readable and consistent on mobile */
@media (max-width: 576px) {

	/* iOS: prevent viewport zoom on input focus (needs >=16px font-size) */
	.form-control-sm,
	.form-select-sm,
	input.form-control,
	select.form-select,
	textarea.form-control {
		font-size: 16px !important;
	}

	/* Toolbar buttons: same minimum tap target */
	.app-toolbar {
		align-items: stretch !important;
	}

	.app-toolbar .btn {
		min-height: 44px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		white-space: normal;
		padding: 0.5rem 0.75rem;
		font-size: 1rem;
	}

	.app-toolbar form {
		align-items: stretch;
	}

	/* Small buttons inside tables/lists: slightly larger on mobile */
	.btn.btn-sm {
		--bs-btn-padding-y: 0.45rem;
		--bs-btn-padding-x: 0.75rem;
		--bs-btn-font-size: 1rem;
	}

	/* Invoice lines: stack fields on mobile with visible labels */
	#linesTable thead {
		display: none;
	}

	#linesTable tbody tr {
		display: flex;
		flex-wrap: wrap;
		gap: 0.5rem;
		padding: 0.5rem 0;
		border-bottom: 1px solid var(--bs-border-color);
	}

	#linesTable tbody td {
		border: 0;
		padding: 0;
		display: flex;
		flex-direction: column;
		gap: 0.15rem;
	}

	/* Labels are rendered in markup (bold) to match Edit/New modals; avoid duplicates */
	#linesTable tbody td::before {
		display: none;
		content: '';
	}

	#linesTable tbody td:nth-child(1) {
		flex: 1 0 100%;
	}

	#linesTable tbody td:nth-child(2) {
		flex: 1 0 22%;
		min-width: 84px;
	}

	#linesTable tbody td:nth-child(3) {
		flex: 1 0 30%;
		min-width: 120px;
	}

	#linesTable tbody td:nth-child(4) {
		flex: 1 0 18%;
		min-width: 76px;
	}

	#linesTable tbody td:nth-child(5) {
		flex: 1 0 22%;
		min-width: 90px;
	}

	#linesTable tbody td:nth-child(6) {
		flex: 0 0 auto;
		margin-left: auto;
		align-self: flex-end;
	}

	#linesTable input.form-control {
		min-height: 44px;
		font-size: 16px;
	}
}

/* Mobile quick nav (fixed under navbar, hides on scroll down) */
:root {
	--app-quick-nav-height: 72px;
	--app-vv-bottom: 0px;
}

.app-quick-nav {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 1020;
	background: var(--bs-body-bg);
	border-top: 1px solid var(--bs-border-color);
	padding-bottom: env(safe-area-inset-bottom, 0px);
	transform: translateY(0);
	transition: transform 180ms ease;
}

.app-quick-nav.app-quick-nav--hidden {
	transform: translateY(110%);
}

.app-quick-nav .app-quick-nav-inner {
	display: flex;
	gap: 0.35rem;
	padding: 0.4rem calc(0.95rem + env(safe-area-inset-right, 0px)) 0.4rem calc(0.95rem + env(safe-area-inset-left, 0px));
	overflow: hidden;
}

.app-quick-nav .app-quick-nav-item {
	flex: 1 1 0;
	min-width: 0;
	text-decoration: none;
	background: var(--bs-primary);
	color: #fff;
	border-radius: 0.5rem;
	padding: 0.35rem 0.25rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	line-height: 1.05;
}

.app-quick-nav .app-quick-nav-item:active {
	transform: translateY(1px);
}

.app-quick-nav .app-quick-nav-item .bi {
	font-size: 1.25rem;
	line-height: 1;
}

.app-quick-nav .app-quick-nav-label {
	display: block;
	font-size: 0.7rem;
	margin-top: 0.15rem;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

@media (max-width: 991.98px) {

	html,
	body {
		height: 100%;
	}

	@supports (height: 100dvh) {

		html,
		body {
			height: 100dvh;
		}
	}

	body {
		overflow: hidden;
	}

	body.modal-open {
		overflow: hidden !important;
	}

	.app-shell {
		display: flex;
		flex-direction: column;
		height: 100%;
	}

	main.app-main {
		flex: 1 1 auto;
		overflow: auto;
		-webkit-overflow-scrolling: touch;
		padding-bottom: 1rem !important;
	}

	body.modal-open main.app-main {
		overflow: hidden;
	}

	.app-quick-nav {
		position: relative;
		left: auto;
		right: auto;
		bottom: auto;
		padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
		margin-bottom: 8px;
		transform: none;
		transition: none;
	}

	.app-quick-nav.app-quick-nav--hidden {
		transform: none;
	}

	.app-a2hs-hint {
		margin: 0 0 6px 0;
		padding: 0.5rem 0.75rem;
		background: rgba(13, 110, 253, 0.10);
		border-top: 1px solid rgba(13, 110, 253, 0.25);
		border-bottom: 1px solid rgba(13, 110, 253, 0.25);
		color: var(--bs-body-color);
		font-size: 0.95rem;
	}

	.app-a2hs-hint .app-a2hs-hint-inner {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 0.75rem;
	}

	.app-a2hs-hint .app-a2hs-hint-text {
		line-height: 1.2;
	}

	.app-a2hs-hint .btn {
		white-space: nowrap;
	}

	@media (max-width: 767.98px) {
		#linesTable {
			border-collapse: separate;
			border-spacing: 0 0.75rem;
		}

		#linesTable td {
			padding-top: 0.35rem;
			padding-bottom: 0.35rem;
			vertical-align: top;
		}

		#linesTable td>.small {
			font-size: 0.85rem;
			line-height: 1.1;
		}
	}
}

.app-embed-frame {
	display: block;
	width: 100%;
	border: 0;
	height: 70vh;
}

@media (max-width: 575.98px) {
	.app-embed-frame {
		height: calc(100dvh - 140px);
	}
}