/* ══════════════════════════════════════════════════════════════════
   TQ14 CRM — "soft console" theme
   Token VALUES are carried verbatim from moma-studio-manager's
   src/assets/styles/main.css, but written as plain CSS: no
   @import "tailwindcss", no @theme, no @apply. That keeps the design
   identical to the manager while needing zero build step, no npm and
   no node_modules.

   Deliberately NOT copied: the manager's giant @source inline(...)
   safelist. That exists only because its older newsletter views use raw
   palette classes (bg-red-50 dark:bg-red-500/10). Use the semantic
   tokens below instead.

   If you later want Tailwind utilities back, this file is already
   compatible — add @import "tailwindcss" plus an @theme inline block
   mapping --color-* to these vars, and run the standalone CLI.
   ══════════════════════════════════════════════════════════════════ */

/* ─── Light theme (default) ─── */
:root {
	/* Surfaces */
	--surface-app: #f6f7f9;
	--surface-card: #ffffff;
	--surface-chrome: #f9fafbd9;
	--surface-muted: #f1f3f6;
	--surface-field: #f4f6f9;
	--surface-field-focus: #ffffff;
	--surface-hover: #eaedf2;
	/* Dropdown/popover surface. Distinct from --surface-card: it must be
	   fully opaque, because it floats over content. */
	--surface-overlay: #ffffff;
	--surface-contrast: #191c22;
	--text-on-contrast: #ffffff;

	/* Borders */
	--border-hairline: #eef0f4;
	--border-subtle: #e6e9ef;
	--border-field: #d7dbe2;
	--border-field-hover: #b4bac4;
	--border-strong: #cbd0da;

	/* Text */
	--text-primary: #171a20;
	--text-secondary: #4d5462;
	--text-tertiary: #6a7181;
	--text-meta: #8b92a1;
	--text-placeholder: #9aa1b0;
	--text-faint: #c1c6d1;

	/* Accent — cobalt */
	--accent: #2563eb;
	--accent-hover: #1d54cf;
	--accent-emphasis: #3b82f6;
	--accent-text: #1d4ed8;
	--accent-soft-bg: #eaf1ff;
	--accent-soft-text: #1a43bd;
	--accent-focus-ring: #2563eb33;

	/* Status */
	--danger: #c5341f;
	--danger-hover: #ab2c19;
	--danger-soft-bg: #fdefec;
	--danger-soft-text: #ab2c19;
	--success-soft-bg: #eafaf1;
	--success-soft-text: #0a6b41;
	--warning-soft-bg: #fdf5e7;
	--warning-soft-text: #8c5c10;
	--info-soft-bg: #eaf1ff;
	--info-soft-text: #1a43bd;
	--neutral-soft-bg: #eef0f4;
	--neutral-soft-text: #596072;

	/* Soft ambient shadows */
	--sh-soft: 0 1px 2px 0 rgb(18 20 28 / 0.05);
	--sh-soft-md: 0 2px 6px -1px rgb(18 20 28 / 0.08), 0 1px 2px 0 rgb(18 20 28 / 0.04);
	--sh-soft-lg: 0 18px 44px -12px rgb(18 20 28 / 0.2), 0 4px 10px -4px rgb(18 20 28 / 0.08);
	--sh-inner: inset 0 1px 0 0 rgb(255 255 255 / 0.7);

	/* Shape — soft, never square */
	--radius-xs: 6px;
	--radius-sm: 7px;
	--radius-md: 9px;
	--radius-lg: 10px;
	--radius-xl: 14px;

	/* Type */
	--font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

	/* Motion */
	--ease-standard: cubic-bezier(0.22, 0.61, 0.24, 1);
	--duration-base: 170ms;

	/* Layout */
	--sidebar-w: 236px;
}

/* ─── Dark theme (`.dark` on <html>) ─── */
.dark {
	--surface-app: #0b0c0f;
	--surface-card: #15171b;
	--surface-chrome: #111216e6;
	--surface-muted: #1c1f24;
	--surface-field: #1c1f24;
	--surface-field-focus: #22252c;
	--surface-hover: #252932;
	--surface-overlay: #212630;
	--surface-contrast: #f1f3f6;
	--text-on-contrast: #0b0c0f;

	--border-hairline: #1e2127;
	--border-subtle: #262a31;
	--border-field: #363b45;
	--border-field-hover: #4c525e;
	--border-strong: #383d47;

	--text-primary: #f1f3f6;
	--text-secondary: #c0c6d1;
	--text-tertiary: #949bab;
	--text-meta: #747b8b;
	--text-placeholder: #747b8b;
	--text-faint: #4c5261;

	--accent: #3b82f6;
	--accent-hover: #5b95f8;
	--accent-emphasis: #60a5fa;
	--accent-text: #93c5fd;
	--accent-soft-bg: #3b82f626;
	--accent-soft-text: #93c5fd;
	--accent-focus-ring: #3b82f64d;

	--danger: #e05244;
	--danger-hover: #ea6355;
	--danger-soft-bg: #c5341f26;
	--danger-soft-text: #f0a49a;
	--success-soft-bg: #0e8a5426;
	--success-soft-text: #6ee7b7;
	--warning-soft-bg: #b57a1726;
	--warning-soft-text: #f0cd8a;
	--info-soft-bg: #3b82f626;
	--info-soft-text: #93c5fd;
	--neutral-soft-bg: #252932;
	--neutral-soft-text: #a6adbb;

	--sh-soft: 0 1px 2px 0 rgb(0 0 0 / 0.4);
	--sh-soft-md: 0 2px 8px -2px rgb(0 0 0 / 0.5);
	--sh-soft-lg: 0 20px 50px -14px rgb(0 0 0 / 0.75), 0 4px 12px -4px rgb(0 0 0 / 0.5);
	--sh-inner: inset 0 1px 0 0 rgb(255 255 255 / 0.05);
}

/* ─── Reset / base ─── */
*,
*::before,
*::after {
	box-sizing: border-box;
}

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

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

/* Global 170ms transition on the soft curve — the manager's signature. */
*,
*::before,
*::after {
	transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
	transition-timing-function: var(--ease-standard);
	transition-duration: var(--duration-base);
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 1ms !important;
		transition-duration: 1ms !important;
	}
}

::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}
::-webkit-scrollbar-track {
	background: transparent;
}
::-webkit-scrollbar-thumb {
	border-radius: 9999px;
	background: var(--border-strong);
}
::-webkit-scrollbar-thumb:hover {
	background: var(--text-faint);
}

code,
.mono {
	font-family: var(--font-mono);
	font-size: 0.92em;
}

