/* =====================================================================
   Ricevute OK — interfaccia
   Sostituisce style.css nelle pagine dell'applicazione.
   Le stampe (p2.html, ricevute) continuano a usare style.css.
   ===================================================================== */

:root {
	--bg: #f3f5f9;
	--surface: #ffffff;
	--surface-2: #f8fafc;
	--text: #1e293b;
	--muted: #64748b;
	--border: #e2e8f0;
	--border-strong: #cbd5e1;
	--primary: #2f6fde;
	--primary-hover: #2459b8;
	--primary-soft: #e8f0fd;
	--success: #15803d;
	--danger: #c62828;
	--sidebar: #0f1b2d;
	--sidebar-2: #16253b;
	--sidebar-text: #b6c2d4;
	--sidebar-active: #ffffff;
	--radius: 12px;
	--radius-sm: 8px;
	--shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);
	--sidebar-w: 264px;
	--font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body.app {
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

body.app a { color: var(--primary); text-decoration: none; }
body.app a[href]:hover { text-decoration: underline; }
/* il vecchio codice racchiude molti testi in <a> senza link: niente aspetto da link */
body.app a:not([href]) { color: inherit; text-decoration: none !important; cursor: inherit; }
body.app img { max-width: 100%; }

/* ---------------------------------------------------------------------
   Struttura
   --------------------------------------------------------------------- */

/* #container è ridimensionato da uno script dei vecchi layout: lo ignoriamo */
/* il vecchio script imposta altezza e larghezza fisse su #container */
#container { height: auto !important; }
#container:not(.auth-card) { width: auto !important; }
#container.auth-card { width: 100% !important; }

#container.app-shell {
	display: flex;
	min-height: 100vh;
	width: auto !important;
	height: auto !important;
}

.app-sidebar {
	position: fixed;
	inset: 0 auto 0 0;
	width: var(--sidebar-w);
	background: var(--sidebar);
	color: var(--sidebar-text);
	display: flex;
	flex-direction: column;
	z-index: 40;
	overflow-y: auto;
	transition: transform .2s ease;
}

