/* dashboard.css - estilo del dashboard WSSP (variables del frontend CTPS) */

[data-theme="ctps"][data-mode="light"],
[data-mode="light"] {
	--bg: #f8fafc;
	--surface: #ffffff;
	--surface-2: #f1f5f9;
	--surface-3: #e2e8f0;
	--border: #e2e8f0;
	--border-strong: #cbd5e1;
	--hover: #f1f5f9;
	--accent: #00a651;
	--accent-hover: #008944;
	--accent-2: #3b82f6;
	--accent-glow: rgba(0, 166, 81, 0.14);
	--accent-bg: rgba(0, 166, 81, 0.1);
	--text: #1e293b;
	--text-2: #64748b;
	--text-3: #94a3b8;
	--text-inverse: #ffffff;
	--success: #16a34a;
	--warning: #fd7e14;
	--error: #dc2626;
	--info: #2563eb;
	--font-display:
		"Poppins", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
		sans-serif;
	--font-body:
		"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	--radius: 6px;
	--radius-lg: 8px;
	--radius-full: 9999px;
	--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
	--shadow-panel: 0 12px 32px rgba(15, 23, 42, 0.12);
	--sidebar-width: 250px;
	--sidebar-collapsed-width: 60px;
	--modal-overlay: rgba(15, 23, 42, 0.55);
}

[data-theme="ctps"][data-mode="dark"],
[data-mode="dark"] {
	--bg: #1a1a1a;
	--surface: #2d2d2d;
	--surface-2: #262626;
	--surface-3: #404040;
	--border: #404040;
	--border-strong: #525252;
	--hover: #404040;
	--accent: #26bf6b;
	--accent-hover: #4dd485;
	--accent-2: #3b82f6;
	--accent-glow: rgba(38, 191, 107, 0.18);
	--accent-bg: rgba(38, 191, 107, 0.14);
	--text: #e2e8f0;
	--text-2: #94a3b8;
	--text-3: #64748b;
	--text-inverse: #0f172a;
	--success: #4ade80;
	--warning: #fb923c;
	--error: #f87171;
	--info: #60a5fa;
	--font-display:
		"Poppins", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
		sans-serif;
	--font-body:
		"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	--radius: 6px;
	--radius-lg: 8px;
	--radius-full: 9999px;
	--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
	--shadow-panel: 0 16px 36px rgba(0, 0, 0, 0.35);
	--sidebar-width: 250px;
	--sidebar-collapsed-width: 60px;
	--modal-overlay: rgba(0, 0, 0, 0.78);
}

* {
	box-sizing: border-box;
}

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

body {
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: 0.875rem;
	line-height: 1.5;
}

a {
	color: inherit;
	text-decoration: none;
}

/* ---------- Layout ---------- */
.layout {
	display: grid;
	grid-template-columns: var(--sidebar-width) 1fr;
	min-height: 100vh;
}

.sidebar {
	background: var(--surface-2);
	border-right: 1px solid var(--border);
	padding: 16px 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	position: sticky;
	top: 0;
	height: 100vh;
	overflow-y: auto;
}

.sidebar__brand {
	display: flex;
	align-items: center;
	gap: 10px;
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 1rem;
	padding: 8px 12px;
	margin-bottom: 8px;
	color: var(--accent);
}

.sidebar__nav {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.sidebar__link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: var(--radius);
	color: var(--text-2);
	font-weight: 600;
	transition:
		background 0.15s ease,
		color 0.15s ease;
}

.sidebar__link:hover {
	background: var(--hover);
	color: var(--text);
}
.sidebar__link--active {
	background: var(--accent-bg);
	color: var(--accent);
}

.main {
	padding: 24px;
	min-width: 0;
}

.page-title {
	margin: 0 0 20px;
	font-family: var(--font-display);
	font-size: 1.6rem;
	font-weight: 700;
}