a {
	color: var(--accent-text);
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════════
   Components — modelled one-to-one on moma-studio-manager's views
   (Newsletter.vue, NewsletterCampaign.vue, ui/*). Each block names the
   Tailwind recipe it reproduces, so the two can be kept in step.
   ══════════════════════════════════════════════════════════════════ */

h1, h2, h3, h4 { margin: 0; }

.muted { color: var(--text-meta); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.sr-only {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.ic { width: 16px; height: 16px; flex-shrink: 0; }
.ic-sm { width: 14px; height: 14px; flex-shrink: 0; }
.ic-xs { width: 12px; height: 12px; flex-shrink: 0; }

/* ─── Top bar ─── (Breadcrumb.vue chrome: bg-chrome, blur, hairline) */
.topbar {
	position: sticky;
	top: 0;
	z-index: 30;
	background: var(--surface-chrome);
	backdrop-filter: saturate(140%) blur(16px);
	border-bottom: 1px solid var(--border-subtle);
}

.topbar-inner {
	max-width: 1240px;
	height: 60px;
	margin: 0 auto;
	padding: 0 24px;
	display: flex;
	align-items: center;
	gap: 28px;
}

/* Sidebar.vue header: round mark + two-line name. */
.brand {
	display: flex;
	align-items: center;
	gap: 11px;
	color: inherit;
	text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-tile {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 9999px;
	background: linear-gradient(135deg, #c40000, #7a0000);
	box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
	color: #fff;
	font-size: 17px;
	font-weight: 700;
	letter-spacing: -0.04em;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); }
.brand-sub { font-size: 10px; font-weight: 500; letter-spacing: 0.04em; color: var(--text-meta); }

/* Sidebar.vue nav item, laid out horizontally. */
.nav { display: flex; align-items: center; gap: 2px; }

.nav-link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 34px;
	padding: 0 11px 0 6px;
	border-radius: var(--radius-lg);
	font-size: 13px;
	color: var(--text-secondary);
	text-decoration: none;
}
.nav-link:hover { background: var(--surface-muted); color: var(--text-primary); text-decoration: none; }

.nav-ic {
	display: inline-grid;
	place-items: center;
	width: 24px;
	height: 24px;
	border-radius: 7px;
	background: var(--surface-muted);
	color: var(--text-tertiary);
}
.nav-link:hover .nav-ic { background: var(--surface-hover); }

.nav-link.is-active {
	background: var(--surface-card);
	color: var(--text-primary);
	font-weight: 500;
	box-shadow: var(--sh-soft-md);
}
.nav-link.is-active .nav-ic { background: var(--accent); color: #fff; }

.topbar-end {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 10px;
}

.user-email {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 8px;
	border-radius: var(--radius-md);
	font-size: 12px;
	color: var(--text-tertiary);
	text-decoration: none;
	max-width: 240px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.user-email:hover,
.user-email.is-active { background: var(--surface-hover); color: var(--text-primary); }

.topbar-sep { width: 1px; height: 18px; background: var(--border-subtle); }

/* Sidebar.vue theme switch (w-12 h-6 track, 20px knob). */
.theme-switch {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
	cursor: pointer;
	flex-shrink: 0;
}
.theme-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.theme-track {
	position: absolute;
	inset: 0;
	border-radius: 9999px;
	background: var(--border-strong);
}
.theme-switch input:checked + .theme-track { background: var(--accent); }
.theme-knob {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 20px;
	height: 20px;
	border-radius: 9999px;
	background: #fff;
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
	display: grid;
	place-items: center;
	color: #f59e0b;
}
.theme-switch input:checked ~ .theme-knob { transform: translateX(20px); color: #737373; }
.theme-knob .ic-moon { display: none; }
.theme-switch input:checked ~ .theme-knob .ic-sun { display: none; }
.theme-switch input:checked ~ .theme-knob .ic-moon { display: block; }
.theme-switch input:focus-visible + .theme-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Page ─── (views: flex flex-col gap-4 p-5) */
.page {
	max-width: 1240px;
	margin: 0 auto;
	padding: 24px 24px 72px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* View header: title 18px semibold, subtitle 12px tertiary, actions right. */
.page-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}

.page-head-main {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}

.page-title {
	font-size: 18px;
	font-weight: 600;
	letter-spacing: -0.015em;
	line-height: 1.3;
	color: var(--text-primary);
}

.page-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.page-sub {
	margin: 2px 0 0;
	font-size: 12px;
	color: var(--text-tertiary);
}

.page-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

/* A <form> per POST action must not add layout to the action row. */
.page-actions form { display: contents; }

.act-sep { width: 1px; height: 20px; margin: 0 2px; background: var(--border-subtle); }

/* Editor header: stays in view while scrolling a long newsletter. */
.page-head.is-sticky {
	position: sticky;
	top: 61px;
	z-index: 20;
	margin: -12px -24px 0;
	padding: 12px 24px;
	background: color-mix(in srgb, var(--surface-app) 92%, transparent);
	backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--border-hairline);
}

/* NewsletterCampaign.vue back button: size-7, rounded-lg, meta. */
.back-btn {
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: var(--radius-lg);
	color: var(--text-meta);
	flex-shrink: 0;
}
.back-btn:hover { background: var(--surface-muted); color: var(--text-secondary); text-decoration: none; }

/* ─── Card ─── (rounded-2xl bg-card border-subtle shadow-soft) */
.card {
	background: var(--surface-card);
	border: 1px solid var(--border-subtle);
	border-radius: 16px;
	box-shadow: var(--sh-soft);
}

/* Cards holding a table: clip the muted header row to the corners. */
.card.is-clipped { overflow: hidden; }

/* px-5 pt-4 pb-3 border-b border-hairline */
.card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	padding: 16px 20px 12px;
	border-bottom: 1px solid var(--border-hairline);
}

.card-title {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-primary);
}

.card-head-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 11px;
	color: var(--text-meta);
}

.card-body { padding: 16px 20px; }

/* Sub-section inside a card, split by a hairline. */
.card-section {
	border-top: 1px solid var(--border-hairline);
	padding: 12px 20px;
}

.card-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 16px;
	border-top: 1px solid var(--border-hairline);
}

/* Small uppercase section label (Destinatari, Statistiche…). */
.eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--text-meta);
}

/* ─── Forms ─── */
.form-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* text-[12px] font-medium text-tertiary uppercase tracking-wide */
.field-label {
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--text-tertiary);
}
.field-label .req { color: var(--danger); margin-left: 2px; }

.field-hint { font-size: 12px; color: var(--text-meta); }

/* InputText.vue medium: h-9 px-3 text-[13px] rounded-lg, field tokens. */
.input {
	width: 100%;
	height: 36px;
	padding: 0 12px;
	font: inherit;
	font-size: 13px;
	color: var(--text-primary);
	background: var(--surface-field);
	border: 1px solid var(--border-field);
	border-radius: var(--radius-lg);
	box-shadow: var(--sh-inner);
	outline: none;
}
.input:hover { border-color: var(--border-field-hover); }
.input:focus {
	background: var(--surface-field-focus);
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-focus-ring);
}
.input::placeholder { color: var(--text-placeholder); }
.input:disabled { opacity: 0.6; cursor: not-allowed; }

/* Read-only value styled like a filled field. */
.input-static {
	display: flex;
	align-items: center;
	min-height: 36px;
	padding: 6px 12px;
	font-size: 13px;
	color: var(--text-secondary);
	background: var(--surface-muted);
	border-radius: var(--radius-lg);
}

/* Input with a leading icon (search). */
.input-wrap { position: relative; display: block; }
.input-wrap .ic {
	position: absolute;
	left: 11px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--text-meta);
	pointer-events: none;
}
.input-wrap .input { padding-left: 34px; }