.app-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 20px 20px 18px;
	color: #fff !important;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: -.01em;
	text-decoration: none !important;
}
.app-brand img { width: 34px; height: 34px; border-radius: 9px; background: #fff; padding: 3px; }
.app-brand b { color: #7fb0ff; font-weight: 800; }

.app-nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.app-nav a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 9px 12px;
	border-radius: var(--radius-sm);
	color: var(--sidebar-text) !important;
	font-weight: 500;
	text-decoration: none !important;
}
.app-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.app-nav a:hover { background: var(--sidebar-2); color: #fff !important; }
.app-nav a.is-active { background: var(--primary); color: var(--sidebar-active) !important; }
.app-nav a.is-active svg { opacity: 1; }

/* sottomenu della sezione */
.app-subnav-wrap { padding: 8px 12px 16px; }
.app-subnav-wrap:empty { display: none; }
.subnav { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 12px; }
.subnav-group { margin-bottom: 10px; }
.subnav-title {
	padding: 4px 12px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: #6f819b;
}
.subnav a {
	display: block;
	padding: 6px 12px 6px 24px;
	border-radius: var(--radius-sm);
	color: var(--sidebar-text) !important;
	font-size: 13.5px;
	text-decoration: none !important;
	position: relative;
}
.subnav a::before {
	content: "";
	position: absolute;
	left: 12px;
	top: 50%;
	width: 5px;
	height: 5px;
	margin-top: -2.5px;
	border-radius: 50%;
	background: #44566f;
}
.subnav a:hover { background: var(--sidebar-2); color: #fff !important; }
.subnav a.is-active { background: rgba(127, 176, 255, .14); color: #fff !important; }
.subnav a.is-active::before { background: #7fb0ff; }

.app-sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.app-sidebar-footer a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 9px 12px;
	border-radius: var(--radius-sm);
	color: var(--sidebar-text) !important;
	text-decoration: none !important;
}
.app-sidebar-footer a:hover { background: var(--sidebar-2); color: #fff !important; }
.app-sidebar-footer svg { width: 18px; height: 18px; }

.app-main {
	flex: 1;
	min-width: 0;
	margin-left: var(--sidebar-w);
	display: flex;
	flex-direction: column;
}

.app-topbar {
	position: sticky;
	top: 0;
	z-index: 30;
	display: flex;
	align-items: center;
	gap: 14px;
	height: 60px;
	padding: 0 28px;
	background: rgba(255, 255, 255, .9);
	backdrop-filter: saturate(180%) blur(8px);
	border-bottom: 1px solid var(--border);
}
.app-breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; }
.app-breadcrumb .crumb-section { color: var(--muted); white-space: nowrap; }
.app-breadcrumb .crumb-sep { color: var(--border-strong); }
.app-breadcrumb .crumb-page { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-toggle {
	display: none;
	width: 38px;
	height: 38px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--text);
	cursor: pointer;
	padding: 0;
	align-items: center;
	justify-content: center;
}
.nav-toggle svg { width: 20px; height: 20px; }

.app-content {
	flex: 1;
	width: 100%;
	max-width: 1280px;
	padding: 28px;
}
.app-content.is-wide { max-width: none; }

.app-backdrop { display: none; }

/* ---------------------------------------------------------------------
   Contenuti: card, titoli, testi
   --------------------------------------------------------------------- */

.app-content h1, .app-content h2, .app-content h3, .app-content h4 {
	color: var(--text);
	letter-spacing: -.01em;
	margin: 0 0 14px;
	line-height: 1.3;
}
.app-content h1 { font-size: 24px; font-weight: 700; }
.app-content h2 { font-size: 20px; font-weight: 650; }
.app-content h3 { font-size: 17px; font-weight: 600; }
.app-content h4 { font-size: 15px; font-weight: 600; }
.app-content p { margin: 0 0 12px; }

/* contenitori storici: diventano neutri, la card è il fieldset o il blocco */
.app-content .div_ins,
.app-content .div_ins2,
.app-content .div_inssocio,
.app-content .div_cont {
	float: none;
	width: auto;
	margin: 0 0 20px;
	padding: 0;
	background: none;
}
.app-content .div_ins::after,
.app-content .div_ins2::after { content: ""; display: table; clear: both; }

/* i moduli non hanno bisogno di tutta la larghezza */
.app-content .div_ins:has(> form fieldset),
.app-content .div_ins:has(> fieldset) { max-width: 920px; }

/* blocchi di testo semplici (pagine di sezione, messaggi) */
.app-content > .div_ins:not(:has(form)):not(:has(table)),
.app-content .card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 22px 24px;
}

/* ---------------------------------------------------------------------
   Moduli
   --------------------------------------------------------------------- */

.app-content form { margin: 0; }

.app-content fieldset {
	float: none;
	display: flow-root;
	width: 100%;
	margin: 0 0 20px;
	padding: 22px 24px 18px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow);
	min-width: 0;
}
.app-content legend {
	float: left;
	width: 100%;
	padding: 0 0 14px;
	margin: 0 0 6px;
	border-bottom: 1px solid var(--border);
	background: none;
	color: var(--text);
	font-size: 17px;
	font-weight: 650;
}
.app-content legend + * { clear: both; }

/* riga etichetta + campo */
.app-content fieldset > div,
.app-content fieldset > form > div {
	float: none;
	clear: both;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 14px;
	width: 100%;
	padding: 10px 0;
	background: none;
	border-bottom: 1px solid #f1f4f8;
}
.app-content fieldset > div:last-child,
.app-content fieldset > form > div:last-child { border-bottom: 0; }

/* gli a capo tra campo e pulsante (es. Calcola codice fiscale) non servono nel layout a righe */
.app-content fieldset > div > br,
.app-content .div1 > br { display: none; }

/* righe affiancate a metà larghezza */
.app-content .div1 {
	float: left;
	clear: none;
	width: 50%;
	padding: 10px 14px 10px 0;
	background: none;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 14px;
}

.app-content .label_xl,
.app-content .label_xxl,
.app-content .label_xxxl,
.app-content .label {
	float: none;
	display: inline-block;
	flex: 0 0 200px;
	width: 200px;
	margin: 0;
	color: var(--muted);
	font-weight: 500;
	line-height: 1.4;
}
.app-content .label_xxl { flex-basis: 220px; width: 220px; }
.app-content .label_xxxl { flex-basis: 300px; width: 300px; }
.app-content label { color: var(--muted); }

.app-content input[type=text],
.app-content input[type=password],
.app-content input[type=email],
.app-content input[type=number],
.app-content input[type=tel],
.app-content input[type=date],
.app-content input[type=search],
.app-content input:not([type]),
.app-content select,
.app-content textarea {
	font: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
	min-height: 38px;
	padding: 7px 11px;
	width: 100%;
	max-width: 380px;
	transition: border-color .15s, box-shadow .15s;
}
.app-content textarea { min-height: 90px; max-width: 640px; }
.app-content select {
	padding-right: 34px;
	-webkit-appearance: none; appearance: none;
	background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
	cursor: pointer;
}
.app-content select:disabled { background-color: var(--surface-2); cursor: default; }
.app-content input:focus,
.app-content select:focus,
.app-content textarea:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(47, 111, 222, .18);
}
.app-content input[readonly] { background: var(--surface-2); color: var(--muted); }
.app-content input[type=radio],
.app-content input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0 14px 0 4px; vertical-align: middle; }

