/* Pulso: capa de tema sobre Franken UI 2.1 (core + utilities vendorizados en /static/vendor/franken-ui).
   Se apoya en las variables HSL de Franken (--background, --primary, ...). Modo oscuro: clase .dark en <html> (theme.js). */
:root {
  --sidebar-w: 256px;
  --ok: 160 84% 24%;      --ok-bg: 152 70% 92%;
  --warn: 30 95% 27%;     --warn-bg: 45 100% 89%;
  --err: 0 72% 38%;       --err-bg: 0 86% 95%;
  --demo: 268 62% 38%;    --demo-bg: 268 80% 94%;
  --app-bg: 220 20% 97%;
  --line: var(--border) / var(--border-alpha, 1);
  --uk-btn-height: 2.25rem; --uk-btn-padding: .4rem .95rem; --uk-btn-font-size: .9rem;
  --uk-form-input-height: 2.4rem; --uk-form-input-font-size: .95rem;
  color-scheme: light;
}
.dark {
  --ok: 152 62% 62%;      --ok-bg: 160 50% 13%;
  --warn: 43 92% 66%;     --warn-bg: 35 60% 13%;
  --err: 0 92% 74%;       --err-bg: 0 50% 15%;
  --demo: 268 92% 80%;    --demo-bg: 268 42% 18%;
  --app-bg: 224 14% 7%;
  --background: 224 14% 9%; --card: 224 14% 11%; --popover: 224 14% 13%;
  --border: 220 12% 100%; --border-alpha: .13; --input: 220 12% 100%; --input-alpha: .16;
  --muted: 222 12% 17%; --secondary: 222 12% 17%; --accent: 222 12% 20%;
  --muted-foreground: 220 10% 68%;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: hsl(var(--app-bg)); color: hsl(var(--foreground)); font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a:not(.uk-btn) { color: hsl(var(--primary)); } a { text-decoration: none; } a:not(.uk-btn):hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; font-weight: 650; } h3 { font-size: .95rem; margin: 0 0 .5rem; font-weight: 650; }