/* ─── Buttons ─── (main.css .btn family, verbatim values) */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	height: 36px;
	padding: 0 14px;
	font: inherit;
	font-size: 13px;
	font-weight: 500;
	letter-spacing: -0.008em;
	line-height: 1;
	border: 0;
	border-radius: var(--radius-lg);
	cursor: pointer;
	white-space: nowrap;
	text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.975); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; gap: 6px; border-radius: var(--radius-md); }
.btn-sm .ic { width: 14px; height: 14px; }
.btn-block { width: 100%; }

.btn-primary {
	background: var(--accent);
	color: #fff;
	box-shadow: inset 0 1px 0 0 rgb(255 255 255 / 0.18), 0 1px 2px 0 rgb(18 20 28 / 0.18);
}
.btn-primary:hover {
	background: var(--accent-hover);
	box-shadow: inset 0 1px 0 0 rgb(255 255 255 / 0.18), 0 3px 10px -2px var(--accent-focus-ring);
}

.btn-danger {
	background: var(--danger);
	color: #fff;
	box-shadow: inset 0 1px 0 0 rgb(255 255 255 / 0.16), 0 1px 2px 0 rgb(18 20 28 / 0.18);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-outline {
	background: var(--surface-card);
	color: var(--text-secondary);
	box-shadow: inset 0 0 0 1px var(--border-subtle);
}
.btn-outline:hover { color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--border-strong); }

.btn-secondary { background: var(--surface-muted); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text-primary); }

.btn-ghost { background: transparent; color: var(--text-tertiary); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text-primary); }

/* Square icon-only button, e.g. row actions (size-7 rounded-lg). */
.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-lg);
	background: transparent;
	color: var(--text-meta);
	cursor: pointer;
}
.icon-btn:hover { background: var(--surface-muted); color: var(--text-secondary); }
.icon-btn-danger:hover { background: var(--danger-soft-bg); color: var(--danger); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Status pill ─── (statusConfig: rounded-full ring-1, 11px, dot size-1) */
.pill {
	--pill-dot: var(--text-faint);
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 2px 10px;
	border-radius: 9999px;
	font-size: 11px;
	font-weight: 500;
	line-height: 1.5;
	white-space: nowrap;
	background: var(--neutral-soft-bg);
	color: var(--neutral-soft-text);
	box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 16%, transparent);
}
.pill::before {
	content: "";
	width: 5px;
	height: 5px;
	border-radius: 9999px;
	background: var(--pill-dot);
	flex-shrink: 0;
}
.pill-info    { background: var(--info-soft-bg);    color: var(--info-soft-text);    --pill-dot: #3b82f6; }
.pill-warning { background: var(--warning-soft-bg); color: var(--warning-soft-text); --pill-dot: #f59e0b; }
.pill-success { background: var(--success-soft-bg); color: var(--success-soft-text); --pill-dot: #22c55e; }
.pill-danger  { background: var(--danger-soft-bg);  color: var(--danger-soft-text);  --pill-dot: #ef4444; }
.pill-live::before { animation: pulse-dot 1.6s ease-in-out infinite; }

@keyframes pulse-dot { 50% { opacity: 0.35; } }

/* ─── Badge ─── (main.css .badge: soft tinted pill, no ring) */
.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 9px;
	border-radius: 9999px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.2;
	white-space: nowrap;
	background: var(--neutral-soft-bg);
	color: var(--neutral-soft-text);
}
.badge-accent  { background: var(--accent-soft-bg);  color: var(--accent-soft-text); }
.badge-info    { background: var(--info-soft-bg);    color: var(--info-soft-text); }
.badge-success { background: var(--success-soft-bg); color: var(--success-soft-text); }
.badge-warning { background: var(--warning-soft-bg); color: var(--warning-soft-text); }
.badge-danger  { background: var(--danger-soft-bg);  color: var(--danger-soft-text); }

/* Small square tag, e.g. "Sola lettura" (rounded-md bg-muted text-meta). */
.tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 8px;
	border-radius: var(--radius-sm);
	font-size: 11px;
	font-weight: 500;
	background: var(--surface-muted);
	color: var(--text-meta);
}

/* ─── Data table ─── (Newsletter.vue list table) */
.table {
	width: 100%;
	border-collapse: collapse;
}

.table th {
	padding: 10px 16px;
	text-align: left;
	font-size: 12px;
	font-weight: 500;
	color: var(--text-tertiary);
	white-space: nowrap;
	background: var(--surface-muted);
	border-bottom: 1px solid var(--border-subtle);
}

/* Header label with its icon at 50% (the manager's th recipe). */
.th { display: inline-flex; align-items: center; gap: 6px; }
.th .ic-sm { opacity: 0.5; }

.table td {
	padding: 13px 16px;
	font-size: 13px;
	color: var(--text-secondary);
	border-top: 1px solid var(--border-hairline);
	vertical-align: middle;
}
.table tbody tr:first-child td { border-top: 0; }

.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.shrink, .table td.shrink { width: 1%; white-space: nowrap; }

.table tbody tr:hover td { background: var(--surface-muted); }

/* Clickable rows: accent left edge on hover — the manager's grid signature. */
.table tr.is-link { cursor: pointer; }
.table tr.is-link:hover td:first-child { box-shadow: inset 3px 0 0 0 var(--accent); }

.t-main { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); }
.t-sub { display: block; margin-top: 1px; font-size: 12px; color: var(--text-meta); }
.t-meta { font-size: 12px; color: var(--text-tertiary); }
.t-secondary { font-size: 13px; color: var(--text-secondary); }
.t-none { color: var(--text-faint); }

/* ─── Stat tiles ─── (grid gap-px bg-muted; tile bg-card px-4 py-3) */
.stat-grid {
	display: grid;
	grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
	gap: 1px;
	background: var(--border-hairline);
}
@media (max-width: 760px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stat { background: var(--surface-card); padding: 12px 16px; min-width: 0; }

.stat-label {
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--text-meta);
}

.stat-line { margin-top: 4px; display: flex; align-items: baseline; gap: 6px; }

.stat-value {
	font-size: 18px;
	font-weight: 600;
	letter-spacing: -0.01em;
	font-variant-numeric: tabular-nums;
	color: var(--text-primary);
}
.stat-value.is-accent  { color: var(--accent-text); }
.stat-value.is-success { color: var(--success-soft-text); }
.stat-value.is-danger  { color: var(--danger-soft-text); }
.stat-value.is-small   { font-size: 14px; font-weight: 600; }

.stat-sub { font-size: 11px; color: var(--text-meta); }

/* Card on its own row with tiles directly inside. */
.card > .stat-grid:first-child { border-radius: 15px 15px 0 0; }
.card > .stat-grid:last-child { border-radius: 0 0 15px 15px; overflow: hidden; }
.card > .stat-grid:only-child { border-radius: 15px; overflow: hidden; }

/* ─── Progress ─── (h-2 rounded-full bg-muted; stripe while running) */
.progress-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 8px;
	font-size: 12px;
	color: var(--text-tertiary);
}
.progress-head strong { font-size: 15px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.progress-pct { font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.progress {
	position: relative;
	height: 8px;
	border-radius: 9999px;
	background: var(--surface-muted);
	overflow: hidden;
}

.progress-bar {
	position: absolute;
	inset: 0 auto 0 0;
	border-radius: 9999px;
	background: var(--accent);
	transition: width 500ms var(--ease-standard);
}
.progress-bar.is-success { background: #22c55e; }

.progress-bar.is-striped {
	background-image: linear-gradient(45deg, rgb(255 255 255 / 0.22) 25%, transparent 25%, transparent 50%, rgb(255 255 255 / 0.22) 50%, rgb(255 255 255 / 0.22) 75%, transparent 75%, transparent);
	background-size: 16px 16px;
	animation: stripe-move 0.8s linear infinite;
}
@keyframes stripe-move { to { background-position: 16px 0; } }

.progress-bar.is-indeterminate { width: 35% !important; animation: indeterminate 1.3s ease-in-out infinite; }
@keyframes indeterminate { 0% { left: -35%; } 100% { left: 100%; } }

.progress-foot { margin-top: 10px; display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--text-tertiary); }
.progress-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* ─── Banner ─── (rounded-xl card px-4 py-3, icon + text) */
.banner {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	font-size: 13px;
	color: var(--text-secondary);
	background: var(--surface-card);
	border: 1px solid var(--border-subtle);
	border-radius: 12px;
	box-shadow: var(--sh-soft);
}
.banner > .ic { color: var(--text-meta); }
.banner strong { color: var(--text-primary); font-weight: 600; }
.banner-text { flex: 1; }
.banner-danger { background: var(--danger-soft-bg); border-color: transparent; color: var(--danger-soft-text); }
.banner-danger > .ic, .banner-danger strong { color: var(--danger-soft-text); }
.banner-warning { background: var(--warning-soft-bg); border-color: transparent; color: var(--warning-soft-text); }
.banner-warning > .ic, .banner-warning strong { color: var(--warning-soft-text); }

/* ─── Empty state ─── (card p-12, size-12 rounded-xl bg-muted icon) */
.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: 48px 24px;
	text-align: center;
}
.empty-icon {
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	border-radius: 12px;
	background: var(--surface-muted);
	color: var(--text-faint);
}
.empty-icon .ic { width: 20px; height: 20px; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.empty-text { margin: 4px 0 0; font-size: 12px; color: var(--text-meta); max-width: 360px; }
.empty-state .btn { margin-top: 4px; }

/* ─── Pager ─── */
.pager-info { font-size: 12px; color: var(--text-meta); font-variant-numeric: tabular-nums; }
.pages { display: flex; align-items: center; gap: 2px; }
.pg {
	min-width: 28px;
	height: 28px;
	padding: 0 6px;
	border: 0;
	border-radius: var(--radius-md);
	background: transparent;
	font: inherit;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	color: var(--text-secondary);
	cursor: pointer;
}
.pg:hover:not(:disabled) { background: var(--surface-muted); color: var(--text-primary); }
.pg:disabled { opacity: 0.35; cursor: default; }
.pg.is-current { background: var(--accent-soft-bg); color: var(--accent-soft-text); font-weight: 600; }
.pg-gap { padding: 0 4px; font-size: 12px; color: var(--text-faint); }

/* ─── Status dot ─── */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 9999px; background: var(--text-faint); flex-shrink: 0; }
.dot-ok { background: #22c55e; }
.dot-warn { background: #f59e0b; }
.dot-err { background: var(--danger); }

/* ─── Toasts ─── (ToastContainer: bottom-right, auto-dismiss) */
.toasts {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 90;
	display: flex;
	flex-direction: column;
	gap: 8px;
	pointer-events: none;
}

.toast {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 260px;
	max-width: 380px;
	padding: 11px 14px;
	font-size: 13px;
	color: var(--text-primary);
	background: var(--surface-overlay);
	border: 1px solid var(--border-subtle);
	border-radius: 12px;
	box-shadow: var(--sh-soft-lg);
	pointer-events: auto;
	animation: toast-in 220ms var(--ease-standard), toast-out 300ms var(--ease-standard) 4.2s forwards;
}
.toast.is-sticky { animation: toast-in 220ms var(--ease-standard); }
.toast-ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 9999px; flex-shrink: 0; }
.toast-ok .toast-ic { background: var(--success-soft-bg); color: var(--success-soft-text); }
.toast-warn .toast-ic { background: var(--warning-soft-bg); color: var(--warning-soft-text); }
.toast-err .toast-ic { background: var(--danger-soft-bg); color: var(--danger-soft-text); }
.toast-close { margin-left: auto; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); visibility: hidden; } }