/* pulsanti */
.app-content input[type=submit],
.app-content input[type=button],
.app-content input[type=reset],
.app-content button,
.app-content .button {
	font: inherit;
	font-weight: 600;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 38px;
	padding: 8px 18px;
	border-radius: var(--radius-sm);
	border: 1px solid transparent;
	background: var(--primary);
	color: #fff !important;
	cursor: pointer;
	width: auto;
	max-width: none;
	text-decoration: none !important;
	transition: background .15s, box-shadow .15s;
	box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}
.app-content input[type=submit]:hover,
.app-content button:hover,
.app-content .button:hover { background: var(--primary-hover); }
.app-content input[type=button],
.app-content input[type=reset] {
	background: var(--surface);
	color: var(--text) !important;
	border-color: var(--border-strong);
	box-shadow: none;
}
.app-content input[type=button]:hover,
.app-content input[type=reset]:hover { background: var(--surface-2); border-color: #94a3b8; }

/* pulsanti con dimensioni fisse scritte nel codice (Crea PDF, Tessera in MIDS…) */
.app-content button[style],
.app-content input[type=submit][style] {
	width: auto !important;
	height: auto !important;
	font-size: 14px !important;
	color: #fff !important;
	padding: 8px 18px !important;
}
.app-content div[style*="margin-bottom: 100px"] { margin: 0 0 24px !important; }

/* pulsante da solo in fondo al modulo */
.app-content fieldset > div:last-child:has(> input[type=submit]:only-child) { padding-top: 16px; }

/* ---------------------------------------------------------------------
   Tabelle (elenchi e contabilità). La tabella .t è la ricevuta: esclusa.
   --------------------------------------------------------------------- */

.app-content table:not(.t) {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	overflow: hidden;
	margin: 0 0 20px;
	font-size: 13.5px;
}
.app-content table:not(.t) th {
	background: var(--surface-2) !important;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .04em;
	text-align: left;
	padding: 11px 14px;
	border: 0;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
.app-content table:not(.t) td {
	padding: 9px 14px;
	border: 0;
	border-bottom: 1px solid #eef2f6;
	background: transparent;
	vertical-align: middle;
}
.app-content table:not(.t) tr:last-child td { border-bottom: 0; }
.app-content table:not(.t) tbody tr:hover td { background: #f8fbff; }
.app-content table:not(.t) td a:not(.icon-btn) { color: inherit; }
.app-content table:not(.t) td a[href]:hover { color: var(--primary); }
.app-content table:not(.t) td img { vertical-align: middle; width: 18px; height: 18px; opacity: .75; }
.app-content table:not(.t) td img:hover { opacity: 1; }
/* righe separatrici dei report storici */
.app-content table:not(.t) hr { display: none; }
.app-content table:not(.t) tr:has(> td > hr:only-child) { display: none; }

.app-content table.t1 td b,
.app-content table.t2 td b { color: var(--text); }

/* DataTables */
.app-content .dataTables_wrapper {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px;
	margin-bottom: 20px;
	overflow-x: auto;
}
.app-content .dataTables_wrapper table.dataTable {
	border: 0 !important;
	box-shadow: none;
	border-radius: 0;
	margin: 12px 0 !important;
}
.app-content table.dataTable thead th,
.app-content table.dataTable thead td { border-bottom: 1px solid var(--border) !important; padding: 11px 14px !important; }
.app-content table.dataTable.no-footer { border-bottom: 1px solid var(--border) !important; }
.app-content table.dataTable tbody tr { background: transparent !important; }
.app-content table.dataTable.display tbody tr.odd > .sorting_1,
.app-content table.dataTable.display tbody tr.even > .sorting_1 { background: transparent !important; }
.app-content .dataTables_wrapper .dataTables_filter input,
.app-content .dataTables_wrapper .dataTables_length select {
	width: auto;
	min-height: 34px;
	margin-left: 8px;
	display: inline-block;
}
.app-content .dataTables_wrapper .dataTables_filter label,
.app-content .dataTables_wrapper .dataTables_length label,
.app-content .dataTables_wrapper .dataTables_info { color: var(--muted); font-size: 13px; }
.app-content .dataTables_wrapper .dataTables_paginate .paginate_button {
	border: 1px solid transparent !important;
	border-radius: var(--radius-sm) !important;
	padding: 4px 10px !important;
	margin-left: 4px;
	color: var(--text) !important;
	background: none !important;
}
.app-content .dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--surface-2) !important; border-color: var(--border) !important; }
.app-content .dataTables_wrapper .dataTables_paginate .paginate_button.current,
.app-content .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
	background: var(--primary) !important;
	border-color: var(--primary) !important;
	color: #fff !important;
}

