/* StackPanel — tokens en 3 capas: primitivos → semánticos (cambian con el tema) → componentes.
   Los nombres semánticos también se usan en las plantillas y en portal-server.py. */

/* ---------- 1. Primitivos ---------- */
:root {
	/* Neutros (slate, con sesgo azul hacia la marca) */
	--slate-0: #ffffff;
	--slate-50: #f7f9fb;
	--slate-100: #eef2f6;
	--slate-200: #dde3ea;
	--slate-400: #94a0b0;
	--slate-500: #5f6b7a;
	--slate-600: #5d6878;
	--slate-700: #263041;
	--slate-800: #1a2230;
	--slate-850: #141b26;
	--slate-900: #0f1722;
	--slate-950: #0a0f17;
	--slate-975: #060a10;

	/* Marca: azul cielo (contenedores, red) */
	--brand-50: #e8f4fb;
	--brand-300: #7dd0f5;
	--brand-400: #38b6f0;
	--brand-500: #1a9ad8;
	--brand-600: #0277b8;
	--brand-700: #03649a;
	--brand-800: #07527d;
	--brand-950: #0b2a3d;

	/* Verde */
	--green-50: #ecfdf3;
	--green-200: #b6ecd2;
	--green-400: #4ade80;
	--green-700: #036b39;
	--green-800: #1f4a30;
	--green-950: #0c2418;

	/* Rojo */
	--red-50: #fef2f2;
	--red-200: #fecaca;
	--red-300: #fca5a5;
	--red-400: #f87171;
	--red-600: #dc2626;
	--red-700: #b42318;
	--red-800: #4a1f1f;
	--red-950: #2a1414;

	/* Ámbar */
	--amber-50: #fffaeb;
	--amber-200: #fde3a5;
	--amber-400: #fbbf24;
	--amber-700: #92610a;
	--amber-800: #4a3a16;
	--amber-950: #2a2210;

	/* Paleta de terminal (monitor htop, teñida con slate) */
	--term-bg: #0b111a;
	--term-bg-hover: #121a26;
	--term-line: #1a2230;
	--term-border: #263041;
	--term-muted: #7d8a9c;
	--term-fg: #c9d1d9;
	--term-fg-strong: #e6edf3;
	--term-blue: #38b6f0;
	--term-blue-soft: #7dd0f5;
	--term-blue-deep: #0277b8;
	--term-green: #3fb950;
	--term-green-deep: #238636;
	--term-yellow: #d29922;
	--term-yellow-deep: #9e6a03;
	--term-red: #f85149;
	--term-red-deep: #da3633;
	--term-purple: #a371f7;
	--term-purple-deep: #8957e5;
	--term-orange: #ffa657;

	/* Espaciado (base 4px) */
	--space-0-5: 2px;
	--space-1: 4px;
	--space-1-5: 6px;
	--space-2: 8px;
	--space-2-5: 10px;
	--space-3: 12px;
	--space-3-5: 14px;
	--space-4: 16px;
	--space-5: 20px;
	--space-6: 24px;
	--space-7: 28px;
	--space-8: 32px;
	--space-10: 40px;
	--space-11: 44px;
	--space-14: 56px;

	/* Tipografía */
	--font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	--fs-2xs: 11px;
	--fs-xs: 12px;
	--fs-sm: 13px;
	--fs-base: 14px;
	--fs-md: 15px;
	--fs-lg: 16px;
	--fs-xl: 20px;
	--fs-2xl: 24px;
	--fs-3xl: 32px;
	--fw-regular: 400;
	--fw-medium: 500;
	--fw-semibold: 600;
	--fw-bold: 700;
	--lh-tight: 1.15;
	--lh-snug: 1.25;
	--lh-normal: 1.55;
	--tracking-tight: -0.02em;
	--tracking-snug: -0.01em;
	--tracking-caps: 0.04em;
	--tracking-label: 0.08em;

	/* Radios */
	--radius-xs: 4px;
	--radius-sm: 6px;
	--radius-md: 8px;
	--radius: 10px;
	--radius-full: 999px;

	/* Movimiento */
	--duration-fast: 150ms;
	--duration-base: 200ms;
	--duration-slow: 400ms;
	--ease-out: cubic-bezier(0.2, 0, 0, 1);

	/* Capas */
	--z-sticky: 10;
	--z-topbar: 100;
	--z-overlay: 9999;

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

/* ---------- 2. Semánticos (tema claro) ---------- */
:root {
	--bg: var(--slate-100);
	--surface: var(--slate-0);
	--surface-2: var(--slate-50);
	--border: var(--slate-200);
	--border-strong: var(--slate-400);
	--text: var(--slate-900);
	--text-muted: var(--slate-500);
	--text-faint: var(--slate-400);

	--primary: var(--brand-600);
	--primary-hover: var(--brand-700);
	--primary-active: var(--brand-800);
	--primary-contrast: var(--slate-0);
	--accent: var(--brand-600);
	--accent-bg: var(--brand-50);
	--ring: var(--brand-500);

	--success-bg: var(--green-50);
	--success-text: var(--green-700);
	--success-border: var(--green-200);
	--danger: var(--red-600);
	--danger-bg: var(--red-50);
	--danger-text: var(--red-700);
	--danger-border: var(--red-200);
	--warn-bg: var(--amber-50);
	--warn-text: var(--amber-700);
	--warn-border: var(--amber-200);

	--overlay: rgb(12 12 14 / 0.35);
	--shadow-sm: 0 1px 2px rgb(16 16 20 / 0.04);
	--shadow-md: 0 4px 16px rgb(16 16 20 / 0.06);

	/* Alias heredados */
	--font: var(--font-sans);
	--mono: var(--font-mono);
}

/* ---------- 2b. Semánticos (tema oscuro: preferencia del sistema y data-theme="dark") ---------- */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: var(--slate-950);
		--surface: var(--slate-850);
		--surface-2: var(--slate-800);
		--border: var(--slate-700);
		--border-strong: var(--slate-600);
		--text: var(--slate-100);
		--text-muted: var(--slate-400);
		--text-faint: var(--slate-600);
		--primary: var(--brand-400);
		--primary-hover: var(--brand-300);
		--primary-active: var(--brand-500);
		--primary-contrast: var(--slate-975);
		--accent: var(--brand-300);
		--accent-bg: var(--brand-950);
		--ring: var(--brand-400);
		--success-bg: var(--green-950);
		--success-text: var(--green-400);
		--success-border: var(--green-800);
		--danger: var(--red-400);
		--danger-bg: var(--red-950);
		--danger-text: var(--red-300);
		--danger-border: var(--red-800);
		--warn-bg: var(--amber-950);
		--warn-text: var(--amber-400);
		--warn-border: var(--amber-800);
		--overlay: rgb(0 0 0 / 0.5);
		--shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
		--shadow-md: 0 4px 20px rgb(0 0 0 / 0.4);
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--bg: var(--slate-950);
	--surface: var(--slate-850);
	--surface-2: var(--slate-800);
	--border: var(--slate-700);
	--border-strong: var(--slate-600);
	--text: var(--slate-100);
	--text-muted: var(--slate-400);
	--text-faint: var(--slate-600);
	--primary: var(--brand-400);
	--primary-hover: var(--brand-300);
	--primary-active: var(--brand-500);
	--primary-contrast: var(--slate-975);
	--accent: var(--brand-300);
	--accent-bg: var(--brand-950);
	--ring: var(--brand-400);
	--success-bg: var(--green-950);
	--success-text: var(--green-400);
	--success-border: var(--green-800);
	--danger: var(--red-400);
	--danger-bg: var(--red-950);
	--danger-text: var(--red-300);
	--danger-border: var(--red-800);
	--warn-bg: var(--amber-950);
	--warn-text: var(--amber-400);
	--warn-border: var(--amber-800);
	--overlay: rgb(0 0 0 / 0.5);
	--shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
	--shadow-md: 0 4px 20px rgb(0 0 0 / 0.4);
	color-scheme: dark;
}

