/* ==========================================================================
   CMS Abbiategrasso da Vivere
   Stile dell'area riservata: tema chiaro e scuro, contrasti WCAG 2.1 AA,
   focus sempre visibile, animazioni disattivate con prefers-reduced-motion.
   Nessuna dipendenza esterna.
   ========================================================================== */

:root {
	--font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	--bg: #f3f5fb;
	--bg-grad: radial-gradient(1200px 600px at 100% -10%, #e4ebff 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #e6f6f3 0%, transparent 55%), #f3f5fb;
	--surface: #ffffff;
	--surface-2: #f7f8fc;
	--text: #141a2e;
	--muted: #556079;
	--border: #e2e6f0;
	--border-strong: #c7cede;

	--primary: #2f55d4;
	--primary-600: #2446b8;
	--primary-50: #eef2ff;
	--primary-text: #ffffff;
	--accent: #13a38a;

	--danger: #c0262d;
	--danger-50: #fdeeee;
	--success: #138a52;
	--success-50: #e8f7ef;
	--warning: #9a6200;
	--warning-50: #fff5e0;

	--sidebar-bg: linear-gradient(180deg, #111a3a 0%, #172452 55%, #1b2c63 100%);
	--sidebar-text: #c9d2ee;
	--sidebar-muted: #8592bd;
	--sidebar-active: rgba(255, 255, 255, .1);

	--focus: #f5b301;
	--radius-sm: 8px;
	--radius: 12px;
	--radius-lg: 18px;
	--shadow-sm: 0 1px 2px rgba(20, 26, 46, .06), 0 1px 1px rgba(20, 26, 46, .04);
	--shadow: 0 6px 18px -6px rgba(20, 26, 46, .14), 0 2px 6px rgba(20, 26, 46, .05);
	--shadow-lg: 0 24px 48px -16px rgba(20, 26, 46, .28);
	--ease: cubic-bezier(.2, .8, .2, 1);
	--sidebar-w: 16.5rem;

	color-scheme: light;
	font-family: var(--font);
	font-size: 100%;
	line-height: 1.55;
	color: var(--text);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
}

/* Tema scuro: segue il sistema, salvo scelta esplicita con il bottone della barra in alto (data-theme) */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0c1122;
		--bg-grad: radial-gradient(1200px 600px at 100% -10%, #172354 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #0d3b39 0%, transparent 55%), #0c1122;
		--surface: #141b33;
		--surface-2: #19213d;
		--text: #e8ecf8;
		--muted: #a3adc9;
		--border: #263052;
		--border-strong: #36426b;
		--primary: #7b98ff;
		--primary-600: #9ab0ff;
		--primary-50: #1b2650;
		--primary-text: #0c1122;
		--danger: #ff8a8f;
		--danger-50: #3a1418;
		--success: #5ad69a;
		--success-50: #0f2f22;
		--warning: #f5c35b;
		--warning-50: #34270b;
		--sidebar-bg: linear-gradient(180deg, #080d1d 0%, #0e1530 100%);
		--shadow: 0 8px 22px -8px rgba(0, 0, 0, .6);
		--shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #0c1122;
	--bg-grad: radial-gradient(1200px 600px at 100% -10%, #172354 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #0d3b39 0%, transparent 55%), #0c1122;
	--surface: #141b33;
	--surface-2: #19213d;
	--text: #e8ecf8;
	--muted: #a3adc9;
	--border: #263052;
	--border-strong: #36426b;
	--primary: #7b98ff;
	--primary-600: #9ab0ff;
	--primary-50: #1b2650;
	--primary-text: #0c1122;
	--danger: #ff8a8f;
	--danger-50: #3a1418;
	--success: #5ad69a;
	--success-50: #0f2f22;
	--warning: #f5c35b;
	--warning-50: #34270b;
	--sidebar-bg: linear-gradient(180deg, #080d1d 0%, #0e1530 100%);
	--shadow: 0 8px 22px -8px rgba(0, 0, 0, .6);
	--shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
	color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg-grad); background-attachment: fixed; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0; }
p { margin: 0 0 1rem; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-600); }
code { font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

.skip-link {
	position: fixed; left: 1rem; top: -4rem; z-index: 1000;
	background: var(--primary); color: var(--primary-text); padding: .6rem 1rem;
	border-radius: var(--radius-sm); font-weight: 600; transition: top .2s var(--ease);
}
.skip-link:focus { top: 1rem; }

.icon { width: 1.15rem; height: 1.15rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ───────────────────────── Struttura ───────────────────────── */

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.sidebar {
	position: sticky; top: 0; height: 100vh; overflow-y: auto;
	background: var(--sidebar-bg); color: var(--sidebar-text);
	padding: 1.25rem .9rem 1.25rem; scrollbar-width: thin; scrollbar-color: #33427a transparent;
	display: flex; flex-direction: column;
}
.sidebar-foot { margin-top: auto; padding: 1.5rem .75rem 0; display: grid; gap: .25rem; font-size: .76rem; color: var(--sidebar-muted); }
.sidebar-foot p { margin: 0; }
.credits { color: inherit; text-decoration: none; }
.credits strong { font-weight: 600; transition: color .2s; }
.sidebar-foot .credits:hover strong { color: #fff; }
.auth-foot .credits:hover strong { color: var(--primary); }
.brand { display: flex; align-items: center; gap: .75rem; padding: .25rem .5rem 1.25rem; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark {
	display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 12px;
	background: linear-gradient(135deg, #5b7cff 0%, #13c2a3 100%); color: #fff; font-weight: 800; font-size: 1.15rem;
	box-shadow: 0 8px 20px -6px rgba(91, 124, 255, .7);
}
.brand-mark-lg { width: 4rem; height: 4rem; font-size: 2rem; border-radius: 18px; }
.brand-text { display: grid; line-height: 1.2; }
.brand-text small { color: var(--sidebar-muted); font-size: .78rem; }

.nav-group { margin: 1.25rem .75rem .4rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--sidebar-muted); }
.nav-link {
	position: relative; display: flex; align-items: center; gap: .7rem;
	padding: .55rem .75rem; margin: 1px 0; border-radius: 10px;
	color: var(--sidebar-text); text-decoration: none; font-size: .94rem;
	transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.nav-link .icon { opacity: .85; transition: transform .25s var(--ease); }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link:hover .icon { transform: translateX(2px); }
.nav-link.is-active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-link.is-active::before {
	content: ""; position: absolute; left: -.9rem; top: 20%; bottom: 20%; width: 4px; border-radius: 0 4px 4px 0;
	background: linear-gradient(180deg, #7b98ff, #13c2a3);
}
.sidebar :focus-visible { outline-color: #ffd257; }

.workspace { min-width: 0; display: flex; flex-direction: column; }

.topbar {
	position: sticky; top: 0; z-index: 50;
	display: flex; align-items: center; gap: 1rem; padding: .75rem 2rem;
	background: color-mix(in srgb, var(--surface) 72%, transparent);
	backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
	border-bottom: 1px solid var(--border);
}
.topbar-title { margin: 0; font-weight: 600; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.topbar-actions form { margin: 0; }
.user-chip { display: flex; align-items: center; gap: .5rem; padding: .25rem .75rem .25rem .25rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.avatar { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: linear-gradient(135deg, #5b7cff, #13c2a3); color: #fff; font-size: .8rem; font-weight: 700; }
.user-name { font-size: .9rem; font-weight: 600; }
.sidebar-toggle { display: inline-grid; border-color: var(--border) !important; background: var(--surface) !important; color: var(--text) !important; box-shadow: var(--shadow-sm); }
.sidebar-toggle:hover { border-color: var(--primary) !important; color: var(--primary) !important; }
/* Computer: menu laterale nascosto con il bottone (scelta ricordata nel browser) */
@media (min-width: 961px) {
	.app { transition: grid-template-columns .3s var(--ease); }
	.app.sidebar-collapsed { grid-template-columns: 0 1fr; }
	.app.sidebar-collapsed .sidebar { visibility: hidden; padding-left: 0; padding-right: 0; overflow: hidden; }
}

.main { padding: 2rem; max-width: 92rem; width: 100%; animation: page-in .45s var(--ease) both; }
.main:focus { outline: none; }

@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 960px) {
	.app { grid-template-columns: 1fr; }
	.sidebar {
		position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-w), 85vw); z-index: 200;
		transform: translateX(-105%); transition: transform .3s var(--ease); box-shadow: var(--shadow-lg);
	}
	.sidebar.is-open { transform: none; }
	.sidebar-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(8, 12, 26, .5); backdrop-filter: blur(2px); }
	.sidebar-toggle { display: inline-grid; }
	.topbar { padding: .6rem 1rem; }
	.user-name, .topbar-actions .btn-ghost span:not(.visually-hidden) { display: none; }
	.main { padding: 1.25rem 1rem 3rem; }
}

/* ───────────────────────── Accesso ───────────────────────── */

body.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-hero {
	position: relative; overflow: hidden; display: grid; place-items: center; padding: 3rem;
	background: linear-gradient(140deg, #111a3a 0%, #1f3389 55%, #13806f 120%); color: #fff;
}
.auth-orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: float 14s ease-in-out infinite; }
.auth-orb-1 { width: 26rem; height: 26rem; background: #5b7cff; top: -8rem; left: -6rem; }
.auth-orb-2 { width: 22rem; height: 22rem; background: #13c2a3; bottom: -8rem; right: -4rem; animation-delay: -5s; }
.auth-orb-3 { width: 14rem; height: 14rem; background: #f5b301; top: 40%; left: 55%; opacity: .25; animation-delay: -9s; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(2rem, -1.5rem) scale(1.08); } }
.auth-hero-text { position: relative; max-width: 26rem; }
.auth-hero-title { font-size: clamp(2.2rem, 1.6rem + 2vw, 3.4rem); font-weight: 800; line-height: 1.05; letter-spacing: -.03em; margin: 1.5rem 0 1rem; }
.auth-hero-sub { font-size: 1.1rem; color: #d4dcf7; }

.auth-panel { display: grid; place-content: center; padding: 2rem; gap: 1.5rem; }
.auth-card {
	width: min(27rem, 100%); padding: 2.5rem; border-radius: var(--radius-lg);
	background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
	animation: card-in .6s var(--ease) both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.auth-card-head { margin-bottom: 1.5rem; }
.auth-card-head h1 { margin-top: 1rem; }
.auth-lock { display: inline-grid; place-items: center; width: 3rem; height: 3rem; border-radius: 14px; background: var(--primary-50); color: var(--primary); }
.auth-lock .icon { width: 1.4rem; height: 1.4rem; }
.auth-foot { text-align: center; font-size: .85rem; color: var(--muted); margin: 0; }

@media (max-width: 860px) {
	body.auth { grid-template-columns: 1fr; }
	.auth-hero { min-height: 14rem; padding: 2rem; }
	.auth-hero-title { font-size: 2rem; margin: 1rem 0 .5rem; }
}

/* ───────────────────────── Pulsanti ───────────────────────── */

.btn {
	--btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
	position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
	min-height: 2.6rem; padding: .5rem 1.05rem; border: 1px solid var(--btn-border); border-radius: 10px;
	background: var(--btn-bg); color: var(--btn-fg); font: inherit; font-weight: 600; font-size: .94rem;
	text-decoration: none; cursor: pointer; white-space: nowrap;
	box-shadow: var(--shadow-sm);
	transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover { color: var(--btn-fg); transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--primary); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: var(--shadow-sm); }
.btn-primary { --btn-bg: linear-gradient(135deg, var(--primary) 0%, #4a6cf0 100%); --btn-fg: var(--primary-text); --btn-border: transparent; box-shadow: 0 8px 18px -8px rgba(47, 85, 212, .75); }
.btn-primary:hover { --btn-fg: var(--primary-text); border-color: transparent; box-shadow: 0 12px 24px -10px rgba(47, 85, 212, .85); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; border-color: var(--border); }
.btn-danger { --btn-fg: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-50); }
.btn-danger-solid { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: transparent; }
.btn-danger-solid:hover { --btn-fg: #fff; border-color: transparent; filter: brightness(1.08); }
.btn-small { min-height: 2.1rem; padding: .3rem .7rem; font-size: .86rem; border-radius: 8px; }
.btn-lg { min-height: 3rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn .icon { width: 1.05rem; height: 1.05rem; }

.icon-btn {
	display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 10px;
	border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
	transition: background .2s var(--ease), color .2s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }

.spinner { display: none; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.is-loading .spinner { display: inline-block; }
.is-loading .btn-label { opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────────────────── Schede e pagine ───────────────────────── */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head .eyebrow { margin: 0 0 .25rem; }
.eyebrow { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); margin-bottom: .35rem; }

.card {
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
	padding: 1.5rem; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-head h2 { display: flex; align-items: center; gap: .5rem; }
.card-head h2 .icon { color: var(--primary); }
.link-more { font-size: .9rem; font-weight: 600; text-decoration: none; }
.link-more::after { content: " →"; display: inline-block; transition: transform .2s var(--ease); }
.link-more:hover::after { transform: translateX(3px); }

.hero-banner {
	display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap;
	padding: 1.75rem 2rem; margin-bottom: 1.5rem; border-radius: var(--radius-lg);
	background:
		radial-gradient(500px 200px at 100% 0%, rgba(19, 194, 163, .16), transparent 70%),
		radial-gradient(500px 220px at 0% 100%, rgba(91, 124, 255, .16), transparent 70%),
		var(--surface);
	border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.hero-banner h1 { margin-bottom: .25rem; }
.hero-banner p:last-child { margin: 0; }
.hero-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(26rem, 100%), 1fr)); gap: 1.5rem; }

/* Statistiche */
.stat-grid { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: 1rem; }
.stat-card a {
	position: relative; overflow: hidden; display: grid; gap: .2rem; height: 100%; padding: 1.25rem 1.35rem;
	border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border);
	color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm);
	transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.stat-card a::after {
	content: ""; position: absolute; right: -2.5rem; top: -2.5rem; width: 8rem; height: 8rem; border-radius: 50%;
	background: var(--tone); opacity: .12; transition: transform .4s var(--ease);
}
.stat-card a:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--tone); }
.stat-card a:hover::after { transform: scale(1.35); }
.stat-icon { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 12px; background: var(--tone); color: #fff; margin-bottom: .6rem; box-shadow: 0 8px 16px -8px var(--tone); }
.stat-value { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .92rem; }
.tone-blue { --tone: #4566e8; }
.tone-teal { --tone: #0f9e86; }
.tone-violet { --tone: #7b4fe0; }
.tone-amber { --tone: #d98a00; }

/* Classifiche della pagina iniziale */
.rank-list, .bar-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; gap: 1rem; align-items: center; padding: .75rem 0; border-top: 1px solid var(--border); }
.rank-list li:first-child { border-top: 0; }
.rank-date { display: grid; place-items: center; flex: none; width: 3.2rem; padding: .35rem 0; border-radius: 10px; background: var(--primary-50); color: var(--primary); line-height: 1.1; }
.rank-day { font-size: 1.2rem; font-weight: 800; }
.rank-month { font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.rank-body { display: grid; gap: .2rem; min-width: 0; flex: 1; }
.rank-body a { font-weight: 600; color: var(--text); text-decoration: none; }
.rank-body a:hover { color: var(--primary); text-decoration: underline; }
.rank-meta { font-size: .85rem; color: var(--muted); }
.meter, .bar-track { display: block; height: .4rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter-bar, .bar-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #4566e8, #13c2a3); transition: width 1.1s var(--ease); }
.bar-list li { display: grid; grid-template-columns: minmax(0, 1fr) 40% auto; gap: .75rem; align-items: center; padding: .55rem 0; }
.bar-list a { color: var(--text); text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list a:hover { color: var(--primary); text-decoration: underline; }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); }

/* Comparsa progressiva */
.reveal { animation: reveal .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms + 60ms); }
@keyframes reveal { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ───────────────────────── Elenchi ───────────────────────── */

.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.search { position: relative; display: flex; gap: .5rem; flex: 1; max-width: 32rem; }
.search input { padding-left: 2.4rem; }
.search .icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { padding: .8rem 1rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table thead th { position: sticky; top: 0; background: var(--surface-2); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: var(--primary); }
.table tbody tr { transition: background .15s var(--ease); }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary-50) 55%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .title-cell a { font-weight: 600; color: var(--text); text-decoration: none; }
.table .title-cell a:hover { color: var(--primary); text-decoration: underline; }

.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; display: inline-flex; gap: .35rem; }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.badge-on { background: var(--success-50); color: var(--success); border-color: transparent; }
.badge-warn { background: var(--warning-50); color: var(--warning); border-color: transparent; }

.swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 6px; border: 1px solid var(--border-strong); vertical-align: -3px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }

.list-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.list-footer p { margin: 0; }
.pagination { display: flex; gap: .3rem; list-style: none; margin: 0; padding: 0; }
.pagination .page, .pagination .gap { display: inline-grid; place-items: center; min-width: 2.3rem; height: 2.3rem; padding: 0 .5rem; border-radius: 9px; text-decoration: none; font-weight: 600; }
.pagination a.page { color: var(--text); border: 1px solid var(--border); background: var(--surface); transition: all .2s var(--ease); }
.pagination a.page:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.pagination .is-current { background: var(--primary); color: var(--primary-text); }

/* ───────────────────────── Moduli ───────────────────────── */

.form { display: grid; gap: 1.25rem; }
.form.card { padding: 2rem; }
.form-section { display: grid; gap: 1.25rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.form-section h2 { font-size: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); gap: 1.25rem; }
.field { display: grid; gap: .4rem; min-width: 0; }
.field > label, .field .label { font-weight: 600; font-size: .94rem; }
.required { color: var(--danger); }
.field .hint { margin: 0; font-size: .86rem; color: var(--muted); }
.field .error { margin: 0; font-size: .86rem; color: var(--danger); font-weight: 600; display: flex; gap: .35rem; align-items: center; animation: shake .35s var(--ease); }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel],
input[type=date], input[type=datetime-local], input[type=search], select, textarea {
	width: 100%; min-height: 2.75rem; padding: .6rem .8rem; font: inherit; color: var(--text);
	background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
	transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
input[type=color] { width: 4rem; height: 2.75rem; padding: .2rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); cursor: pointer; }
textarea { min-height: 6rem; resize: vertical; }
[aria-invalid=true] { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent) !important; }

.checkbox { display: inline-flex; align-items: center; gap: .6rem; font-weight: 500; cursor: pointer; }
.checkbox input { appearance: none; width: 1.25rem; height: 1.25rem; margin: 0; border: 2px solid var(--border-strong); border-radius: 6px; background: var(--surface); display: grid; place-items: center; transition: all .2s var(--ease); cursor: pointer; }
.checkbox input::after { content: ""; width: .35rem; height: .65rem; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform .2s var(--ease); margin-top: -2px; }
.checkbox input:checked { background: var(--primary); border-color: var(--primary); }
.checkbox input:checked::after { transform: rotate(45deg) scale(1); }
.checkbox-group { border: 0; padding: 0; margin: 0; }
.checkbox-group legend { padding: 0; margin-bottom: .4rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .5rem 1rem; padding: .9rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }

.form-actions {
	position: sticky; bottom: 0; z-index: 10; display: flex; gap: .75rem; justify-content: flex-end;
	margin: 0 -2rem -2rem; padding: 1rem 2rem; border-top: 1px solid var(--border);
	background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(10px);
	border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ───────────────────────── Avvisi ───────────────────────── */

.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.alert .icon { margin-top: .15rem; }
.alert-error { background: var(--danger-50); color: var(--danger); }
.alert-success { background: var(--success-50); color: var(--success); }
.alert-warning { background: var(--warning-50); color: var(--warning); }

.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 500; display: grid; gap: .6rem; width: min(24rem, calc(100vw - 2.5rem)); }
.toast {
	display: flex; align-items: center; gap: .75rem; padding: .8rem .8rem .8rem 1rem;
	border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
	border-left: 4px solid var(--success); animation: toast-in .45s var(--ease) both;
}
.toast p { margin: 0; flex: 1; font-weight: 500; }
.toast > .icon { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error > .icon { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning > .icon { color: var(--warning); }
.toast.is-leaving { animation: toast-out .3s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* Finestra di conferma */
.confirm-dialog {
	width: min(26rem, calc(100vw - 2rem)); padding: 2rem; border: 0; border-radius: var(--radius-lg);
	background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); text-align: center;
}
.confirm-dialog[open] { animation: card-in .3s var(--ease) both; }
.confirm-dialog::backdrop { background: rgba(8, 12, 26, .55); backdrop-filter: blur(3px); }
.confirm-icon { display: inline-grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 50%; background: var(--danger-50); color: var(--danger); margin-bottom: .75rem; }
.confirm-icon .icon { width: 1.5rem; height: 1.5rem; }
.confirm-dialog h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.confirm-actions { display: flex; gap: .75rem; justify-content: center; margin-top: 1.25rem; }

/* ───────────────────────── Movimento ridotto ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ───────────────────────── Pannello dei file ───────────────────────── */

.media-panel { margin-top: 1.5rem; }
.dropzone {
	display: grid; justify-items: center; gap: .5rem; padding: 2rem 1rem; text-align: center;
	border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
	transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
.dropzone p { margin: 0; }
.dropzone.is-dragging { border-color: var(--primary); background: var(--primary-50); transform: scale(1.01); }
.dropzone-icon { width: 2.2rem; height: 2.2rem; padding: .45rem; border-radius: 50%; background: var(--primary-50); color: var(--primary); }
.dropzone input:focus-visible + .hint, .dropzone:focus-within { outline: none; }
.dropzone:focus-within label.btn { outline: 3px solid var(--focus); outline-offset: 2px; }
.upload-progress { width: min(24rem, 100%); display: grid; gap: .35rem; font-size: .88rem; color: var(--muted); }

.media-list { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: .75rem; }
.media-item {
	display: grid; grid-template-columns: 10rem 1fr auto; gap: 1rem; align-items: start;
	padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
	transition: box-shadow .2s var(--ease), opacity .25s var(--ease), transform .25s var(--ease);
}
.media-item:hover { box-shadow: var(--shadow); }
.media-item.is-hidden .media-thumb { opacity: .45; }
.media-item.is-dragged { opacity: .5; transform: scale(.98); }
.media-item.is-new { animation: reveal .5s var(--ease) both; }
.media-item.is-removing { opacity: 0; transform: translateX(16px); }
.media-thumb { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: grab; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s var(--ease); }
.media-item:hover .media-thumb img { transform: scale(1.04); }
.media-doc { display: grid; place-content: center; justify-items: center; gap: .25rem; height: 100%; color: var(--danger); font-weight: 800; }
.media-doc .icon { width: 2rem; height: 2rem; }
.media-flag { position: absolute; top: .4rem; left: .4rem; display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--warning); color: #fff; }
.media-flag .icon { width: 1rem; height: 1rem; }
.media-small { position: absolute; bottom: .4rem; left: .4rem; padding: .15rem .5rem; border-radius: 999px; background: #b42318; color: #fff; font-size: .72rem; font-weight: 700; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.media-handle { position: absolute; right: .4rem; bottom: .3rem; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); letter-spacing: -2px; }
.media-text { display: grid; gap: .35rem; min-width: 0; }
.media-text label { font-weight: 600; font-size: .86rem; }
.media-text .hint { margin: 0 0 .35rem; font-size: .8rem; color: var(--muted); }
.media-text .btn { justify-self: start; margin-top: .25rem; }
.media-actions { display: grid; grid-template-columns: repeat(2, auto); gap: .25rem; }
.icon-btn-danger:hover { color: var(--danger); background: var(--danger-50); }

@media (max-width: 720px) {
	.media-item { grid-template-columns: 1fr; }
	.media-actions { grid-template-columns: repeat(5, auto); justify-content: start; }
}

/* ───────────────────────── Editor di testo ───────────────────────── */

.editor { border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); overflow: hidden; transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .2rem; padding: .4rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.editor-btn { min-width: 2.2rem; height: 2.2rem; padding: 0 .5rem; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; transition: background .15s var(--ease); }
.editor-btn:hover { background: var(--surface); border-color: var(--border); }
.editor-area { min-height: 12rem; max-height: 60vh; overflow-y: auto; padding: .9rem 1rem; outline: none; line-height: 1.6; }
.editor-area:empty::before { content: "Scrivi qui il testo…"; color: var(--muted); }
.editor-area h2 { font-size: 1.25rem; margin: 1rem 0 .5rem; }
.editor-area h3 { font-size: 1.1rem; margin: .9rem 0 .4rem; }
.editor-area p { margin: 0 0 .75rem; }

/* ───────────────────────── Ritaglio immagini ───────────────────────── */

.crop-dialog {
	width: min(84rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 1.5rem; overflow-x: hidden;
	border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.crop-dialog[open] { animation: card-in .3s var(--ease) both; }
.crop-dialog::backdrop { background: rgba(8, 12, 26, .65); backdrop-filter: blur(4px); }
.crop-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.crop-head h2 { font-size: 1.3rem; margin-bottom: .25rem; }
.crop-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.crop-tab {
	display: inline-flex; align-items: center; gap: .55rem; padding: .5rem .9rem; border-radius: 999px;
	border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
	transition: all .2s var(--ease);
}
.crop-tab:hover { border-color: var(--primary); }
.crop-tab[aria-selected=true] { background: var(--primary); border-color: var(--primary); color: var(--primary-text); box-shadow: 0 8px 18px -10px var(--primary); }
.crop-tab-ratio { display: inline-block; height: .9rem; border: 2px solid currentColor; border-radius: 3px; }
.crop-tab.is-saved::after { content: "✓"; font-size: .8rem; }
.crop-body { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 1.5rem; align-items: start; }
.crop-stage { position: relative; justify-self: center; max-width: 100%; user-select: none; touch-action: none; border-radius: 10px; overflow: hidden; background: #000; }
.crop-stage img { display: block; max-width: 100%; max-height: 62vh; }
.crop-box {
	position: absolute; cursor: move; outline: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(8, 12, 26, .6);
	transition: box-shadow .2s var(--ease);
}
.crop-box:focus-visible { outline: 3px solid var(--focus); }
.crop-box.is-active { box-shadow: 0 0 0 9999px rgba(8, 12, 26, .45); }
.crop-grid {
	position: absolute; inset: 0; pointer-events: none; opacity: .55;
	background:
		linear-gradient(to right, transparent 33.2%, rgba(255,255,255,.7) 33.3%, rgba(255,255,255,.7) 33.5%, transparent 33.6%, transparent 66.5%, rgba(255,255,255,.7) 66.6%, rgba(255,255,255,.7) 66.8%, transparent 66.9%),
		linear-gradient(to bottom, transparent 33.2%, rgba(255,255,255,.7) 33.3%, rgba(255,255,255,.7) 33.5%, transparent 33.6%, transparent 66.5%, rgba(255,255,255,.7) 66.6%, rgba(255,255,255,.7) 66.8%, transparent 66.9%);
}
.crop-handle { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--primary); cursor: nwse-resize; box-shadow: var(--shadow); }
.crop-side { display: grid; gap: .6rem; min-width: 0; }
.crop-side .label { font-weight: 600; margin: 0; }
.crop-format-desc { margin: 0; font-weight: 500; }
.crop-preview { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); box-shadow: var(--shadow); }
.crop-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }

@media (max-width: 860px) {
	.crop-body { grid-template-columns: 1fr; }
}

/* ───────────────────────── Elementi degli elenchi e delle schede ───────────────────────── */

.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.head-actions form { margin: 0; }
.nowrap { white-space: nowrap; }

.segmented { display: inline-flex; gap: .25rem; padding: .25rem; margin-bottom: 1rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.segment { padding: .45rem 1rem; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; transition: all .2s var(--ease); }
.segment:hover { color: var(--text); background: var(--surface-2); }
.segment.is-active { background: var(--primary); color: var(--primary-text); box-shadow: 0 6px 14px -8px var(--primary); }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; width: 100%; }
.filters .search { flex: 1 1 18rem; }
.filters select { width: auto; min-width: 12rem; }

.date-chip { display: inline-grid; place-items: center; min-width: 3.4rem; padding: .3rem .4rem; border-radius: 10px; background: var(--primary-50); color: var(--primary); line-height: 1.1; }
.date-chip-day { font-size: 1.15rem; font-weight: 800; }
.date-chip-month { font-size: .68rem; font-weight: 700; text-transform: uppercase; }
.cell-meta { display: block; margin-top: .2rem; font-size: .84rem; color: var(--muted); }

.count-pill { display: inline-grid; place-items: center; min-width: 2rem; padding: .1rem .6rem; border-radius: 99px; background: var(--primary-50); color: var(--primary); font-size: .85rem; }
.registrations-panel { margin-top: 1.5rem; display: grid; gap: 1rem; }
.meter-lg { height: .6rem; }
.table-flat { box-shadow: none; }
details.cancelled summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: .5rem 0; }
details.cancelled[open] summary { margin-bottom: .75rem; }
.form-section h2 { display: flex; align-items: center; gap: .5rem; }
.form-section h2 .icon { color: var(--primary); }

/* Archivio file a griglia e filtri con etichette visibili */
.media-library { grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr)); gap: 1rem; }
.media-library .media-item { grid-template-columns: 1fr; }
.media-library .media-thumb { cursor: default; }
.media-library .media-actions { grid-template-columns: repeat(auto-fit, 2.4rem); justify-content: end; }
.toolbar .field { flex: 1 1 12rem; }
.toolbar > .btn { align-self: flex-end; }
.filters-inline { width: auto; }

/* Mappa della posizione */
.map-field { display: grid; gap: .5rem; }
.map-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.map-head .label { margin: 0; font-weight: 600; }
.map-field .hint { margin: 0; font-size: .86rem; color: var(--muted); }
.map-canvas { height: 22rem; border-radius: var(--radius); border: 1px solid var(--border-strong); overflow: hidden; z-index: 0; box-shadow: var(--shadow-sm); }
.map-status { margin: 0; font-size: .88rem; font-weight: 500; color: var(--primary); }
.map-coords { grid-template-columns: repeat(2, minmax(0, 12rem)); }

/* Newsletter */
.stat-grid-compact .stat-value { font-size: 1.6rem; }
.send-progress, .send-box { margin-bottom: 1.5rem; display: grid; gap: 1rem; }
.send-box { margin-top: 1.5rem; }
.send-box h2 { display: flex; align-items: center; gap: .5rem; }
.send-box p { margin: 0; color: var(--muted); }
.progress-stats { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; list-style: none; margin: 0; padding: 0; color: var(--muted); }
.progress-stats strong { color: var(--text); font-size: 1.15rem; }
.sent-body { max-width: 46rem; }
.danger-zone { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px dashed var(--border-strong); display: flex; justify-content: flex-end; }

/* Interruttori a forma di etichetta nelle tabelle */
.inline-toggle { margin: 0; }
.badge-btn { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 99px; }
.badge-btn:hover .badge { filter: brightness(.95); box-shadow: 0 0 0 2px var(--border-strong); }

/* Comunicazioni agli iscritti */
.notices-panel { margin-top: 1.5rem; display: grid; gap: 1rem; }
.notices-panel > p { margin: 0; }
.notice-form { padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.choice-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .8rem; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface); cursor: pointer; font-weight: 500; transition: all .2s var(--ease); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.choice input { accent-color: var(--primary); }
.notice-actions { display: flex; justify-content: flex-end; }
.subhead { font-size: 1rem; margin: .5rem 0 0; }
.notice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.notice-list li { padding: .75rem 1rem; border: 1px solid var(--border); border-radius: 10px; display: grid; gap: .25rem; }
fieldset.field { border: 0; padding: 0; margin: 0; }

.crop-status { margin: 0 0 12px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2, #f1f3f6); font-size: 13px; color: var(--muted, #5b6270); }
.crop-status[data-custom="1"] { background: rgba(30, 125, 60, .1); color: #1e7d3c; }

/* Installazione guidata */
.install-steps { display: grid; gap: 22px; margin: 18px 0 24px; padding-left: 20px; }
.install-steps h2 { font-size: 16px; margin: 0 0 4px; }
.install-steps p { margin: 0 0 10px; }

/* ───────────────────────── Come appare sul sito (colonna a destra) ───────────────────────── */

.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 24rem; gap: 1.5rem; align-items: start; }
.edit-main { min-width: 0; }
.site-preview { position: sticky; top: 1.25rem; max-height: calc(100vh - 2.5rem); overflow-y: auto; border-radius: var(--radius-lg); scrollbar-width: thin; }
.site-preview .card { padding: 1.25rem; }
.site-preview .card-head { margin-bottom: .5rem; }
.site-preview .card-head h2 { font-size: 1.1rem; }
.sp-intro { font-size: .88rem; margin: 0 0 1rem; }
.sp-box { padding: 1rem 0; border-top: 1px solid var(--border); }
.sp-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.sp-head h3 { font-size: .95rem; margin: 0; }
.sp-ratio { font-size: .75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.sp-box .hint { margin: .2rem 0 .65rem; font-size: .8rem; }

/* Cornice: l'immagine è ingrandita e spostata secondo il ritaglio (posizioni impostate dal JavaScript) */
.sp-frame { position: relative; overflow: hidden; background: var(--surface-2); }
.sp-frame img { position: absolute; max-width: none; display: block; }
.sp-frame img.is-fallback { inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sp-frame-cover { aspect-ratio: 16 / 9; }
.sp-frame-card { aspect-ratio: 4 / 3; }
.sp-frame-square { aspect-ratio: 1; width: 5rem; flex: none; border-radius: 10px; }
.sp-frame-social { aspect-ratio: 1200 / 630; }
.sp-box.is-empty .sp-frame::after { content: "Nessuna immagine"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .8rem; color: var(--muted); }

/* Riquadri simili a quelli del sito */
.sp-mock { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.sp-mock .sp-body { display: grid; gap: .2rem; padding: .65rem .8rem; line-height: 1.3; }
.sp-mock strong { font-size: .92rem; }
.sp-kicker { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); }
.sp-mock-cover { position: relative; }
.sp-mock-cover::after { content: ""; position: absolute; inset: 40% 0 0; background: linear-gradient(transparent, rgba(8, 12, 26, .75)); pointer-events: none; }
.sp-cover-title { position: absolute; left: .8rem; right: .8rem; bottom: .6rem; z-index: 1; color: #fff; font-size: 1rem !important; text-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.sp-mock-square { display: flex; align-items: center; gap: .75rem; padding: .6rem; }
.sp-mock-square .sp-body { padding: 0; }
.sp-mock-social { border-radius: 8px; background: var(--surface-2); }
.sp-host { font-size: .7rem; letter-spacing: .03em; color: var(--muted); }
.sp-excerpt { font-size: .8rem; color: var(--muted); }

/* Scelta dell'immagine */
.sp-picker { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.sp-option { width: 3.4rem; height: 2.6rem; padding: 0; border: 2px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--surface-2); transition: border-color .15s, transform .15s var(--ease); }
.sp-option img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-option:hover { border-color: var(--primary); transform: translateY(-1px); }
.sp-option[aria-checked=true] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.sp-option:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sp-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }

@media (max-width: 1200px) {
	.edit-layout { grid-template-columns: 1fr; }
	.site-preview { position: static; max-height: none; overflow: visible; }
	.site-preview .card { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); column-gap: 1.5rem; }
	.site-preview .card-head, .sp-intro, [data-sp-empty] { grid-column: 1 / -1; }
}

/* Bottone tema chiaro/scuro */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: inline; }
	:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: background-color .35s ease, color .35s ease, border-color .35s ease !important; }

/* Editor dei ritagli: modalità «Ritaglia» / «Adatta con sfondo» */
.crop-mode { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.crop-mode legend { grid-column: 1 / -1; margin-bottom: .35rem; padding: 0; }
.crop-mode label {
	display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.5rem; padding: .4rem .6rem;
	border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: .88rem; font-weight: 600; text-align: center;
	transition: border-color .2s, background .2s, color .2s;
}
.crop-mode input { position: absolute; opacity: 0; pointer-events: none; }
.crop-mode label:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.crop-mode label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.crop-fit { display: grid; gap: .45rem; padding: .75rem; border-radius: 12px; background: var(--surface-2); }
.crop-fit .hint { margin: 0; }
.crop-fit .label { margin: 0; font-weight: 600; }
.crop-fit input[type=range] { width: 100%; accent-color: var(--primary); }
.crop-swatches { display: flex; flex-wrap: wrap; gap: .45rem; }
.crop-swatch {
	--swatch: #fff; position: relative; width: 2.25rem; height: 2.25rem; padding: 0; border-radius: 50%; cursor: pointer;
	border: 2px solid var(--border-strong); background: var(--swatch); box-shadow: inset 0 0 0 2px var(--surface);
}
.crop-swatch[data-crop-swatch="#ffffff"] { --swatch: #ffffff; }
.crop-swatch[data-crop-swatch="#f4f1ea"] { --swatch: #f4f1ea; }
.crop-swatch[data-crop-swatch="#1e1b18"] { --swatch: #1e1b18; }
.crop-swatch[data-crop-swatch="#0059b3"] { --swatch: #0059b3; }
.crop-swatch.is-auto::after { content: "A"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .75rem; font-weight: 800; color: #fff; text-shadow: 0 0 3px rgba(0, 0, 0, .7); }
.crop-swatch[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 2px var(--primary); }
.crop-swatch.is-custom { display: grid; place-items: center; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.crop-swatch.is-custom input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); opacity: 0; cursor: pointer; }
.crop-swatch.is-custom:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.crop-stage.is-fit img { opacity: .55; }

/* Tabelle con ricerca e ordinamento */
.table-tools { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: .75rem 0; }
.table-search { position: relative; flex: 1; min-width: 14rem; max-width: 28rem; }
.table-search .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; color: var(--muted); pointer-events: none; }
.table-search input { width: 100%; padding-left: 2.2rem; }
.table-count { margin: 0; font-size: .85rem; }
.th-sort { display: inline-flex; align-items: center; gap: .3rem; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.th-sort:hover { color: var(--primary); }
.th-sort-icon { width: .9rem; height: .9rem; opacity: .4; }
th[aria-sort] .th-sort { color: var(--primary); }
th[aria-sort] .th-sort-icon { opacity: 1; }
th[aria-sort="ascending"] .th-sort-icon path { d: path("M8 14l4-4 4 4"); }
th[aria-sort="descending"] .th-sort-icon path { d: path("M8 10l4 4 4-4"); }

/* Storico email */
.detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .9rem 1.5rem; margin: 0 0 1.25rem; }
.detail-list dt { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.detail-list dd { margin: .15rem 0 0; overflow-wrap: anywhere; }
.mail-body-title { margin: 0 0 .5rem; }
.mail-body { margin: 0; padding: 1rem 1.2rem; max-height: 60vh; overflow: auto; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: .95rem; line-height: 1.6; }
