/* ============================================================
   O2 Marketing — design system
   ------------------------------------------------------------
   Alineado con el O2 Order System (orders.o2marketinghouse.com):
   mismos tokens de papel calido, mismos radios (10/6/16), misma escala
   tipografica y un solo acento (terracota). Las dos apps deben leerse como una.

   Capas: `base` = escritorio; `modules` = estilos de cada modulo
   aislado (.cal-*, .cmp-*, .tsk-*, .mc-*, .ag-*); `responsive`
   (responsive.css) va despues y por tanto GANA SIEMPRE.
   ============================================================ */

@layer base, modules, responsive;

@layer base {

	:root {
		/* Superficies — papel calido, no gris frio.
		   Mismos valores que el rebranding del O2 Order System: el area de trabajo es
		   papel (#f6f2ea), los paneles son casi blancos (#fffdfa) y la barra lateral
		   es un papel mas profundo (#f2ece1) para que la navegacion se lea como
		   estructura y no compita con el contenido. */
		--bg: #f9fafb;
		--bg-2: #f3f4f6;
		--surface: #ffffff;
		--surface-2: #f3f4f6;
		--sidebar-bg: #ffffff;
		--sidebar-hover: #f3f4f6;
		--line: #e5e7eb;
		--line-strong: #d1d5db;

		/* Texto */
		--text: #111827;
		--text-2: #4b5563;
		--muted: #6b7280;
		--faint: #9ca3af;
		--ink: var(--text);

		--accent: #18181b;
		--accent-ink: #111827;
		--accent-soft: #f3f4f6;
		--accent-line: #d1d5db;

		/* Estados */
		--ok: #15803d;      --good: #15803d;
		--ok-bg: #f0fdf4;   --good-bg: #f0fdf4;
		--warn: #a16207;    --warn-bg: #fefce8;
		--info: #1d4ed8;    --info-bg: #eff6ff;
		--danger: #b91c1c;  --error: #b91c1c;
		--danger-bg: #fef2f2; --error-bg: #fef2f2;
		--neutral: #4b5563; --neutral-bg: #f3f4f6;

		/* Tintas semanticas (mismo lenguaje que O2 Orders: el color vive en la tinta,
		   sin fondos pastel de semaforo). */
		--pill-rose-bg:   transparent; --pill-rose-fg:   var(--danger);
		--pill-amber-bg:  transparent; --pill-amber-fg:  var(--warn);
		--pill-mint-bg:   transparent; --pill-mint-fg:   var(--ok);
		--pill-sky-bg:    transparent; --pill-sky-fg:    var(--info);
		--pill-violet-bg: transparent; --pill-violet-fg: var(--accent-ink);
		--pill-slate-bg:  transparent; --pill-slate-fg:  var(--neutral);

		/* Forma: tres radios y nada mas (10 / 6 / 16, como el Order System). */
		--radius: 10px;
		--radius-sm: 6px;
		--radius-lg: 16px;

		/* Tipografia: seis pasos (11 -> 24). Un tamano fuera de esta escala es una
		   excepcion que hay que justificar, no un valor mas. Los tamanos heredados
		   (22px del H1, 15px del H2) siguen en su regla hasta que se toque esa regla:
		   migrarlos todos de golpe es un refactor aparte, no un cambio de tokens. */
		--fs-11: 11px;
		--fs-12: 12px;
		--fs-13: 13px;
		--fs-14: 14px;
		--fs-16: 16px;
		--fs-20: 20px;
		--fs-24: 24px;

		/* Sombras con el mismo marron que la tinta, no con azul-gris: una sombra
		   fria sobre papel calido se ve como un borde sucio. */
		--shadow: 0 1px 2px rgba(45, 35, 26, .06);
		/* Sombra de tarjeta/pill elevada: dos capas muy suaves (contacto + difusa).
		   Una sola sombra grande se ve como un drop-shadow pegado. */
		--shadow-raised: 0 1px 2px rgba(45, 35, 26, .07), 0 1px 3px rgba(45, 35, 26, .05);
		/* Ancho de la barra lateral: 232px es lo que necesita la etiqueta mas larga
		   ("Mailchimp & Leads") para no partirse ni recortarse. */
		--sidebar-w: 232px;
		--sidebar-rail: 58px;
		--font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
		--mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
	}

	* { box-sizing: border-box; }
	/* `pinch-zoom` se declara explicito: la matriz de categorias y el calendario se
	   leen mejor ampliando, y un `touch-action` restrictivo lo bloquearia (WCAG 1.4.4). */
	html { -webkit-text-size-adjust: 100%; touch-action: pan-x pan-y pinch-zoom; }
	body {
		margin: 0;
		background: var(--bg);
		color: var(--text);
		font-family: var(--font);
		font-size: var(--fs-14);
		line-height: 1.5;
		-webkit-font-smoothing: antialiased;
	}
	a { color: var(--accent); text-decoration: none; }
	a:hover { color: var(--accent-ink); text-decoration: underline; }
	h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.011em; color: var(--text); }
	h1 { font-size: 22px; font-weight: 650; }
	h2 { font-size: 15px; }
	p { margin: 0; }
	code { font-family: var(--mono); font-size: var(--fs-12); background: var(--bg-2); padding: 2px 5px; border-radius: 4px; }
	.muted { color: var(--muted); }
	.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
	.num { text-align: right; 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; }

	/* ---------- Auth ----------
	   Puerta con panel de marca a la IZQUIERDA y tarjeta a la derecha, como la del
	   Order System: la foto se oscurece con un velo y el copy va abajo. El fondo cae
	   a papel (#f6f2ea) cuando la plantilla no declara `--auth-bg`. */
	.auth-body {
		min-height: 100vh; padding: 0;
		background: var(--auth-bg, #f9fafb);
	}
	.auth-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
	.auth-form { display: flex; align-items: center; justify-content: center; flex: 1 1 auto; padding: 24px; min-width: 0; }
	/* La marca va a la izquierda y el formulario a la derecha: se invierte con `order`,
	   no moviendo el HTML, porque el formulario debe seguir siendo lo primero del DOM. */
	.auth-shell.has-side { display: grid; grid-template-columns: minmax(360px, 46%) minmax(420px, 1fr); align-items: stretch; padding: 0; }
	.auth-shell.has-side .auth-form { padding: 32px; }
	.auth-shell.has-side .auth-side { order: -1; width: 100%; max-width: none; min-height: 100vh; }
	.auth-card {
		background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
		padding: 34px 32px 26px; width: min(420px, 92vw);
		box-shadow: 0 20px 48px rgba(75, 58, 48, .13), 0 2px 6px rgba(75, 58, 48, .05);
	}
	.auth-logo { display: block; height: 30px; width: auto; margin-bottom: 18px; }
	.auth-card h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
	.auth-lead { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
	.auth-card .alert { margin-bottom: 16px; }
	.auth-fields { display: grid; gap: 14px; }
	.auth-card label { font-size: 12.5px; color: var(--text-2); }
	.auth-card .check { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }
	.auth-card .check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
	.auth-card .btn { width: 100%; justify-content: center; margin-top: 4px; padding: 10px 14px; }
	.input-wrap { position: relative; display: flex; align-items: center; }
	.input-wrap input { width: 100%; padding-right: 38px; }
	.input-wrap input::-ms-reveal,
	.input-wrap input::-ms-clear { display: none; }
	.pw-toggle [hidden] { display: none !important; }
	.pw-toggle {
		position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
		display: inline-flex; align-items: center; justify-content: center;
		width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px;
		background: transparent; color: var(--muted); cursor: pointer;
	}
	.pw-toggle:hover { color: var(--text); background: var(--bg-2); }
	.auth-meta {
		display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px;
		margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line);
		font-size: 12px; line-height: 1.45;
	}
	.auth-meta dt { color: var(--text-2); font-weight: 600; }
	.auth-meta dd { margin: 0; color: var(--muted); }
	.auth-foot { margin: 14px 0 0; font-size: 11.5px; color: var(--muted); }

	/* Ayuda de la puerta: etiqueta + valor en una columna, con lineas finas. */
	.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin: 0; }
	.facts > div { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
	.facts > div:last-child { border-bottom: 0; }
	.facts dt { font-size: 11.5px; color: var(--muted); padding-top: 1px; }
	.facts dd { margin: 0; font-size: 13px; }
	.facts.auth-help { grid-template-columns: 1fr; margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
	.facts.auth-help > div { grid-template-columns: 92px minmax(0, 1fr); }
	.facts.auth-help dt { color: var(--text-2); font-weight: 600; }
	.facts.auth-help dd { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
	.facts.auth-help dd strong { color: var(--text); font-weight: 600; }
	.facts.auth-help dd a { font-weight: 600; }

	/* Panel de marca: foto + velo + copy abajo. El fondo cae al acento de la marca
	   (`app.accent`), no a un hex propio: en un proyecto white-label el panel cambia
	   con el token, sin tocar esta hoja. */
	.auth-side { position: relative; flex: 0 0 46%; max-width: 620px; overflow: hidden; background: var(--accent); }
	.auth-side-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
	.auth-side::after {
		content: ""; position: absolute; inset: 0;
		background-image: linear-gradient(to top, rgba(28, 22, 19, .86) 0%, rgba(28, 22, 19, .55) 32%, rgba(28, 22, 19, 0) 62%);
		background-color: rgba(28, 22, 19, var(--auth-veil, 45%));
	}
	.auth-side-body {
		position: relative; z-index: 1; height: 100%; padding: 52px 44px;
		display: flex; flex-direction: column; justify-content: flex-end; gap: 8px;
		color: #fff; text-shadow: 0 1px 14px rgba(0, 0, 0, .5);
	}
	.auth-side-eyebrow { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #f0b79c; }
	.auth-side-title { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 650; letter-spacing: -.01em; }
	.auth-side-text { margin: 0; font-size: 14px; line-height: 1.6; color: rgba(255, 255, 255, .9); max-width: 46ch; }
	.auth-side-link {
		display: inline-block; margin-top: 6px; padding: 9px 16px; border-radius: var(--radius-sm);
		background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .35);
		color: #fff; font-size: 13px; font-weight: 600; text-decoration: none;
	}
	.auth-side-link:hover { background: rgba(28, 22, 19, .3); border-color: rgba(255, 255, 255, .6); color: #fff; text-decoration: none; }
	.auth-side-link:visited { color: #fff; }
	.auth-side-link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

	/* ---------- Shell ---------- */
	.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; transition: grid-template-columns .16s ease; }
	.sidebar {
		position: sticky; top: 0; height: 100dvh; overflow-y: auto; scrollbar-gutter: stable;
		display: flex; flex-direction: column; gap: 14px;
		padding: 16px 12px;
		/* #f2ece1: un papel mas profundo que el area de trabajo, para que la
		   navegacion se lea como estructura. La tarjeta activa (`.nav-link.is-active`)
		   se eleva con #fffdfa, el mismo casi-blanco de los paneles. */
		background: var(--sidebar-bg);
		border-right: 1px solid var(--line);
		z-index: 30;
	}
	.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 8px 4px; }
	/* Marca white-label: el nombre sale de `app.name` (config), nunca del HTML.
	   Con `app.logo` se pinta el logo; sin el, una teja con la inicial. */
	.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-decoration: none; min-width: 0; }
	.brand:hover { text-decoration: none; }
	.brand-mark {
		display: grid; place-items: center; flex: 0 0 28px;
		width: 28px; height: 28px; border-radius: var(--radius-sm);
		background: var(--accent); color: #fff;
		font-size: 14px; font-weight: 700; letter-spacing: -.02em;
	}
	.brand-logo { display: block; height: 24px; width: auto; max-width: 100%; }
	.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
	.brand-name { font-size: 13.5px; font-weight: 650; color: var(--text); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.brand-tag { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.rail-toggle {
		width: 26px; height: 26px; flex: 0 0 26px;
		display: grid; place-items: center; padding: 0;
		border: 1px solid transparent; border-radius: var(--radius-sm);
		background: transparent; color: var(--muted); cursor: pointer;
	}
	.rail-toggle:hover { background: var(--sidebar-hover); border-color: var(--line); color: var(--text); }
	.rail-toggle svg { width: 15px; height: 15px; transition: transform .16s ease; }

	.nav { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
	.nav-group { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
	.nav-label { padding: 6px 10px 3px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
	.nav-link {
		display: flex; align-items: center; gap: 9px;
		padding: 7px 10px; border-radius: var(--radius-sm);
		/* Borde transparente siempre presente: el item activo lo pinta y asi la
		   etiqueta no se desplaza 1px al cambiar de seccion. */
		border: 1px solid transparent;
		color: var(--text-2); font-size: 13.5px; font-weight: 500; text-decoration: none;
		min-width: 0; position: relative;
		transition: background .14s ease, border-color .14s ease, box-shadow .14s ease, color .14s ease;
	}
	.nav-link svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); }
	/* Sin `text-overflow: ellipsis`: una etiqueta recortada a media palabra es peor
	   que una etiqueta en dos lineas. El ancho (232px) hace que casi nunca haga falta. */
	.nav-link span { min-width: 0; line-height: 1.35; overflow-wrap: anywhere; }
	.nav-link:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
	/* Activo = tarjeta de papel casi blanco (#fffdfa) elevada sobre el papel mas
	   profundo de la barra. Se lee como posicion (una tarjeta encima de otra
	   superficie), no como un bloque de color: el unico acento es el icono, el punto
	   y el badge. */
	.nav-link.is-active {
		background: var(--accent-soft);
		border-color: var(--accent-line);
		box-shadow: none;
		color: var(--accent-ink); font-weight: 600;
	}
	/* `aria-current="page"` es el estado real del enlace activo; la clase `.is-active`
	   sigue pintandolo para no depender del atributo en cada plantilla. */
	.nav-link[aria-current="page"] {
		background: var(--accent-soft);
		border-color: var(--accent-line);
		box-shadow: none;
		color: var(--accent-ink); font-weight: 600;
	}
	.nav-link.is-active:hover { background: var(--accent-soft); }
	.nav-link[aria-current="page"]:hover { background: var(--accent-soft); }
	.nav-link.is-active svg { color: var(--accent); }
	.nav-link[aria-current="page"] svg { color: var(--accent); }
	.nav-link.is-active::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-left: auto; flex: 0 0 5px; }
	.nav-link[aria-current="page"]::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-left: auto; flex: 0 0 5px; }
	.nav-badge {
		flex: 0 0 auto; margin-left: auto; padding: 1px 5px; border-radius: 999px;
		font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums;
		background: var(--sidebar-hover); color: var(--text-2);
	}
	.nav-link.is-active .nav-badge { background: var(--accent-soft); color: var(--accent-ink); }
	.nav-link[aria-current="page"] .nav-badge { background: var(--accent-soft); color: var(--accent-ink); }
	.nav-link:has(.nav-badge).is-active::after { display: none; }
	.nav-link:has(.nav-badge)[aria-current="page"]::after { display: none; }

	.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 10px 0; }
	.user-card { display: flex; align-items: center; gap: 8px; min-width: 0; }
	.avatar {
		width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px;
		display: grid; place-items: center;
		background: var(--accent-soft); color: var(--accent-ink);
		font-weight: 650; font-size: 11.5px; border: 1px solid var(--accent-line);
	}
	.user-meta { min-width: 0; }
	.user-card strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.user-card span { display: block; font-size: 11.5px; color: var(--muted); }
	.theme-toggle {
		display: flex; align-items: center; gap: 7px; width: 100%;
		margin: 0 0 8px; padding: 6px 8px;
		border: 1px solid transparent; border-radius: var(--radius-sm);
		background: transparent; color: var(--muted);
		font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
	}
	.theme-toggle:hover { background: var(--sidebar-hover); border-color: var(--line); color: var(--text); }
	.theme-toggle:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
	.theme-toggle-icon { font-size: 13px; line-height: 1; }
	.theme-toggle[aria-pressed="true"] .theme-toggle-icon { color: var(--text); }
	.logout-link { display: block; margin: 8px -8px 0; padding: 6px 8px; border-radius: var(--radius-sm); color: var(--muted); font-size: 12.5px; }
	.logout-link:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }

	/* ---------- Collapsible Rail Mode (`Ctrl+B` / `data-nav="rail"`) ---------- */
	.app-shell[data-nav="rail"] { grid-template-columns: var(--sidebar-rail) minmax(0, 1fr); }
	/* `overflow: visible` en el rail: los tooltips CSS (`[data-tooltip]`) salen por
	   fuera de la barra y un contenedor con scroll los recortaria. El rail cabe de
	   sobra en alto, asi que no se pierde el scroll que si necesita el modo ancho. */
	.app-shell[data-nav="rail"] .sidebar { padding: 14px 8px; align-items: center; overflow: visible; }
	.app-shell[data-nav="rail"] .sidebar-head { flex-direction: column; padding: 0; gap: 8px; }
	.app-shell[data-nav="rail"] .brand-logo,
	.app-shell[data-nav="rail"] .brand-text,
	.app-shell[data-nav="rail"] .nav-label,
	.app-shell[data-nav="rail"] .nav-link span,
	.app-shell[data-nav="rail"] .nav-badge,
	.app-shell[data-nav="rail"] .nav-link.is-active::after,
	.app-shell[data-nav="rail"] .nav-link[aria-current="page"]::after,
	.app-shell[data-nav="rail"] .user-meta,
	.app-shell[data-nav="rail"] .theme-toggle-label,
	.app-shell[data-nav="rail"] .logout-text { display: none; }
	.app-shell[data-nav="rail"] .rail-toggle svg { transform: rotate(180deg); }
	.app-shell[data-nav="rail"] .nav,
	.app-shell[data-nav="rail"] .nav-group { width: 100%; align-items: center; }
	.app-shell[data-nav="rail"] .nav-link { justify-content: center; width: 38px; height: 36px; padding: 0; }
	.app-shell[data-nav="rail"] .sidebar-foot { width: 100%; padding: 10px 0 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
	.app-shell[data-nav="rail"] .theme-toggle { width: auto; margin: 0; padding: 6px; justify-content: center; }
	.app-shell[data-nav="rail"] .logout-link { margin: 0; padding: 6px; font-size: 11px; text-align: center; }

	/* ---------- Tooltip CSS-only para el rail ----------
	   Solo existe cuando la barra esta colapsada: ahi la etiqueta esta oculta y el
	   icono necesita nombre. Va en `::before` porque `::after` lo ocupa el punto de
	   la seccion activa (que el rail esconde con `display:none`, y eso mataria
	   tambien el tooltip si compartiesen pseudo-elemento). */
	.app-shell[data-nav="rail"] .nav-link[data-tooltip]::before {
		content: attr(data-tooltip);
		position: absolute; left: calc(100% + 10px); top: 50%; z-index: 95;
		transform: translateY(-50%) translateX(-4px);
		padding: 4px 9px; border-radius: var(--radius-sm);
		background: var(--text); color: #fff;
		font-size: 12px; font-weight: 500; line-height: 1.3; letter-spacing: 0;
		white-space: nowrap; text-transform: none;
		opacity: 0; pointer-events: none;
		transition: opacity .12s ease, transform .12s ease;
	}
	.app-shell[data-nav="rail"] .nav-link[data-tooltip]:hover::before,
	.app-shell[data-nav="rail"] .nav-link[data-tooltip]:focus-visible::before { opacity: 1; transform: translateY(-50%) translateX(0); }

	.main { min-width: 0; display: flex; flex-direction: column; }
	/* Cabecera en una sola fila cuando cabe: titulo+resumen a la izquierda y las
	   acciones a la derecha. Si no cabe, el bloque de acciones baja entero en vez
	   de dejar un boton huerfano en una segunda linea. */
	.topbar { display: flex; align-items: flex-start; gap: 12px; padding: 28px 32px 0; flex-wrap: wrap; }
	/* `flex-basis: 0`: el titulo ocupa lo que sobra y las acciones se quedan a su
	   derecha en la misma fila. Sin esto el bloque de titulo (con el resumen) pide
	   todo el ancho y empuja las acciones a una fila vacia. */
	.page-title { flex: 1 1 0; min-width: 0; }
	.page-title h1 { font-size: 22px; font-weight: 650; letter-spacing: -.014em; }
	.page-title p { margin-top: 2px; color: var(--muted); font-size: 13px; }

	/* ---------- Breadcrumb de seccion ----------
	   Estructura, no navegacion principal: va encima del H1 para que el titulo siga
	   siendo lo primero que se lee. La ultima miga es texto (nunca un enlace a la
	   pagina en la que ya estas) y todo cabe en una linea en escritorio. */
	.breadcrumb { margin: 0 0 5px; }
	.breadcrumb-list {
		display: flex; align-items: center; flex-wrap: wrap; gap: 2px 6px;
		list-style: none; margin: 0; padding: 0;
		font-size: 11.5px; font-weight: 500; line-height: 1.4; color: var(--muted);
	}
	.breadcrumb-sep { color: var(--faint); user-select: none; }
	.breadcrumb-current { color: var(--text-2); font-weight: 600; }

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

	/* ---------- Team avatar stack ----------
	   Presencia compacta junto a las acciones. Los avatares se solapan con un anillo
	   del color de la superficie (no un borde de pagina): asi la pila se lee como un
	   grupo y no como cinco circulos sueltos. Los tonos salen de los tokens pastel,
	   de modo que cada inicial tiene identidad sin inventar una paleta aparte. */
	.team-stack { display: flex; align-items: center; padding-right: 2px; }
	.team-avatar {
		display: grid; place-items: center;
		width: 26px; height: 26px; flex: 0 0 26px;
		margin-left: -7px; border-radius: 50%;
		background: var(--pill-slate-bg); color: var(--pill-slate-fg);
		border: 2px solid var(--surface);
		font-size: 10px; font-weight: 700; letter-spacing: .01em; line-height: 1;
		box-shadow: 0 1px 2px rgba(45, 35, 26, .10);
		transition: transform .12s ease;
	}
	.team-avatar:first-child { margin-left: 0; }
	.team-avatar:hover { transform: translateY(-1px); z-index: 1; }
	.team-avatar.is-more { background: var(--surface); color: var(--text-2); border-color: var(--line); font-variant-numeric: tabular-nums; }
	.team-avatar[data-tone="rose"]   { background: var(--pill-rose-bg);   color: var(--pill-rose-fg); }
	.team-avatar[data-tone="amber"]  { background: var(--pill-amber-bg);  color: var(--pill-amber-fg); }
	.team-avatar[data-tone="mint"]   { background: var(--pill-mint-bg);   color: var(--pill-mint-fg); }
	.team-avatar[data-tone="sky"]    { background: var(--pill-sky-bg);    color: var(--pill-sky-fg); }
	.team-avatar[data-tone="violet"] { background: var(--pill-violet-bg); color: var(--pill-violet-fg); }
	.team-avatar[data-tone="slate"]  { background: var(--pill-slate-bg);  color: var(--pill-slate-fg); }
	.menu-toggle {
		display: none; width: 30px; height: 30px; flex: 0 0 auto;
		border: 1px solid var(--line); border-radius: var(--radius-sm);
		background: var(--surface); color: var(--text-2); cursor: pointer;
		place-items: center; padding: 0;
	}
	.menu-toggle:hover { background: var(--surface-2); color: var(--text); }
	.menu-toggle svg { width: 16px; height: 16px; }
	.content { padding: 20px 32px 72px; display: grid; gap: 16px; align-content: start; max-width: 1344px; }
	/* Pantallas de trabajo ancho (calendario, tableros, CRM): la rejilla usa el
	   ancho disponible hasta 1720px en vez de quedarse en la columna de lectura. */
	.content.is-wide { max-width: 1720px; }
	/* Sin esto, una tabla ancha estira la rejilla y la pagina hace scroll horizontal en
	   el movil: los hijos de una rejima heredan min-width:auto. */
	.content > *, .grid-2 > *, .panel { min-width: 0; }

	/* ---------- Page summary (una linea, sin cajas) ---------- */
	.page-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 0; margin-top: 8px; font-size: 13px; color: var(--muted); }
	.page-summary > span { display: inline-flex; align-items: baseline; gap: 5px; padding: 0 12px; border-right: 1px solid var(--line); white-space: nowrap; }
	.page-summary > span:first-child { padding-left: 0; }
	.page-summary > span:last-child { padding-right: 0; border-right: 0; }
	.page-summary b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
	.page-summary-total b { font-size: 17px; }
	/* El punto solo aparece cuando hay un estado que señalar; si no, es ruido. */
	.page-summary-stat::before { content: ""; align-self: center; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
	.page-summary-stat:not([data-tone])::before { display: none; }
	.page-summary .delta { margin-left: 5px; }

	/* ---------- Health bar (una linea, sin panel) ----------
	   La salud de las conexiones es contexto, no un panel: cuatro puntos y un
	   enlace, separados por la misma linea fina que `.page-summary`. */
	.health-bar {
		display: flex; align-items: center; flex-wrap: wrap; gap: 2px 0;
		padding: 0 0 2px; font-size: 12.5px; color: var(--muted);
	}
	.health-item { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-right: 1px solid var(--line); white-space: nowrap; }
	.health-item:first-child { padding-left: 0; }
	.health-item b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
	.health-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: 0 0 6px; }
	.health-dot.is-ok { background: var(--ok); }
	.health-dot.is-warn { background: var(--warn); }
	.health-dot.is-error { background: var(--danger); }
	.health-link { margin-left: auto; padding-left: 12px; }

	/* Punto "en vivo": late solo cuando el dato es de ahora mismo (cola del drawer,
	   salud de una conexion). Con `prefers-reduced-motion` se queda quieto. */
	.live-dot {
		display: inline-block;
		width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%;
		background: var(--ok); animation: live-pulse 2.4s ease-out infinite;
		vertical-align: middle;
	}
	.live-dot.is-warn { background: var(--warn); }
	.live-dot.is-idle { background: var(--faint); animation: none; }
	@keyframes live-pulse {
		0%   { box-shadow: 0 0 0 0 rgba(47, 106, 73, .38); }
		70%  { box-shadow: 0 0 0 6px rgba(47, 106, 73, 0); }
		100% { box-shadow: 0 0 0 0 rgba(47, 106, 73, 0); }
	}
	@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }


	/* ---------- Micro-primitives (.delta, .kbd, .status-pill, .drawer-over) ---------- */
	.delta {
		display: inline-flex; align-items: center;
		padding: 1px 6px; border-radius: 4px;
		font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; font-style: normal;
		background: var(--neutral-bg); color: var(--neutral);
	}
	.delta.is-up { background: var(--ok-bg); color: var(--ok); }
	.delta.is-down { background: var(--danger-bg); color: var(--danger); }
	.delta.is-flat { background: var(--neutral-bg); color: var(--muted); }

	.kbd {
		display: inline-flex; align-items: center; justify-content: center;
		min-width: 18px; height: 18px; padding: 0 5px;
		border: 1px solid var(--line-strong); border-radius: 4px;
		background: var(--surface-2); color: var(--muted);
		font-family: var(--mono); font-size: 11px; font-weight: 500; line-height: 1;
	}

	.status-pill {
		display: inline-flex; align-items: center; gap: 5px;
		padding: 0; border-radius: 0;
		border: 0;
		font-size: 12px; font-weight: 600; white-space: nowrap;
		background: transparent; color: var(--text-2);
	}
	.status-pill::before { content: none; }
	.status-pill[data-stage="idea"] { background: transparent; color: var(--muted); }
	.status-pill[data-stage="copy_design"] { background: transparent; color: var(--warn); }
	.status-pill[data-stage="approved"] { background: transparent; color: var(--ok); }
	.status-pill[data-stage="scheduled"] { background: transparent; color: var(--info); }
	.status-pill[data-stage="live_sent"] { background: transparent; color: var(--accent-ink); }

	/* ---------- Chips semanticos (tinta sobria como O2 Orders, sin pastilla semaforo) ---------- */
	.chip {
		display: inline-flex; align-items: center; gap: 5px;
		padding: 0; border-radius: 0;
		background: transparent; color: var(--text-2);
		font-size: 12px; font-weight: 600; white-space: nowrap;
	}
	.chip::before { content: none; }
	.chip[data-tone="rose"],   .status-pill[data-tone="rose"],   .badge[data-tone="rose"]   { background: transparent; color: var(--danger); }
	.chip[data-tone="amber"],  .status-pill[data-tone="amber"],  .badge[data-tone="amber"]  { background: transparent; color: var(--warn); }
	.chip[data-tone="mint"],   .status-pill[data-tone="mint"],   .badge[data-tone="mint"]   { background: transparent; color: var(--ok); }
	.chip[data-tone="sky"],    .status-pill[data-tone="sky"],    .badge[data-tone="sky"]    { background: transparent; color: var(--info); }
	.chip[data-tone="violet"], .status-pill[data-tone="violet"], .badge[data-tone="violet"] { background: transparent; color: var(--accent-ink); }
	.chip[data-tone="slate"],  .status-pill[data-tone="slate"],  .badge[data-tone="slate"]  { background: transparent; color: var(--muted); }

	.drawer-backdrop {
		position: fixed; inset: 0; z-index: 75;
		background: rgba(34, 29, 25, .28);
		opacity: 0; pointer-events: none; transition: opacity .18s ease;
	}
	.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
	.drawer-over {
		position: fixed; inset: 0 0 0 auto; z-index: 80;
		width: 440px; max-width: 92vw; height: 100dvh;
		display: flex; flex-direction: column;
		background: var(--surface); border-left: 1px solid var(--line);
		box-shadow: -12px 0 36px rgba(45, 35, 26, .14);
		transform: translateX(100%); transition: transform .2s ease;
	}
	.drawer-over.is-open { transform: translateX(0); }
	.drawer-head {
		display: flex; align-items: center; justify-content: space-between; gap: 12px;
		padding: 16px 20px; border-bottom: 1px solid var(--line);
	}
	.drawer-head h2 { font-size: 15px; font-weight: 650; }
	.drawer-close {
		width: 28px; height: 28px; border: 1px solid var(--line); border-radius: var(--radius-sm);
		background: var(--surface); color: var(--muted); cursor: pointer;
		display: grid; place-items: center; padding: 0;
	}
	.drawer-close:hover { background: var(--surface-2); color: var(--text); }
	.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px; display: grid; gap: 14px; align-content: start; }
	.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--bg); }
	/* Bloques internos del drawer: antes eran atributos `style=""` en la plantilla. */
	.drawer-panel { padding: 12px; }
	.drawer-panel-head { margin-bottom: 8px; padding-bottom: 8px; }
	.quick-task-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
	.drawer-hint { font-size: 11.5px; }
	.drawer-shortcuts { font-size: 12px; }

	/* ---------- Controls ---------- */
	.segmented {
		justify-self: start;
		display: inline-flex; gap: 2px; padding: 2px;
		background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
	}
	.segmented-item { padding: 5px 11px; border-radius: 4px; color: var(--muted); font-size: 12.5px; font-weight: 500; text-decoration: none; }
	.segmented-item:hover { color: var(--text); text-decoration: none; }
	.segmented-item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
	/* Dos pantallas, un solo trabajo: el conmutador no es una segunda navegacion, asi que
	   ocupa una linea y no se estira con el contenedor. */
	.view-tabs { display: flex; align-items: center; flex-wrap: wrap; }
	.btn {
		display: inline-flex; align-items: center; justify-content: center; gap: 7px;
		height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
		border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
		font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
	}
	.btn:hover { background: var(--surface-2); text-decoration: none; }
	.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
	.btn-primary { background: var(--text); border-color: var(--text); color: #fff; }
	.btn-primary:hover { background: #3a322c; border-color: #3a322c; color: #fff; }
	.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
	.btn-secondary:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
	/* Fantasma: acciones de fila y enlaces con peso de boton, sin caja visible. */
	.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
	.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
	.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; gap: 5px; }
	.btn-sm .kbd { min-width: 16px; height: 16px; font-size: 10px; }
	.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
	.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
	.btn-block { width: 100%; }
	.field { display: grid; gap: 4px; }
	.field span { font-size: 11.5px; font-weight: 500; color: var(--muted); }
	.field input, .field select {
		height: 34px; width: 100%; padding: 0 10px;
		border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
		background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px;
	}
	.field input:focus, .field select:focus { outline: 2px solid var(--accent-line); outline-offset: 1px; border-color: var(--accent); }
	.sync-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
	.sync-form .field { min-width: 180px; }
	/* Filtros de atribucion: un formulario GET normal. Sin JS, sin selects que se
	   autoenvian (eso rompe el historial y el boton "atras"). */
	.filter-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
	.filter-bar .field { min-width: 148px; }
	.filter-bar .field span { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
	.filter-bar .field input, .filter-bar .field select { height: 30px; font-size: 13px; }
	.filter-bar .btn { height: 30px; }
	.filter-bar .text-link { padding-bottom: 7px; }
	.text-link { font-size: 12.5px; font-weight: 600; }

	/* ---------- Alerts / notices ---------- */
	.alert { padding: 10px 13px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 13px; }
	.alert.is-ok { background: var(--ok-bg); border-color: #bbf7d0; color: var(--ok); }
	.alert.is-error { background: var(--error-bg); border-color: #fecaca; color: var(--error); }
	/* Aviso sin borde de color: un rayo de 3px en terracota es tic de plantilla. */
	.notice {
		display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline;
		padding: 10px 13px; border-radius: var(--radius-sm);
		background: var(--accent-soft); color: var(--text-2); font-size: 12.5px;
	}
	.notice strong { color: var(--text); font-weight: 600; }

	/* ---------- KPIs ---------- */
	/* No hay tarjetas de KPI: las cifras van en UNA linea de resumen bajo el titulo
	   (`.page-summary`). Ocho tarjetas iguales con numero grande son el esqueleto de
	   plantilla que mas delata un dashboard. */

	/* ---------- Panels ---------- */
	.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
	/* La linea a todo lo ancho bajo el titulo se quitaba por defecto: convertia cada
	   panel en la misma caja rayada. Ahora la separacion es el espacio, y la linea
	   se pide con `.is-divided` cuando de verdad separa algo (tablas largas, drawer). */
	.panel-head {
		display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
		padding-bottom: 0; margin-bottom: 14px;
	}
	.panel-head.is-divided {
		padding-bottom: 12px; margin-bottom: 14px;
		border-bottom: 1px solid var(--line);
	}
	.panel-head h2 { font-size: 14px; font-weight: 600; }
	.panel-head p { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
	.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
	.chart-panel { padding-bottom: 10px; }
	.chart-wrap { position: relative; height: 300px; }
	.chart-wrap canvas { width: 100% !important; height: 100% !important; }
	.legend { display: flex; gap: 14px; flex-wrap: wrap; }
	.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; font-weight: 500; }
	.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
	.dot-sessions { background: var(--accent); }
	.dot-revenue { background: var(--text); }
	.dot-events { background: var(--info); }
	.dot-mailchimp { background: var(--info); }
	.dot-show { background: var(--warn); }

	/* ---------- Sources ---------- */
	/* Nombre + estado, sin el cuadrado con una letra: eso era un icono de relleno. */
	.source-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
	.source-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
	.source-list li:last-child { border-bottom: 0; padding-bottom: 0; }
	.source-list strong { display: block; font-size: 13px; font-weight: 600; }
	.source-list small { display: block; color: var(--muted); font-size: 12px; }

	/* ---------- Runways & approval tray ----------
	   Misma densidad que `.source-list`: nombre, contexto y una cifra a la derecha.
	   Sin iconos de relleno ni tarjetas dentro de la tarjeta. */
	.runway-list, .approval-list { list-style: none; margin: 0; padding: 0; }
	.runway, .approval-list li {
		display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
		padding: 9px 0; border-bottom: 1px solid var(--line);
	}
	.runway:first-child, .approval-list li:first-child { padding-top: 0; }
	.runway:last-child, .approval-list li:last-child { border-bottom: 0; padding-bottom: 0; }
	.runway-main, .approval-main { min-width: 0; }
	.runway-main strong, .approval-main strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.runway-main small, .approval-main small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.runway-days {
		padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line);
		background: var(--surface-2); color: var(--text-2);
		font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
	}
	.runway-days.is-close { border-color: #fde047; background: var(--warn-bg); color: var(--warn); }
	.sub-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
	.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
	.sub-head h3 { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--text-2); }
	.sub-foot-link { display: inline-block; margin-top: 10px; }

	/* ---------- Tables ---------- */
	.table-wrap { overflow-x: auto; margin: 0 -16px -16px; padding: 0 16px 4px; }
	.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
	.data-table th {
		text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line);
		font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
		white-space: nowrap;
	}
	.data-table th.num { text-align: right; }
	.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
	.data-table tbody tr:last-child td { border-bottom: 0; }
	.data-table tbody tr:hover { background: var(--surface-2); }
	.data-table .num { text-align: right; white-space: nowrap; }
	.data-table.compact td { padding: 8px 6px; }
	.data-table .muted { color: var(--muted); }
	.page-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.error-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--error); }
	.share-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
	.share { flex: 1; height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
	.share i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
	.share-cell small { color: var(--muted); font-size: 11px; min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
	.migration-log { max-height: 320px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }

	/* ---------- Badges / details (tinta sobria como Orders) ---------- */
	.badge {
		display: inline-flex; align-items: center; gap: 5px;
		padding: 0; border-radius: 0;
		font-size: 12px; font-weight: 600; letter-spacing: 0;
		background: transparent; color: var(--neutral); white-space: nowrap;
	}
	.badge.is-ok { background: transparent; color: var(--ok); }
	.badge.is-warn { background: transparent; color: var(--warn); }
	.badge.is-error { background: transparent; color: var(--error); }
	.badge.is-neutral { background: transparent; color: var(--neutral); }
	.badge.is-event { background: transparent; color: var(--accent-ink); }
	.attr-cell { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

	/* ---------- Connection cards (Sync) ----------
	   Cuatro tarjetas iguales: nombre + estado + dos o tres hechos. La rejilla es
	   la unica "tarjeta" de la app, y por eso lleva borde de 1px y nada mas. */
	.conn-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }
	.conn-card { display: flex; flex-direction: column; gap: 10px; }
	.conn-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
	.conn-head h2 { font-size: 13.5px; font-weight: 600; }
	.conn-facts { display: grid; gap: 0; margin: 0; }
	.conn-facts > div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
	.conn-facts > div:last-child { border-bottom: 0; }
	.conn-facts dt { color: var(--muted); white-space: nowrap; }
	.conn-facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
	.conn-hint { margin-top: auto; font-size: 11.5px; color: var(--muted); }

	/* ---------- Expandable error ---------- */
	.err { font-size: 12px; max-width: 420px; }
	.err > summary { cursor: pointer; color: var(--error); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.err > summary:hover { text-decoration: underline; }
	.err pre {
		margin: 6px 0 0; padding: 8px 10px; max-height: 220px; overflow: auto;
		background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
		font-family: var(--mono); font-size: 11.5px; line-height: 1.45;
		white-space: pre-wrap; word-break: break-word; color: var(--text-2);
	}
	.detail-list { display: grid; gap: 0; margin: 0; }
	.detail-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line); }
	.detail-list > div:last-child { border-bottom: 0; }
	.detail-list dt { color: var(--muted); font-size: 12px; }
	.detail-list dd { margin: 0; font-size: 13px; font-weight: 500; text-align: right; }
	.hint { margin-top: 12px; color: var(--muted); font-size: 12.5px; }
	.empty { padding: 26px 8px; color: var(--muted); text-align: center; font-size: 13px; }
	/* Estado vacio con salida: un vacio sin accion es un callejon sin salida. */
	.empty-state { display: grid; justify-items: center; gap: 6px; padding: 24px 14px; text-align: center; }
	.empty-state strong { font-size: 13.5px; font-weight: 650; color: var(--text); }
	.empty-state p { font-size: 12.5px; color: var(--muted); max-width: 48ch; }
	.empty-state .btn { margin-top: 6px; }
	.error-page { max-width: 520px; margin: 12vh auto; text-align: center; display: grid; gap: 10px; }

	/* ---------- Motion ---------- */
	/* Sin animacion de entrada en cada bloque: el mismo rise en todas las secciones se
	   ve en el screencast y delata la plantilla. Aqui la pantalla esta viva y ya. */

	/* ---------- Command palette (Ctrl+K / Cmd+K) ---------- */
	/* Twenty CRM pattern: one native <dialog>, a search field and a list. White on the
	   #f9fafb canvas, hairlines for hierarchy, no opaque overlay stack. */
	.cmdk {
		width: min(640px, 92vw);
		max-height: min(560px, 82vh);
		padding: 0;
		border: 1px solid var(--line);
		border-radius: 14px;
		background: var(--surface);
		color: var(--text);
		box-shadow: 0 24px 60px rgba(24, 24, 27, .22);
		overflow: hidden;
	}

	.cmdk::backdrop {
		background: rgba(24, 24, 27, .38);
	}

	.cmdk-panel {
		display: grid;
		grid-template-rows: auto minmax(0, 1fr) auto;
		max-height: min(560px, 82vh);
	}

	.cmdk-head {
		display: flex;
		align-items: center;
		gap: 10px;
		padding: 12px 14px;
		border-bottom: 1px solid var(--line);
		background: var(--surface);
	}

	.cmdk-search-icon {
		display: grid;
		place-items: center;
		width: 18px;
		height: 18px;
		color: var(--muted);
		flex: 0 0 auto;
	}

	.cmdk-search-icon svg {
		width: 18px;
		height: 18px;
	}

	.cmdk-input {
		flex: 1 1 auto;
		min-width: 0;
		padding: 3px 0;
		border: 0;
		background: transparent;
		color: var(--text);
		font: inherit;
		font-size: 15px;
		outline: none;
	}

	.cmdk-input::placeholder {
		color: var(--faint);
	}

	.cmdk-esc {
		flex: 0 0 auto;
	}

	.cmdk-list {
		margin: 0;
		padding: 6px;
		list-style: none;
		overflow: auto;
		background: var(--bg);
	}

	.cmdk-group {
		padding: 8px 10px 4px;
		font-size: 10px;
		font-weight: 700;
		letter-spacing: .06em;
		text-transform: uppercase;
		color: var(--faint);
	}

	.cmdk-group[hidden],
	.cmdk-item[hidden] {
		display: none;
	}

	.cmdk-link {
		display: flex;
		align-items: center;
		gap: 10px;
		width: 100%;
		padding: 9px 10px;
		border: 0;
		border-radius: 8px;
		background: transparent;
		color: inherit;
		font: inherit;
		text-align: left;
		text-decoration: none;
		cursor: pointer;
	}

	.cmdk-link:hover {
		background: var(--surface);
		text-decoration: none;
	}

	.cmdk-item.is-active .cmdk-link {
		background: var(--surface);
		box-shadow: inset 0 0 0 1px var(--line-strong);
	}

	.cmdk-item-label {
		font-size: 13px;
		font-weight: 600;
		color: var(--text);
	}

	.cmdk-item-hint {
		margin-left: auto;
		font-size: 11px;
		color: var(--muted);
		white-space: nowrap;
	}

	.cmdk-enter {
		opacity: 0;
	}

	.cmdk-item.is-active .cmdk-enter {
		opacity: 1;
	}

	.cmdk-empty {
		padding: 20px 10px;
		text-align: center;
		font-size: 12.5px;
		color: var(--muted);
	}

	.cmdk-foot {
		display: flex;
		flex-wrap: wrap;
		gap: 12px;
		padding: 9px 14px;
		border-top: 1px solid var(--line);
		background: var(--surface);
		font-size: 11px;
		color: var(--muted);
	}

	.cmdk-trigger {
		gap: 6px;
	}

	.cmdk-trigger svg {
		width: 15px;
		height: 15px;
	}

	.cmdk-trigger-key {
		font-size: 10px;
	}

	@media (max-width: 640px) {
		.cmdk-trigger-key {
			display: none;
		}

		.cmdk {
			width: 94vw;
		}
	}

}

