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

/* ─── Themes ──────────────────────────────────────── */

:root,
html[data-theme="dark"] {
	--bg:          #0d1117;
	--surface:     #161b27;
	--surface-2:   #1e2638;
	--surface-3:   #28334a;
	--border:      #2d3a52;
	--accent:      #5b8ef0;
	--accent-dim:  rgba(91, 142, 240, 0.12);
	--text:        #e2e8f4;
	--text-muted:  #7a8fa8;
	--text-dim:    #445268;
	--read:        #34d399;
	--unread:      #f87171;
	--urgent:      #fbbf24;
	--shadow:      rgba(0,0,0,0.4);

	--status-red-bg:   linear-gradient(135deg, #7f1d1d, #991b1b);
	--status-red-bdr:  var(--unread);
	--status-red-txt:  #fff;
	--status-green-bg: linear-gradient(135deg, #14532d, #166534);
	--status-green-bdr:var(--read);
	--status-green-txt:#fff;
	--status-black-bg: linear-gradient(135deg, #451a03, #78350f);
	--status-black-bdr:var(--urgent);
	--status-black-txt:#fff;
}

html[data-theme="light"] {
	--bg:          #f0f4f8;
	--surface:     #ffffff;
	--surface-2:   #f1f5f9;
	--surface-3:   #e2e8f0;
	--border:      #cbd5e1;
	--accent:      #2563eb;
	--accent-dim:  rgba(37, 99, 235, 0.08);
	--text:        #0f172a;
	--text-muted:  #64748b;
	--text-dim:    #94a3b8;
	--read:        #16a34a;
	--unread:      #dc2626;
	--urgent:      #d97706;
	--shadow:      rgba(0,0,0,0.08);

	--status-red-bg:   linear-gradient(135deg, #fee2e2, #fecaca);
	--status-red-bdr:  #ef4444;
	--status-red-txt:  #7f1d1d;
	--status-green-bg: linear-gradient(135deg, #dcfce7, #bbf7d0);
	--status-green-bdr:#16a34a;
	--status-green-txt:#14532d;
	--status-black-bg: linear-gradient(135deg, #fef3c7, #fde68a);
	--status-black-bdr:#d97706;
	--status-black-txt:#78350f;
}

html {
	transition: background 0.25s, color 0.25s;
}

/* ─── Base ────────────────────────────────────────── */

html, body {
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

body {
	display: flex;
	flex-direction: column;
}

/* ─── Header ──────────────────────────────────────── */

.app-header {
	flex-shrink: 0;
	min-height: 56px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 20px;
	z-index: 100;
	gap: 16px;
	flex-wrap: wrap;
	transition: background 0.25s, border-color 0.25s;
}

.header-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

.brand-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 10px var(--accent);
	animation: blink 2.5s ease-in-out infinite;
	transition: background 0.25s, box-shadow 0.25s;
}

@keyframes blink {
	0%, 100% { opacity: 1;   box-shadow: 0 0 10px var(--accent); }
	50%       { opacity: 0.5; box-shadow: 0 0 4px  var(--accent); }
}

.brand-name {
	font-size: 17px;
	font-weight: 700;
	letter-spacing: 0.4px;
	color: var(--text);
}

.header-right {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

/* Refresh alert */

.refresh-alert {
	display: none;
	align-items: center;
	gap: 7px;
	background: rgba(220, 38, 38, 0.12);
	border: 1px solid rgba(220, 38, 38, 0.4);
	color: var(--unread);
	padding: 6px 14px;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	animation: slideIn 0.25s ease, pulseBorder 2s ease-in-out infinite;
	transition: background 0.15s, transform 0.1s;
}

.refresh-alert:hover {
	background: rgba(220, 38, 38, 0.22);
	transform: scale(1.02);
}

.refresh-alert:active { transform: scale(0.97); }

.refresh-alert svg {
	animation: spinSlow 3s linear infinite;
}

@keyframes slideIn {
	from { opacity: 0; transform: translateY(-4px); }
	to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulseBorder {
	0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
	50%       { box-shadow: 0 0 0 4px rgba(220,38,38,0.15); }
}

@keyframes spinSlow {
	from { transform: rotate(0deg); }
	to   { transform: rotate(360deg); }
}

/* Block selector */
.block-selector-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
}

.selector-label {
	font-size: 11px;
	font-weight: 600;
	color: var(--text-dim);
	text-transform: uppercase;
	letter-spacing: 0.9px;
}

.block-select,
#bloques {
	background: var(--surface-2);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: 7px;
	padding: 7px 32px 7px 12px;
	font-size: 13px;
	cursor: pointer;
	outline: none;
	transition: border-color 0.2s, box-shadow 0.2s, background 0.25s;
	min-width: 190px;
	-webkit-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8fa8' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
}

.block-select:hover,
#bloques:hover,
#bloques:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-dim);
}

#bloques option {
	background: var(--surface-2);
	color: var(--text);
}

/* API status indicator */
.api-status {
	display: flex;
	align-items: center;
	gap: 7px;
	background: var(--surface-3);
	border: 1px solid var(--border);
	border-radius: 20px;
	padding: 5px 12px 5px 8px;
	font-size: 12px;
	font-weight: 600;
	color: var(--text-muted);
	transition: background 0.3s, border-color 0.3s, color 0.3s;
	cursor: default;
	white-space: nowrap;
}

.api-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
	background: var(--text-dim);
	transition: background 0.3s;
}

/* checking */
.api-status[data-state="checking"] .api-dot {
	background: #60a5fa;
	animation: blink 1.2s ease-in-out infinite;
}
.api-status[data-state="checking"] {
	color: #60a5fa;
	border-color: rgba(96, 165, 250, 0.3);
	background: rgba(96, 165, 250, 0.07);
}

/* online */
.api-status[data-state="online"] .api-dot {
	background: var(--read);
	box-shadow: 0 0 6px var(--read);
}
.api-status[data-state="online"] {
	color: var(--read);
	border-color: rgba(52, 211, 153, 0.3);
	background: rgba(52, 211, 153, 0.07);
}

/* offline */
.api-status[data-state="offline"] .api-dot {
	background: var(--unread);
	animation: blink 0.8s ease-in-out infinite;
}
.api-status[data-state="offline"] {
	color: var(--unread);
	border-color: rgba(248, 113, 113, 0.3);
	background: rgba(248, 113, 113, 0.07);
}

/* Switch toggle — "Con menciones" filter */
.switch-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--surface-3);
	border: 1px solid var(--border);
	border-radius: 20px;
	padding: 4px 12px 4px 6px;
	cursor: pointer;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: border-color 0.2s ease;
}

.switch-toggle:hover {
	border-color: var(--accent);
}

.switch-toggle input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.switch-track {
	position: relative;
	width: 36px;
	height: 20px;
	background: var(--surface-3);
	border: 1px solid var(--border);
	border-radius: 999px;
	transition: background 0.2s ease, border-color 0.2s ease;
	flex-shrink: 0;
}

.switch-thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	background: var(--text-muted);
	border-radius: 50%;
	transition: left 0.2s ease, background 0.2s ease;
}