/* ─── Login ─── (App.vue splash: logo tile, title, card) */
.auth-body {
	min-height: 100vh;
	display: grid;
	place-items: center;
	padding: 24px;
	background: radial-gradient(1000px 520px at 50% -10%, var(--accent-soft-bg), transparent 70%), var(--surface-app);
}
.auth-shell { width: 100%; max-width: 360px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 24px; text-align: center; }
.auth-brand .brand-tile { width: 56px; height: 56px; font-size: 27px; margin-bottom: 12px; box-shadow: var(--sh-soft-lg), inset 0 0 0 1px rgb(255 255 255 / 0.12); }
.auth-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }
.auth-sub { font-size: 12px; color: var(--text-meta); }
.auth-card { padding: 22px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-error {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 14px;
	padding: 9px 12px;
	font-size: 12.5px;
	border-radius: var(--radius-lg);
	background: var(--danger-soft-bg);
	color: var(--danger-soft-text);
}
.auth-shell-wide { max-width: 420px; }
.auth-notice {
	display: flex; align-items: center; gap: 8px;
	margin-bottom: 14px; padding: 9px 12px;
	font-size: 12.5px; border-radius: var(--radius-lg);
	background: var(--success-soft-bg); color: var(--success-soft-text);
}
.auth-resend { margin-top: 8px; }
.auth-form .choice { margin: 0; }
.auth-lead { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.auth-lead strong { color: var(--text-primary); font-weight: 600; word-break: break-all; }
.auth-foot { margin: 16px 0 0; text-align: center; font-size: 12.5px; }
.auth-foot a { color: var(--text-meta); text-decoration: none; }
.auth-foot a:hover { color: var(--text-primary); text-decoration: underline; }
.input-code {
	font-family: var(--font-mono);
	font-size: 20px;
	letter-spacing: 0.3em;
	text-align: center;
}

/* Authenticator setup */
.mfa-steps { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.mfa-steps li + li { margin-top: 4px; }
/* Always white behind the QR: scanners need dark-on-light, in dark mode too. */
.mfa-qr {
	align-self: center;
	width: 196px;
	padding: 6px;
	border-radius: var(--radius-lg);
	background: #ffffff;
	box-shadow: var(--sh-soft);
}
.mfa-qr svg { display: block; width: 100%; height: auto; }
.mfa-manual { font-size: 12.5px; color: var(--text-meta); }
.mfa-manual summary { cursor: pointer; }
.mfa-secret {
	display: block;
	margin-top: 8px;
	padding: 8px 10px;
	border-radius: var(--radius-md);
	background: var(--surface-muted);
	font-family: var(--font-mono);
	font-size: 13px;
	letter-spacing: 0.08em;
	color: var(--text-primary);
	word-break: break-all;
	user-select: all;
}

/* Profile */
.profile-page { max-width: 760px; }
.profile-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0; padding: 16px 20px; }
.profile-facts dt { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-meta); }
.profile-facts dd { margin: 4px 0 0; font-size: 13px; color: var(--text-primary); overflow-wrap: anywhere; }
@media (max-width: 560px) { .profile-facts { grid-template-columns: 1fr; } }
.profile-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.profile-text { flex: 1 1 320px; margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.profile-form { display: flex; flex-direction: column; gap: 16px; }
.profile-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Users */
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.table tr.is-muted td { opacity: 0.55; }
.table tr.is-muted td:last-child { opacity: 1; }
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.banner .mfa-secret { margin-top: 6px; user-select: all; }

/* File drop zone (Carica CSV) */
.dropzone {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 22px 16px;
	text-align: center;
	border: 1.5px dashed var(--border-strong);
	border-radius: var(--radius-xl);
	background: var(--surface-muted);
	cursor: pointer;
	transition: border-color var(--duration-base) var(--ease-standard), background var(--duration-base) var(--ease-standard);
}
.dropzone:hover,
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft-bg); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-ic {
	display: inline-flex; align-items: center; justify-content: center;
	width: 36px; height: 36px; margin-bottom: 6px;
	border-radius: 10px; background: var(--surface-card); color: var(--text-tertiary);
	box-shadow: var(--sh-soft);
}
.dropzone-title { font-size: 13px; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.dropzone-sub { font-size: 12px; color: var(--text-meta); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); }
.dropzone.has-file .dropzone-ic { color: var(--accent); }

/* Date + time picker (manager's DatePicker.vue) */
.dt { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dt .sel { width: 100%; }
.dp-toggle {
	position: relative;
	display: inline-flex; align-items: center; gap: 10px;
	width: 100%; height: 36px; padding: 0 12px;
	font: inherit; font-size: 13px; text-align: start; cursor: pointer;
	border-radius: var(--radius-lg);
	background: var(--surface-field);
	border: 1px solid var(--border-field);
	box-shadow: var(--sh-inner);
	color: var(--text-primary);
}
.dp-toggle:hover { border-color: var(--border-field-hover); }
.dp-toggle:focus-visible { outline: 3px solid var(--accent-focus-ring); outline-offset: 1px; }
.dp-toggle .dp-ic { color: var(--text-meta); flex: none; }
.dp-label.is-placeholder { color: var(--text-meta); }
.dp-panel {
	position: fixed; z-index: 300;
	width: 280px; padding: 12px;
	background: var(--surface-overlay);
	border: 1px solid var(--border-subtle);
	border-radius: 14px;
	box-shadow: var(--sh-soft-lg);
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-nav {
	display: inline-flex; align-items: center; justify-content: center;
	width: 32px; height: 32px; border: 0; border-radius: var(--radius-lg);
	background: none; color: var(--text-tertiary); cursor: pointer;
}
.dp-nav svg { width: 16px; height: 16px; }
.dp-nav:hover, .dp-title:hover { background: var(--surface-muted); color: var(--text-primary); }
.dp-title {
	padding: 4px 8px; border: 0; border-radius: var(--radius-lg); background: none;
	font: inherit; font-size: 13px; font-weight: 600; color: var(--text-primary); cursor: pointer;
}
span.dp-title:hover { background: none; cursor: default; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dp-grid-3 { grid-template-columns: repeat(3, 1fr); gap: 4px; }
.dp-grid-4 { grid-template-columns: repeat(4, 1fr); gap: 4px; }
.dp-dow { margin-bottom: 4px; }
.dp-dow span { padding: 4px 0; text-align: center; font-size: 11px; font-weight: 500; color: var(--text-meta); }
.dp-day, .dp-cell {
	position: relative;
	display: inline-flex; align-items: center; justify-content: center;
	border: 0; border-radius: var(--radius-lg); background: none;
	font: inherit; font-size: 13px; color: var(--text-secondary); cursor: pointer;
}
.dp-day { width: 36px; height: 36px; }
.dp-cell { padding: 9px 0; }
.dp-day:hover, .dp-cell:hover { background: var(--surface-muted); }
.dp-day.is-outside { color: var(--text-faint); cursor: default; }
.dp-day:disabled { color: var(--text-faint); cursor: not-allowed; background: none; }
.dp-day.is-today { font-weight: 600; color: var(--accent); }
.dp-day.is-today::after {
	content: ""; position: absolute; bottom: 3px; left: 50%;
	width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent);
}
.dp-day.is-selected, .dp-cell.is-selected { background: var(--accent); color: #ffffff; font-weight: 600; }
.dp-foot {
	display: flex; justify-content: space-between;
	margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-hairline);
}
.dp-link { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; font-weight: 500; color: var(--text-tertiary); cursor: pointer; }
.dp-link:hover { color: var(--text-primary); }
.dp-link.is-accent { color: var(--accent-text); }

/* Campaign list Esiti — the manager's compact counters */
.outcomes { display: flex; align-items: center; gap: 10px; font-size: 11px; font-variant-numeric: tabular-nums; }
.outcome { display: inline-flex; align-items: center; gap: 4px; cursor: help; }
.outcome-dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; }
.outcome.is-delivered { color: #15803d; }
.outcome.is-bounced { color: #b91c1c; }
.outcome.is-complained { color: #b45309; }
.outcome.is-failed { color: var(--text-tertiary); }
:root.dark .outcome.is-delivered { color: #4ade80; }
:root.dark .outcome-dot { background: #4ade80; }
:root.dark .outcome.is-bounced { color: #f87171; }
:root.dark .outcome.is-complained { color: #fbbf24; }

/* Tooltip — manager's Tooltip.vue: bg-contrast, 12px, rounded-md, arrow */
.tip {
	position: fixed; z-index: 9999;
	width: max-content; max-width: 320px;
	pointer-events: none;
	opacity: 0; transform: translateY(2px);
	transition: opacity 150ms ease-out, transform 150ms ease-out;
}
.tip.is-visible { opacity: 1; transform: none; }
.tip-box {
	position: relative;
	padding: 6px 10px;
	font-size: 12px; line-height: 1.6; font-weight: 400; text-transform: none; letter-spacing: normal;
	color: var(--text-on-contrast);
	background: var(--surface-contrast);
	border-radius: 6px;
	box-shadow: var(--sh-soft-lg);
	white-space: normal; overflow-wrap: break-word;
}
.tip-arrow {
	position: absolute; bottom: -4px;
	width: 8px; height: 8px;
	background: var(--surface-contrast);
	transform: rotate(45deg);
}
.tip.is-below .tip-arrow { bottom: auto; top: -4px; }
.tip-info {
	display: inline-flex; align-items: center;
	color: var(--text-faint); cursor: help; border-radius: 50%;
}
.tip-info:hover, .tip-info:focus-visible { color: var(--text-tertiary); outline: none; }
[data-tip].pill, .outcome[data-tip] { cursor: help; }
.stat-label { display: flex; align-items: center; gap: 4px; }

/* Klaviyo import preview */
.import-page { max-width: 880px; }
.import-notes p { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }
.import-notes p + p { margin-top: 6px; }
.import-notes .ic { flex: none; margin-top: 2px; }
.import-actions { justify-content: flex-end; }

/* ─── HTMX request state ─── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Campaign content preview (read-only campaigns) ─── */
.content-frame {
	display: block;
	width: 100%;
	min-height: 360px;
	border: 0;
	background: #ffffff;
	color-scheme: light;
	border-radius: 0 0 15px 15px;
}

/* ══════════════════════════════════════════════════════════════════
   Select (.sel) — port of the manager's ui/Select.vue anatomy.
   Native <select> cannot style its option list (the OS draws it), so the
   control is rebuilt: hidden input for the value, button for the toggle,
   absolutely-positioned panel for the list.
   ══════════════════════════════════════════════════════════════════ */
.sel {
	position: relative;
	display: inline-block;
}

.sel.is-open {
	z-index: 60;
}

/* h-9 ps-3 pe-10 rounded-lg text-[13px] bg-field border-fieldborder
   shadow-inner-soft */
.sel-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	width: 100%;
	height: 36px;
	padding: 0 40px 0 12px;
	font-family: inherit;
	font-size: 13px;
	text-align: start;
	white-space: nowrap;
	cursor: pointer;
	border-radius: var(--radius-lg);
	background: var(--surface-field);
	border: 1px solid var(--border-field);
	box-shadow: var(--sh-inner);
	color: var(--text-primary);
}
.sel-toggle:hover {
	border-color: var(--border-field-hover);
}
.sel-toggle:focus-visible {
	outline: 3px solid var(--accent-focus-ring);
	outline-offset: 1px;
}

.sel-value {
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--text-primary);
}
.sel-value.is-placeholder {
	color: var(--text-meta);
}

/* size-3.5 text-meta, end-3.5, vertically centred */
.sel-chevron {
	position: absolute;
	right: 14px;
	top: 50%;
	width: 14px;
	height: 14px;
	margin-top: -7px;
	color: var(--text-meta);
	pointer-events: none;
	transition: transform var(--duration-base) var(--ease-standard);
}
.sel.is-open .sel-chevron {
	transform: rotate(180deg);
}

/* max-h-72 p-[5px] bg-overlay border-subtle rounded-[12px] shadow-soft-lg */
.sel-panel {
	position: absolute;
	z-index: 50;
	left: 0;
	top: calc(100% + 8px);
	min-width: 100%;
	max-height: 288px;
	overflow-y: auto;
	padding: 5px;
	background: var(--surface-overlay);
	border: 1px solid var(--border-subtle);
	border-radius: 12px;
	box-shadow: var(--sh-soft-lg);
}
.sel.is-above .sel-panel {
	top: auto;
	bottom: calc(100% + 8px);
}

/* py-[7px] px-[9px] text-[13px] rounded-lg, selected in accent-soft */
.sel-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	padding: 7px 9px;
	font-size: 13px;
	border-radius: var(--radius-lg);
	cursor: pointer;
	color: var(--text-secondary);
	white-space: nowrap;
}
.sel-option:hover {
	background: var(--accent-soft-bg);
	color: var(--accent-soft-text);
}
.sel-option.is-selected {
	background: var(--accent-soft-bg);
	color: var(--accent-soft-text);
	font-weight: 500;
}

.sel-check {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	color: var(--accent);
	opacity: 0;
}
.sel-option.is-selected .sel-check {
	opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════
   Editor newsletter (TipTap) — stessa anatomia del componente del
   manager, riscritta in CSS semplice invece che in classi Tailwind.
   ══════════════════════════════════════════════════════════════════ */

.rt-wrap {
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-xl);
	background: var(--surface-card);
}

.rt-toolbar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 2px;
	padding: 6px 8px;
	border-bottom: 1px solid var(--border-hairline);
	background: var(--surface-muted);
	border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.rt-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	height: 28px;
	min-width: 28px;
	padding: 0 4px;
	border: 0;
	border-radius: var(--radius-md);
	background: transparent;
	color: var(--text-tertiary);
	font-family: inherit;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--duration-base) var(--ease-standard),
	            color var(--duration-base) var(--ease-standard);
}

.rt-btn:hover:not(:disabled) {
	background: var(--surface-hover);
	color: var(--text-primary);
}

.rt-btn:disabled { opacity: 0.3; pointer-events: none; }

.rt-btn.is-on {
	background: var(--accent-soft-bg);
	color: var(--accent-soft-text);
}

.rt-btn.is-busy { opacity: 0.5; }

.rt-btn svg { width: 14px; height: 14px; }
.rt-btn .rt-label { padding: 0 3px; font-size: 11px; font-weight: 500; }

/* "Personalizza" is always tinted, as in the manager: it is the one toolbar
   item people forget exists. */
.rt-btn-accent {
	background: var(--accent-soft-bg);
	color: var(--accent-soft-text);
	padding: 0 8px;
}

.rt-sep {
	width: 1px;
	height: 20px;
	margin: 0 4px;
	background: var(--border-subtle);
}

/* Swatch under the "A" icon, showing the current text colour. */
.rt-dot {
	position: absolute;
	left: 5px;
	right: 5px;
	bottom: 3px;
	height: 3px;
	border-radius: 2px;
	background: var(--text-meta);
}

/* ── popovers ── */

.rt-pop { position: relative; }

.rt-panel {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	z-index: 60;
	min-width: 224px;
	padding: 10px;
	background: var(--surface-overlay);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-xl);
	box-shadow: var(--sh-soft-lg);
}

.rt-panel-wide { width: 320px; }

.rt-panel-title {
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--text-meta);
	margin: 8px 2px 5px;
}

.rt-panel-title:first-child { margin-top: 0; }

.rt-panel .input { width: 100%; }

.rt-panel-actions {
	display: flex;
	justify-content: flex-end;
	margin-top: 10px;
}

.rt-swatches {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 6px;
}

.rt-swatches-round {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.rt-swatch {
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-md);
	box-shadow: 0 0 0 1px var(--border-subtle);
	color: var(--text-meta);
	font-size: 14px;
	cursor: pointer;
}

.rt-swatch:hover { box-shadow: 0 0 0 1px var(--border-strong); }

.rt-swatch.is-on,
.rt-swatch:focus-visible {
	box-shadow: 0 0 0 2px var(--surface-overlay), 0 0 0 4px var(--accent);
	outline: none;
}

.rt-swatch-round { border-radius: 999px; width: 24px; height: 24px; }

.rt-field-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.rt-color-input {
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-md);
	background: transparent;
	cursor: pointer;
}

.rt-cta-preview {
	margin-top: 10px;
	padding: 12px;
	text-align: center;
	background: var(--surface-muted);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-lg);
}