/* ---------- 3. Componentes ---------- */
:root {
	--transition-colors: color var(--duration-fast) ease, background-color var(--duration-fast) ease,
		border-color var(--duration-fast) ease, box-shadow var(--duration-base) var(--ease-out);

	/* Botón */
	--btn-radius: var(--radius-sm);
	--btn-py: var(--space-2-5);
	--btn-px: var(--space-4);
	--btn-py-sm: var(--space-1-5);
	--btn-px-sm: var(--space-3);
	--btn-fs: var(--fs-sm);
	--btn-fs-sm: var(--fs-xs);

	/* Input */
	--input-bg: var(--surface);
	--input-border: var(--border);
	--input-radius: var(--radius-sm);
	--input-py: var(--space-2-5);
	--input-px: var(--space-3);
	--input-focus-border: var(--ring);
	--input-focus-ring: 0 0 0 3px var(--accent-bg);

	/* Card / secciones */
	--card-bg: var(--surface);
	--card-border: var(--border);
	--card-radius: var(--radius);
	--card-shadow: var(--shadow-sm);
	--card-shadow-hover: var(--shadow-md);
	--card-p: var(--space-4) var(--space-5);
	--section-p: var(--space-5) var(--space-6);

	--card-border-hover: color-mix(in srgb, var(--accent) 40%, var(--border));

	/* Navegación lateral */
	--nav-item-py: var(--space-2);
	--nav-item-px: var(--space-3);
	--nav-item-fs: var(--fs-sm);

	/* Tabla */
	--table-cell-py: var(--space-3);
	--table-cell-px: var(--space-3-5);
	--table-head-bg: var(--surface-2);

	/* Pill / chip */
	--pill-radius: var(--radius-full);
	--chip-radius: var(--radius-xs);

	/* Switch */
	--switch-w: 34px;
	--switch-h: 20px;
	--switch-thumb: 16px;

	/* Anillo de foco accesible */
	--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--ring);
}

/* ========== Base ========== */
* { box-sizing: border-box; }

html, body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-sans);
	font-size: var(--fs-md);
	line-height: var(--lh-normal);
	-webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
	border-radius: var(--radius-xs);
}

code {
	font-family: var(--font-mono);
	font-size: 0.9em;
	background: var(--surface-2);
	border: 1px solid var(--border);
	color: var(--text);
	padding: 1px 5px;
	border-radius: var(--radius-xs);
}

button, input, select, textarea { font: inherit; color: inherit; }

.inline-form { display: inline; margin: 0; }

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

/* ---------- Switch on/off (tema oscuro, backups, monitoreo…) ---------- */
.switch-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-2-5);
	cursor: pointer;
}
.switch-row-label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text); }
.switch { position: relative; display: inline-block; width: var(--switch-w); height: var(--switch-h); flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
	position: absolute;
	inset: 0;
	border-radius: var(--radius-full);
	background: var(--border-strong);
	transition: background var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
.switch-thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: var(--switch-thumb);
	height: var(--switch-thumb);
	border-radius: 50%;
	background: var(--surface);
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
	transition: transform var(--duration-fast) var(--ease-out);
}
.switch input:checked ~ .switch-track { background: var(--primary); }
.switch input:checked ~ .switch-track .switch-thumb {
	transform: translateX(calc(var(--switch-w) - var(--switch-thumb) - 4px));
	background: var(--primary-contrast);
}
.switch input:focus-visible ~ .switch-track { box-shadow: var(--focus-ring); }

/* Sidebar: fila del switch de tema */
.theme-switch {
	display: flex; align-items: center; justify-content: space-between; gap: var(--space-2-5);
	width: 100%; padding: var(--space-1-5) var(--space-0-5); margin-bottom: var(--space-2); cursor: pointer;
}
.theme-switch-label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text); }

/* ---------- Controles segmentados ---------- */
.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-switch-btn {
	background: var(--surface); border: none; color: var(--text-muted);
	padding: var(--space-2) var(--space-3); font-size: var(--fs-base); cursor: pointer; line-height: 1;
	transition: var(--transition-colors);
}
.view-switch-btn + .view-switch-btn { border-left: 1px solid var(--border); }
.view-switch-btn.active { background: var(--primary); color: var(--primary-contrast); }
.view-switch-btn:hover:not(.active) { background: var(--surface-2); color: var(--text); }
.view-switch-btn:focus-visible { border-radius: 0; box-shadow: inset 0 0 0 2px var(--ring); }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: var(--space-4); }
.segmented label {
	padding: var(--space-2) var(--space-4);
	font-size: var(--fs-sm);
	font-weight: var(--fw-semibold);
	cursor: pointer;
	color: var(--text-muted);
	background: var(--surface);
	transition: var(--transition-colors);
}
.segmented label:hover { color: var(--text); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + label,
.segmented label.active { background: var(--primary); color: var(--primary-contrast); }
.segmented input:focus-visible + label { box-shadow: inset 0 0 0 2px var(--ring); }

/* ========== Botones ========== */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-1-5);
	border: 1px solid transparent;
	border-radius: var(--btn-radius);
	padding: var(--btn-py) var(--btn-px);
	font-weight: var(--fw-semibold);
	font-size: var(--btn-fs);
	cursor: pointer;
	text-decoration: none;
	line-height: 1.2;
	white-space: nowrap;
	transition: var(--transition-colors), opacity var(--duration-fast) ease;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--btn-radius); }