.switch-text {
	font-size: 12px;
	font-weight: 500;
	color: var(--text-muted);
	white-space: nowrap;
	transition: color 0.2s ease;
}

.switch-toggle:hover .switch-track {
	border-color: var(--accent);
}

.switch-toggle input:checked ~ .switch-track {
	background: var(--accent);
	border-color: var(--accent);
}

.switch-toggle input:checked ~ .switch-track .switch-thumb {
	left: 18px;
	background: #fff;
}

.switch-toggle input:checked ~ .switch-text {
	color: var(--text);
}

.switch-toggle input:focus-visible ~ .switch-track {
	box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Theme toggle button */
.theme-toggle {
	background: var(--surface-3);
	color: var(--text-muted);
	border: 1px solid var(--border);
	border-radius: 7px;
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: all 0.15s;
}

.theme-toggle:hover {
	background: var(--accent-dim);
	border-color: var(--accent);
	color: var(--accent);
}

/* ─── Toolbar ─────────────────────────────────────── */

.toolbar {
	flex-shrink: 0;
	height: 56px;
	background: var(--surface-2);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 20px;
	z-index: 99;
	gap: 16px;
	transition: background 0.25s, border-color 0.25s;
}

.toolbar-left {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

.toolbar-right {
	flex-shrink: 0;
}

.btn-marcar {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: linear-gradient(135deg, #16a34a, #15803d);
	color: #fff;
	border: none;
	border-radius: 7px;
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	flex-shrink: 0;
	transition: filter 0.15s, transform 0.15s, box-shadow 0.15s;
}

.btn-marcar:hover {
	filter: brightness(1.1);
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35);
}

.btn-marcar:active {
	transform: translateY(0);
	filter: brightness(0.95);
}

.block-title-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

#nombreBloque {
	font-size: 15px;
	font-weight: 600;
	color: var(--text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.icon-btn {
	background: var(--surface-3);
	color: var(--text-muted);
	border: 1px solid var(--border);
	border-radius: 7px;
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: all 0.15s;
}

.icon-btn:hover {
	background: var(--accent-dim);
	border-color: var(--accent);
	color: var(--accent);
}

.badge-pendientes {
	display: inline-block;
	font-size: 13px;
	font-weight: 600;
	padding: 4px 14px;
	border-radius: 20px;
	white-space: nowrap;
	transition: background 0.3s, border-color 0.3s, color 0.3s;
	/* estado por defecto: sin pendientes → verde */
	color: var(--read);
	background: rgba(22, 163, 74, 0.1);
	border: 1px solid rgba(22, 163, 74, 0.3);
}

.badge-pendientes.has-pending {
	color: var(--unread);
	background: rgba(220, 38, 38, 0.1);
	border: 1px solid rgba(220, 38, 38, 0.25);
}

/* ─── Workspace ───────────────────────────────────── */

.workspace {
	flex: 1;
	min-height: 0;
	display: flex;
	overflow: hidden;
}

/* ─── Main mention panel ──────────────────────────── */

.panel-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	border-right: 1px solid var(--border);
	background: var(--surface);
	overflow: hidden;
	transition: background 0.25s, border-color 0.25s;
}

.panel-main-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 20px;
	border-bottom: 1px solid var(--border);
	background: var(--surface-2);
	flex-shrink: 0;
	min-height: 50px;
	gap: 12px;
	transition: background 0.25s, border-color 0.25s;
}

.panel-cliente {
	font-size: 15px;
	font-weight: 600;
	color: var(--accent);
	letter-spacing: 0.3px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: color 0.25s;
}

.panel-actions {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-shrink: 0;
}

.font-controls {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

/* Teleprompter controls */
.tele-controls {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding-right: 14px;
	border-right: 1px solid var(--border);
}

.tele-btn {
	background: var(--surface-3);
	color: var(--text-muted);
	border: 1px solid var(--border);
	border-radius: 6px;
	width: 30px;
	height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.15s;
	flex-shrink: 0;
}

.tele-btn:hover {
	border-color: var(--accent);
	color: var(--accent);
	background: var(--accent-dim);
}

.tele-btn.playing {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
	box-shadow: 0 0 0 3px var(--accent-dim);
}

.tele-slider {
	-webkit-appearance: none;
	appearance: none;
	width: 100px;
	height: 4px;
	background: var(--border);
	border-radius: 2px;
	outline: none;
	cursor: pointer;
	transition: background 0.15s;
}

.tele-slider:hover {
	background: var(--text-dim);
}

.tele-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--accent);
	cursor: pointer;
	border: 2px solid var(--surface);
	transition: transform 0.1s;
}