.rt-token {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	padding: 7px 9px;
	border: 0;
	border-radius: var(--radius-lg);
	background: transparent;
	text-align: left;
	cursor: pointer;
	font-family: inherit;
}

.rt-token:hover { background: var(--surface-hover); }
.rt-token > span { display: flex; flex-direction: column; }
.rt-token-label { font-size: 12.5px; font-weight: 500; color: var(--text-primary); }
.rt-token-sample { font-size: 11px; color: var(--text-meta); }

.rt-token code {
	font-family: var(--font-mono);
	font-size: 10px;
	padding: 2px 6px;
	border-radius: var(--radius-xs);
	background: var(--accent-soft-bg);
	color: var(--accent-soft-text);
}

/* ── writing surface ── */

.rt-surface {
	padding: 14px 16px;
	font-size: 14px;
	color: var(--text-primary);
	min-height: 300px;
}

.rt-surface .ProseMirror { outline: none; min-height: 280px; }
.rt-surface .ProseMirror p { margin: 0.5em 0; line-height: 1.6; }
.rt-surface .ProseMirror h1 { font-size: 1.5em; font-weight: 700; margin: 0.6em 0 0.4em; line-height: 1.3; }
.rt-surface .ProseMirror h2 { font-size: 1.25em; font-weight: 600; margin: 0.6em 0 0.4em; line-height: 1.3; }
.rt-surface .ProseMirror h3 { font-size: 1.1em; font-weight: 600; margin: 0.5em 0 0.3em; }
.rt-surface .ProseMirror ul,
.rt-surface .ProseMirror ol { padding-left: 1.5em; margin: 0.5em 0; }
.rt-surface .ProseMirror ul { list-style-type: disc; }
.rt-surface .ProseMirror ol { list-style-type: decimal; }
.rt-surface .ProseMirror li { margin: 0.2em 0; }