.btn-primary { background: var(--primary); color: var(--primary-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-secondary:active { background: var(--border); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-danger:active { background: var(--danger-border); }

.btn-sm { padding: var(--btn-py-sm) var(--btn-px-sm); font-size: var(--btn-fs-sm); }

.btn[disabled],
.btn.is-disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn.is-disabled { pointer-events: none; }

@keyframes admin-spin { to { transform: rotate(360deg); } }

.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 14px;
	height: 14px;
	margin: -7px 0 0 -7px;
	border-radius: 50%;
	border: 2px solid rgb(255 255 255 / 0.4);
	border-top-color: var(--primary-contrast);
	animation: admin-spin 0.6s linear infinite;
}
.btn-secondary.is-loading::after, .btn-danger.is-loading::after {
	border-color: var(--border);
	border-top-color: var(--text);
}

/* ---------- Overlay global de carga ---------- */
.admin-busy-overlay {
	position: fixed;
	inset: 0;
	z-index: var(--z-overlay);
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--overlay);
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--duration-fast) ease;
}
.admin-busy-overlay.is-active { opacity: 1; pointer-events: all; }
.admin-busy-overlay .admin-busy-box {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	background: var(--surface);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-md);
	padding: var(--space-3-5) var(--space-5);
	font-weight: var(--fw-semibold);
	font-size: var(--fs-sm);
}
.admin-busy-overlay .admin-busy-spinner {
	width: 18px;
	height: 18px;
	flex: none;
	border-radius: 50%;
	border: 3px solid var(--border);
	border-top-color: var(--primary);
	animation: admin-spin 0.6s linear infinite;
}

/* ========== Alertas ========== */
.alert {
	padding: var(--space-3) var(--space-3-5);
	border-radius: var(--radius-sm);
	margin-bottom: var(--space-4);
	font-size: var(--fs-sm);
	border: 1px solid transparent;
}
.alert-error { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.alert-warning { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }

/* ========== Formularios ========== */
.field { margin-bottom: var(--space-4); }
.field label {
	display: block;
	margin-bottom: var(--space-1-5);
	font-weight: var(--fw-semibold);
	font-size: var(--fs-sm);
	color: var(--text-muted);
}
.field-hint { color: var(--text-faint); font-size: var(--fs-xs); margin-top: var(--space-1); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
	width: 100%;
	padding: var(--input-py) var(--input-px);
	border: 1px solid var(--input-border);
	border-radius: var(--input-radius);
	background: var(--input-bg);
	color: var(--text);
	font-size: var(--fs-base);
	transition: var(--transition-colors);
}
input[type="text"]:hover, input[type="email"]:hover, input[type="password"]:hover,
input[type="number"]:hover, input[type="url"]:hover, select:hover, textarea:hover {
	border-color: var(--border-strong);
}
input:focus, select:focus, textarea:focus {
	outline: none;
	border-color: var(--input-focus-border);
	box-shadow: var(--input-focus-ring);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* Editor de código (archivos, consultas SQL) */
textarea.input-code {
	font-family: var(--font-mono);
	font-size: var(--fs-sm);
	line-height: 1.5;
	resize: vertical;
}
textarea.input-code--editor { min-height: 60vh; padding: var(--space-3-5); }

.checkbox-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--text); }
.checkbox-row input { width: auto; accent-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3-5); }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

.git-repo-block {
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--card-radius);
	padding: var(--card-p);
	margin-bottom: var(--space-3-5);
}
.git-repo-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.git-repo-head strong { font-size: var(--fs-base); }
.git-repo-block details { margin-top: var(--space-1); }
.git-repo-block summary { cursor: pointer; font-size: var(--fs-xs); color: var(--text-muted); }

/* ========== Portal público ========== */
.landing-page { background: var(--bg); }
.landing-topbar {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	padding: var(--space-3-5) var(--space-6);
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: var(--space-2-5);
	position: sticky;
	top: 0;
	z-index: var(--z-topbar);
}
.landing-topbar-brand {
	display: flex; align-items: center; gap: var(--space-3);
	font-weight: var(--fw-bold); font-size: var(--fs-md); letter-spacing: var(--tracking-snug);
	color: var(--text); text-decoration: none;
}
.landing-topbar-brand span { padding-left: var(--space-3); border-left: 1px solid var(--border); }
.landing-logo { display: block; height: 40px; width: auto; }
@media (max-width: 560px) { .landing-topbar-brand span { display: none; } }
.landing-topbar nav { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.landing-topbar nav a,
.landing-topbar nav .admin-user,
.landing-topbar nav .logout-form button {
	color: var(--text-muted);
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
	text-decoration: none;
	transition: color var(--duration-fast) ease;
}
.landing-topbar nav a:hover,
.landing-topbar nav .logout-form button:hover { color: var(--text); }
.landing-topbar nav .logout-form { display: inline; margin: 0; padding: 0; }
.landing-topbar nav .logout-form button { background: none; border: none; padding: 0; cursor: pointer; }
.landing-topbar nav .theme-toggle-btn {
	background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-full);
	color: var(--text-muted); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
	padding: var(--space-1) var(--space-3); cursor: pointer; transition: var(--transition-colors);
}
.landing-topbar nav .theme-toggle-btn:hover { color: var(--text); border-color: var(--border-strong); }

.landing-wrap { max-width: 1040px; margin: 0 auto; padding: 0 var(--space-5) var(--space-14); }

.landing-hero { padding: var(--space-11) 0 var(--space-7); }
.landing-hero-copy .landing-tagline {
	font-size: var(--fs-sm); font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase;
	color: var(--accent); margin: 0 0 var(--space-2-5);
}
.landing-hero-copy h1 { margin: 0 0 var(--space-3); font-size: var(--fs-3xl); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); }
.landing-hero-copy p { margin: 0; color: var(--text-muted); max-width: 620px; }

.landing-section-title {
	margin: var(--space-1) 0 var(--space-3);
	font-family: var(--font-mono);
	font-size: var(--fs-2xs);
	font-weight: var(--fw-semibold);
	letter-spacing: var(--tracking-label);
	text-transform: uppercase;
	color: var(--text-faint);
}

