/* ─────────────────────────────────────────────────────────────
   app.css — Diseño premium, mobile-first. Marca blanca por dominio
   (--color-primario), modo oscuro y CSP-safe (sin recursos externos).
   ───────────────────────────────────────────────────────────── */

:root {
  --color-primario: #2563eb;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --text: #131722;
  --muted: #5b6472;
  --border: #e6e9f0;
  --error-bg: #fdecec;
  --error-fg: #b42318;

  /* Radios */
  --r-sm: 10px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;
  --radius: 16px;
  /* Alturas de control unificadas */
  --h-md: 48px; --h-sm: 40px;

  /* Sombras en capas + filo de luz superior (inner highlight) */
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --shadow: 0 6px 18px -6px rgba(16,24,40,.16), 0 2px 6px -2px rgba(16,24,40,.08);
  --shadow-lg: 0 24px 50px -16px rgba(16,24,40,.26), 0 8px 18px -10px rgba(16,24,40,.14);
  --hl: inset 0 1px 0 rgba(255,255,255,.65);
  --glow: 0 8px 22px -8px color-mix(in srgb, var(--color-primario) 50%, transparent);
  --ring: 0 0 0 4px color-mix(in srgb, var(--color-primario) 16%, transparent);

  --brand-grad: linear-gradient(135deg, color-mix(in srgb, var(--color-primario) 82%, #ffffff), var(--color-primario));

  /* Iconos (máscara → heredan currentColor, modo oscuro gratis) */
  --i-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M5 4h14a3 3 0 0 1 3 3v7a3 3 0 0 1-3 3H11l-4 3v-3H5a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z'/%3E%3C/svg%3E");
  --i-send: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M2 21l21-9L2 3v7l15 2-15 2v7z'/%3E%3C/svg%3E");
  --i-stop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='6' width='12' height='12' rx='2' fill='%23000'/%3E%3C/svg%3E");
  --i-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M11 4h2v9.2l3.5-3.5 1.4 1.4L12 17l-5.9-5.9 1.4-1.4L11 13.2z'/%3E%3C/svg%3E");
  --i-warn: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' fill-rule='evenodd' d='M12 2 1 21h22L12 2zm0 5a1 1 0 0 1 1 1v6a1 1 0 1 1-2 0V8a1 1 0 0 1 1-1zm0 11a1.2 1.2 0 1 1 0-2.4 1.2 1.2 0 0 1 0 2.4z'/%3E%3C/svg%3E");
  --i-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' fill-rule='evenodd' d='M10 2a8 8 0 1 0 4.9 14.32l5.39 5.4 1.42-1.42-5.4-5.39A8 8 0 0 0 10 2zm0 2a6 6 0 1 1 0 12 6 6 0 0 1 0-12z'/%3E%3C/svg%3E");
  --i-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%235b6472' d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-5 0-9 2.46-9 5.5V22h18v-2.5c0-3.04-4-5.5-9-5.5z'/%3E%3C/svg%3E");
  --i-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%235b6472' fill-rule='evenodd' d='M6 10V8a6 6 0 1 1 12 0v2h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1zm2 0h8V8a4 4 0 1 0-8 0v2z'/%3E%3C/svg%3E");
  --i-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5l8 7-8 7z'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
.is-hidden { display: none !important; }

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

html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", sans-serif;
  font-size: 15px;
  color: var(--text);
  line-height: 1.55;
  letter-spacing: -.006em;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  background: radial-gradient(1100px 460px at 50% -8%, color-mix(in srgb, var(--color-primario) 11%, transparent), transparent 70%), var(--bg);
  background-attachment: fixed;
}
:focus-visible { outline: 2px solid var(--color-primario); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 38%, transparent); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }

/* Sistema de iconos por máscara */
.ico { display: inline-block; flex: 0 0 auto; width: 1.2em; height: 1.2em; background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ico-send { --i: var(--i-send); } .ico-stop { --i: var(--i-stop); } .ico-warn { --i: var(--i-warn); }
.ico-chat { --i: var(--i-chat); } .ico-search { --i: var(--i-search); } .ico-down { --i: var(--i-down); }

/* ── Login ── */
.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-right)); }
.auth__card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg), var(--hl); padding: 34px 28px 30px; position: relative; overflow: hidden;
  animation: pop .4s cubic-bezier(.2,.7,.2,1) both; }