.tele-slider::-webkit-slider-thumb:hover {
	transform: scale(1.15);
}

.tele-slider::-moz-range-thumb {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--accent);
	cursor: pointer;
	border: 2px solid var(--surface);
}

.tele-speed-value {
	font-size: 11px;
	color: var(--text-muted);
	font-variant-numeric: tabular-nums;
	min-width: 28px;
	text-align: right;
	font-weight: 600;
}

.font-btn {
	background: var(--surface-3);
	color: var(--text-muted);
	border: 1px solid var(--border);
	border-radius: 6px;
	width: 36px;
	height: 30px;
	font-size: 12px;
	font-weight: 700;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: all 0.15s;
}

.font-btn:hover {
	background: var(--accent-dim);
	border-color: var(--accent);
	color: var(--accent);
}

.panel-main-body,
#mencion {
	flex: 1;
	overflow-y: auto;
	padding: 28px 32px;
	font-size: 60px;
	line-height: 1.35;
	color: var(--text);
	scrollbar-width: thin;
	scrollbar-color: var(--border) transparent;
	transition: color 0.25s;
}

.panel-main-body::-webkit-scrollbar,
#mencion::-webkit-scrollbar {
	width: 5px;
}

.panel-main-body::-webkit-scrollbar-thumb,
#mencion::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 3px;
}

