/* MR LUX IA — tokens y componentes. Un acento, neutros con matiz frio, radio 6px. */
:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #f0f2f4;
  --border: #dde1e5;
  --border-strong: #c5cbd1;
  --text: #15191d;
  --text-2: #56606a;
  --text-3: #7d8790;
  --accent: #0f766e;
  --accent-hover: #0b5f58;
  --accent-soft: #e2f3f1;
  --on-accent: #ffffff;
  --ok: #15803d;
  --warn: #a16207;
  --err: #b91c1c;
  --err-soft: #fdecec;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-pop: 0 8px 24px rgba(16, 24, 32, 0.12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1214;
    --surface: #161a1d;
    --surface-2: #1d2226;
    --border: #2a3136;
    --border-strong: #3a434a;
    --text: #e4e8eb;
    --text-2: #a2acb4;
    --text-3: #7a848c;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: #10302d;
    --on-accent: #06201d;
    --ok: #4ade80;
    --warn: #facc15;
    --err: #f87171;
    --err-soft: #3a1717;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
.hidden { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: 36px; padding: 0 var(--s4); border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 14px var(--font); cursor: pointer; transition: background 150ms, border-color 150ms; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 var(--s3); font-size: 13px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: var(--s1); }
.field label { font-weight: 600; font-size: 13px; }
.field .help { font-size: 12px; color: var(--text-3); }
input, select, textarea { width: 100%; height: 36px; padding: 0 var(--s3); border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font: 14px var(--font); }
textarea { height: auto; padding: var(--s2) var(--s3); resize: vertical; line-height: 1.5; }
.check { display: flex; gap: var(--s2); align-items: flex-start; font-size: 13px; }
.check input { width: 16px; height: 16px; margin-top: 2px; }
.form { display: flex; flex-direction: column; gap: var(--s4); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.alert { padding: var(--s3) var(--s4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.alert.err { border-color: var(--err); background: var(--err-soft); color: var(--err); }
.alert.ok { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

/* Layout de la app */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: var(--s4) var(--s3); display: flex; flex-direction: column; gap: var(--s5); position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s2); font-weight: 600; font-size: 16px; color: var(--text); }
.brand .mark { width: 24px; height: 24px; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .label { font-size: 12px; color: var(--text-3); padding: var(--s3) var(--s2) var(--s1); font-weight: 600; }
.nav a { display: flex; align-items: center; gap: var(--s3); height: 36px; padding: 0 var(--s2); border-radius: var(--radius); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav a.active svg { color: var(--accent); }
.side .foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) var(--s2) 0; border-top: 1px solid var(--border); }
.main { min-width: 0; }
.topbar { display: none; }
.page { max-width: 1120px; margin: 0 auto; padding: var(--s6) var(--s6) var(--s8); display: flex; flex-direction: column; gap: var(--s5); }
.page > * { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.page-head p { margin-top: var(--s1); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card > .hd { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.card > .bd { padding: var(--s5); }
.card > .bd.flush { padding: 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s1); }
.stat .k { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v.accent { color: var(--accent); }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.md td { white-space: normal; }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
.empty { padding: var(--s7) var(--s5); text-align: center; color: var(--text-2); display: flex; flex-direction: column; gap: var(--s3); align-items: center; }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--s2); border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.ok { color: var(--ok); }
.badge.err { color: var(--err); }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* Grafico de barras */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: var(--s2); }
.bars .b { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: 0.85; position: relative; }
.bars .b:hover { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; margin-top: var(--s2); }

/* Bloques de codigo */
pre.code { margin: 0; padding: var(--s4); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; line-height: 1.55; white-space: pre; }
.copyable { position: relative; }
.copyable .btn { position: absolute; top: var(--s2); right: var(--s2); }
.keybox { display: flex; gap: var(--s2); align-items: center; padding: var(--s3); background: var(--surface-2); border: 1px solid var(--accent); border-radius: var(--radius); font-family: var(--mono); word-break: break-all; }
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: var(--s2) var(--s3); font: 500 13px var(--font); color: var(--text-2); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* Dialogo */
.overlay { position: fixed; inset: 0; background: rgba(10, 14, 18, 0.45); display: grid; place-items: center; padding: var(--s4); z-index: 50; }
.dialog { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); }
.dialog .hd { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.dialog .bd { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.dialog .ft { padding: var(--s3) var(--s5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--s2); }

.toast { position: fixed; bottom: var(--s5); right: var(--s5); background: var(--text); color: var(--bg); padding: var(--s3) var(--s4); border-radius: var(--radius); font-size: 13px; box-shadow: var(--shadow-pop); z-index: 60; max-width: 360px; }
.toast.err { background: var(--err); color: #fff; }

/* Chat */
.chat { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }
.chat-list { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.chat-list .top { padding: var(--s3); border-bottom: 1px solid var(--border); }
.chat-list .items { overflow-y: auto; padding: var(--s2); display: flex; flex-direction: column; gap: 2px; }
.chat-list .item { display: flex; align-items: center; gap: var(--s2); padding: var(--s2); border-radius: var(--radius); color: var(--text-2); cursor: pointer; font-size: 13px; }
.chat-list .item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list .item:hover { background: var(--surface-2); color: var(--text); }
.chat-list .item.on { background: var(--accent-soft); color: var(--text); }
.chat-list .item .del { opacity: 0; }
.chat-list .item:hover .del { opacity: 1; }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { height: 52px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s5); gap: var(--s3); background: var(--surface); }
.msgs { flex: 1; overflow-y: auto; }
.msgs-inner { max-width: 760px; margin: 0 auto; padding: var(--s5) var(--s5) var(--s6); display: flex; flex-direction: column; gap: var(--s5); }
.msg { display: flex; flex-direction: column; gap: var(--s1); }
.msg .who { font-size: 12px; font-weight: 600; color: var(--text-3); }
.msg.user .body { background: var(--surface-2); border: 1px solid var(--border); padding: var(--s3) var(--s4); border-radius: var(--radius-lg); align-self: flex-start; max-width: 100%; white-space: pre-wrap; word-wrap: break-word; }
.msg .body { font-size: 15px; line-height: 1.65; word-wrap: break-word; }
.md p { margin: 0 0 var(--s3); }
.md p:last-child { margin-bottom: 0; }
.md pre { margin: var(--s3) 0; padding: var(--s3) var(--s4); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.md code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md ul, .md ol { margin: 0 0 var(--s3); padding-left: var(--s5); }
.md h1, .md h2, .md h3 { margin: var(--s4) 0 var(--s2); font-size: 16px; }
.md blockquote { margin: 0 0 var(--s3); padding-left: var(--s3); border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md table { margin: var(--s3) 0; }
.md td, .md th { padding: var(--s2) var(--s3); border: 1px solid var(--border); }
.cursor::after { content: ""; display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.composer { border-top: 1px solid var(--border); background: var(--surface); padding: var(--s3) var(--s5) var(--s4); }
.composer-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s2); }
.composer-box { display: flex; gap: var(--s2); align-items: flex-end; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: var(--s2); background: var(--bg); }
.composer-box:focus-within { border-color: var(--accent); }
.composer textarea { border: 0; background: transparent; max-height: 240px; min-height: 36px; padding: var(--s2); resize: none; }
.composer textarea:focus-visible { outline: none; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text-2); font: 500 12px var(--font); padding: 0 var(--s3); height: 28px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent-soft); color: var(--text); }

/* Paginas publicas */
.pub-nav { max-width: 1120px; margin: 0 auto; padding: var(--s4) var(--s5); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.pub { max-width: 1120px; margin: 0 auto; padding: 0 var(--s5) var(--s8); display: flex; flex-direction: column; gap: var(--s7); }
.hero { padding: var(--s7) 0 var(--s4); display: grid; grid-template-columns: 1.1fr 1fr; gap: var(--s6); align-items: center; }
.hero h1 { font-size: 40px; letter-spacing: -0.02em; }
.hero p.lead { font-size: 16px; color: var(--text-2); margin-top: var(--s4); max-width: 52ch; }
.hero .row { margin-top: var(--s5); }
.specs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.specs > div { padding: var(--s4) var(--s5); border-right: 1px solid var(--border); }
.specs > div:last-child { border-right: 0; }
.specs .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.section h2 { margin-bottom: var(--s2); }
.section > p { color: var(--text-2); margin-bottom: var(--s5); max-width: 65ch; }
.two > *, .hero > *, .pub > *, .stats > * { min-width: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s5) var(--s4); }
.auth { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--s5); }
.legal { max-width: 720px; }
.legal h2 { margin: var(--s5) 0 var(--s2); font-size: 16px; }
.legal p, .legal li { color: var(--text-2); margin-bottom: var(--s2); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: var(--s5); }
  .hero h1 { font-size: 32px; }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform 180ms; }
  .side.open { transform: none; box-shadow: var(--shadow-pop); }
  .topbar { display: flex; align-items: center; gap: var(--s3); height: 52px; padding: 0 var(--s4); border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30; }
  .page { padding: var(--s5) var(--s4) var(--s7); }
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 52px); }
  .chat-list { display: none; }
  .chat-list.open { display: flex; position: fixed; inset: 52px 0 0 0; z-index: 35; }
  .chat-head { padding: 0 var(--s4); }
  .msgs-inner, .composer { padding-left: var(--s4); padding-right: var(--s4); }
  .specs { grid-template-columns: 1fr; }
  .specs > div { border-right: 0; border-bottom: 1px solid var(--border); }
  .specs > div:last-child { border-bottom: 0; }
  .stat .v { font-size: 20px; }
  .card > .bd { padding: var(--s4); }
  .card > .hd { padding: var(--s3) var(--s4); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