.rt-surface .ProseMirror blockquote {
	border-left: 3px solid var(--border-subtle);
	padding-left: 1em;
	margin: 0.8em 0;
	color: var(--text-tertiary);
	font-style: italic;
}

.rt-surface .ProseMirror a:not([style]) {
	color: var(--accent);
	text-decoration: underline;
}

.rt-surface .ProseMirror img {
	max-width: 100%;
	height: auto;
	border-radius: 4px;
	display: block;
	margin: 0.5em 0;
}

.rt-surface .ProseMirror p.is-editor-empty:first-child::before {
	content: attr(data-placeholder);
	float: left;
	color: var(--text-placeholder);
	pointer-events: none;
	height: 0;
}

/* Hidden only once the editor has actually mounted — see editor.js. */
.rt-source { display: none; }

/* ══════════════════════════════════════════════════════════════════
   Modals — native <dialog>. The browser centres it, dims the page,
   closes it on Esc and keeps focus inside; we only style the box.
   ══════════════════════════════════════════════════════════════════ */

dialog.modal {
	padding: 0;
	border: 0;
	background: transparent;
	max-width: none;
	max-height: none;
	overflow: visible;
}

dialog.modal::backdrop {
	background: rgb(10 12 16 / 0.55);
	backdrop-filter: blur(3px);
}