.proyectos-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: var(--space-3-5);
	margin-bottom: var(--space-8);
}
.proyecto-card {
	display: flex;
	gap: var(--space-3-5);
	align-items: flex-start;
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--card-radius);
	padding: var(--space-5);
	text-decoration: none;
	color: inherit;
	box-shadow: var(--card-shadow);
	transition: var(--transition-colors), transform var(--duration-base) var(--ease-out);
}
.proyecto-card:hover {
	border-color: var(--card-border-hover);
	box-shadow: var(--card-shadow-hover);
	text-decoration: none;
	transform: translateY(-1px);
}
.proyecto-card:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--card-radius); }
.proyecto-card-icon { flex-shrink: 0; border-radius: var(--radius-sm); }
.proyecto-card-icon--placeholder {
	width: 38px; height: 38px;
	display: flex; align-items: center; justify-content: center;
	background: var(--accent-bg); color: var(--accent);
	font-weight: var(--fw-bold); font-size: var(--fs-lg);
}
.proyecto-card-body h3 { margin: 0 0 var(--space-1-5); font-size: var(--fs-md); }
.proyecto-card-body p { margin: 0 0 var(--space-2-5); color: var(--text-muted); font-size: var(--fs-sm); }
.proyecto-card-link { color: var(--accent); font-weight: var(--fw-semibold); font-size: var(--fs-sm); }

.landing-footer {
	text-align: center;
	padding: var(--space-6) var(--space-4);
	color: var(--text-faint);
	font-size: var(--fs-xs);
	border-top: 1px solid var(--border);
	margin-top: var(--space-4);
}

@media (max-width: 640px) {
	.landing-hero-copy h1 { font-size: var(--fs-2xl); }
	.landing-wrap { padding: 0 var(--space-4) var(--space-10); }
}

/* ========== Tarjeta de autenticación (login, 2FA, asistente) ========== */
.auth-shell {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--space-6);
	background: var(--bg);
}
.auth-card {
	width: 100%;
	max-width: 380px;
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--card-radius);
	padding: var(--space-8) var(--space-7);
	box-shadow: var(--shadow-md);
}
.auth-card h1 { margin: 0 0 var(--space-1-5); font-size: var(--fs-xl); letter-spacing: var(--tracking-snug); }
.auth-subtitle { color: var(--text-muted); margin: 0 0 var(--space-5); font-size: var(--fs-sm); }
.auth-card .btn { width: 100%; justify-content: center; margin-top: var(--space-1-5); }
.auth-footer { margin-top: var(--space-4); text-align: center; font-size: var(--fs-sm); }

/* ========== Shell de administración (sidebar) ========== */
.admin-shell { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
	/* Sigue el tema activo (claro u oscuro) igual que el resto del panel. */
	color: var(--text);

	width: var(--sidebar-w);
	flex-shrink: 0;
	background: var(--surface);
	border-right: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	position: sticky;
	top: 0;
	height: 100vh;
}
.admin-brand {
	display: flex; align-items: center; gap: var(--space-2);
	padding: var(--space-4) var(--space-5);
	min-height: 57px;
	font-weight: var(--fw-bold); font-size: var(--fs-md); letter-spacing: var(--tracking-snug);
	color: var(--text); text-decoration: none;
	border-bottom: 1px solid var(--border);
}
.admin-brand-dot {
	width: 10px; height: 10px; border-radius: 3px; background: var(--accent); flex-shrink: 0;
	box-shadow: 0 0 0 3px var(--accent-bg), 0 0 12px var(--accent);
}
/* El logo tiene texto azul marino: en tema oscuro necesita fondo claro. */
.admin-brand-logo { display: block; width: 100%; height: auto; }
.auth-logo { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto var(--space-4); }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .admin-brand-logo,
	:root:not([data-theme="light"]) .auth-logo,
	:root:not([data-theme="light"]) .landing-logo { background: #f4f6fb; border-radius: var(--radius-sm); padding: 4px 8px; }
}
:root[data-theme="dark"] .admin-brand-logo,
:root[data-theme="dark"] .auth-logo,
:root[data-theme="dark"] .landing-logo { background: #f4f6fb; border-radius: var(--radius-sm); padding: 4px 8px; }
.admin-nav { display: flex; flex-direction: column; padding: var(--space-2-5) var(--space-3); gap: var(--space-0-5); flex: 1; overflow-y: auto; }
.admin-nav a {
	display: flex;
	align-items: center;
	gap: var(--space-2-5);
	padding: var(--nav-item-py) var(--nav-item-px);
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	text-decoration: none;
	font-size: var(--nav-item-fs);
	font-weight: var(--fw-medium);
	transition: var(--transition-colors);
}
.admin-nav a:hover { background: var(--surface-2); color: var(--text); }
.admin-nav a:focus-visible { box-shadow: inset 0 0 0 2px var(--ring); border-radius: var(--radius-sm); }
.admin-nav a.active { background: var(--accent-bg); color: var(--text); font-weight: var(--fw-semibold); }
.admin-nav a.active .icon { color: var(--accent); }
.admin-nav a .icon { color: inherit; opacity: 0.85; }
.admin-nav a.active .icon { opacity: 1; }

/* ---------- Iconos (heroicons-style, stroke) ---------- */
.icon {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	vertical-align: -3px;
}
.icon-sm { width: 15px; height: 15px; vertical-align: -2px; }
.btn .icon { margin-right: 1px; }
.btn-sm .icon { width: 15px; height: 15px; }
.admin-service-chip .icon { width: 12px; height: 12px; vertical-align: -1.5px; }
.proyecto-card-icon--placeholder .icon { width: 20px; height: 20px; }

.admin-sidebar-footer { border-top: 1px solid var(--border); padding: var(--space-3-5) var(--space-4); }
.admin-sidebar-link {
	display: flex; align-items: center; gap: var(--space-1-5);
	font-size: var(--fs-xs); color: var(--text-muted); text-decoration: none; margin-bottom: var(--space-2-5);
	transition: color var(--duration-fast) ease;
}
.admin-sidebar-link:hover { color: var(--text); }
.admin-user {
	font-size: var(--fs-xs); color: var(--text-faint);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	margin-bottom: var(--space-2);
}
.admin-sidebar-footer .logout-form { margin: 0; }
.admin-sidebar-logout {
	width: 100%;
	background: var(--surface-2);
	border: 1px solid var(--border);
	color: var(--text);
	padding: var(--space-2) var(--space-2-5);
	border-radius: var(--radius-sm);
	font-size: var(--fs-xs);
	font-weight: var(--fw-semibold);
	cursor: pointer;
	transition: var(--transition-colors);
}
.admin-sidebar-logout:hover { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
	padding: var(--space-4) var(--space-7);
	min-height: 57px;
	border-bottom: 1px solid var(--border);
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	backdrop-filter: saturate(1.4) blur(8px);
	-webkit-backdrop-filter: saturate(1.4) blur(8px);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	position: sticky;
	top: 0;
	z-index: var(--z-sticky);
}
.admin-topbar-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: var(--tracking-snug); }
.admin-content { padding: var(--space-6) var(--space-7) var(--space-14); width: 100%; }