.grid {
	display: grid;
	gap: 16px;
}
.grid--2 {
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* ---------- Componentes (ui-kit) ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 40px;
	padding: 8px 16px;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: transparent;
	color: var(--text);
	font-family: var(--font-body);
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition:
		background 0.15s ease,
		border-color 0.15s ease,
		color 0.15s ease;
	white-space: nowrap;
}
.btn:hover:not(:disabled) {
	transform: translateY(-1px);
}
.btn:disabled {
	cursor: not-allowed;
	opacity: 0.6;
}
.btn--primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--text-inverse);
}
.btn--primary:hover:not(:disabled) {
	background: var(--accent-hover);
}
.btn--ghost {
	border-color: var(--border);
	background: var(--surface);
}
.btn--ghost:hover:not(:disabled) {
	background: var(--hover);
	border-color: var(--border-strong);
}
.btn--danger {
	background: var(--error);
	border-color: var(--error);
	color: #fff;
}
.btn--danger:hover:not(:disabled) {
	filter: brightness(0.93);
}
.btn--sm {
	min-height: 34px;
	padding: 6px 12px;
	font-size: 0.8rem;
}

.input {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font-family: var(--font-body);
	font-size: 0.875rem;
	transition:
		border-color 0.15s ease,
		box-shadow 0.15s ease;
}
.input::placeholder {
	color: var(--text-3);
}
.input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-glow);
}

.card {
	padding: 20px;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
	box-shadow: var(--shadow-card);
}

.card__title {
	margin: 0 0 12px;
	font-size: 1rem;
	font-weight: 700;
}

.badge {
	display: inline-flex;
	align-items: center;
	width: fit-content;
	min-height: 24px;
	padding: 3px 10px;
	border: 1px solid transparent;
	border-radius: var(--radius-full);
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.badge--success {
	background: var(--accent-glow);
	color: var(--accent);
}
.badge--muted {
	background: var(--surface-3);
	color: var(--text-2);
}
.badge--danger {
	background: color-mix(in srgb, var(--error) 18%, transparent);
	color: var(--error);
}
.badge--warning {
	background: color-mix(in srgb, var(--warning) 18%, transparent);
	color: var(--warning);
}

.table-wrapper {
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
	overflow-x: auto;
}
.table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.875rem;
}
.table thead {
	background: var(--surface-2);
}
.table th {
	padding: 12px 16px;
	text-align: left;
	font-weight: 700;
	color: var(--text);
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
.table td {
	padding: 12px 16px;
	color: var(--text);
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}
.table tbody tr:hover {
	background: var(--hover);
}
.td-mono {
	font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
	font-size: 0.82rem;
	color: var(--text-2);
}
.td-actions {
	display: flex;
	gap: 8px;
	align-items: center;
}

.form-card {
	display: grid;
	gap: 16px;
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
}
.form-field {
	display: grid;
	gap: 6px;
}
.form-label {
	font-size: 0.78rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-2);
}
.form-error {
	font-size: 0.78rem;
	color: var(--error);
}
.form-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding-top: 8px;
	border-top: 1px solid var(--border);
}

/* Estados */
.muted {
	color: var(--text-2);
}
.mono {
	font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
}
.empty {
	padding: 32px 16px;
	text-align: center;
	color: var(--text-2);
	font-style: italic;
}

.code-block {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 12px 16px;
	overflow-x: auto;
	font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
	font-size: 0.8rem;
	color: var(--text);
	line-height: 1.5;
	white-space: pre;
}

.docs-section + .docs-section {
	margin-top: 20px;
}
.docs-section h4 {
	margin: 0 0 8px;
}

/* Skeleton */
.skeleton {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--radius);
	background: var(--surface-3);
}
.skeleton::after {
	position: absolute;
	inset: 0;
	content: "";
	background: linear-gradient(
		90deg,
		transparent 0%,
		var(--surface) 48%,
		transparent 100%
	);
	opacity: 0.72;
	transform: translateX(-100%);
	animation: shimmer 1.35s ease-in-out infinite;
}
@keyframes shimmer {
	100% {
		transform: translateX(100%);
	}
}

/* Login */
.auth-screen {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 24px;
	background: var(--bg);
}
.auth-box {
	width: 100%;
	max-width: 400px;
	padding: 32px;
	border: 1px solid var(--border);
	border-radius: var(--radius-xl);
	background: var(--surface);
	box-shadow: var(--shadow-panel);
}
.auth-logo-img {
	width: 72px;
	height: 72px;
	margin: 0 auto 18px;
	display: block;
	object-fit: contain;
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-card);
}