.auth__card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--brand-grad); }
.auth__brand { text-align: center; margin-bottom: 24px; }
.auth__logo { max-height: 64px; max-width: 80%; margin-bottom: 14px; }
.auth__mark { width: 64px; height: 64px; margin: 4px auto 16px; border-radius: 19px;
  background: var(--i-chat) center / 34px no-repeat, var(--brand-grad); -webkit-mask: none; box-shadow: var(--glow); }
.auth__title { font-size: 1.55rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; margin: 0; }
.auth__sub { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }
.auth__form { display: flex; flex-direction: column; gap: 16px; }

/* ── Campos ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field__input {
  width: 100%; min-height: var(--h-md); font-size: 16px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field__input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.field__input:focus { outline: none; border-color: var(--color-primario); box-shadow: var(--ring); }
select.field__input {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%235b6472' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.field__input[type="file"] { padding: 8px 12px; }
.field__input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; font-size: .9rem;
}

/* Checkboxes y switches custom (sin tocar HTML: input + span) */
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: .92rem; color: var(--text); user-select: none; cursor: pointer; }
.check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 22px; height: 22px; margin: 0;
  border: 1.5px solid var(--border); border-radius: 7px; background: var(--surface); cursor: pointer; position: relative;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.check input[type="checkbox"]:hover { border-color: color-mix(in srgb, var(--color-primario) 45%, var(--border)); }
.check input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--ring); }
.check input[type="checkbox"]:checked { background: var(--brand-grad); border-color: transparent; }
.check input[type="checkbox"]:checked::after { content: ""; position: absolute; left: 7px; top: 3px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.guardar-tgl { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: .9rem; color: var(--muted); cursor: pointer; user-select: none; }
.guardar-tgl input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 42px; height: 25px; margin: 0;
  border-radius: 999px; background: color-mix(in srgb, var(--muted) 42%, transparent); position: relative; cursor: pointer;
  transition: background .2s ease;
}
.guardar-tgl input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .22s cubic-bezier(.2,.7,.2,1); }
.guardar-tgl input[type="checkbox"]:checked { background: var(--brand-grad); }
.guardar-tgl input[type="checkbox"]:checked::after { transform: translateX(17px); }
.guardar-tgl input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--ring); }

/* ── Botones (escala unificada) ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--h-md); padding: 12px 18px;
  font-size: .95rem; font-weight: 600; border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer;
  transition: transform .12s ease, box-shadow .15s, background .15s, filter .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.btn--primary { background: var(--brand-grad); color: #fff; box-shadow: var(--glow); }
.btn--primary:hover { filter: brightness(1.05); box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--color-primario) 58%, transparent); }
.btn--primary:active { box-shadow: var(--shadow-sm); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); font-size: .9rem; }
.btn--ghost:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--color-primario) 35%, var(--border)); }
.btn--sm { min-height: var(--h-sm); padding: 8px 14px; font-size: .85rem; }

/* ── Alertas ── */
.alert { border-radius: var(--r-md); padding: 11px 14px; margin: 0 0 16px; font-size: .92rem; border: 1px solid transparent; }
.alert--error { background: var(--error-bg); color: var(--error-fg); border-color: color-mix(in srgb, var(--error-fg) 22%, transparent); }
.alert--ok { background: #e7f7ee; color: #067647; border-color: #b6eccf; }

/* ── Topbar (cristal) ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__logo { max-height: 30px; border-radius: 7px; }
.topbar__title { font-weight: 700; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__logout { margin: 0; }
.topbar__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar__actions .topbar__logout { margin: 0; }
.topbar__back { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem; line-height: 1; text-decoration: none; color: var(--text); border-radius: var(--r-md); margin-left: -6px; }
.topbar__back:hover { background: var(--surface-2); }

/* ── Página / tarjetas ── */
.page { padding: 22px max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.page__title { font-size: 1.4rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; margin: 4px 2px 18px; }
.page__sub { font-size: .8rem; color: var(--muted); margin: 18px 2px 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow), var(--hl); padding: 22px; max-width: 640px; margin: 0 auto; }
.card h1 { margin-top: 0; }
.card__title { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 14px; }
.card + .card { margin-top: 16px; }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sep { border: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--border) 18%, var(--border) 82%, transparent); margin: 18px 0; }