.admin-hint { color: var(--text-muted); font-size: var(--fs-sm); margin: calc(var(--space-1-5) * -1) 0 var(--space-5); }
.admin-page-actions { margin-bottom: var(--space-5); }

.admin-sidebar-top { display: contents; }
.admin-nav-toggle { display: none; }

@media (max-width: 880px) {
	.admin-layout { flex-direction: column; }
	.admin-sidebar {
		position: static;
		height: auto;
		width: 100%;
		flex-direction: column;
		align-items: stretch;
		border-right: none;
		border-bottom: 1px solid var(--border);
	}
	.admin-sidebar-top {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: var(--space-3) var(--space-4);
	}
	.admin-brand { border-bottom: none; padding: 0; min-height: 0; }
	.admin-brand-logo { width: auto; height: 40px; }
	.admin-nav-toggle {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		gap: var(--space-1);
		width: 40px;
		height: 40px;
		background: var(--surface-2);
		border: 1px solid var(--border);
		border-radius: var(--radius-sm);
		cursor: pointer;
		flex-shrink: 0;
	}
	.admin-nav-toggle span { display: block; width: 16px; height: 2px; background: var(--text); border-radius: 2px; }

	.admin-nav, .admin-sidebar-footer { display: none; }
	.admin-sidebar.nav-open .admin-nav,
	.admin-sidebar.nav-open .admin-sidebar-footer { display: flex; }

	.admin-nav { flex-direction: column; padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border); }
	.admin-nav a { padding: var(--space-2-5) var(--space-3); }
	.admin-sidebar-footer {
		flex-direction: column;
		align-items: stretch;
		padding: var(--space-3) var(--space-4);
	}
	.admin-user { display: block; }
	.admin-topbar { padding: var(--space-3-5) var(--space-4); min-height: 0; }
	.admin-content { padding: var(--space-4) var(--space-4) var(--space-11); }
}

/* ========== Estadísticas ========== */
.stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: var(--space-3);
	margin-bottom: var(--space-3-5);
}
.stat-tile {
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--card-radius);
	padding: var(--space-3-5) var(--space-4);
	box-shadow: var(--card-shadow);
}
.stat-tile-value {
	font-family: var(--font-mono);
	font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: var(--tracking-snug);
	line-height: var(--lh-tight); font-variant-numeric: tabular-nums;
}
.stat-tile-label { margin-top: var(--space-1); font-size: var(--fs-xs); color: var(--text-muted); }
.stat-tile-sub { margin-top: var(--space-0-5); font-size: var(--fs-2xs); color: var(--text-faint); }
.stat-tile.accent-success .stat-tile-value { color: var(--success-text); }
.stat-tile.accent-danger .stat-tile-value { color: var(--danger-text); }
.stat-tile.accent-accent .stat-tile-value { color: var(--accent); }

.stats-panels {
	display: grid;
	grid-template-columns: minmax(240px, 340px) 1fr;
	gap: var(--space-3-5);
	margin-bottom: var(--space-7);
}
@media (max-width: 720px) {
	.stats-panels { grid-template-columns: 1fr; }
}