/* ─── Sidebar ─────────────────────────────────────── */

.sidebar,
#demas {
	width: 320px;
	flex-shrink: 0;
	overflow-y: auto;
	background: var(--bg);
	padding: 12px 10px;
	display: flex;
	flex-direction: column;
	gap: 7px;
	scrollbar-width: thin;
	scrollbar-color: var(--border) transparent;
	transition: background 0.25s;
}

.sidebar::-webkit-scrollbar,
#demas::-webkit-scrollbar {
	width: 4px;
}

.sidebar::-webkit-scrollbar-thumb,
#demas::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 2px;
}

/* ─── Dynamic mention cards (generated by utils.js) ── */

.panel {
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid var(--border);
	background: var(--surface);
	transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, background 0.25s;
	margin-bottom: 0 !important;
}

.panel:hover {
	border-color: var(--accent);
	box-shadow: 0 0 0 1px var(--accent), 0 4px 16px rgba(91, 142, 240, 0.15);
	transform: translateX(3px);
}

.panel-primary {
	border-color: var(--border);
}

/* Status colour overrides — intercept inline styles set by utils.js */
.panel-heading[style*="background-color: red"],
.panel-heading[style*="background-color:red"] {
	background: var(--status-red-bg) !important;
	border-bottom: 1px solid rgba(0,0,0,0.08);
	border-left: 3px solid var(--status-red-bdr);
}
.panel-heading[style*="background-color: red"] .panel-title,
.panel-heading[style*="background-color:red"] .panel-title {
	color: var(--status-red-txt) !important;
}

.panel-heading[style*="background-color: green"],
.panel-heading[style*="background-color:green"] {
	background: var(--status-green-bg) !important;
	border-bottom: 1px solid rgba(0,0,0,0.08);
	border-left: 3px solid var(--status-green-bdr);
	opacity: 0.8;
}
.panel-heading[style*="background-color: green"] .panel-title,
.panel-heading[style*="background-color:green"] .panel-title {
	color: var(--status-green-txt) !important;
}

.panel-heading[style*="background-color: black"],
.panel-heading[style*="background-color:black"] {
	background: var(--status-black-bg) !important;
	border-bottom: 1px solid rgba(0,0,0,0.08);
	border-left: 3px solid var(--status-black-bdr);
}
.panel-heading[style*="background-color: black"] .panel-title,
.panel-heading[style*="background-color:black"] .panel-title {
	color: var(--status-black-txt) !important;
}

.panel-heading {
	padding: 9px 12px;
}

.panel-title,
h3.panel-title {
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	letter-spacing: 0.2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin: 0;
	line-height: 1.4;
}

.panel-body {
	padding: 7px 12px;
	font-size: 12px;
	color: var(--text-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.4;
	background: var(--surface);
	transition: background 0.25s, color 0.25s;
}

/* ─── Legend ──────────────────────────────────────── */

.leyenda {
	width: 9px;
	height: 9px;
	border-radius: 3px;
	display: inline-block;
	vertical-align: middle;
}

.leida    { background: var(--read); }
.no-leida { background: var(--unread); }
.atrasada { background: var(--urgent); }

.leyendas {
	font-size: 12px;
	color: var(--text-muted);
	padding: 3px 6px;
}

#tabla {
	display: inline;
	float: left;
}

/* ─── Tab bar (hidden on desktop) ────────────────── */

.tab-bar {
	display: none;
}

/* ─── Mobile ──────────────────────────────────────── */