/* Estado vacío reutilizable */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty__icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; color: var(--color-primario); background: color-mix(in srgb, var(--color-primario) 12%, transparent); }
.empty__icon .ico { width: 28px; height: 28px; }
.empty__title { color: var(--text); font-weight: 650; margin: 0 0 4px; }

/* ── Tarjetas de workspace (home) ── */
.ws-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ws-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; text-decoration: none; color: var(--text);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.ws-card::before { content: ""; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 13px; background: var(--i-chat) center / 24px no-repeat, var(--brand-grad); }
.ws-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--color-primario) 40%, var(--border)); }
.ws-card:active { transform: translateY(-1px); }
.ws-card__name { font-weight: 700; flex: 1; min-width: 0; }
.ws-card__desc { color: var(--muted); font-size: .9rem; flex-basis: 100%; order: 3; padding-left: 58px; margin-top: -4px; }
.ws-card__arrow { font-size: 1.6rem; color: color-mix(in srgb, var(--color-primario) 60%, var(--muted)); transition: transform .16s ease; }
.ws-card:hover .ws-card__arrow { transform: translateX(3px); }
.admin-quick { display: flex; flex-direction: column; gap: 10px; }
.admin-quick .ws-card::before { display: none; }

/* ── Chat ── */
.chat { display: flex; flex-direction: column; height: 100dvh; position: relative; }
/* El topbar del chat NO debe ocupar alto: el chat ocupa el viewport completo */
body:has(.chat) { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body:has(.chat) .topbar { position: static; }
body:has(.chat) .chat { flex: 1 1 auto; height: auto; min-height: 0; }

.chat-controls { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 80%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); }
.modo-bar { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.modo-opt { flex: 1; min-height: 40px; font-size: .82rem; font-weight: 650; padding: 8px 6px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; white-space: nowrap; }
.modo-opt:hover:not(.is-active) { color: var(--text); }
.modo-opt.is-active { background: var(--surface); color: var(--color-primario); box-shadow: var(--shadow-sm); }

.chat__scroll { flex: 1; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch;
  background: radial-gradient(700px 280px at 50% 0%, color-mix(in srgb, var(--color-primario) 6%, transparent), transparent 60%), var(--bg); }
.chat__welcome { margin: auto; color: var(--muted); text-align: center; max-width: 320px; animation: pop .4s ease both; }
.chat__welcome-mark { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 18px; background: var(--i-chat) center / 32px no-repeat, var(--brand-grad); box-shadow: var(--glow); }
.chat__welcome-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 0 0 4px; letter-spacing: -.02em; }

.msg { max-width: 86%; padding: 11px 15px; border-radius: 18px; line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere; animation: msgIn .26s ease both; }
.msg--user { align-self: flex-end; background: var(--brand-grad); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg--assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; box-shadow: var(--shadow-sm); }
.msg--error { background: var(--error-bg); color: var(--error-fg); border-color: color-mix(in srgb, var(--error-fg) 22%, transparent); }
.msg--target { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primario) 55%, transparent); }