/* ---------------------------------------------------------------------
   Home
   --------------------------------------------------------------------- */

.home-hero {
	background: linear-gradient(135deg, #1f4fa8 0%, #2f6fde 55%, #4f8df0 100%);
	color: #fff;
	border-radius: 16px;
	padding: 30px 32px;
	margin-bottom: 24px;
	box-shadow: var(--shadow);
}
.home-hero h1 { color: #fff !important; margin: 0 0 6px; font-size: 26px; }
.home-hero p { margin: 0; opacity: .85; font-size: 15px; }

.home-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 16px;
}
.home-tile {
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 20px;
	box-shadow: var(--shadow);
	color: var(--text) !important;
	text-decoration: none !important;
	transition: transform .15s, box-shadow .15s, border-color .15s;
}
.home-tile:hover { transform: translateY(-2px); border-color: #b9cff5; box-shadow: 0 8px 24px rgba(15, 23, 42, .1); }
.home-tile .tile-icon {
	width: 40px;
	height: 40px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--primary-soft);
	color: var(--primary);
}
.home-tile .tile-icon svg { width: 20px; height: 20px; }
.home-tile strong { font-size: 15px; }
.home-tile span { color: var(--muted); font-size: 13px; }

/* pagine di sezione (Soci, Contabilità, MIDS, Dati di base) */
.section-landing { margin: 4px 0 22px; }
.section-landing h1 { font-size: 26px; margin-bottom: 6px; }
.section-landing p { color: var(--muted); font-size: 15px; max-width: 680px; }
.section-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 16px;
}
.section-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 18px 18px 12px;
	display: flex;
	flex-direction: column;
}
.section-card h3 {
	font-size: 12px !important;
	font-weight: 600 !important;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--muted) !important;
	margin: 0 0 8px !important;
}
.section-card a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 9px 10px;
	margin: 0 -10px;
	border-radius: var(--radius-sm);
	color: var(--text) !important;
	font-weight: 500;
	text-decoration: none !important;
}
.section-card a::after { content: "›"; color: var(--border-strong); font-size: 18px; line-height: 1; }
.section-card a:hover { background: var(--primary-soft); color: var(--primary) !important; }
.section-card a:hover::after { color: var(--primary); }

/* ---------------------------------------------------------------------
   Accesso (login, errori)
   --------------------------------------------------------------------- */