@media (max-width: 767px) {

	/* Cambio clave: layout flex-column en el body para que el header
	   pueda tener altura variable sin recalcular tops en JS */
	body {
		display: flex;
		flex-direction: column;
		height: 100dvh;
		overflow: hidden;
	}

	/* Header */
	.app-header {
		position: static;
		height: auto;
		min-height: 52px;
		flex-wrap: wrap;
		flex-shrink: 0;
		padding: 8px 14px;
		gap: 8px;
	}

	.header-right {
		flex-wrap: wrap;
		gap: 8px;
	}

	.brand-name { font-size: 15px; }

	.selector-label { display: none; }

	#sel-emisora,
	#bloques {
		min-width: 0;
		width: 120px;
		font-size: 12px;
		padding: 6px 26px 6px 9px;
	}

	/* API badge: solo el punto, sin texto */
	.api-status {
		padding: 0;
		width: 30px;
		height: 30px;
		justify-content: center;
		border-radius: 50%;
	}
	.api-label { display: none; }

	.theme-toggle {
		width: 30px;
		height: 30px;
	}

	/* Refresh alert: banner fijo en la parte inferior */
	.refresh-alert {
		position: fixed;
		bottom: 0; left: 0; right: 0;
		border-radius: 0;
		border: none;
		border-top: 1px solid rgba(220, 38, 38, 0.3);
		justify-content: center;
		padding: 12px 16px;
		z-index: 200;
		font-size: 13px;
	}

	/* Toolbar */
	.toolbar {
		position: static;
		top: auto;
		height: 52px;
		min-height: 52px;
		flex-shrink: 0;
		padding: 0 14px;
		gap: 10px;
	}

	.btn-marcar {
		padding: 7px 12px;
		font-size: 12px;
	}

	#nombreBloque {
		font-size: 13px;
		max-width: 110px;
	}

	.badge-pendientes {
		font-size: 11px;
		padding: 3px 10px;
	}

	/* Tab bar */
	.tab-bar {
		display: flex;
		position: static;
		top: auto;
		height: 44px;
		flex-shrink: 0;
		background: var(--surface);
		border-bottom: 1px solid var(--border);
		z-index: 98;
		transition: background 0.25s, border-color 0.25s;
	}

	.tab-btn {
		flex: 1;
		background: none;
		border: none;
		border-bottom: 2px solid transparent;
		color: var(--text-muted);
		font-size: 13px;
		font-weight: 600;
		cursor: pointer;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 7px;
		transition: color 0.15s, border-color 0.15s;
		-webkit-tap-highlight-color: transparent;
	}

	.tab-btn.active {
		color: var(--accent);
		border-bottom-color: var(--accent);
	}

	.tab-badge {
		background: var(--unread);
		color: #fff;
		border-radius: 10px;
		font-size: 10px;
		font-weight: 700;
		padding: 2px 6px;
		line-height: 1.4;
		display: none;
	}

	.tab-badge.visible { display: inline-block; }

	/* Workspace: ocupa el espacio restante */
	.workspace {
		position: static;
		top: auto;
		flex: 1;
		min-height: 0; /* necesario para que flex child haga scroll interno */
	}

	/* Vista mención activa */
	#workspace[data-tab="mention"] .sidebar,
	#workspace[data-tab="mention"] #demas {
		display: none;
	}
	#workspace[data-tab="mention"] .panel-main {
		border-right: none;
	}

	/* Vista lista activa */
	#workspace[data-tab="list"] .panel-main {
		display: none;
	}
	#workspace[data-tab="list"] .sidebar,
	#workspace[data-tab="list"] #demas {
		width: 100%;
	}

	/* Tamaño de fuente menor en móvil */
	.panel-main-body,
	#mencion {
		padding: 16px 20px;
	}

	/* Tarjetas con targets táctiles más grandes */
	.panel-heading {
		padding: 13px 14px;
	}

	.panel-title,
	h3.panel-title {
		font-size: 14px;
	}

	.panel-body {
		padding: 10px 14px;
		font-size: 13px;
	}

	.panel:hover {
		transform: none; /* sin hover shift en táctil */
	}

	/* Teleprompter más compacto */
	.panel-actions { gap: 8px; }

	.tele-controls {
		gap: 6px;
		padding-right: 8px;
	}

	.tele-slider { width: 70px; }

	.tele-speed-value { display: none; }

	/* Switch toggle en móvil: un poco más compacto */
	.switch-text {
		font-size: 11px;
	}

	.login-card {
		padding: 24px;
	}
}

/* ─── Login ──────────────────────────────────────── */

body.login-mode .app-header,
body.login-mode .toolbar,
body.login-mode .tab-bar,
body.login-mode .workspace {
	display: none;
}