.donut-card, .mini-stats-card {
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--card-radius);
	padding: var(--card-p);
	box-shadow: var(--card-shadow);
}
.donut-card { display: flex; align-items: center; gap: var(--space-5); }
.donut-wrap { position: relative; width: 104px; height: 104px; flex-shrink: 0; }
.donut-svg { width: 104px; height: 104px; }
.donut-svg circle { stroke-linecap: butt; }
.donut-center {
	position: absolute; inset: 0; display: flex; flex-direction: column;
	align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
.donut-center-value { font-family: var(--font-mono); font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.donut-center-label { font-size: var(--fs-2xs); color: var(--text-muted); }
.donut-legend { display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--fs-xs); flex: 1; min-width: 0; }
.donut-legend-row { display: flex; align-items: center; gap: var(--space-2); }
.donut-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-value { color: var(--text); font-weight: var(--fw-semibold); margin-left: auto; padding-left: var(--space-2-5); white-space: nowrap; font-variant-numeric: tabular-nums; }

.mini-stats-card { display: flex; flex-direction: column; justify-content: center; gap: var(--space-3); }
.mini-stats-row { display: flex; align-items: center; gap: var(--space-2-5); }
.mini-stats-row-label { flex: 0 0 128px; font-size: var(--fs-xs); color: var(--text-muted); }
.mini-stats-bar-track { flex: 1; height: 6px; border-radius: var(--radius-xs); background: var(--surface-2); overflow: hidden; }
.mini-stats-bar-fill { height: 100%; border-radius: var(--radius-xs); background: var(--accent); transition: width var(--duration-slow) var(--ease-out); }
.mini-stats-row-value { flex: 0 0 auto; font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ========== Tarjetas de servicio / tablas ========== */
.admin-services {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: var(--space-3-5);
	margin-bottom: var(--space-8);
	align-items: stretch;
}
.admin-service-card {
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--card-radius);
	padding: var(--card-p);
	box-shadow: var(--card-shadow);
	display: flex;
	flex-direction: column;
	transition: var(--transition-colors);
}
.admin-service-card:hover { box-shadow: var(--card-shadow-hover); border-color: var(--card-border-hover); }
.admin-service-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2-5); margin-bottom: var(--space-2-5); }
.admin-service-title-row { display: flex; align-items: center; gap: var(--space-2-5); min-width: 0; }
.admin-service-avatar {
	width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0;
	background: var(--accent-bg); color: var(--accent);
	display: flex; align-items: center; justify-content: center;
	font-weight: var(--fw-bold); font-size: var(--fs-base); overflow: hidden;
}
.admin-service-avatar img { width: 100%; height: 100%; object-fit: cover; }
.admin-service-head h3 { margin: 0; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-service-card p { margin: 0 0 var(--space-1-5); font-size: var(--fs-sm); color: var(--text-muted); }
.admin-service-card p strong { color: var(--text); font-weight: var(--fw-semibold); }
.admin-service-desc { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.admin-service-meta { display: flex; flex-wrap: wrap; gap: var(--space-1-5); margin: var(--space-1) 0 var(--space-0-5); }
.admin-service-chip {
	display: inline-flex; align-items: center; gap: var(--space-1);
	font-size: var(--fs-2xs); padding: 3px var(--space-2); border-radius: var(--chip-radius);
	background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
	white-space: nowrap;
}
.admin-service-error { color: var(--danger-text); font-size: var(--fs-xs); margin-top: var(--space-2); }
.admin-actions { margin-top: var(--space-3-5); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.admin-service-card > .admin-actions:last-child { margin-top: auto; padding-top: var(--space-3-5); border-top: 1px solid var(--border); }

/* Pill de estado: con punto indicador para no depender solo del color */
.status-pill {
	display: inline-flex; align-items: center; gap: 5px;
	font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-medium); letter-spacing: 0.02em;
	padding: 3px var(--space-2-5); border-radius: var(--pill-radius); white-space: nowrap;
	border: 1px solid transparent;
}
.status-pill::before {
	content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0;
}
@keyframes led-pulse {
	0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
	70%, 100% { box-shadow: 0 0 0 5px transparent; }
}
.status-pill.running::before { animation: led-pulse 2s var(--ease-out) infinite; }
.status-pill.running { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.status-pill.stopped { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.status-pill.pending { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.status-pill.custom { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }

.admin-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--card-radius);
	overflow: hidden;
	font-size: var(--fs-sm);
}
.admin-table th, .admin-table td { padding: var(--table-cell-py) var(--table-cell-px); text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th {
	background: var(--table-head-bg); font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-medium);
	text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--text-muted);
}
.admin-table tbody tr { transition: background-color var(--duration-fast) ease; }
.admin-table tbody tr:hover { background: var(--surface-2); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table-wrap { overflow-x: auto; border-radius: var(--card-radius); }

.empty-state {
	border: 1px dashed var(--border-strong);
	border-radius: var(--card-radius);
	padding: var(--space-8) var(--space-5);
	text-align: center;
	color: var(--text-muted);
	font-size: var(--fs-sm);
	background: var(--surface-2);
}

/* ---------- Layouts de dos columnas ---------- */
.detail-columns {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--space-4);
	align-items: start;
}
@media (max-width: 900px) {
	.detail-columns { grid-template-columns: 1fr; }
}
.detail-col { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.detail-col .detail-section { margin-bottom: 0; }

.sidebar-layout {
	display: grid;
	grid-template-columns: 1fr 340px;
	gap: var(--space-4);
	align-items: start;
}
@media (max-width: 900px) {
	.sidebar-layout { grid-template-columns: 1fr; }
}
.sidebar-col { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.sidebar-col .detail-section { margin-bottom: 0; }

/* ========== Detalle de proyecto ========== */
.detail-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: var(--space-4);
	padding-bottom: var(--space-5);
	margin-bottom: var(--space-6);
	border-bottom: 1px solid var(--border);
}
.detail-header-meta { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-2); }
.detail-header-path { color: var(--text-muted); font-size: var(--fs-sm); }

.detail-section {
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--card-radius);
	padding: var(--section-p);
	margin-bottom: var(--space-4);
	box-shadow: var(--card-shadow);
}
.detail-section-title { margin: 0 0 var(--space-1); font-size: var(--fs-md); font-weight: var(--fw-bold); letter-spacing: var(--tracking-snug); }
.detail-section-hint { margin: 0 0 var(--space-3-5); color: var(--text-muted); font-size: var(--fs-sm); }
.detail-section-body { display: flex; flex-direction: column; gap: var(--space-3-5); }
.detail-section-danger { border-color: var(--danger-border); background: var(--danger-bg); box-shadow: none; }
.detail-section-danger .detail-section-title { color: var(--danger-text); }

.db-connection-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: var(--space-2-5);
	padding: var(--space-3) var(--space-3-5);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
}
.db-connection-row + .db-connection-row { margin-top: var(--space-2); }

/* ========== Monitor htop (siempre oscuro, paleta de terminal) ========== */
.htop-panel {
	--htop-bg: var(--term-bg);
	--htop-fg: var(--term-fg);
	--htop-border: var(--term-border);
	--htop-line: var(--term-line);
	--htop-muted: var(--term-muted);
	--htop-heading: var(--term-blue-soft);
	--htop-highlight: var(--term-orange);

	background: var(--htop-bg);
	color: var(--htop-fg);
	border: 1px solid var(--htop-border);
	border-radius: var(--radius);
	padding: var(--space-4) var(--space-5) var(--space-5);
	margin-bottom: var(--space-7);
	font-family: var(--font-mono);
	font-size: var(--fs-sm);
	box-shadow: var(--shadow-md);
}
.htop-header {
	display: flex; justify-content: space-between; align-items: center;
	margin-bottom: var(--space-3-5); color: var(--term-blue); font-weight: var(--fw-bold);
}
.htop-title { letter-spacing: 0.02em; }
.htop-clock { color: var(--htop-muted); font-weight: var(--fw-regular); font-variant-numeric: tabular-nums; }
.htop-bars { margin-bottom: var(--space-3); }
.htop-bar-row { display: grid; grid-template-columns: 52px 1fr 90px; gap: var(--space-2-5); align-items: center; margin-bottom: var(--space-2); }
.htop-bar-label { color: var(--htop-heading); font-weight: var(--fw-bold); }
.htop-bar-track { height: 16px; background: var(--htop-line); border: 1px solid var(--htop-border); border-radius: 3px; overflow: hidden; }
.htop-bar-fill { height: 100%; transition: width var(--duration-slow) ease; border-radius: 2px; }
.htop-bar-fill.cpu { background: linear-gradient(90deg, var(--term-green-deep), var(--term-green)); }
.htop-bar-fill.mem { background: linear-gradient(90deg, var(--term-blue-deep), var(--term-blue)); }
.htop-bar-fill.disk,
.htop-bar-fill.cpu.warm { background: linear-gradient(90deg, var(--term-yellow-deep), var(--term-yellow)); }
.htop-bar-fill.mem.warm,
.htop-bar-fill.disk.warm { background: linear-gradient(90deg, var(--term-purple-deep), var(--term-purple)); }
.htop-bar-fill.cpu.hot,
.htop-bar-fill.mem.hot,
.htop-bar-fill.disk.hot { background: linear-gradient(90deg, var(--term-red-deep), var(--term-red)); }
.htop-bar-value { text-align: right; color: var(--term-fg-strong); font-variant-numeric: tabular-nums; }
.htop-top { margin: 0 0 var(--space-3); color: var(--htop-highlight); font-size: var(--fs-xs); }
.htop-table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.htop-table th {
	text-align: left; color: var(--htop-heading); border-bottom: 1px solid var(--htop-border);
	padding: var(--space-1-5) var(--space-2); font-weight: var(--fw-bold);
}
.htop-table td { padding: 5px var(--space-2); border-bottom: 1px solid var(--htop-line); font-variant-numeric: tabular-nums; }
.htop-table tbody tr:hover { background: var(--term-bg-hover); }
.htop-row-top td { color: var(--htop-highlight); font-weight: var(--fw-bold); }
.htop-loading { color: var(--htop-muted); text-align: center; }
.htop-table code {
	background: var(--htop-line); color: var(--htop-fg); padding: 1px var(--space-1);
	border-radius: 3px; font-size: var(--fs-2xs); border: none;
}
.htop-details { margin-top: var(--space-3-5); color: var(--htop-muted); }
.htop-details summary { cursor: pointer; color: var(--term-blue); margin-bottom: var(--space-2); user-select: none; }
.htop-table-containers { margin-top: var(--space-2); }
.htop-error { margin: var(--space-2-5) 0 0; color: var(--term-red); font-size: var(--fs-xs); }

