/**
 * Tabelle dati Amministrazione Trasparente — Design Comuni / Blu Italia AGID.
 */

.apsp-at-opendata-table {
	--apsp-at-primary: #0066cc;
	--apsp-at-primary-dark: #003366;
	--apsp-at-primary-light: #e6f2ff;
	--apsp-at-border: #d9dadb;
	--apsp-at-text-muted: #5c6f82;
	margin-top: 1.5rem;
	margin-bottom: 2rem;
	max-width: 100%;
	width: 100%;
	box-sizing: border-box;
	font-family: "Titillium Web", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.apsp-at-datatable-slot,
.page-content-wrapper .apsp-at-datatable-slot,
.apsp-at-layout__main .apsp-at-datatable-slot {
	display: block;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.page-content-wrapper .apsp-at-opendata-table,
.apsp-at-layout__main .apsp-at-opendata-table,
.apsp-at-datatable-slot .apsp-at-opendata-table {
	width: 100%;
	max-width: 100%;
}

.apsp-at-opendata-table .apsp-at-table-section-title {
	margin-top: 1.25rem;
	margin-bottom: 0.75rem;
	font-size: 1.15rem;
	color: var(--apsp-at-primary-dark);
}

.apsp-at-datatable-page .apsp-comuni-page-column {
	min-width: 0;
}

body.apsp-at-datatable-page .apsp-comuni-page .entry-content,
body.apsp-at-datatable-page .apsp-comuni-page .page-content-wrapper {
	max-width: none;
	width: 100%;
	min-width: 0;
}

@media (max-width: 991.98px) {
	body.apsp-at-datatable-page .apsp-comuni-page .entry-content,
	body.apsp-at-datatable-page .apsp-comuni-page .page-content-wrapper {
		overflow-x: hidden;
	}
}

.apsp-at-table-empty {
	margin-top: 1rem;
	color: var(--apsp-at-text-muted);
}

/* —— Blocco tabella singola —— */
.apsp-at-datatable-block {
	margin-bottom: 1.75rem;
}

.apsp-at-datatable__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.75rem 1rem;
	margin-bottom: 0.75rem;
	padding: 0.85rem 1rem;
	background: #f5f6f7;
	border: 1px solid var(--apsp-at-border);
	border-radius: 4px;
}

.apsp-at-datatable__search-wrap {
	flex: 1 1 14rem;
	min-width: 12rem;
}

.apsp-at-datatable__search {
	min-height: 44px;
	border: 1px solid #5c6f82;
	border-radius: 4px;
	font-size: 1rem;
}

.apsp-at-datatable__search:focus {
	border-color: var(--apsp-at-primary);
	box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.apsp-at-datatable__year-wrap {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 9rem;
}

.apsp-at-datatable__year-label {
	font-size: 0.875rem;
	font-weight: 600;
	color: #435a70;
	margin: 0;
}

.apsp-at-datatable__year {
	min-height: 44px;
	min-width: 9rem;
	border: 1px solid #5c6f82;
	border-radius: 4px;
	font-size: 1rem;
}

.apsp-at-datatable__count {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0.35rem 0.9rem;
	background: var(--apsp-at-primary-dark);
	color: #fff;
	border-radius: 999px;
	font-size: 0.875rem;
	font-weight: 600;
	white-space: nowrap;
}

.apsp-at-datatable__scroll-hint {
	margin: 0 0 0.5rem;
	font-size: 0.875rem;
	color: var(--apsp-at-text-muted);
}

.apsp-at-datatable__table-wrap {
	overflow-x: auto;
	max-width: 100%;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--apsp-at-border);
	border-radius: 4px;
	background: #fff;
}

.apsp-at-datatable__table-wrap.is-scrollable {
	box-shadow: inset -12px 0 12px -12px rgba(0, 51, 102, 0.12);
}

.apsp-at-datatable__empty {
	margin: 0.75rem 0 0;
	padding: 0.75rem 1rem;
	background: #fff8e6;
	border-left: 4px solid #cc8b00;
	color: #1a1a1a;
	font-size: 0.9375rem;
}

/* —— Tabella dati —— */
.apsp-at-opendata-table .apsp-at-data-table {
	width: 100%;
	margin-bottom: 0;
	font-size: 0.9375rem;
	border-collapse: collapse;
	table-layout: fixed;
}

.apsp-at-opendata-table .apsp-at-data-table thead th {
	background: var(--apsp-at-primary-dark);
	color: #fff;
	font-weight: 600;
	padding: 0.75rem 0.65rem;
	border: none;
	text-align: left;
	vertical-align: top;
	line-height: 1.3;
	white-space: normal;
}

.apsp-at-opendata-table .apsp-at-data-table tbody td {
	padding: 0.7rem 0.65rem;
	border-bottom: 1px solid var(--apsp-at-border);
	vertical-align: top;
	word-break: break-word;
	overflow-wrap: anywhere;
}

.apsp-at-opendata-table .apsp-at-data-table tbody tr:nth-child(even) {
	background: #f8f9fa;
}

.apsp-at-opendata-table .apsp-at-data-table tbody tr:hover {
	background: var(--apsp-at-primary-light);
}

.apsp-at-opendata-table .apsp-at-data-table tbody tr[hidden] {
	display: none;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-num,
.apsp-at-opendata-table .apsp-at-data-table td.col-num {
	white-space: nowrap;
	text-align: center;
	width: 5.5rem;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-anno,
.apsp-at-opendata-table .apsp-at-data-table td.col-anno {
	white-space: nowrap;
	width: 5rem;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-date,
.apsp-at-opendata-table .apsp-at-data-table td.col-date {
	white-space: nowrap;
	width: 7.5rem;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table td.col-oggetto {
	min-width: 18rem;
	width: 38%;
}

/* Tabelle larghe (bilanci, piani): scroll orizzontale, colonne documento leggibili */
.apsp-at-opendata-table .apsp-at-data-table--cols-5,
.apsp-at-opendata-table .apsp-at-data-table--cols-6,
.apsp-at-opendata-table .apsp-at-data-table--cols-7,
.apsp-at-opendata-table .apsp-at-data-table--cols-8 {
	width: max-content;
	min-width: 100%;
	table-layout: auto;
}

.apsp-at-opendata-table .apsp-at-data-table--cols-5 th.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table--cols-5 td.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table--cols-6 th.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table--cols-6 td.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table--cols-7 th.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table--cols-7 td.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table--cols-8 th.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table--cols-8 td.col-oggetto {
	min-width: 8rem;
	max-width: 12rem;
	width: auto;
}

.apsp-at-opendata-table .apsp-at-data-table--cols-5 th.col-doc,
.apsp-at-opendata-table .apsp-at-data-table--cols-5 td.col-doc,
.apsp-at-opendata-table .apsp-at-data-table--cols-5 th.col-text,
.apsp-at-opendata-table .apsp-at-data-table--cols-5 td.col-text,
.apsp-at-opendata-table .apsp-at-data-table--cols-6 th.col-doc,
.apsp-at-opendata-table .apsp-at-data-table--cols-6 td.col-doc,
.apsp-at-opendata-table .apsp-at-data-table--cols-6 th.col-text,
.apsp-at-opendata-table .apsp-at-data-table--cols-6 td.col-text,
.apsp-at-opendata-table .apsp-at-data-table--cols-7 th.col-doc,
.apsp-at-opendata-table .apsp-at-data-table--cols-7 td.col-doc,
.apsp-at-opendata-table .apsp-at-data-table--cols-7 th.col-text,
.apsp-at-opendata-table .apsp-at-data-table--cols-7 td.col-text,
.apsp-at-opendata-table .apsp-at-data-table--cols-8 th.col-doc,
.apsp-at-opendata-table .apsp-at-data-table--cols-8 td.col-doc,
.apsp-at-opendata-table .apsp-at-data-table--cols-8 th.col-text,
.apsp-at-opendata-table .apsp-at-data-table--cols-8 td.col-text {
	min-width: 10.5rem;
	width: 10.5rem;
}

.apsp-at-opendata-table[data-opendata-class="bilancio_consuntivo"] .apsp-at-data-table thead th,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table thead th {
	font-size: 0.8125rem;
	line-height: 1.25;
}

.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-3,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-4,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-5,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-6 {
	width: max-content;
	min-width: 100%;
	table-layout: auto;
}

.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-3 th.col-oggetto,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-3 td.col-oggetto,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-4 th.col-oggetto,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-4 td.col-oggetto {
	min-width: 8rem;
	max-width: 12rem;
	width: auto;
}

.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-3 th.col-doc,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-3 td.col-doc,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-4 th.col-doc,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-4 td.col-doc,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-5 th.col-doc,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-5 td.col-doc,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-6 th.col-doc,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-6 td.col-doc,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-3 th.col-text,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-3 td.col-text,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-4 th.col-text,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-4 td.col-text,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-5 th.col-text,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-5 td.col-text,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-6 th.col-text,
.apsp-at-opendata-table[data-opendata-class="bilancio_preventivo"] .apsp-at-data-table--cols-6 td.col-text {
	min-width: 10.5rem;
	width: 10.5rem;
}

/* Piano triennale anticorruzione: molte colonne documento + descrizione lunga */
.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table {
	min-width: 52rem;
}

.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table th.col-anno,
.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table td.col-anno {
	min-width: 4.5rem;
	width: 4.5rem;
}

.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table th.col-doc,
.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table td.col-doc {
	min-width: 9.5rem;
	max-width: 13rem;
	white-space: normal;
	word-break: break-word;
}

.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table th.col-oggetto,
.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table td.col-oggetto,
.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table th.col-text,
.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-data-table td.col-text {
	min-width: 10rem;
	max-width: 20rem;
	white-space: normal;
	word-break: break-word;
}

.apsp-at-opendata-table[data-opendata-class="piano_triennale_pct"] .apsp-at-doc-links a {
	display: inline-block;
	max-width: 100%;
	overflow-wrap: anywhere;
}

/* Mini-tabella piani programmatici nel body pagina */
.openpa-widget,
.page-content .table-responsive:has(.openpa-widget-title) {
	margin: 1.5rem 0 1.75rem;
}

.openpa-widget-title,
.page-content .table-responsive > .openpa-widget-title {
	margin: 0 0 0.75rem;
	font-size: 1.15rem;
	font-weight: 600;
	color: var(--apsp-at-primary-dark, #003366);
}

.openpa-widget .table,
.page-content .table-responsive:has(.openpa-widget-title) .table {
	font-size: 0.9375rem;
	border-collapse: collapse;
}

.openpa-widget .table thead th,
.page-content .table-responsive:has(.openpa-widget-title) .table thead th {
	background: var(--apsp-at-primary-dark, #003366);
	color: #fff;
	font-weight: 600;
	padding: 0.75rem 0.65rem;
	border: none;
}

.openpa-widget .table tbody td,
.page-content .table-responsive:has(.openpa-widget-title) .table tbody td {
	padding: 0.7rem 0.65rem;
	border-bottom: 1px solid var(--apsp-at-border, #d9dadb);
	vertical-align: top;
}

.apsp-at-datatable__empty[hidden] {
	display: none !important;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-doc,
.apsp-at-opendata-table .apsp-at-data-table td.col-doc {
	min-width: 10rem;
}

/* Link documenti */
.apsp-at-doc-links {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	align-items: flex-start;
}

.apsp-at-doc-link {
	display: inline-flex;
	align-items: center;
	max-width: 100%;
	min-height: 36px;
	padding: 0.35rem 0.75rem;
	font-size: 0.8125rem;
	font-weight: 600;
	text-align: left;
	white-space: normal;
	word-break: break-word;
	line-height: 1.3;
	text-decoration: none;
	color: var(--apsp-at-primary) !important;
	background: #fff !important;
	border: 1px solid var(--apsp-at-primary) !important;
	border-radius: 4px;
}

.apsp-at-doc-link:hover,
.apsp-at-doc-link:focus {
	color: var(--apsp-at-primary-dark) !important;
	border-color: var(--apsp-at-primary-dark) !important;
	background: var(--apsp-at-primary-light) !important;
	text-decoration: none;
}

.apsp-at-doc-link:focus-visible {
	outline: 2px solid var(--apsp-at-primary);
	outline-offset: 2px;
}

.apsp-at-doc-link__label {
	display: block;
}

/* Provvedimenti per anno */
.apsp-at-opendata-table--provvedimenti .apsp-at-table-year-heading {
	margin-top: 1.5rem;
	margin-bottom: 0.5rem;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--apsp-at-primary-dark);
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--provvedimenti {
	table-layout: fixed;
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--cols-3 col.col-num {
	width: 8%;
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--cols-3 col.col-date {
	width: 14%;
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--cols-4 col.col-num {
	width: 7%;
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--cols-4 col.col-date {
	width: 12%;
}

/* —— Vista card mobile —— */
.apsp-at-datatable__cards {
	display: grid;
	gap: 1rem;
	margin-top: 0.5rem;
}

.apsp-at-datatable__cards[hidden] {
	display: none !important;
}

.apsp-at-datatable-card {
	border: 1px solid var(--apsp-at-border);
	border-left: 4px solid var(--apsp-at-primary);
	border-radius: 4px;
	background: #fff;
	padding: 1rem 1.1rem;
}

.apsp-at-datatable-card__list {
	margin: 0;
}

.apsp-at-datatable-card__row {
	display: grid;
	grid-template-columns: minmax(7rem, 38%) 1fr;
	gap: 0.35rem 0.75rem;
	padding: 0.45rem 0;
	border-bottom: 1px solid #eef0f2;
}

.apsp-at-datatable-card__row:last-child {
	border-bottom: none;
}

.apsp-at-datatable-card__label {
	margin: 0;
	font-size: 0.8125rem;
	font-weight: 700;
	color: #435a70;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.apsp-at-datatable-card__value {
	margin: 0;
	font-size: 0.9375rem;
	color: #1a1a1a;
	word-break: break-word;
}

/* —— Vista scheda persona (incarichi dirigenziali, ecc.) —— */
.apsp-at-opendata-table--person-cards {
	margin-top: 1.5rem;
}

.apsp-at-person-cards {
	display: grid;
	gap: 1.25rem;
}

.apsp-at-person-card {
	border: 1px solid var(--apsp-at-border);
	border-left: 4px solid var(--apsp-at-primary);
	border-radius: 4px;
	background: #fff;
	padding: 1.25rem 1.35rem;
	box-shadow: 0 1px 2px rgba(0, 51, 102, 0.06);
}

.apsp-at-person-card__header {
	margin-bottom: 1rem;
	padding-bottom: 0.85rem;
	border-bottom: 1px solid #eef0f2;
}

.apsp-at-person-card__name {
	margin: 0 0 0.25rem;
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--apsp-at-primary-dark);
	line-height: 1.3;
}

.apsp-at-person-card__role {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	color: var(--apsp-at-text-muted);
}

.apsp-at-person-card__fields {
	margin: 0 0 1rem;
}

.apsp-at-person-card__field {
	display: grid;
	grid-template-columns: minmax(8rem, 34%) 1fr;
	gap: 0.35rem 0.85rem;
	padding: 0.5rem 0;
	border-bottom: 1px solid #eef0f2;
}

.apsp-at-person-card__field:last-child {
	border-bottom: none;
}

.apsp-at-person-card__label {
	margin: 0;
	font-size: 0.8125rem;
	font-weight: 700;
	color: #435a70;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.apsp-at-person-card__value {
	margin: 0;
	font-size: 0.9375rem;
	color: #1a1a1a;
	word-break: break-word;
}

.apsp-at-person-card__value a {
	color: var(--apsp-at-primary);
}

.apsp-at-person-card__docs {
	margin-bottom: 0.75rem;
}

.apsp-at-person-card__docs-title {
	margin: 0 0 0.5rem;
	font-size: 0.875rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: #435a70;
}

.apsp-at-long-text {
	margin-top: 0.65rem;
	border: 1px solid var(--apsp-at-border);
	border-radius: 4px;
	background: #f8f9fa;
}

.apsp-at-long-text__summary {
	padding: 0.65rem 0.85rem;
	font-size: 0.9375rem;
	font-weight: 600;
	color: var(--apsp-at-primary-dark);
	cursor: pointer;
	list-style: none;
}

.apsp-at-long-text__summary::-webkit-details-marker {
	display: none;
}

.apsp-at-long-text__summary::before {
	content: "▸ ";
	color: var(--apsp-at-primary);
}

.apsp-at-long-text[open] .apsp-at-long-text__summary::before {
	content: "▾ ";
}

.apsp-at-long-text__body {
	padding: 0 0.85rem 0.85rem;
	font-size: 0.9375rem;
	line-height: 1.55;
	color: #1a1a1a;
}

.apsp-at-long-text__body p {
	margin: 0 0 0.65rem;
}

.apsp-at-long-text__body p:last-child {
	margin-bottom: 0;
}

@media (max-width: 575.98px) {
	.apsp-at-person-card__field {
		grid-template-columns: 1fr;
		gap: 0.2rem;
	}
}

@media (max-width: 991.98px) {
	.apsp-at-datatable__scroll-hint {
		display: none;
	}

	.apsp-at-datatable__toolbar {
		flex-direction: column;
		align-items: stretch;
	}

	.apsp-at-datatable__search-wrap {
		flex: 1 1 100%;
		min-width: 0;
	}

	.apsp-at-datatable__year-wrap {
		width: 100%;
		min-width: 0;
	}

	.apsp-at-datatable__year {
		width: 100%;
	}

	.apsp-at-datatable__count {
		align-self: flex-start;
	}

	.apsp-at-datatable__table-wrap {
		display: none;
	}

	.apsp-at-datatable__cards:not([hidden]) {
		display: grid;
	}

	/* Se JS non ha ancora costruito le card, mostra tabella scrollabile invece di area vuota */
	.apsp-at-datatable-block:not(:has(.apsp-at-datatable-card)) .apsp-at-datatable__table-wrap {
		display: block;
		overflow-x: auto;
		max-width: 100%;
		-webkit-overflow-scrolling: touch;
	}

	.apsp-at-opendata-table .apsp-at-data-table {
		min-width: 0;
	}

	.apsp-at-opendata-table .apsp-at-data-table th.col-oggetto,
	.apsp-at-opendata-table .apsp-at-data-table td.col-oggetto {
		min-width: 0;
		width: auto;
	}
}

@media (max-width: 479.98px) {
	.apsp-at-datatable-card__row {
		grid-template-columns: 1fr;
		gap: 0.15rem 0;
	}

	.apsp-at-datatable-card__label {
		font-size: 0.75rem;
	}
}

@media (min-width: 992px) {
	.apsp-at-datatable__cards {
		display: none !important;
	}
}

.apsp-at-leaf-content {
	margin-top: 1rem;
}

.apsp-at-leaf-content h3 {
	margin-top: 1rem;
	margin-bottom: 0.5rem;
	font-size: 1.1rem;
}

.apsp-at-leaf-content p {
	margin-bottom: 0.75rem;
}