.login-overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	background: var(--bg);
	padding: 40px 20px;
	z-index: 1000;
	overflow-y: auto;
}

.login-overlay[hidden] { display: none; }

.login-card {
	width: 100%;
	max-width: 360px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 32px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.login-brand {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 4px;
}

.login-title {
	font-size: 20px;
	font-weight: 600;
	color: var(--text);
	margin-bottom: 4px;
}

.login-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.login-field span {
	font-size: 12px;
	font-weight: 500;
	color: var(--text-muted);
}

.login-field input {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px;
	color: var(--text);
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.login-field input:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-dim);
}

.login-error {
	font-size: 12px;
	color: #ef4444;
	background: rgba(248, 113, 113, 0.1);
	border: 1px solid rgba(248, 113, 113, 0.3);
	border-radius: 6px;
	padding: 8px 12px;
}

.login-submit {
	background: var(--accent);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 11px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, transform 0.05s;
}

.login-submit:hover { background: var(--accent-hover, var(--accent)); filter: brightness(1.08); }
.login-submit:active { transform: scale(0.98); }

/* ─── User info (logged-in) ─────────────────────── */

.user-info {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--surface-3);
	border: 1px solid var(--border);
	border-radius: 20px;
	padding: 4px 4px 4px 12px;
	font-size: 12px;
	font-weight: 600;
	color: var(--text);
	white-space: nowrap;
}

.logout-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.logout-btn:hover {
	background: rgba(248, 113, 113, 0.12);
	color: #ef4444;
}

.admin-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	width: 26px;
	height: 26px;
	justify-content: center;
	border-radius: 50%;
	color: var(--text-muted);
	text-decoration: none;
	transition: background 0.15s, color 0.15s;
}
.admin-link:hover { background: var(--surface-3); color: var(--text); }

/* ─── Admin page ─────────────────────────────────── */

body.admin-page {
	display: block;
	height: auto;
	min-height: 100vh;
	overflow-y: auto;
}

.admin-main {
	max-width: 1000px;
	margin: 0 auto;
	padding: 24px 20px 40px;
}

.admin-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
	gap: 12px;
	flex-wrap: wrap;
}

.admin-title {
	font-size: 22px;
	font-weight: 600;
	color: var(--text);
}

.admin-table-wrap {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	overflow: hidden;
}

.admin-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.admin-table th,
.admin-table td {
	padding: 12px 16px;
	text-align: left;
	border-bottom: 1px solid var(--border);
	color: var(--text);
}

.admin-table th {
	background: var(--surface-2);
	font-size: 12px;
	font-weight: 600;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.admin-table tr:last-child td { border-bottom: none; }

.emisoras-cell {
	color: var(--text-muted);
	font-size: 13px;
	max-width: 420px;
}

.role-badge {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 12px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.role-user  { background: var(--surface-3); color: var(--text-muted); }
.role-admin { background: var(--accent-dim); color: var(--accent); }

.empty-cell {
	text-align: center;
	padding: 32px;
	color: var(--text-muted);
}

.row-actions {
	display: flex;
	gap: 6px;
	justify-content: flex-end;
	white-space: nowrap;
}

.btn-mini {
	background: var(--surface-3);
	border: 1px solid var(--border);
	color: var(--text);
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 500;
	border-radius: 6px;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-mini:hover { border-color: var(--accent); color: var(--accent); }

.btn-mini.btn-danger:hover {
	border-color: #ef4444;
	color: #ef4444;
	background: rgba(248, 113, 113, 0.08);
}

.admin-form { max-width: 480px; }

.emisoras-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 6px;
	padding: 8px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
}

.emisora-chk {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: var(--text);
	cursor: pointer;
	padding: 4px 6px;
	border-radius: 4px;
}
.emisora-chk:hover { background: var(--surface-3); }
.emisora-chk input { margin: 0; }

.form-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 8px;
}

.btn-ghost {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text-muted);
	border-radius: 8px;
	padding: 10px 16px;
	font-size: 14px;
	cursor: pointer;
	transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

/* ─── Sessions mesh ─────────────────────────────── */

.sessions-mesh {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 12px;
	margin-bottom: 8px;
}

.session-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 16px;
	display: flex;
	gap: 12px;
	align-items: flex-start;
	transition: border-color 0.2s;
	position: relative;
	overflow: hidden;
}