/* ============================================================
   Dark mode
   ------------------------------------------------------------
   Deliberately unlayered: app.css lives in `@layer base` and the layout injects
   the brand accent from an unlayered <style>. An unlayered block is the only
   place that reliably overrides the injected `--accent` tokens, and it keeps
   the whole theme in one file. `data-theme` is set on <html> by a head script
   before first paint, from localStorage; light stays the default.
   ============================================================ */
html[data-theme="dark"] {
	color-scheme: dark;
	--bg: #0f1115;
	--bg-2: #161920;
	--surface: #161920;
	--surface-2: #1e222b;
	--sidebar-bg: #13161c;
	--sidebar-hover: #1e222b;
	--line: #262a34;
	--line-strong: #343946;
	--text: #f3f4f6;
	--text-2: #cbd5e1;
	--muted: #94a3b8;
	--faint: #64748b;
	--accent: #f3f4f6;
	--accent-ink: #ffffff;
	--accent-soft: #1e222b;
	--accent-line: #343946;
}

/* Filled controls invert too: a light button with white text would disappear. */
html[data-theme="dark"] .btn-primary { background: #f3f4f6; border-color: #f3f4f6; color: #0f1115; }
html[data-theme="dark"] .btn-primary:hover { background: #e5e7eb; border-color: #e5e7eb; color: #0f1115; }
html[data-theme="dark"] .brand-mark { color: #0f1115; }
html[data-theme="dark"] .app-shell[data-nav="rail"] .nav-link[data-tooltip]::before { color: #0f1115; }

/* Module-scoped surface tokens (each module keeps its own set so app.css can stay
   frozen for module agents). Only the structural paper/ink inverts; the pastel
   stage tints keep their ink so the stage colours stay recognisable. */
html[data-theme="dark"] .cal-app {
	--cal-paper: #0f1115;
	--cal-surface: #161920;
	--cal-lane: #1e222b;
	--cal-hair: #262a34;
	--cal-hair-strong: #343946;
	--cal-ink: #f3f4f6;
	--cal-ink-soft: #cbd5e1;
	--cal-ink-faint: #64748b;
}
html[data-theme="dark"] .cmp-app {
	--cmp-lane: #1e222b;
	--cmp-hair: #262a34;
	--cmp-hair-strong: #343946;
}
html[data-theme="dark"] .tsk-app {
	--tsk-lane: #1e222b;
	--tsk-hair: #262a34;
	--tsk-hair-strong: #343946;
}
html[data-theme="dark"] .cal-day.is-weekend { background: var(--bg-2); }
html[data-theme="dark"] .cal-day.is-show-day { background: linear-gradient(180deg, #1e222b, var(--surface) 46%); }

/* ---------- Chrome-free embed surfaces ----------
   `templates/layout/embed.php` renders a view inside an iframe (the centered post
   modal on Content & Calendar). The frame is the chrome, so the document must not
   add its own scroll container or shell height; the padding keeps the sheet crisp
   on both themes. */
body.is-embed { background: var(--surface); height: 100dvh; margin: 0; overflow: hidden; }
.embed-main { padding: 0; max-width: none; margin: 0; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.embed-main > .alert { margin: 0; border-radius: 0; border-inline: 0; border-top: 0; flex: 0 0 auto; }
@media (max-width: 920px) {
	body.is-embed { height: auto; overflow: auto; }
	.embed-main { height: auto; }
}