/* ---------- Gráficas: el color sigue a la entidad; "Otros" va en gris ---------- */
.viz-root {
	--series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
	--series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
	--series-0: #b4b2ab;
}
@media (prefers-color-scheme: dark) {
	:root:where(:not([data-theme="light"])) .viz-root {
		--series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
		--series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
		--series-0: #5e5d59;
	}
}
:root[data-theme="dark"] .viz-root {
	--series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
	--series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
	--series-0: #5e5d59;
}
.viz-root .s0 { fill: var(--series-0); } .viz-root .s1 { fill: var(--series-1); } .viz-root .s2 { fill: var(--series-2); }
.viz-root .s3 { fill: var(--series-3); } .viz-root .s4 { fill: var(--series-4); } .viz-root .s5 { fill: var(--series-5); }
.viz-root .s6 { fill: var(--series-6); } .viz-root .s7 { fill: var(--series-7); } .viz-root .s8 { fill: var(--series-8); }
.viz-legend { display:flex; flex-wrap:wrap; gap:6px 16px; margin:0 0 8px; font-size:var(--fs-xs); color:var(--text); }
.viz-legend span { display:inline-flex; align-items:center; gap:6px; }
.viz-swatch { width:10px; height:10px; border-radius:3px; display:inline-block; flex:none; }
.viz-legend .viz-total { color:var(--text-muted); }
.viz-plot { position:relative; }
.viz-plot svg { display:block; width:100%; height:auto; overflow:visible; }
.viz-axis { fill:var(--text-muted); font-size:11px; font-family:var(--font-mono); }
.viz-grid { stroke:var(--border); stroke-width:1; }
.viz-hit { fill:transparent; cursor:default; }
.viz-hit:hover, .viz-hit.is-active { fill:var(--text); fill-opacity:0.05; }
.viz-tip { position:absolute; pointer-events:none; background:var(--surface); color:var(--text); border:1px solid var(--border);
	border-radius:8px; padding:8px 10px; font-size:var(--fs-xs); box-shadow:var(--card-shadow); min-width:140px; display:none; z-index:2; }
.viz-tip .row { display:flex; align-items:center; gap:6px; justify-content:space-between; }
.viz-tip .row b { font-variant-numeric:tabular-nums; }
.viz-line { fill:none; stroke-width:2; stroke-linejoin:round; stroke-linecap:round; }
.viz-area { stroke:none; fill-opacity:0.14; }
.viz-stack { stroke:var(--surface); stroke-width:1; stroke-linejoin:round; }
.viz-cross { stroke:var(--text-muted); stroke-width:1; stroke-dasharray:3 3; }
.viz-dot { stroke:var(--surface); stroke-width:2; }
.viz-grid-2 { display:grid; grid-template-columns:repeat(auto-fit, minmax(300px, 1fr)); gap:16px; margin-bottom:16px; }
.viz-card-head { display:flex; justify-content:space-between; align-items:baseline; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
.viz-card-head h3 { margin:0; font-size:var(--fs-sm); }
.viz-card-head .viz-now { font-family:var(--font-mono); font-size:var(--fs-sm); color:var(--text); font-variant-numeric:tabular-nums; }
.viz-bars { display:grid; grid-template-columns:minmax(90px, max-content) 1fr minmax(64px, max-content); gap:6px 10px; align-items:center; font-size:var(--fs-xs); }
.viz-bars .bar { height:10px; border-radius:0 4px 4px 0; background:var(--series-1); min-width:2px; }
.viz-bars .val { font-family:var(--font-mono); text-align:right; color:var(--text); font-variant-numeric:tabular-nums; }
.viz-bars .name { color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.segmented a { padding: var(--space-2) var(--space-4); font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); background: var(--surface); text-decoration:none; transition: var(--transition-colors); }
.segmented a:hover { color: var(--text); }
.segmented a.active { background: var(--primary); color: var(--primary-contrast); }

/* ========== Menú agrupado, campana, cuenta, pestañas y cards ========== */
.admin-nav-group {
	margin: var(--space-3) var(--space-3) var(--space-1);
	font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-medium);
	text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--text-faint);
}
.admin-nav-group:first-child { margin-top: var(--space-1); }
.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; }

/* Mi cuenta (pie del menú) */
.admin-account { margin-bottom: var(--space-2); }
.admin-account summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: var(--space-1); margin: 0; }
.admin-account summary::-webkit-details-marker { display: none; }
.admin-account summary::after { content: "▾"; color: var(--text-faint); }
.admin-account[open] summary::after { content: "▴"; }
.admin-account-menu { display: flex; flex-direction: column; gap: 2px; margin-top: var(--space-1-5); }
.admin-account-menu a {
	display: flex; justify-content: space-between; align-items: center; gap: var(--space-2);
	font-size: var(--fs-xs); color: var(--text-muted); text-decoration: none;
	padding: var(--space-1-5) var(--space-2); border-radius: var(--radius-sm); min-height: 32px;
}
.admin-account-menu a:hover { background: var(--surface-2); color: var(--text); }