.auth-logo {
	width: 64px;
	height: 64px;
	margin: 0 auto 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-full);
	background: var(--accent);
	color: var(--text-inverse);
	font-family: var(--font-display);
	font-size: 1.8rem;
	font-weight: 700;
}
.auth-title {
	margin: 0 0 4px;
	text-align: center;
	font-family: var(--font-display);
	font-size: 1.5rem;
}
.auth-sub {
	margin: 0 0 20px;
	text-align: center;
	color: var(--text-2);
}
.auth-desc {
	margin: 0 0 16px;
	line-height: 1.5;
}
.auth-legal {
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
	font-size: 0.78rem;
	color: var(--text-2);
	text-align: center;
}
.auth-legal a {
	color: var(--accent-2);
}
.auth-footer {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	font-size: 0.75rem;
	color: var(--text-3);
}
.auth-footer a {
	color: var(--text-2);
}
.auth-footer a:hover {
	color: var(--accent);
}

.auth-divider {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 14px 0 12px;
	color: var(--text-3);
	font-size: 0.78rem;
}
.auth-divider::before,
.auth-divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--border);
}

.btn--block {
	width: 100%;
}

.otp-grid {
	display: flex;
	gap: 8px;
	justify-content: center;
}
.otp-input {
	width: 48px;
	height: 56px;
	text-align: center;
	font-size: 1.4rem;
	font-weight: 700;
}

.notice {
	padding: 12px 16px;
	border-radius: var(--radius);
	margin-bottom: 16px;
	font-size: 0.85rem;
}
.notice--success {
	background: var(--accent-glow);
	color: var(--accent);
}
.notice--error {
	background: color-mix(in srgb, var(--error) 14%, transparent);
	color: var(--error);
}

/* Selector de pais + numero en el login */
.auth-field {
	display: grid;
	gap: 6px;
	margin-bottom: 16px;
}
.auth-phone-row {
	display: flex;
	gap: 8px;
	align-items: stretch;
}
.auth-select {
	flex: 0 0 165px;
}
.auth-phone-input {
	flex: 1 1 auto;
}
.auth-cooldown {
	margin-top: 10px;
	text-align: center;
	font-size: 0.78rem;
}
.auth-back {
	display: flex;
	justify-content: center;
	margin-top: 14px;
}
.link-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text-2);
	font-family: var(--font-body);
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
	transition:
		background 0.15s ease,
		color 0.15s ease,
		border-color 0.15s ease;
}
.link-btn:hover {
	background: var(--hover);
	color: var(--text);
	border-color: var(--border-strong);
}

/* Modal */
.modal-backdrop {
	position: fixed;
	inset: 0;
	background: var(--modal-overlay);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
	padding: 16px;
}
.modal-backdrop[hidden] {
	display: none;
}
.modal {
	width: 100%;
	max-width: 560px;
	padding: 24px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
}
.modal h3 {
	margin: 0 0 16px;
}
.modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 16px;
}

/* ---------- Chat de agente ---------- */
.layout--chat {
	grid-template-columns: var(--sidebar-width) 1fr;
	/* Sin fila explicita, la fila implicita es `auto` y crece con el contenido:
	   con `overflow: hidden` en el layout eso dejaba los mensajes antiguos
	   inalcanzables (14.008 px de alto dentro de un contenedor de 100vh). */
	grid-template-rows: 100vh;
	height: 100vh;
	overflow: hidden;
}

.brand-logo {
	width: 26px;
	height: 26px;
	border-radius: var(--radius);
	object-fit: contain;
	flex-shrink: 0;
}

.chat-shell {
	display: grid;
	grid-template-columns: 320px 1fr;
	min-width: 0;
	height: 100%;
	/* Los items de grid/flex no bajan de su contenido sin min-height: 0. */
	min-height: 0;
	overflow: hidden;
}

/* Lista de conversaciones */
.conversations {
	display: flex;
	flex-direction: column;
	min-width: 0;
	border-right: 1px solid var(--border);
	background: var(--surface);
	height: 100%;
}

.conversations__header {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-bottom: 1px solid var(--border);
	align-items: center;
}

.conversations__search {
	flex: 1;
	min-width: 0;
}

.conversations__list {
	flex: 1;
	overflow-y: auto;
	min-height: 0;
}

.conversations__list .skeleton {
	height: 56px;
	margin: 10px 12px;
}

.conversations__list.is-loading {
	overflow: hidden;
}

.conv-item {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 12px 14px;
	border: none;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	text-align: left;
	cursor: pointer;
	font: inherit;
	transition: background 0.15s ease;
}

.conv-item:hover {
	background: var(--hover);
}

.conv-item.is-active {
	background: var(--accent-bg);
}