/* Markdown */
.msg--md p:first-child { margin-top: 0; } .msg--md p:last-child { margin-bottom: 0; }
.msg--md > :first-child { margin-top: 0; } .msg--md > :last-child { margin-bottom: 0; }
.msg--md a { color: var(--color-primario); }
.msg--md h1, .msg--md h2, .msg--md h3 { line-height: 1.25; letter-spacing: -.01em; margin: .8em 0 .4em; }
.msg--md ul, .msg--md ol { padding-left: 1.3em; }
.msg--md pre { background: #0d1117; border: 1px solid #20262f; border-radius: 12px; padding: 14px; overflow-x: auto; font-size: .85rem; margin: .6em 0; position: relative; }
.msg--md pre code.hljs { padding: 0; background: transparent; }
.msg--md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.msg--md :not(pre) > code { background: color-mix(in srgb, var(--color-primario) 10%, var(--surface-2)); color: color-mix(in srgb, var(--color-primario) 70%, var(--text)); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
.msg--md table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; margin: .6em 0; }
.msg--md th, .msg--md td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; white-space: nowrap; }
.msg--md th { background: var(--surface-2); }
.msg--md img { max-width: 100%; height: auto; border-radius: 8px; }
.copy-btn { position: absolute; top: 8px; right: 8px; font-size: .72rem; font-weight: 600; padding: 5px 10px; min-height: 30px;
  border: 1px solid rgba(255,255,255,.16); border-radius: 8px; background: rgba(255,255,255,.08); color: #c9d4e2; cursor: pointer; transition: background .15s, color .15s; }
.copy-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.copy-btn.is-ok { color: #7ee2a8; border-color: rgba(126,226,168,.4); }

/* Cursor de streaming inline */
.stream-cursor { display: inline-block; width: .5em; height: 1.05em; margin-left: 2px; vertical-align: text-bottom; border-radius: 2px; background: var(--color-primario); animation: cursor-blink 1s steps(2) infinite; }

/* Fuentes como chips */
.fuentes { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fuentes__lab { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: 2px; }
.fuente-chip { font-size: .78rem; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

/* "Escribiendo" */
.typing { display: inline-flex; gap: 5px; padding: 3px 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--color-primario); opacity: .5; animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }

.chat__disclaimer { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: .8rem; color: #92500e; background: #fef3c7; padding: 8px 12px; }
.chat__disclaimer .ico { width: 16px; height: 16px; }

.chat__input { display: flex; gap: 10px; align-items: flex-end;
  padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 85%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
.chat__input textarea { flex: 1; resize: none; font-size: 16px; font-family: inherit; line-height: 1.45; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 22px; max-height: 160px; background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s; }
.chat__input textarea:focus { outline: none; border-color: var(--color-primario); box-shadow: var(--ring); }
.chat__send { flex: 0 0 auto; min-height: 48px; min-width: 48px; padding: 0; border-radius: 50%; border: 0;
  background: var(--brand-grad); color: #fff; box-shadow: var(--glow); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: transform .12s, filter .15s, box-shadow .15s; }
.chat__send .ico { width: 22px; height: 22px; }
.chat__send .ico-stop { display: none; }
.chat__send:hover { filter: brightness(1.05); }
.chat__send:active { transform: scale(.94); }
.chat__send:disabled { opacity: .45; box-shadow: none; cursor: default; }
.is-enviando .chat__send { background: var(--surface); color: var(--error-fg); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.is-enviando .chat__send .ico-send { display: none; }
.is-enviando .chat__send .ico-stop { display: inline-block; }

/* FAB bajar al final */
.chat__fab { position: absolute; right: 16px; bottom: 92px; z-index: 30; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--color-primario); box-shadow: var(--shadow);
  cursor: pointer; display: grid; place-items: center; opacity: 0; transform: translateY(8px) scale(.9); pointer-events: none;
  transition: opacity .18s, transform .18s; }
.chat__fab::before { content: ""; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--i-down) center/contain no-repeat; mask: var(--i-down) center/contain no-repeat; }
.chat__fab.is-visible { opacity: 1; transform: none; pointer-events: auto; }

/* Feedback 👍/👎 */
.fb { display: flex; gap: 6px; margin-top: 10px; }
.fb-btn { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--muted); cursor: pointer; opacity: .8;
  transition: opacity .15s, border-color .15s, background .15s, color .15s; }
.fb-btn:hover { opacity: 1; color: var(--text); }
.fb-btn:active { transform: translateY(1px); }
.fb-btn.is-active { opacity: 1; border-color: var(--color-primario); background: color-mix(in srgb, var(--color-primario) 12%, var(--surface)); color: var(--color-primario); }

/* Reintentar */
.retry-btn { display: inline-flex; align-items: center; min-height: var(--h-sm); margin-top: 10px; font-size: .85rem; font-weight: 650;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); cursor: pointer; }
.retry-btn:hover { background: var(--surface-2); }
.retry-btn:active { transform: translateY(1px); }

/* ── Buscador / historial ── */
.buscador { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.buscador__q { width: 100%; min-height: var(--h-md); font-size: 16px; padding: 13px 16px 13px 44px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface) var(--i-search) no-repeat left 14px center / 18px; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.buscador__q:focus { outline: none; border-color: var(--color-primario); box-shadow: var(--ring); }
.buscador__filtros { display: flex; flex-wrap: wrap; gap: 8px; }
.buscador__filtros .field__input { flex: 1; min-width: 130px; min-height: var(--h-md); font-size: 16px; }
.buscador__filtros .btn { flex-basis: 100%; }

.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item-row { display: flex; align-items: stretch; gap: 8px; }
.item-row form { display: flex; }
.item { flex: 1; display: block; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
  text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s; }
.item:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--color-primario) 30%, var(--border)); }
.item__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.item__date { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.item__title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__snippet { font-size: .88rem; color: var(--muted); margin-top: 4px; }
.item__snippet mark { background: #fde68a; color: #14161a; padding: 0 2px; border-radius: 3px; }
.item__rol { font-weight: 650; color: var(--text); }
.item__meta { font-size: .8rem; margin-top: 2px; }
.badge { font-size: .72rem; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--color-primario) 14%, var(--surface)); color: var(--color-primario); }
.btn-borrar { min-height: var(--h-sm); min-width: 44px; display: inline-flex; align-items: center; justify-content: center; height: 100%;
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); padding: 0 14px; font-size: 1.05rem; cursor: pointer; color: var(--error-fg);
  transition: background .15s, border-color .15s; }
