:root {
  --page:#f3f4f6; --card:#fff; --header:#f9fafb; --fg:#111827; --fg2:#374151; --muted:#6b7280;
  --border:#e5e7eb; --input-border:#d1d5db; --input-bg:#fff;
  --accent:#4f46e5; --btn:#166534; --btn-hover:#15803d; --err:#b91c1c; --err-bg:#fef2f2; --err-border:#fecaca;
  --row-alt:#f9fafb; --warn:#b45309; --shadow:0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
}
.dark {
  --page:#111827; --card:#1f2937; --header:rgb(31 41 55 / .4); --fg:#f9fafb; --fg2:#d1d5db; --muted:#9ca3af;
  --border:#374151; --input-border:#374151; --input-bg:#111827;
  --accent:#818cf8; --btn:#166534; --btn-hover:#15803d; --err:#fca5a5; --err-bg:rgb(127 29 29 / .25); --err-border:#7f1d1d;
  --row-alt:rgb(255 255 255 / .03); --warn:#fbbf24;
}
* { box-sizing:border-box; }
body { margin:0; font-family:Figtree, ui-sans-serif, system-ui, "Segoe UI", sans-serif; font-size:14px; line-height:1.5;
       background:var(--page); color:var(--fg); -webkit-font-smoothing:antialiased; }
[hidden] { display:none !important; }

/* ── Barra superior ── */
nav.top { background:var(--card); border-bottom:1px solid var(--border); box-shadow:var(--shadow); }
.top-in { display:flex; justify-content:space-between; align-items:stretch; height:64px; padding:0 clamp(16px,3vw,48px); gap:16px; }
.top-left, .top-right { display:flex; align-items:center; gap:8px; }
.logo { height:32px; width:auto; display:block; margin-right:24px; }
.dark .logo { background:#fff; padding:5px 10px; border-radius:6px; height:38px; }
.nav-trigger { display:inline-flex; align-items:center; height:100%; padding:0 14px; font-size:14px; font-weight:500; color:var(--muted);
               border-bottom:2px solid transparent; }
.nav-trigger--active { color:var(--accent); border-bottom-color:var(--accent); }
.chip { max-width:420px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; color:var(--muted);
        background:var(--page); border:1px solid var(--border); border-radius:9999px; padding:4px 12px; }
.icon-btn { display:inline-flex; align-items:center; justify-content:center; width:34px; height:34px; padding:0; border-radius:6px;
            background:transparent; border:1px solid var(--border); color:var(--muted); cursor:pointer; }
.icon-btn:hover { color:var(--accent); border-color:var(--accent); }
.icon-btn svg { width:18px; height:18px; }
.dark .i-moon { display:none; } html:not(.dark) .i-sun { display:none; }

/* ── Cabecera de página ── */
header.page-header { background:var(--header); border-bottom:1px solid var(--border); box-shadow:0 1px 2px 0 rgb(0 0 0 / .05); }
header.page-header h2 { margin:0; padding:20px clamp(16px,3vw,48px); font-size:18px; font-weight:700; letter-spacing:-.01em;
                        display:flex; align-items:center; gap:10px; color:var(--fg); }
header.page-header h2::before { content:''; width:3px; height:1.25em; border-radius:9999px; background:var(--accent); flex-shrink:0; }

main { padding:24px clamp(16px,3vw,48px) 48px; }

/* ── Tarjetas y formularios ── */
.card { background:var(--card); border:1px solid var(--border); border-radius:8px; box-shadow:var(--shadow); padding:20px; margin-bottom:16px; }
.card h3 { margin:0 0 4px; font-size:16px; font-weight:600; }
label { display:block; font-size:14px; font-weight:500; color:var(--fg2); margin:12px 0 4px; }
input, select { width:100%; font:inherit; padding:8px 12px; color:var(--fg); background:var(--input-bg);
                border:1px solid var(--input-border); border-radius:6px; box-shadow:0 1px 2px 0 rgb(0 0 0 / .05); }
input:focus, select:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.btn { display:inline-flex; align-items:center; padding:8px 16px; font:inherit; font-weight:600; font-size:12px; text-transform:uppercase;
       letter-spacing:.1em; border-radius:6px; border:1px solid transparent; cursor:pointer; color:#fff; background:var(--btn);
       transition:background-color .15s ease-in-out; }
.btn:hover { background:var(--btn-hover); }
.btn:focus-visible { outline:none; box-shadow:0 0 0 2px var(--card), 0 0 0 4px #22c55e; }
.btn.secondary { background:var(--card); color:var(--fg2); border-color:var(--input-border); }
.btn.secondary:hover { background:var(--page); }
.btn:disabled { opacity:.5; cursor:wait; }
.grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:16px; align-items:end; }
.grid label { margin-top:0; }
.row { display:flex; gap:8px; align-items:center; margin-top:16px; flex-wrap:wrap; }
.hint { color:var(--muted); font-size:12px; margin:12px 0 0; }
code { background:var(--page); padding:1px 5px; border-radius:4px; font-size:12px; }
.err { margin-top:12px; padding:8px 12px; border:1px solid var(--err-border); background:var(--err-bg); color:var(--err);
       border-radius:6px; font-size:13px; white-space:pre-wrap; }
.err:empty { display:none; }

/* ── Login (estilo layout guest) ── */
#login { display:flex; flex-direction:column; align-items:center; padding-top:24px; }
#login .login-logo { height:48px; width:auto; margin-bottom:24px; }
.dark #login .login-logo { background:#fff; padding:8px 16px; border-radius:8px; height:64px; }
#login .card { width:100%; max-width:448px; padding:24px; }
.tabs { display:flex; border-bottom:1px solid var(--border); margin:12px 0 4px; }
.tab { background:none; border:0; border-bottom:2px solid transparent; padding:8px 14px; margin-bottom:-1px; font:inherit; font-weight:500;
       color:var(--muted); cursor:pointer; }
.tab.active { color:var(--accent); border-bottom-color:var(--accent); }

/* ── Resultados ── */
#logs { font:12px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace; max-height:62vh; overflow:auto; padding:0; }
.ev { display:grid; grid-template-columns:170px 1fr; gap:12px; padding:6px 14px; border-bottom:1px solid var(--border); }
.ev:nth-child(even) { background:var(--row-alt); }
.ev .ts { color:var(--muted); white-space:nowrap; }
.ev .msg { white-space:pre-wrap; word-break:break-word; }
.ev .stream { color:var(--muted); font-size:11px; margin-top:2px; }
.ev.error { box-shadow:inset 3px 0 0 var(--err); }
.ev.warn { box-shadow:inset 3px 0 0 var(--warn); }
@media (max-width:640px) { .ev { grid-template-columns:1fr; gap:2px; } .chip { display:none; } }

/* ── Ajustes de espaciado puntuales (antes eran atributos style en el HTML) ── */
#rcustom { margin-top:12px; }
#rcatalogInfo { margin-top:6px; }
#count { margin:0 0 0 8px; }

/* Con cuatro pestañas pueden no caber en una línea */
.tabs { flex-wrap:wrap; }

/* ── Selector de perfil (radios) ── */
.radios { border:0; padding:0; margin:12px 0 0; min-width:0; }
.radios legend { padding:0; margin-bottom:4px; font-size:14px; font-weight:500; color:var(--fg2); }
.radio { display:flex; align-items:center; gap:8px; margin:6px 0; font-weight:500; cursor:pointer; }
.radio input { width:auto; margin:0; padding:0; box-shadow:none; accent-color:var(--accent); }
.radio small { color:var(--muted); font-weight:400; }