/* Page behind must not scroll while a modal is open. */
body:has(dialog[open]) { overflow: hidden; }

.modal-box {
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 48px);
	width: min(440px, calc(100vw - 32px));
	background: var(--surface-card);
	border: 1px solid var(--border-subtle);
	border-radius: 16px;
	box-shadow: var(--sh-soft-lg);
	color: var(--text-primary);
	overflow: hidden;
}

.modal-lg { width: min(720px, calc(100vw - 32px)); height: calc(100vh - 48px); }

.modal-head,
.modal-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 12px 12px 20px;
	flex-shrink: 0;
}

.modal-head { border-bottom: 1px solid var(--border-hairline); }

.modal-foot {
	padding: 12px 20px;
	justify-content: flex-end;
	border-top: 1px solid var(--border-hairline);
}

.modal-title { font-weight: 600; font-size: 14px; margin-right: 8px; }

/* The only scrolling region: wheel anywhere inside the box scrolls it. */
.modal-body {
	padding: 16px 20px;
	overflow-y: auto;
	overscroll-behavior: contain;
	flex: 1;
}

/* The email has its own white canvas; no padding around it. */
.modal-body-flush { padding: 0; background: #ffffff; }

/* White regardless of theme: it previews what lands in an inbox. Height is
   set to the email's own height on load (see the iframe's onload), so the
   modal body scrolls instead of a box inside a box. */
.mail-preview {
	display: block;
	width: 100%;
	min-height: 400px;
	border: 0;
	background: #ffffff;
	color-scheme: light;
}

/* ── send modal: two choices ── */

.choice {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px;
	margin-bottom: 8px;
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-lg);
	cursor: pointer;
	transition: border-color var(--duration-base) var(--ease-standard),
	            background var(--duration-base) var(--ease-standard);
}

.choice:hover { border-color: var(--border-field-hover); }

.choice:has(input:checked) {
	border-color: var(--accent);
	background: var(--accent-soft-bg);
}

.choice input { margin-top: 3px; accent-color: var(--accent); }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice-title { font-weight: 600; font-size: 13px; }
.choice-sub { font-size: 12px; color: var(--text-tertiary); }

/* Date picker and button label follow the chosen option — pure CSS, so
   there is no JS state that could disagree with the radio. */
.schedule-field { display: none; margin: 4px 0 8px 30px; }
.schedule-field .input { width: 100%; }
.modal:has(input[value="schedule"]:checked) .schedule-field { display: block; }

.when-schedule { display: none; }
.modal:has(input[value="schedule"]:checked) .when-now { display: none; }
.modal:has(input[value="schedule"]:checked) .when-schedule { display: inline; }

.unschedule {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid var(--border-hairline);
	font-size: 12.5px;
}

/* Square icon-only button, e.g. the trash can in the campaign list. */

/* ══════════════════════════════════════════════════════════════════
   Page-specific layout
   ══════════════════════════════════════════════════════════════════ */

/* Vertical rhythm for a swapped body: same 16px gap as .page. */
.stack { display: flex; flex-direction: column; gap: 16px; }

/* Contatti: search + state filter in the table card's header. */
.filters { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }
.filters-search { flex: 1; min-width: 220px; max-width: 380px; }