.btn-borrar:hover { background: var(--error-bg); border-color: color-mix(in srgb, var(--error-fg) 30%, var(--border)); }
.btn-borrar:active { transform: translateY(1px); }
.paginacion { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }

/* ── Cuenta ── */
.form-vert { display: flex; flex-direction: column; gap: 14px; }
.consumo { display: flex; flex-direction: column; gap: 18px; }
.consumo__cab { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 7px; font-weight: 650; }
.consumo__cab .muted { font-weight: 400; font-size: .85rem; font-variant-numeric: tabular-nums; }
.barra { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.06); }
.barra__fill { height: 100%; background: var(--brand-grad); border-radius: 999px; transition: width .4s cubic-bezier(.2,.7,.2,1); }

/* Banner sin conexión */
.netbar { position: fixed; left: 0; right: 0; top: 0; z-index: 1000; background: #b42318; color: #fff; text-align: center; font-size: .85rem; font-weight: 600; padding: 7px 12px; transform: translateY(-100%); transition: transform .25s; padding-top: max(7px, env(safe-area-inset-top)); }
.netbar.is-visible { transform: translateY(0); }

/* ── Admin ── */
.adminnav { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch; position: sticky; top: 56px; z-index: 40; }
.adminnav__item { white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; padding: 9px 15px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 650; font-size: .9rem; transition: background .15s, color .15s; }
.adminnav__item:hover { background: var(--surface-2); color: var(--text); }
.adminnav__item.is-active { background: var(--brand-grad); color: #fff; box-shadow: var(--glow); }

.admin.page { max-width: 1000px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; text-align: center; box-shadow: var(--shadow-sm), var(--hl); transition: transform .15s, box-shadow .15s; }
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-box__n { display: block; font-size: 2rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-box__l { display: block; font-size: .8rem; color: var(--muted); margin-top: 2px; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.field--full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.inline-form .field__input { flex: 1; min-width: 200px; }
.chk-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
fieldset.field { border: 0; padding: 0; margin: 0; }

.tabla-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th, .tabla td { text-align: left; padding: 10px 11px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tabla th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
.tabla tbody tr { transition: background .12s; }
.tabla tbody tr:hover { background: var(--surface-2); }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla .nowrap { white-space: nowrap; }
.tabla code { font-size: .85em; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.acciones { display: flex; gap: 8px; align-items: center; white-space: nowrap; }

.pill { font-size: .72rem; font-weight: 650; padding: 3px 9px; border-radius: 999px; }
.pill--ok { background: #e7f7ee; color: #067647; }
.pill--off { background: #f1f3f5; color: var(--muted); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin-right: 6px; border: 1px solid var(--border); }
.logo-preview { max-height: 48px; max-width: 160px; border-radius: 8px; }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.chart__col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.chart__bar { width: 100%; background: var(--brand-grad); border-radius: 4px 4px 0 0; min-height: 3px; transition: opacity .15s; }
.chart__col:hover .chart__bar { opacity: .75; }

.rank { margin-bottom: 14px; }
.rank__cab { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 5px; font-weight: 600; }
.cols-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
/* Admin: columna de contenido unificada a 880px (títulos, rejillas y tarjetas
   alineados). Antes la página medía 1000px pero las tarjetas 880px centradas. */
.admin.page { max-width: 880px; }
.admin .card { max-width: none; margin: 0; }
.admin .cols-2, .admin .stat-grid, .admin .admin-quick { max-width: none; margin: 0; }
.admin .cols-2 .card { max-width: none; margin: 0; }

.fbneg { padding: 12px 0; border-bottom: 1px solid var(--border); }
.fbneg__txt { font-size: .9rem; margin-top: 4px; }

.audit-msg { padding: 12px 0; border-bottom: 1px solid var(--border); }
.audit-msg__rol { font-weight: 650; font-size: .85rem; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.audit-msg--user .audit-msg__rol { color: var(--color-primario); }
.audit-msg__txt { font-size: .92rem; word-wrap: break-word; overflow-wrap: anywhere; }

/* ── Avatar del asistente ── */
.msg--assistant { position: relative; margin-left: 44px; max-width: calc(100% - 52px); }
.msg--assistant::before { content: ""; position: absolute; left: -44px; top: 0; width: 34px; height: 34px; border-radius: 11px;
  background: var(--i-chat) center / 19px no-repeat, var(--brand-grad); box-shadow: var(--shadow-sm); }

/* ── Razonamiento del modelo (plegable) ── */
.think { margin: 0 0 10px; }
.think-head { display: inline-flex; align-items: center; gap: 7px; padding: 3px 2px; margin: 0; background: none;
  border: 0; cursor: pointer; color: var(--muted); font: italic 600 .85rem/1.2 inherit; font-family: inherit; }
.think-head:hover { color: var(--text); }
.think.is-thinking .think-head { cursor: default; }
.think-label { letter-spacing: .01em; }
.think.is-thinking .think-label { animation: thinkPulse 1.3s ease-in-out infinite; }
.think-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; opacity: .5; }
.think.is-thinking .think-dot { background: var(--color-primario); opacity: 1; animation: thinkPulse 1.1s ease-in-out infinite; }
.think-chev { width: 11px; height: 11px; flex: none; background: currentColor; opacity: .65; transition: transform .18s ease;
  -webkit-mask: var(--i-chevron) center / contain no-repeat; mask: var(--i-chevron) center / contain no-repeat; }
.think.is-thinking .think-chev { display: none; }
.think.is-open .think-chev { transform: rotate(90deg); }
.think-body { max-height: 0; overflow: hidden; opacity: 0; transition: max-height .28s ease, opacity .2s ease;
  font-size: .82rem; line-height: 1.55; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
/* Mientras piensa: el razonamiento se ve en vivo, recortado a ~3 líneas con desvanecido superior. */
.think.is-thinking .think-body { max-height: 4.7em; opacity: 1; overflow: hidden; margin-top: 6px; padding-left: 12px;
  border-left: 2px solid var(--border); transition: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.6em);
          mask-image: linear-gradient(to bottom, transparent 0, #000 1.6em); }
.think.is-open .think-body { max-height: 420px; overflow-y: auto; opacity: 1; margin-top: 7px; padding: 2px 0 2px 12px;
  border-left: 2px solid var(--border); }

/* ── Chips de sugerencia (bienvenida) ── */
.sugger { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip-sug { font-size: .85rem; font-weight: 600; padding: 9px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .14s, box-shadow .14s, border-color .14s, background .14s; }
.chip-sug:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--color-primario) 40%, var(--border)); }
.chip-sug:active { transform: translateY(0); }

/* ── Bloque de código con cabecera ── */
.code-block { border: 1px solid #20262f; border-radius: 12px; overflow: hidden; margin: .7em 0; }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px 7px 14px;
  background: #161b22; border-bottom: 1px solid #20262f; }
.code-lang { font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: #8b98a9; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-block .copy-btn { position: static; top: auto; right: auto; }
.code-block pre { border: 0; border-radius: 0; margin: 0; }

/* ── Spinner de carga en botones ── */
.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: #fff; animation: spin .6s linear infinite; }
.btn--ghost.is-loading::after { border-top-color: var(--color-primario); }

/* ── Entrada escalonada de listas ── */
.ws-list > li, .lista > li { animation: msgIn .42s cubic-bezier(.2,.7,.2,1) both; }
.ws-list > li:nth-child(2), .lista > li:nth-child(2) { animation-delay: .05s; }
.ws-list > li:nth-child(3), .lista > li:nth-child(3) { animation-delay: .1s; }
.ws-list > li:nth-child(4), .lista > li:nth-child(4) { animation-delay: .15s; }
.ws-list > li:nth-child(5), .lista > li:nth-child(5) { animation-delay: .2s; }
.ws-list > li:nth-child(n+6), .lista > li:nth-child(n+6) { animation-delay: .25s; }
.stat-box { animation: pop .4s ease both; }
.stat-box:nth-child(2) { animation-delay: .05s; } .stat-box:nth-child(3) { animation-delay: .1s; }
.stat-box:nth-child(4) { animation-delay: .15s; } .stat-box:nth-child(5) { animation-delay: .2s; }

/* ── Alertas con entrada ── */
.alert { animation: slideDown .3s ease both; }

/* ── Iconos del login en los campos ── */
.auth__form input[name="nombre"], .auth__form input[name="password"] { padding-left: 42px; background-repeat: no-repeat; background-position: left 14px center; background-size: 18px; }
.auth__form input[name="nombre"] { background-image: var(--i-user); }
.auth__form input[name="password"] { background-image: var(--i-lock); }

/* ── Barras de consumo por umbral ── */
.barra__fill.is-warn { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.barra__fill.is-full { background: linear-gradient(135deg, #f87171, #ef4444); }

/* ════════ Pulido UX (ronda 2) ════════ */
/* Evita que el pull-to-refresh del móvil recargue y mate el streaming. */
.chat__scroll { overscroll-behavior: contain; }
body:has(.chat) { overscroll-behavior: none; }

/* Zonas táctiles ≥44px y respuesta de tap inmediata (sin retardo de 300ms). */
.modo-opt { min-height: 44px; font-size: .85rem; }
.fb-btn { min-height: 44px; min-width: 44px; }
.check { min-height: 44px; }
.chat__send, .fb-btn, .copy-btn, .modo-opt, .chip-sug, .retry-btn, .chat__fab, .think-head { touch-action: manipulation; }

/* Foco visible accesible (WCAG 2.4.7) — anillo doble a prueba de marca blanca
   (no se confunde con el borde del botón aunque sea del color primario). */
.btn:focus-visible, .modo-opt:focus-visible, .adminnav__item:focus-visible,
.fb-btn:focus-visible, .copy-btn:focus-visible, .chip-sug:focus-visible,
.retry-btn:focus-visible, .think-head:focus-visible, .chat__fab:focus-visible,
.chat__send:focus-visible, .ws-card:focus-visible, .item:focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--color-primario);
}

/* Burbuja de error con icono de aviso. */
.msg--error { display: flex; align-items: flex-start; gap: 9px; }
.msg--error__ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.msg--error__txt { flex: 1; }

/* Aviso de envío sin conexión (sacude el campo). */
.chat__input textarea.shake { animation: shake .4s; }

/* Bloque de código: pista visual de scroll horizontal a la derecha. */
.code-block { position: relative; }
.code-block pre { -webkit-overflow-scrolling: touch; }
.code-block::after { content: ""; position: absolute; top: 38px; right: 0; bottom: 0; width: 24px; pointer-events: none;
  background: linear-gradient(90deg, transparent, #0d1117); border-radius: 0 0 12px 0; }

/* Utilidad solo-lector (anuncios a lectores de pantalla, sin afectar al layout). */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,1px); white-space: nowrap; border: 0; }

/* Aviso contextual (p. ej. precios sin configurar en coste). */
.notice { display: flex; gap: 8px; align-items: baseline; border-radius: var(--r-md); padding: 10px 13px;
  margin: 0 0 12px; font-size: .88rem; border: 1px solid #fde68a; background: #fef3c7; color: #92500e; }
.notice a { color: inherit; font-weight: 650; text-decoration: underline; }

/* Badges de acción en la tabla de logs (escaneo rápido). */
.badge--danger { background: #fde8e8; color: #b42318; }
.badge--ok { background: #e7f7ee; color: #067647; }
.badge--mut { background: var(--surface-2); color: var(--muted); }
.badge--info { background: color-mix(in srgb, var(--color-primario) 14%, var(--surface-2)); color: color-mix(in srgb, var(--color-primario) 75%, var(--text)); }

/* Eje de la gráfica de consultas por día. */
.chart__axis { display: flex; justify-content: space-between; margin-top: 6px; }

/* Celda "detalle" de logs: truncada con elipsis (el completo va en title=""). */
.celda-detalle { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-color-scheme: dark) {
  .notice { background: #3a2e12; color: #fcd34d; border-color: #5a4715; }
  .badge--danger { background: #3a1c1c; color: #f7a3a3; }
  .badge--ok { background: #14331f; color: #86efac; }
}

/* ── Animaciones ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes thinkPulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes typing { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes cursor-blink { 50% { opacity: 0; } }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

/* ── Escritorio ── */
@media (min-width: 768px) {
  .auth__card { padding: 40px 36px 36px; }
  .page { max-width: 780px; margin: 0 auto; }
  .cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .chat { max-width: 860px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  body:has(.chat) .chat { margin: 0 auto; }
  .buscador__filtros .btn { flex-basis: auto; }
  .copy-btn { opacity: 0; transition: opacity .15s; }
  .msg--md pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────
   Modo oscuro (al final, gana por orden de cascada).
   ───────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e13; --surface: #161922; --surface-2: #1e222c; --text: #e9ebf0; --muted: #99a1ad; --border: #2b313d;
    --error-bg: #3a1c1c; --error-fg: #f7a3a3;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 8px 22px -8px rgba(0,0,0,.6); --shadow-lg: 0 28px 60px -18px rgba(0,0,0,.7);
    --hl: inset 0 1px 0 rgba(255,255,255,.04);
  }
  body { background: radial-gradient(1100px 460px at 50% -8%, color-mix(in srgb, var(--color-primario) 22%, transparent), transparent 70%), var(--bg); }
  .field__input, .buscador__q, .chat__input textarea, .modo-bar, .check input[type="checkbox"] { background-color: #0f131a; }
  .buscador__q { background-color: #0f131a; }
  select.field__input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%2399a1ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
  .modo-opt.is-active { background: var(--surface); }
  .fb-btn, .btn-borrar, .btn--ghost, .retry-btn, .stat-box, .item, .ws-card, .card, .fuente-chip, .chip-sug, .field__input[type="file"]::file-selector-button { background: var(--surface); color: var(--text); }
  .auth__form input[name="nombre"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2399a1ad' d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-5 0-9 2.46-9 5.5V22h18v-2.5c0-3.04-4-5.5-9-5.5z'/%3E%3C/svg%3E"); }
  .auth__form input[name="password"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2399a1ad' fill-rule='evenodd' d='M6 10V8a6 6 0 1 1 12 0v2h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1zm2 0h8V8a4 4 0 1 0-8 0v2z'/%3E%3C/svg%3E"); }
  .fb-btn { color: var(--muted); }
  .badge { background: color-mix(in srgb, var(--color-primario) 26%, transparent); color: color-mix(in srgb, var(--color-primario) 45%, #ffffff); }
  .tabla th, .tabla code, .msg--md :not(pre) > code { background: var(--surface-2); }
  .pill--ok { background: #14331f; color: #86efac; } .pill--off { background: #2b313d; color: var(--muted); }
  .alert--ok { background: #11331f; color: #86efac; border-color: #1d5236; }
  .chat__disclaimer { background: #3a2e12; color: #fcd34d; }
  .item__snippet mark { background: #b58900; color: #14161a; }
  .stat-box__n { background: linear-gradient(135deg, color-mix(in srgb, var(--color-primario) 55%, #fff), var(--color-primario)); -webkit-background-clip: text; background-clip: text; }
}