/* Barra superior y campana */
.admin-topbar-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.notif-bell { position: relative; }
.notif-bell summary {
	list-style: none; cursor: pointer; position: relative;
	width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
	border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
}
.notif-bell summary::-webkit-details-marker { display: none; }
.notif-bell summary:hover { border-color: var(--accent); }
.notif-bell summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.notif-count {
	position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
	border-radius: 9px; background: var(--danger-text); color: #fff;
	font-size: 11px; font-weight: var(--fw-bold); line-height: 18px; text-align: center; white-space: nowrap;
}
.notif-menu {
	position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 32px));
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-radius);
	box-shadow: var(--card-shadow-hover); z-index: calc(var(--z-sticky) + 1); overflow: hidden;
}
.notif-menu-head { display: flex; justify-content: space-between; align-items: center; padding: var(--space-3) var(--space-3-5); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.notif-menu-head a { color: var(--accent); text-decoration: none; font-size: var(--fs-xs); }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.notif-list li { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2-5) var(--space-3-5); border-bottom: 1px solid var(--border); font-size: var(--fs-xs); }
.notif-list li:last-child { border-bottom: none; }
.notif-list li strong { font-size: var(--fs-sm); color: var(--text); }
.notif-list li span { color: var(--text-muted); overflow-wrap: anywhere; }
.notif-list li time { color: var(--text-faint); font-family: var(--font-mono); font-size: var(--fs-2xs); }
.notif-list li.is-new { background: var(--accent-bg); }
.notif-list .notif-empty { color: var(--text-muted); text-align: center; padding: var(--space-5); }

/* Pestañas de página: separan reportes de configuración */
.page-tabs {
	display: flex; gap: var(--space-1); overflow-x: auto; margin: 0 0 var(--space-5);
	border-bottom: 1px solid var(--border); scrollbar-width: thin;
}
.page-tabs a {
	padding: var(--space-2-5) var(--space-3-5); min-height: 44px; display: inline-flex; align-items: center; gap: var(--space-1-5);
	color: var(--text-muted); text-decoration: none; font-size: var(--fs-sm); font-weight: var(--fw-medium);
	border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.page-tabs a:hover { color: var(--text); }
.page-tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: var(--fw-semibold); }
.page-tabs a:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.tab-panel > .landing-section-title:first-child { margin-top: 0; }

/* Cards: títulos que no se corten y formularios con ancho cómodo */
.admin-service-head h3 { white-space: normal; overflow-wrap: anywhere; }
.form-card { width: 100%; max-width: 880px; margin-bottom: var(--space-4); }
/* Columnas tipo masonry: sin huecos junto a una card alta. */
.cards-2 { columns: 2 380px; column-gap: var(--space-4); margin-bottom: var(--space-4); }
.cards-2 > * { break-inside: avoid; width: 100%; margin: 0 0 var(--space-4) !important; max-width: none !important; }

/* Números de las tarjetas de estadística: nunca se salen de la card */
.stat-tile { min-width: 0; }
.stat-tile-value { overflow-wrap: anywhere; }
.stats-grid--text { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stats-grid--text .stat-tile-value { font-size: var(--fs-xl); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-6) 0 var(--space-3); }
.section-head .landing-section-title { margin: 0; }

/* Tablas: en pantallas pequeñas se desplazan; los inputs no se comprimen */
.admin-table-wrap { -webkit-overflow-scrolling: touch; position: relative; }
.admin-table-wrap > .admin-table { min-width: 560px; }
.admin-table td input[type="number"] { min-width: 72px; }
.admin-table td .btn { white-space: nowrap; }

/* Avisos de peligro (reiniciar servidor) */
.danger-card { border-color: var(--danger-border) !important; }
.danger-card .admin-service-head h3 { color: var(--danger-text); }

@media (max-width: 880px) {
	.admin-topbar { flex-wrap: wrap; }
	.admin-nav-group { margin-left: var(--space-3); }
}

/* Buscador, orden y paginado de tablas (compartido) */
.ban-toolbar { display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center; justify-content:space-between; margin:0 0 10px; }
.ban-search { display:flex; gap:8px; align-items:center; flex:1 1 320px; max-width:520px; }
.ban-search input[type="search"] { flex:1; min-width:0; }
.ban-sort { color:inherit; text-decoration:none; display:inline-flex; align-items:center; gap:4px; white-space:nowrap; }
.ban-sort:hover { color:var(--accent); }
.ban-sort-icon { font-size:10px; color:var(--text-faint, var(--text-muted)); }
.ban-sort.is-active .ban-sort-icon { color:var(--accent); }
.ban-pager { display:flex; flex-wrap:wrap; gap:6px; align-items:center; justify-content:space-between; margin-top:10px; }
.ban-pages { display:flex; flex-wrap:wrap; gap:4px; }
.ban-pages a, .ban-pages span { min-width:32px; text-align:center; padding:4px 8px; border:1px solid var(--border); border-radius:6px; font-size:var(--fs-xs); text-decoration:none; color:var(--text); }
.ban-pages a:hover { border-color:var(--accent); color:var(--accent); }
.ban-pages .is-current { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
.ban-pages .is-disabled { opacity:.4; }
mark.ban-hit { background:var(--warn-bg); color:inherit; border-radius:3px; padding:0 1px; }

/* Menú compacto para que quepa entero en pantallas de ~900 px de alto */
@media (min-width: 881px) {
	.admin-nav { gap: 0; }
	.admin-nav a { padding-top: 7px; padding-bottom: 7px; }
	.admin-nav-group { margin: var(--space-2-5) var(--space-3) 2px; }
	.admin-sidebar-footer { padding-top: var(--space-2-5); padding-bottom: var(--space-2-5); }
}

/* Botón con menú desplegable (agrupa acciones relacionadas) */
.menu-btn { position: relative; }
.menu-btn > summary { list-style: none; cursor: pointer; }
.menu-btn > summary::-webkit-details-marker { display: none; }
.menu-btn > summary::after { content: " ▾"; }
.menu-btn-list {
	position: absolute; right: 0; top: calc(100% + 6px); min-width: 260px; z-index: calc(var(--z-sticky) + 1);
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--card-radius);
	box-shadow: var(--card-shadow-hover); padding: var(--space-1-5); display: flex; flex-direction: column;
}
.menu-btn-list a {
	display: flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-3);
	border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: var(--fs-sm);
}
.menu-btn-list a:hover, .menu-btn-list a:focus-visible { background: var(--surface-2); }

/* Tabla de servicios: en móvil cada fila es un bloque, sin desplazamiento lateral */
@media (max-width: 640px) {
	.admin-table-wrap > .svc-table { min-width: 0; }
	.svc-table thead { display: none; }
	.svc-table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
	.svc-table tr:last-child { border-bottom: none; }
	.svc-table td { display: block; padding: 0; border: none; }
	.svc-table td:nth-child(3) { grid-column: 1 / -1; }
	.svc-table td:nth-child(4) { grid-column: 1 / -1; text-align: left !important; }
}