/* Campaign: "Destinatari" row under the fields. */
/* Destinatari — the manager's header line + three tiles split by 1px gaps. */
.recipients { border-top: 1px solid var(--border-hairline); }
.recipients-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 12px 20px; }
.recipients-note { font-size: 11px; color: var(--text-meta); }
.recipients-tiles {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1px;
	background: var(--surface-muted);
	border-top: 1px solid var(--border-hairline);
	border-radius: 0 0 16px 16px;
	overflow: hidden;
}
.recipients-tile { padding: 10px 16px; background: var(--surface-card); }
.recipients-label { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-meta); }
.recipients-value { margin-top: 2px; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.recipients-value.is-valid { color: #15803d; }
.recipients-value.is-invalid { color: #b45309; }
:root.dark .recipients-value.is-valid { color: #4ade80; }
:root.dark .recipients-value.is-invalid { color: #fbbf24; }
.recipients-sent { display: flex; align-items: center; gap: 10px; }
.recipients-count { margin-left: auto; }

/* First line of the send modal: who and how fast. */
.modal-lead {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 14px;
	font-size: 13px;
	color: var(--text-secondary);
}
.modal-lead .ic-sm { color: var(--text-meta); }
/* Plain explanatory paragraph in a modal (modal-lead is an icon + one line). */
.modal-text { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.modal-text strong { color: var(--text-primary); font-weight: 600; }
.modal-lead strong { color: var(--text-primary); }

/* ─── Panoramica ─── */

/* Trend line under a stat tile when it went up. */
.stat-sub.is-up { color: var(--success-soft-text); }
.stat .stat-sub { margin-top: 2px; }

.chart-body { padding: 8px 12px 4px; }
.chart { min-height: 220px; }

.dash-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	align-items: stretch;
}

/* Side-by-side cards share one height; the body grows and the footer line
   (Prossimo invio / Prossima lettura) sits on the bottom edge of both. */
.dash-grid > .card { display: flex; flex-direction: column; }
.dash-grid > .card > .card-body,
.dash-grid > .card > .empty-state { flex: 1; }
.dash-grid > .card > .card-section:last-child { margin-top: auto; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* "Vedi esiti ›" link in a card header. */
.card-link {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	font-size: 12px;
	font-weight: 500;
	color: var(--accent-text);
}

.dash-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dash-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.dash-title:hover { color: var(--accent-text); text-decoration: none; }

/* Three inline figures inside a card. */
.dash-metrics {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
	margin: 16px 0 14px;
}
.dash-metrics > div { display: flex; flex-direction: column; gap: 1px; }
.dash-metric { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.dash-metric.is-success { color: var(--success-soft-text); }
.dash-metric.is-danger { color: var(--danger-soft-text); }
.dash-metric-label { font-size: 11px; color: var(--text-meta); }

/* One-line footer row in a card (next send / next import). */
.dash-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); }
.dash-line .ic-sm { color: var(--text-meta); }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 20px;
	border-top: 1px solid var(--border-hairline);
}
.alert-row:first-child { border-top: 0; }
.alert-ic {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 8px;
	background: var(--warning-soft-bg);
	color: var(--warning-soft-text);
	flex-shrink: 0;
}
.alert-text { flex: 1; font-size: 13px; color: var(--text-secondary); }

/* ══════════════════════════════════════════════════════════════════
   Phone (≤ 720px). One block, so the desktop layout above stays the
   reference and this only reflows it:
   · the nav becomes a bottom tab bar (thumb reach, frees the top bar);
   · tables (.table-stack) become one card per row, labels from data-label;
   · headers and action rows wrap; inputs get 16px text so iOS Safari does
     not zoom the page on focus.
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
	/* Top bar: mark + actions only. backdrop-filter is dropped because it
	   would make the fixed bottom nav position against the bar, not the
	   viewport. */
	.topbar { backdrop-filter: none; background: var(--surface-card); }
	.topbar-inner { height: 56px; padding: 0 16px; gap: 12px; }
	.brand-text { display: none; }
	.user-email { max-width: 44px; padding: 6px; font-size: 0; gap: 0; }
	.user-email .ic { width: 18px; height: 18px; }

	.nav {
		position: fixed;
		left: 0; right: 0; bottom: 0;
		z-index: 40;
		justify-content: space-around;
		gap: 0;
		padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
		background: var(--surface-card);
		border-top: 1px solid var(--border-subtle);
		box-shadow: 0 -4px 16px rgb(0 0 0 / 0.04);
	}
	.nav-link {
		flex: 1;
		flex-direction: column;
		justify-content: center;
		gap: 3px;
		height: 52px;
		padding: 0 4px;
		font-size: 11px;
		background: none;
		box-shadow: none;
	}
	.nav-link.is-active { background: none; box-shadow: none; color: var(--accent-text); }
	.nav-link:hover { background: none; }

	/* Page: tighter gutter, room for the tab bar. */
	.page { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); gap: 12px; }
	.page-title { font-size: 17px; }
	.page-head { align-items: stretch; flex-direction: column; gap: 12px; }
	.page-actions { width: 100%; }
	.page-actions > .btn, .page-actions > form > .btn { flex: 1 1 auto; }
	.page-head.is-sticky { top: 56px; margin: -8px -16px 0; padding: 10px 16px; }
	.page-head.is-sticky .page-actions { flex-wrap: wrap; }
	.page-head.is-sticky .btn { height: 34px; padding: 0 10px; }

	.card-head { padding: 14px 16px 10px; }
	.card-body { padding: 14px 16px; }
	.card-section { padding: 12px 16px; }
	.card-foot { flex-wrap: wrap; padding: 10px 12px; }

	/* iOS zooms into any focused field under 16px. */
	.input, .sel-toggle, .dp-toggle, textarea { font-size: 16px; }
	.input-code { font-size: 20px; }

	/* Stacked tables: each row a small card, each cell "Label   value". */
	.table-stack thead { display: none; }
	.table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
	.table-stack tr {
		position: relative;
		padding: 12px 16px;
		border-top: 1px solid var(--border-hairline);
	}
	.table-stack tbody tr:first-child { border-top: 0; }
	.table-stack td {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding: 4px 0;
		border: 0;
		text-align: right;
		min-width: 0;
	}
	.table-stack td[data-label]::before {
		content: attr(data-label);
		flex: none;
		font-size: 11px;
		font-weight: 500;
		text-transform: uppercase;
		letter-spacing: 0.05em;
		color: var(--text-meta);
		text-align: left;
	}
	.table-stack td > * { min-width: 0; overflow-wrap: anywhere; }
	.table-stack td.cell-main { display: block; padding: 0 0 6px; text-align: left; }
	/* Row actions float top-right; the title makes room only where they exist. */
	.table-stack tr:has(td.cell-act) td.cell-main { padding-right: 76px; }
	.table-stack td.cell-act { position: absolute; top: 8px; right: 8px; width: auto; padding: 0; }
	.table-stack tbody tr:hover td { background: none; }
	.table-stack tr.is-link:hover td:first-child { box-shadow: none; }
	.table-stack tr.is-link:active { background: var(--surface-muted); }
	.table-stack td[data-label="Avanzamento"] > div { flex: 1; max-width: 180px; }
	.table-stack .progress-head { justify-content: flex-end; gap: 8px; }

	/* Filters / search full width. */
	.filters { width: 100%; }
	.filters-search { min-width: 0; max-width: none; flex: 1 1 100%; }
	.filters .sel { width: 100% !important; }

	/* Pager: info above, pages below. */
	.pager-info { width: 100%; }
	.pages { flex-wrap: wrap; }
	.pg { min-width: 34px; height: 34px; }

	/* Stats: two per row; the Destinatari tiles keep three but smaller. */
	.stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
	.recipients-head { padding: 12px 16px; }
	.recipients-tile { padding: 10px 12px; }
	.recipients-value { font-size: 16px; }

	/* Modals: near full width, actions stacked big for thumbs. */
	.modal-box { width: calc(100vw - 24px); max-height: calc(100vh - 32px); }
	.modal-foot { flex-direction: column-reverse; align-items: stretch; padding: 12px 16px 16px; }
	.modal-foot .btn { width: 100%; height: 40px; }
	.modal-body { padding: 16px; }
	.modal-lg { width: calc(100vw - 24px); height: calc(100vh - 32px); }

	/* Editor toolbar: one scrollable row instead of three wrapped ones. */
	.rt-toolbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
	.rt-toolbar::-webkit-scrollbar { display: none; }
	.rt-toolbar > * { flex: none; }

	/* Toasts above the tab bar, full width. */
	.toasts { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); }

	/* Profile / users. */
	.profile-row { flex-direction: column; align-items: stretch; }
	.profile-actions { flex-wrap: wrap; }
	.profile-actions .btn { flex: 1 1 auto; }

	/* Sign-in pages. */
	.auth-body { padding: 16px; place-items: start center; padding-top: 10vh; }
	.auth-card { padding: 18px; }

	/* Date picker panel: fits the narrowest phones. */
	.dp-panel { width: min(280px, calc(100vw - 24px)); }
	.dp-day { width: 100%; }
}