.muted { color: hsl(var(--muted-foreground)); } .small { font-size: .85rem; } .mono { font-family: ui-monospace, "Geist Mono", Menlo, Consolas, monospace; }
.icon { flex: none; vertical-align: -.2em; }
.skip { position: absolute; left: -999px; top: 0; z-index: 100; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); padding: .5rem 1rem; border-radius: 0 0 8px 0; }
.skip:focus { left: 0; }
:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: hsl(var(--card)); border-right: 1px solid hsl(var(--line)); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-size: 1.1rem; padding: .35rem .6rem 1.1rem; display: flex; align-items: center; gap: .6rem; color: hsl(var(--foreground)); font-weight: 700; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand .logo { display: block; width: auto; max-width: 100%; color: hsl(var(--foreground)); }
.login-brand { justify-content: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: 8px; color: hsl(var(--muted-foreground)); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); text-decoration: none; }
.nav a.active { background: hsl(var(--primary) / .12); color: hsl(var(--primary)); font-weight: 650; }
.dark .nav a.active { background: hsl(var(--primary) / .18); }
.nav .sub { margin: .1rem 0 .5rem 1.2rem; padding-left: .8rem; border-left: 1px solid hsl(var(--line)); display: grid; }
.nav .sub a { padding: .3rem .6rem; font-size: .88rem; font-weight: 500; margin: 0; }
.nav .sub a.active { background: none; color: hsl(var(--primary)); font-weight: 650; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .6rem; padding: .6rem 1.25rem; background: hsl(var(--card) / .9); backdrop-filter: blur(8px); border-bottom: 1px solid hsl(var(--line)); position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
.content { padding: 1.5rem 1.5rem 5rem; max-width: 1200px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { margin-bottom: .15rem; }
.bottomnav, .scrim, .icon-btn.hamburger { display: none; }
.icon-btn { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 8px; border: 1px solid transparent; background: none; color: hsl(var(--muted-foreground)); cursor: pointer; }
.icon-btn:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.theme-moon { display: none; } .dark .theme-sun { display: none; } .dark .theme-moon { display: inline-flex; } .theme-sun, .theme-moon { align-items: center; }
.ws-trigger, .user-trigger { gap: .5rem; }
.ws-dot { width: .55rem; height: .55rem; border-radius: 50%; background: hsl(var(--primary)); }
.avatar { display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 50%; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: .75rem; font-weight: 700; }
.menu-item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: .6rem; padding: .45rem .6rem; border: 0; background: none; color: inherit; font: inherit; border-radius: 6px; cursor: pointer; text-align: left; }
.menu-item:hover { background: hsl(var(--accent)); } .menu-item.on { font-weight: 650; color: hsl(var(--primary)); }
.uk-dropdown { min-width: 14rem; }

/* ---------- Componentes ---------- */
.card, .uk-card.card { background: hsl(var(--card)); color: hsl(var(--card-foreground)); border: 1px solid hsl(var(--line)); border-radius: 12px; padding: 1.1rem 1.25rem; box-shadow: 0 1px 2px rgb(0 0 0 / .04); }
.grid { display: grid; gap: 1rem; } .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.table-wrap { overflow-x: auto; margin: 0 -.25rem; padding: 0 .25rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; vertical-align: top; }
td { border-top: 1px solid hsl(var(--line)); }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: hsl(var(--muted-foreground)); font-weight: 600; }
tbody tr:hover td { background: hsl(var(--muted) / .5); }
.uk-table th, .uk-table td { padding: .55rem .5rem; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; line-height: 1.4; border: 1px solid transparent; }
.badge-ok { background: hsl(var(--ok-bg)); color: hsl(var(--ok)); } .badge-warn { background: hsl(var(--warn-bg)); color: hsl(var(--warn)); }
.badge-err { background: hsl(var(--err-bg)); color: hsl(var(--err)); } .badge-muted { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
/* DEMO: siempre rayado violeta con borde discontinuo; nunca se parece a "Conectada" (verde) */
.badge-demo { background: repeating-linear-gradient(135deg, hsl(var(--demo-bg)), hsl(var(--demo-bg)) 6px, transparent 6px, transparent 12px); color: hsl(var(--demo)); border: 1px dashed hsl(var(--demo)); letter-spacing: .08em; }
.btn-danger { color: hsl(var(--err)); border-color: hsl(var(--err) / .5); } .btn-danger:hover { background: hsl(var(--err-bg)); }
.btn-block { display: flex; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
form.stack { display: grid; gap: .9rem; max-width: 560px; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.uk-input, .uk-select, .uk-textarea { width: 100%; background-color: hsl(var(--background)); }
.uk-checkbox, .uk-radio { flex: none; }
textarea.uk-textarea { min-height: 7rem; resize: vertical; height: auto; }
input[type=file] { font: inherit; }
.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid transparent; border-left-width: 4px; background: hsl(var(--muted)); }
.alert-err { background: hsl(var(--err-bg)); color: hsl(var(--err)); border-color: hsl(var(--err) / .35); }
.alert-warn { background: hsl(var(--warn-bg)); color: hsl(var(--warn)); border-color: hsl(var(--warn) / .35); }
.alert-ok { background: hsl(var(--ok-bg)); color: hsl(var(--ok)); border-color: hsl(var(--ok) / .35); }
.alert .badge-demo { background-color: hsl(var(--background)); }
.empty { text-align: center; padding: 2.25rem 1rem; color: hsl(var(--muted-foreground)); }
.empty strong { display: block; color: hsl(var(--foreground)); margin-bottom: .25rem; font-size: 1rem; }
.empty-ico { display: inline-grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 50%; background: hsl(var(--muted)); margin-bottom: .6rem; }
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: .6rem 0; border-bottom: 1px solid hsl(var(--line)); display: flex; gap: .75rem; justify-content: space-between; align-items: center; } .list li:last-child { border-bottom: 0; }
pre.prompt { white-space: pre-wrap; background: hsl(var(--muted) / .6); border: 1px solid hsl(var(--line)); border-radius: 8px; padding: .8rem; font-size: .85rem; max-height: 22rem; overflow: auto; }
details { margin: .5rem 0; } summary { cursor: pointer; color: hsl(var(--primary)); font-weight: 500; }
code, .code { font-family: ui-monospace, "Geist Mono", Menlo, Consolas, monospace; font-size: .85em; background: hsl(var(--muted)); padding: .05rem .35rem; border-radius: 5px; }
hr { border: 0; border-top: 1px solid hsl(var(--line)); margin: 1rem 0; }

/* ---------- Acceso / errores ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(60rem 30rem at 50% -10%, hsl(var(--primary) / .14), transparent), hsl(var(--app-bg)); }
.login-card { width: 100%; max-width: 400px; padding: 2rem 1.75rem; position: relative; }
.login-brand { padding: 0 0 .25rem; font-size: 1.3rem; } .login-sub { margin: 0 0 1.25rem; }
.login-theme { position: absolute; top: .75rem; right: .75rem; }

/* ---------- Editorial (medios, bandeja, prompts) ---------- */
.cols-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
pre.raw, pre.extracted { white-space: pre-wrap; word-break: break-word; background: hsl(var(--muted) / .6); border: 1px solid hsl(var(--line)); border-radius: 8px; padding: .8rem; font-size: .8rem; max-height: 36rem; overflow: auto; }
pre.extracted { font-family: inherit; font-size: .92rem; line-height: 1.55; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid hsl(var(--line)); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .95rem; border-radius: 8px 8px 0 0; color: hsl(var(--muted-foreground)); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: hsl(var(--primary)); font-weight: 650; border-bottom-color: hsl(var(--primary)); }
.tabs a:hover { text-decoration: none; background: hsl(var(--accent)); }
.flags { display: flex; gap: .25rem; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: 1rem; }
.filters label { min-width: 9rem; }
form.inline, .inline { display: inline; }
.thumb { width: 100%; max-height: 260px; object-fit: cover; border-radius: 8px; border: 1px solid hsl(var(--line)); background: hsl(var(--muted)); }
.banner { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; background: hsl(var(--warn-bg)); color: hsl(var(--warn)); border: 1px solid hsl(var(--warn) / .4); }
.banner-test { background: hsl(var(--demo-bg)); color: hsl(var(--demo)); border: 1px dashed hsl(var(--demo)); padding: .6rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; }
.qr { max-width: 280px; width: 100%; background: #fff; padding: .5rem; border-radius: 10px; border: 1px solid hsl(var(--line)); }
.score { font-variant-numeric: tabular-nums; font-weight: 700; }
.score-ok { color: hsl(var(--ok)); } .score-mid { color: hsl(var(--warn)); } .score-bad { color: hsl(var(--err)); }
.uk-btn[disabled], .uk-btn.disabled { opacity: .5; cursor: not-allowed; }
textarea.tall { min-height: 16rem; font-family: ui-monospace, "Geist Mono", Menlo, Consolas, monospace; font-size: .85rem; }
textarea.body { min-height: 18rem; line-height: 1.5; }
.fieldset { border: 1px solid hsl(var(--line)); border-radius: 10px; padding: .8rem 1rem; margin: 0 0 1rem; }
.fieldset > legend { font-weight: 600; padding: 0 .4rem; }
form.wide { max-width: none; }
.help { font-weight: 400; color: hsl(var(--muted-foreground)); font-size: .82rem; }
.steps { list-style: none; display: flex; gap: .5rem; flex-wrap: wrap; padding: 0; margin: 0 0 1rem; counter-reset: step; }
.steps li { counter-increment: step; padding: .3rem .8rem; border-radius: 999px; background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); font-size: .85rem; }
.steps li::before { content: counter(step) ". "; } .steps li.on { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 84%; max-width: 310px; z-index: 40; transform: translateX(-102%); transition: transform .2s; height: 100%; visibility: hidden; }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 30; }
  .icon-btn.hamburger { display: inline-grid; }
  .grid.cols-2, .grid.cols-3, .cols-split { grid-template-columns: 1fr; }
  .topbar { padding: .5rem .75rem; } .content { padding: 1rem .9rem 6rem; }
  .topbar .who { display: none; } .user-trigger { padding-inline: .5rem; }
  .ws-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
  h1 { font-size: 1.4rem; }
  .bottomnav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset: auto 0 0 0; background: hsl(var(--card)); border-top: 1px solid hsl(var(--line)); z-index: 25; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { display: grid; justify-items: center; gap: 2px; padding: .5rem .2rem .45rem; font-size: .7rem; color: hsl(var(--muted-foreground)); font-weight: 500; }
  .bottomnav a.active { color: hsl(var(--primary)); font-weight: 650; } .bottomnav a:hover { text-decoration: none; }
}