.session-card::before {
	content: '';
	position: absolute;
	top: 0; left: 0; right: 0;
	height: 3px;
	background: var(--border);
	transition: background 0.3s;
}

.session-card[data-online="1"]::before { background: #22c55e; }
.session-card[data-online="0"]::before { background: #ef4444; }
.session-card[data-online="1"] { border-color: rgba(34,197,94,0.25); }
.session-card[data-online="0"] { border-color: rgba(239,68,68,0.15); }

.session-avatar {
	width: 40px;
	height: 40px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 700;
	flex-shrink: 0;
	background: var(--surface-3);
	color: var(--text-muted);
}

.session-card[data-online="1"] .session-avatar {
	background: rgba(34,197,94,0.15);
	color: #22c55e;
}

.session-info { flex: 1; min-width: 0; }

.session-username {
	font-size: 14px;
	font-weight: 600;
	color: var(--text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.session-role { margin: 4px 0; }

.session-meta {
	display: flex;
	align-items: center;
	gap: 5px;
	margin: 6px 0 4px;
}

.session-status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	flex-shrink: 0;
	background: #ef4444;
}

.session-card[data-online="1"] .session-status-dot {
	background: #22c55e;
	box-shadow: 0 0 0 2px rgba(34,197,94,0.25);
	animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
	0%, 100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.25); }
	50%       { box-shadow: 0 0 0 4px rgba(34,197,94,0.1); }
}

.session-status-text {
	font-size: 12px;
	color: var(--text-muted);
}

.session-card[data-online="1"] .session-status-text { color: #22c55e; }

.session-ip {
	font-size: 11px;
	margin-top: 4px;
	display: flex;
	align-items: center;
	gap: 5px;
	flex-wrap: wrap;
	color: var(--text-muted);
}

.ip-badge {
	font-family: monospace;
	font-size: 12px;
	background: var(--surface-3);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 2px 7px;
	color: var(--accent);
}

.text-muted {
	color: var(--text-muted);
	font-size: 13px;
}

/* Live dot */
.live-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--border);
	margin-left: 8px;
	vertical-align: middle;
	transition: background 0.3s;
}
.live-dot.live-dot-active {
	background: #22c55e;
	box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
	animation: pulse-dot 2s ease-in-out infinite;
}

/* Log rows */
.log-row-new {
	animation: fadeInLog 0.5s ease;
	background: rgba(34,197,94,0.06) !important;
}
.log-cliente {
	font-weight: 600;
	color: var(--text);
}

@keyframes fadeInLog {
	from { opacity: 0; transform: translateY(-6px); background: rgba(34,197,94,0.18); }
	to   { opacity: 1; transform: translateY(0);    background: rgba(34,197,94,0.06); }
}

.pass-note {
	font-weight: 400;
	font-size: 11px;
	color: var(--text-muted);
	margin-left: 4px;
}

/* ─── Print / PDF export ─────────────────────────── */
@media print {
	/* Ocultar todo excepto el log */
	.app-header,
	.admin-toolbar,
	.admin-table-wrap:not(.print-target),
	.sessions-mesh,
	.form-overlay,
	#form-overlay {
		display: none !important;
	}

	/* Mostrar solo la tabla de log */
	.print-target {
		display: block !important;
	}

	body, html {
		overflow: visible !important;
		height: auto !important;
		background: #fff !important;
		color: #000 !important;
	}

	.admin-main {
		padding: 0 !important;
		max-width: 100% !important;
	}

	.admin-table {
		width: 100%;
		font-size: 11px;
		border-collapse: collapse;
	}

	.admin-table th,
	.admin-table td {
		border: 1px solid #ccc !important;
		padding: 6px 8px !important;
		color: #000 !important;
		background: #fff !important;
	}

	.admin-table th {
		background: #f0f0f0 !important;
		font-weight: 700;
	}

	/* Título del PDF */
	.print-target::before {
		content: attr(data-print-title);
		display: block;
		font-size: 16px;
		font-weight: 700;
		margin-bottom: 12px;
		color: #000;
	}

	@page {
		margin: 15mm;
	}
}