.conv-item__avatar,
.chat__avatar {
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	border-radius: var(--radius-full);
	background: var(--accent-glow);
	color: var(--accent);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 0.8rem;
}

.conv-item__body {
	flex: 1;
	min-width: 0;
}

.conv-item__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.conv-item__name {
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.conv-item__time {
	font-size: 0.72rem;
	color: var(--text-3);
	flex-shrink: 0;
}

.conv-item__preview {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--text-2);
	font-size: 0.82rem;
}

.conv-item__unread {
	flex-shrink: 0;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: var(--radius-full);
	background: var(--accent);
	color: var(--text-inverse);
	font-size: 0.72rem;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.window-dot {
	flex-shrink: 0;
	width: 9px;
	height: 9px;
	border-radius: var(--radius-full);
}
.window-dot.window--open {
	background: var(--success);
}
.window-dot.window--warning {
	background: var(--warning);
}
.window-dot.window--expired {
	background: var(--error);
}
.window-dot.window--none {
	background: var(--text-3);
}

/* Panel de chat */
.chat {
	display: flex;
	flex-direction: column;
	min-width: 0;
	height: 100%;
	/* Sin esto el panel crece con el hilo y nunca activa el scroll interno. */
	min-height: 0;
	background: var(--bg);
}

.chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
}

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

.chat__name {
	font-weight: 700;
}

.chat__meta {
	font-size: 0.78rem;
	color: var(--text-2);
}

.chat__window {
	flex-shrink: 0;
}

.window-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border-radius: var(--radius-full);
	font-size: 0.72rem;
	font-weight: 700;
}
.window-pill.window--open {
	background: var(--accent-glow);
	color: var(--accent);
}
.window-pill.window--warning {
	background: color-mix(in srgb, var(--warning) 18%, transparent);
	color: var(--warning);
}
.window-pill.window--expired {
	background: color-mix(in srgb, var(--error) 18%, transparent);
	color: var(--error);
}
.window-pill.window--none {
	background: var(--surface-3);
	color: var(--text-2);
}

.chat__messages {
	flex: 1;
	overflow-y: auto;
	min-height: 0;
	padding: 20px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.msg {
	display: flex;
	max-width: 72%;
}

.msg--in {
	align-self: flex-start;
}

.msg--out {
	align-self: flex-end;
}

.msg__bubble {
	padding: 8px 12px;
	border-radius: var(--radius-lg);
	background: var(--surface);
	border: 1px solid var(--border);
	box-shadow: var(--shadow-card);
}

.msg--out .msg__bubble {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--text-inverse);
}

.msg__text {
	white-space: pre-wrap;
	word-break: break-word;
	font-size: 0.875rem;
	line-height: 1.45;
}

/* Insignia que identifica un mensaje enviado con plantilla aprobada. */
.msg__chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-bottom: 5px;
	padding: 1px 7px;
	border-radius: 999px;
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	border: 1px solid currentColor;
	opacity: 0.78;
}

.msg--in .msg__chip {
	color: var(--text-3);
}

.msg--out .msg__chip {
	color: var(--text-inverse);
}

.msg__meta {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	align-items: center;
	margin-top: 4px;
	font-size: 0.7rem;
	color: var(--text-3);
}

.msg--out .msg__meta {
	color: color-mix(in srgb, var(--text-inverse) 80%, transparent);
}

.msg__status {
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	gap: 3px;
}
.msg__status.status--read {
	color: var(--success);
}
.msg__status.status--failed {
	color: var(--error);
}

/* Composer */
.chat__composer {
	border-top: 1px solid var(--border);
	background: var(--surface);
	padding: 10px 16px 14px;
}

.composer__tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 8px;
}

.composer__tab {
	padding: 6px 12px;
	border: 1px solid transparent;
	border-radius: var(--radius-full);
	background: transparent;
	color: var(--text-2);
	font-weight: 700;
	cursor: pointer;
	font-size: 0.8rem;
	transition: all 0.15s ease;
}

.composer__tab.is-active {
	background: var(--accent-bg);
	color: var(--accent);
}

.composer__tab.is-disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.composer__body--text textarea {
	resize: none;
	min-height: 44px;
}

.composer__templates {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 8px;
	align-items: center;
}

.template-chip {
	padding: 6px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius-full);
	background: var(--bg);
	color: var(--text);
	font-size: 0.8rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s ease;
}

.template-chip:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.template-chip.is-active {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--text-inverse);
}