body.app-auth {
	font-family: var(--font);
	font-size: 14px;
	color: var(--text);
	-webkit-font-smoothing: antialiased;
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	background:
		radial-gradient(1200px 600px at 10% -10%, #2f6fde33, transparent 60%),
		radial-gradient(900px 500px at 110% 110%, #7fb0ff33, transparent 60%),
		var(--bg);
}
.auth-card {
	width: 100%;
	max-width: 420px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 16px;
	box-shadow: 0 10px 40px rgba(15, 23, 42, .12);
	padding: 32px 32px 28px;
}
.auth-card .auth-logo { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto 18px; }
.auth-card h1 { font-size: 20px; text-align: center; margin: 0 0 6px; }
.auth-card .auth-sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.auth-card .auth-field { margin-bottom: 14px; }
.auth-card .auth-field label { display: block; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.auth-card input[type=text],
.auth-card input[type=password] {
	width: 100%;
	max-width: none;
	font: inherit;
	min-height: 42px;
	padding: 9px 12px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
}
.auth-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 222, .18); }
.auth-card input[type=submit],
.auth-card input[type=button] {
	width: 100%;
	min-height: 42px;
	margin-top: 8px;
	font: inherit;
	font-weight: 600;
	color: #fff;
	background: var(--primary);
	border: 0;
	border-radius: var(--radius-sm);
	cursor: pointer;
}
.auth-card input[type=submit]:hover,
.auth-card input[type=button]:hover { background: var(--primary-hover); }
.auth-card .auth-error { text-align: center; }
.auth-card .auth-error .auth-icon {
	width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: #fdecec; color: var(--danger);
}
.auth-footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------------------------------------------------------------------
   Pagine senza menu (primo avvio, iscrizione pubblica)
   --------------------------------------------------------------------- */

body.app-plain .app-plain-header {
	background: var(--sidebar);
	color: #fff;
	padding: 14px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
body.app-plain .app-plain-header .app-brand { padding: 0; }
body.app-plain .app-plain-header a.plain-link { color: var(--sidebar-text); }
body.app-plain .app-content { margin: 0 auto; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */

@media (max-width: 1024px) {
	.app-sidebar { transform: translateX(-100%); box-shadow: none; }
	.app-main { margin-left: 0; }
	.nav-toggle { display: inline-flex; }
	body.nav-open .app-sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
	body.nav-open .app-backdrop {
		display: block;
		position: fixed;
		inset: 0;
		background: rgba(15, 23, 42, .45);
		z-index: 35;
	}
	.app-topbar { padding: 0 16px; }
	.app-content { padding: 20px 16px; }
}

@media (max-width: 720px) {
	.app-content .div1 { float: none; width: 100%; padding-right: 0; }
	.app-content .label_xl,
	.app-content .label_xxl,
	.app-content .label_xxxl,
	.app-content .label { flex-basis: 100%; width: 100%; }
	.app-content input[type=text],
	.app-content input[type=password],
	.app-content input[type=email],
	.app-content input[type=number],
	.app-content input[type=date],
	.app-content input:not([type]),
	.app-content select,
	.app-content textarea { max-width: none; }
	.app-content fieldset { padding: 18px 16px 14px; }
	/* le tabelle larghe scorrono dentro la card invece di allargare la pagina */
	.app-content table:not(.t) { display: block; overflow-x: auto; white-space: nowrap; }
	.home-hero { padding: 22px 20px; }
}

/* ---------------------------------------------------------------------
   Stampa: solo il contenuto
   --------------------------------------------------------------------- */

@media print {
	.app-sidebar, .app-topbar, .app-backdrop { display: none !important; }
	.app-main { margin: 0 !important; }
	.app-content { padding: 0 !important; max-width: none !important; }
	body.app { background: #fff; }
	.app-content table:not(.t), .app-content fieldset { box-shadow: none; }
}

/* ---------------------------------------------------------------------
   Documenti
   --------------------------------------------------------------------- */

.doc-list {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	max-width: 760px;
	overflow: hidden;
}
.doc-item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 18px;
	border-bottom: 1px solid var(--border);
	color: var(--text) !important;
	text-decoration: none !important;
}
.doc-item:last-child { border-bottom: 0; }
.doc-item:hover { background: var(--surface-2); }
.doc-icon {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	border-radius: 10px;
	background: #fdecec;
	color: var(--danger);
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}
.doc-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.doc-text small { color: var(--muted); }
.doc-action { color: var(--primary); font-weight: 600; font-size: 13px; }

/* ---------------------------------------------------------------------
   Messaggi di conferma
   --------------------------------------------------------------------- */

.alert-success {
	display: flex;
	align-items: center;
	gap: 14px;
	max-width: 760px;
	padding: 18px 22px;
	background: #ecfdf3;
	border: 1px solid #b7ebc9;
	border-radius: var(--radius);
	color: #14532d;
}
.alert-success h3 { margin: 0 !important; font-size: 16px !important; color: #14532d !important; }
.alert-success .alert-icon {
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: #16a34a;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
}
.alert-success .alert-icon svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------------
   Pulsanti azione negli elenchi (modifica, elimina, tessera)
   --------------------------------------------------------------------- */

.app-content td:has(> .icon-btn) { white-space: nowrap; width: 1%; }
.app-content a.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	margin: 2px 4px 2px 0;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--muted) !important;
	text-decoration: none !important;
	vertical-align: middle;
	transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.app-content a.icon-btn svg { width: 17px; height: 17px; }
.app-content a.icon-btn:active { transform: scale(.94); }
.app-content a.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(47, 111, 222, .25); }
.app-content a.icon-edit:hover { background: var(--primary-soft); border-color: #b9cff5; color: var(--primary) !important; }
.app-content a.icon-delete:hover { background: #fdecec; border-color: #f5c2c2; color: var(--danger) !important; }
.app-content a.icon-card:hover { background: #ecfdf3; border-color: #b7ebc9; color: var(--success) !important; }

/* su touch: area di tocco più ampia e colori sempre visibili */
@media (hover: none), (max-width: 720px) {
	.app-content a.icon-btn { width: 42px; height: 42px; margin-right: 6px; }
	.app-content a.icon-btn svg { width: 20px; height: 20px; }
	.app-content a.icon-edit { color: var(--primary) !important; background: var(--primary-soft); border-color: #cfdcf6; }
	.app-content a.icon-delete { color: var(--danger) !important; background: #fdf1f1; border-color: #f5d0d0; }
	.app-content a.icon-card { color: var(--success) !important; background: #f0fbf4; border-color: #c9ecd5; }
}

/* ---------------------------------------------------------------------
   Pannello di amministrazione
   --------------------------------------------------------------------- */

.app-admin .app-sidebar { background: #111a2b; }
.admin-tag {
	margin: -8px 20px 14px 64px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: #f5b84b;
}
.admin-who { padding: 4px 12px 8px; font-size: 12px; color: #6f819b; }
.app-breadcrumb a.crumb-section { color: var(--muted) !important; }

.alert {
	max-width: 920px;
	padding: 13px 16px;
	margin: 0 0 18px;
	border-radius: var(--radius-sm);
	border: 1px solid;
	font-size: 14px;
}
.alert-success { background: #ecfdf3; border-color: #b7ebc9; color: #14532d; }
.alert-error { background: #fdf0f0; border-color: #f3c4c4; color: #8a1f1f; }
.alert-warning { background: #fff8e8; border-color: #f6dfa4; color: #7a5300; }
.alert-info { background: var(--primary-soft); border-color: #c9d9f7; color: #1d4386; }

.badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
	background: var(--surface-2);
	color: var(--muted);
	border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: #ecfdf3; color: #15803d; border-color: #c9ecd5; }
.badge-warn { background: #fff8e8; color: #a16207; border-color: #f6dfa4; }
.badge-err { background: #fdf0f0; color: #b42318; border-color: #f3c4c4; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px !important; }
.page-head p { margin: 0; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px 18px;
}
.stat .stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat .stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .stat-note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.panel {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 20px 22px;
	margin-bottom: 20px;
	max-width: 920px;
}
.panel h2 { font-size: 17px !important; margin-bottom: 12px !important; }
.panel.is-danger { border-color: #f3c4c4; }

.kv { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.form-help { flex-basis: 100%; margin: 2px 0 0 214px; color: var(--muted); font-size: 12.5px; }
.app-content .button-danger,
.app-content input[type=submit].button-danger { background: var(--danger) !important; }
.app-content .button-danger:hover { background: #a61f1f !important; }
.app-content a.button { color: #fff !important; }
.app-content a.button.button-light { background: var(--surface); color: var(--text) !important; border-color: var(--border-strong); box-shadow: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

@media (max-width: 720px) {
	.kv { grid-template-columns: 1fr; gap: 2px; }
	.kv dd { margin-bottom: 8px; }
	.form-help { margin-left: 0; }
}

/* stagione mostrata nei report */
.report-stagione { margin: 0 0 12px; color: var(--muted); }
.report-stagione strong { color: var(--text); }
.app-content button.link-button {
	background: none !important;
	border: 0;
	box-shadow: none;
	padding: 0;
	min-height: 0;
	color: var(--primary) !important;
	font-weight: 500;
	cursor: pointer;
}
.app-content button.link-button:hover { text-decoration: underline; }
.banner-impersona {
	background: #fff4d6;
	border-bottom: 1px solid #f6dfa4;
	color: #7a5300;
	padding: 8px 28px;
	font-size: 13px;
	display: flex;
	gap: 12px;
	align-items: center;
	flex-wrap: wrap;
}
.banner-impersona a { color: #7a5300 !important; font-weight: 600; }
.topbar-stagione {
	margin-left: auto;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--primary-soft);
	color: var(--primary);
	font-size: 12.5px;
	font-weight: 600;
	white-space: nowrap;
}

/* pulsanti "Elimina" degli elenchi: piccoli moduli POST */
.app-content form.inline-form { display: inline; margin: 0; }
.app-content button.icon-btn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 34px; height: 34px; min-height: 0; margin: 2px 4px 2px 0; padding: 0;
	border-radius: var(--radius-sm); border: 1px solid var(--border);
	background: var(--surface); color: var(--muted) !important; box-shadow: none;
	vertical-align: middle; cursor: pointer;
}
.app-content button.icon-btn svg { width: 17px; height: 17px; }
.app-content button.icon-delete:hover { background: #fdecec; border-color: #f5c2c2; color: var(--danger) !important; }
@media (hover: none), (max-width: 720px) {
	.app-content button.icon-btn { width: 42px; height: 42px; }
	.app-content button.icon-btn svg { width: 20px; height: 20px; }
	.app-content button.icon-delete { color: var(--danger) !important; background: #fdf1f1; border-color: #f5d0d0; }
}

/* avviso dopo un salvataggio, in cima alla pagina di destinazione */
.avviso-flash { position: relative; margin: 0 0 20px; max-width: 920px; }
.avviso-flash > .alert-success,
.avviso-flash > .alert { margin: 0; padding-right: 48px; max-width: none; }
.avviso-flash .alert-success h3 a { margin-left: 6px; font-weight: 600; }
.avviso-chiudi {
	position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
	width: 28px; height: 28px; min-height: 0 !important; padding: 0 !important;
	border: 0 !important; border-radius: 50%; box-shadow: none !important;
	background: transparent !important; color: inherit !important; opacity: .55;
	font-size: 20px; line-height: 1; cursor: pointer;
}
.avviso-chiudi:hover { opacity: 1; background: rgba(0,0,0,.06) !important; }

/* ---------------------------------------------------------------
   Ordinamento, ricerca e filtri delle tabelle (js/tabelle.js)
   --------------------------------------------------------------- */
.tab-strumenti { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 10px; }
.tab-strumenti .tab-cerca { max-width: 320px; margin: 0 !important; }
.tab-strumenti .tab-info { color: var(--muted); font-size: 13px; }
.app-content .tab-strumenti .tab-azzera { background: var(--surface) !important; color: var(--primary) !important; border: 1px solid var(--border-strong) !important; box-shadow: none !important; border-radius: var(--radius-sm); padding: 6px 12px !important; font-size: 13px !important; font-weight: 600; min-height: 0; width: auto; cursor: pointer; }
.app-content .tab-strumenti .tab-azzera:hover { background: var(--primary-soft) !important; }
th.ordinabile { cursor: pointer; user-select: none; }
th.ordinabile::after { content: '↕'; margin-left: 3px; opacity: .35; font-size: .75em; }
.tab-scorri { overflow-x: auto; max-width: 100%; }
th.ordinabile[aria-sort="ascending"]::after { content: '▲'; opacity: .9; }
th.ordinabile[aria-sort="descending"]::after { content: '▼'; opacity: .9; }
th.ordinabile:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
tr.tab-filtri th { padding: 4px 6px !important; background: var(--surface-2) !important; }
tr.tab-filtri input { width: 100%; min-width: 3.5em; max-width: none !important; margin: 0 !important; padding: 5px 7px !important; font-size: 12.5px !important; font-weight: 400; text-transform: none; letter-spacing: 0; border-radius: 6px; }
table.dataTable thead tr.tab-filtri th { background-image: none !important; cursor: default; }
.tab-nascosta { display: none !important; }
tr.tab-totale-filtro td { font-weight: 700; background: var(--primary-soft) !important; border-top: 2px solid var(--primary) !important; white-space: nowrap; }
tr.tab-totale-filtro td.pos { color: var(--success); }
tr.tab-totale-filtro td.neg { color: var(--danger); }
tr.tab-vuoto td { text-align: center; color: var(--muted); padding: 18px !important; }

/* ---------------------------------------------------------------
   Moduli: allineamento delle righe e data in un'unica riga
   --------------------------------------------------------------- */
/* righe annidate (es. Fornitore/Causale dentro un blocco che si mostra o nasconde) */
.app-content fieldset > div:has(> div > label) { display: block; padding: 0; border-bottom: 0; }
.app-content fieldset > div:has(> div > label) > div:not(.div1) {
	display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
	padding: 10px 0; border-bottom: 1px solid #f1f4f8;
}
/* etichette "label_l" nelle righe intere: stessa colonna delle altre */
.app-content fieldset div:not(.div1) > .label_l { flex: 0 0 200px; width: 200px; margin: 0; font-weight: 500; }
/* giorno / mese / anno affiancati */
.app-content select[name=gg], .app-content select[name=mm], .app-content select[name=aaaa] { width: auto; min-width: 92px; flex: 0 0 auto; }
.app-content .div1:has(> select[name=gg]) > label { flex-basis: 100%; width: 100%; }

/* ---------------------------------------------------------------
   Menu a tendina con ricerca (js/menu.js)
   --------------------------------------------------------------- */
.mt-guscio { position: relative; display: inline-block; width: 100%; max-width: 380px; vertical-align: middle; }
.app-content .mt-guscio > input { max-width: none; }
.mt-nascosto { position: absolute !important; opacity: 0; pointer-events: none; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; left: 12px; bottom: 0; }
.app-content .mt-pulsante {
	display: flex; align-items: center; width: 100%; min-height: 38px; padding: 7px 34px 7px 11px !important;
	background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center !important;
	color: var(--text) !important; border: 1px solid var(--border-strong) !important; border-radius: var(--radius-sm); box-shadow: none !important;
	font: inherit !important; font-weight: 400 !important; text-align: left; justify-content: flex-start !important; cursor: pointer;
}
.app-content .mt-pulsante:hover { border-color: var(--primary) !important; }
.app-content .mt-pulsante:focus-visible, .mt-aperto .mt-pulsante { outline: none; border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(47, 111, 222, .18) !important; }
.app-content .mt-pulsante.mt-segnaposto { color: var(--muted) !important; }
.app-content .mt-pulsante.mt-errore { border-color: var(--danger) !important; }
.app-content .mt-pulsante:disabled { background-color: var(--surface-2) !important; cursor: default; }
.mt-etichetta { flex: 1 1 auto; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-pannello { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0; min-width: 260px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(15, 23, 42, .16); padding: 8px; }
.app-content .mt-pannello .mt-cerca { max-width: none; margin: 0 0 6px !important; min-height: 34px; }
.mt-pannello .mt-elenco { position: static; box-shadow: none; border: 0; max-height: 280px; padding: 0; }
.mt-elenco {
	position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0; min-width: 260px;
	margin: 0; padding: 6px; list-style: none; max-height: 320px; overflow-y: auto;
	background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
	box-shadow: 0 10px 30px rgba(15, 23, 42, .16);
}
.mt-elenco li { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 14px; line-height: 1.3; }
.mt-elenco li.mt-attiva, .mt-elenco li[data-i]:hover { background: var(--primary-soft); }
.mt-elenco li.mt-scelta { font-weight: 600; color: var(--primary); }
.mt-elenco .mt-nota { color: var(--muted); font-size: 12.5px; }
.mt-elenco mark { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
.mt-elenco li.mt-vuoto, .mt-elenco li.mt-altri { cursor: default; color: var(--muted); font-size: 13px; font-style: italic; }
.mt-elenco li.mt-vuoto:hover, .mt-elenco li.mt-altri:hover { background: none; }
@media (max-width: 760px) { .mt-guscio { max-width: none; } }