.composer__vars {
	display: grid;
	gap: 8px;
	margin-bottom: 8px;
}

.composer__actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 8px;
}

.composer__hint {
	font-size: 0.76rem;
	color: var(--text-3);
}

.composer__hint.is-warning {
	color: var(--warning);
	font-weight: 600;
}

/* Modal plantillas */
.modal--wide {
	max-width: 640px;
}

.modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
}
.modal__header h3 {
	margin: 0;
}
.modal__close {
	border: none;
	background: transparent;
	color: var(--text-2);
	font-size: 1.4rem;
	cursor: pointer;
	line-height: 1;
}
.modal__close:hover {
	color: var(--text);
}

.form-row {
	display: grid;
	gap: 8px;
	margin-bottom: 16px;
}

.templates-list {
	display: grid;
	gap: 8px;
	max-height: 300px;
	overflow-y: auto;
	margin-top: 12px;
}

.template-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.template-row__info {
	flex: 1;
	min-width: 0;
}

.template-row__name {
	font-weight: 700;
	display: flex;
	align-items: center;
	gap: 8px;
}

.template-row__src {
	font-size: 0.66rem;
	padding: 2px 8px;
	border-radius: var(--radius-full);
	font-weight: 700;
	text-transform: uppercase;
}
.template-row__src--meta {
	background: var(--info);
	color: #fff;
}
.template-row__src--local {
	background: var(--accent-glow);
	color: var(--accent);
}

.template-row__body {
	font-size: 0.82rem;
	color: var(--text-2);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.template-row__meta {
	font-size: 0.7rem;
	color: var(--text-3);
}

/* Responsive */
@media (max-width: 768px) {
	.layout {
		grid-template-columns: 1fr;
	}
	.sidebar {
		position: fixed;
		inset: 0 auto 0 0;
		width: var(--sidebar-width);
		transform: translateX(-100%);
		transition: transform 0.2s ease;
		box-shadow: var(--shadow-panel);
		z-index: 90;
	}
	.sidebar--open {
		transform: translateX(0);
	}
	.main {
		padding: 16px;
	}
	.layout--chat {
		grid-template-columns: 1fr;
	}
	.chat-shell {
		grid-template-columns: 1fr;
	}
	.conversations {
		display: none;
	}
	.msg {
		max-width: 88%;
	}
}

/* Detalle de un mensaje (se abre al pulsar la burbuja) */
.msg[role="button"] {
	cursor: pointer;
}

.msg[role="button"]:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.msg-detail {
	position: fixed;
	inset: 0;
	z-index: 80;
	display: flex;
	justify-content: flex-end;
}

/* `display: flex` gana al `display: none` del atributo `hidden`: sin esta
   regla el panel de detalle quedaba siempre visible y su ✕ no lo cerraba. */
.msg-detail[hidden] {
	display: none;
}

.msg-detail__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
}

.msg-detail__panel {
	position: relative;
	width: min(460px, 100%);
	height: 100%;
	overflow-y: auto;
	background: var(--surface);
	border-left: 1px solid var(--border);
	box-shadow: -8px 0 28px rgba(15, 23, 42, 0.22);
	padding: 16px 18px 28px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.msg-detail__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--border);
}

.msg-detail__header h2 {
	margin: 2px 0 0;
	font-size: 1rem;
	line-height: 1.3;
	word-break: break-word;
}

.msg-detail__eyebrow {
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--text-3);
}

.msg-detail__rows {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.msg-detail__row {
	display: grid;
	grid-template-columns: 118px 1fr;
	gap: 10px;
	font-size: 0.82rem;
	align-items: baseline;
}

.msg-detail__label {
	color: var(--text-3);
	font-weight: 600;
}

.msg-detail__value {
	color: var(--text);
	word-break: break-word;
}

.msg-detail__section-title {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--text-3);
	margin-bottom: 6px;
}

.msg-detail__text {
	margin: 0;
	padding: 10px 12px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: rgba(148, 163, 184, 0.1);
	font-family: inherit;
	font-size: 0.82rem;
	line-height: 1.5;
	white-space: pre-wrap;
	word-break: break-word;
}

.msg-detail__empty {
	margin: 0;
	font-size: 0.78rem;
	line-height: 1.5;
	color: var(--text-3);
	font-style: italic;
}

.msg-detail__vars {
	margin: 0;
	padding-left: 20px;
	font-size: 0.82rem;
	line-height: 1.6;
	word-break: break-word;
}
