:root {
  --bg: #f7f6f3; --panel: #ffffff; --side: #efede8; --line: #e2dfd8; --text: #1f1e1c; --muted: #6b6862; --faint: #9a968e;
  --accent: #0f766e; --accent-2: #14b8a6; --accent-soft: #e3f4f1; --danger: #b42318; --danger-soft: #fdecea; --warn: #9a6700; --warn-soft: #fff6dc;
  --user: #ebe8e1; --code: #f2f0eb; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 14px; --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1c1b19; --panel: #252421; --side: #161513; --line: #36342f; --text: #ecebe7; --muted: #a8a49b; --faint: #7a766e;
    --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: #163a36; --danger: #ff7b72; --danger-soft: #3a1d1b; --warn: #e3b341; --warn-soft: #33290f;
    --user: #2f2d29; --code: #1a1917; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); }
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ── Login ── */
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); outline: none; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field small { color: var(--faint); font-size: 12px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #062420; } }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 8px; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .2px; }
.logo img { width: 26px; height: 26px; border-radius: 7px; }

/* ── Layout ── */
.shell { display: grid; grid-template-columns: 272px 1fr; height: 100%; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 10px; }
.side-top .row { display: flex; align-items: center; justify-content: space-between; }
.newchat { justify-content: flex-start; width: 100%; background: var(--panel); }
.ws-select { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.convs { flex: 1; overflow: auto; padding: 4px 8px 12px; }
.convs h4 { font-size: 12px; font-weight: 600; color: var(--faint); margin: 14px 8px 4px; text-transform: uppercase; letter-spacing: .5px; }
.conv { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 9px; color: var(--text); text-decoration: none; font-size: 14px; cursor: pointer; }
.conv span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv:hover { background: rgba(0,0,0,.05); }
@media (prefers-color-scheme: dark) { .conv:hover { background: rgba(255,255,255,.05); } }
.conv.active { background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.conv .x { opacity: 0; border: 0; background: none; color: var(--faint); padding: 0 4px; }
.conv:hover .x { opacity: 1; }
.side-bottom { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.navbtn { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 9px; display: flex; gap: 8px; align-items: center; color: var(--text); }
.navbtn:hover { background: rgba(0,0,0,.05); }
.me { font-size: 13px; color: var(--muted); padding: 4px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.status-dot.ok { background: #16a34a; } .status-dot.warn { background: #d97706; } .status-dot.bad { background: var(--danger); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar { display: none; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.scroll { flex: 1; overflow: auto; }
.thread { max-width: 800px; margin: 0 auto; padding: 28px 24px 24px; }
.empty { max-width: 720px; margin: 12vh auto 0; padding: 0 24px; text-align: center; }
.empty h2 { font: 500 32px/1.25 var(--serif); margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 0 26px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px; font-size: 14px; color: var(--muted); }
.chip:hover { color: var(--text); border-color: var(--faint); }

.msg { margin-bottom: 26px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--user); border-radius: 18px 18px 4px 18px; padding: 10px 16px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant .body { font-size: 15.5px; }
.prose p { margin: 0 0 12px; }
.prose h2, .prose h3, .prose h4 { font-family: var(--serif); margin: 18px 0 8px; line-height: 1.3; }
.prose h2 { font-size: 22px; } .prose h3 { font-size: 19px; } .prose h4 { font-size: 17px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 24px; }
.prose li { margin: 3px 0; } .prose li.sub { margin-left: 18px; list-style-type: circle; }
.prose code { font-family: var(--mono); font-size: 13px; background: var(--code); padding: 1px 5px; border-radius: 5px; }
.prose pre { position: relative; background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow: auto; margin: 0 0 12px; }
.prose pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; }
.prose pre .copy { position: absolute; top: 6px; right: 6px; font-size: 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 2px 8px; opacity: 0; }
.prose pre:hover .copy { opacity: 1; }
.prose blockquote { margin: 0 0 12px; padding: 2px 14px; border-left: 3px solid var(--line); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.tablewrap { overflow: auto; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--code); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }
.cursor::after { content: ''; display: inline-block; width: 8px; height: 16px; background: var(--accent); margin-left: 2px; vertical-align: -3px; animation: blink 1s steps(2) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* Herramientas */
.tool { border: 1px solid var(--line); border-radius: 12px; margin: 8px 0 12px; background: var(--panel); overflow: hidden; font-size: 13.5px; }
.tool > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: var(--muted); }
.tool > summary::-webkit-details-marker { display: none; }
.tool > summary .name { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.tool > summary .srv { font-size: 12px; color: var(--faint); }
.tool > summary .st { margin-left: auto; font-size: 12px; }
.tool .ico { width: 16px; height: 16px; display: inline-grid; place-items: center; }
.tool .detail { border-top: 1px solid var(--line); padding: 8px 12px 10px; }
.tool .detail h5 { margin: 6px 0 4px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .5px; }
.tool .detail pre { margin: 0; font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto; background: var(--code); padding: 8px 10px; border-radius: 8px; }
.tool.err > summary .st { color: var(--danger); }
.spin { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.approval { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 12px; padding: 12px 14px; margin: 8px 0 12px; font-size: 14px; }
.approval b { font-family: var(--mono); font-size: 13px; }
.approval pre { font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; background: var(--panel); border-radius: 8px; padding: 8px 10px; max-height: 220px; overflow: auto; margin: 8px 0; }
.approval .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--faint); }
.meta .tag { border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.cites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cite { font-size: 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 3px 8px; color: var(--muted); text-decoration: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cite:hover { color: var(--text); }
.notice { font-size: 13px; color: var(--muted); background: var(--code); border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
.notice.err { color: var(--danger); background: var(--danger-soft); }
.thinking { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }

/* Composer */
.composer-wrap { padding: 0 24px 18px; }
.composer { max-width: 800px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 10px 10px 8px 16px; }
.composer.drag { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { width: 100%; border: 0; outline: none; resize: none; background: none; max-height: 240px; min-height: 26px; padding: 4px 0; line-height: 1.5; }
.composer .bar { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.composer .bar .grow { flex: 1; font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; color: var(--muted); }
.iconbtn:hover { color: var(--text); }
.send { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; }
.send:disabled { opacity: .35; cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }
.hint { text-align: center; font-size: 12px; color: var(--faint); margin-top: 8px; }

/* Panel lateral derecho */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 20; transform: translateX(100%); transition: transform .2s ease; }
.drawer.open { transform: none; }
.drawer header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer header h3 { margin: 0; font: 600 18px var(--serif); flex: 1; }
.drawer .tabs { display: flex; gap: 4px; padding: 8px 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.drawer .tabs button { border: 0; background: none; padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); }
.drawer .tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.drawer .content { flex: 1; overflow: auto; padding: 16px 18px 40px; }
.drawer h4 { margin: 18px 0 8px; font-size: 14px; }
.drawer h4:first-child { margin-top: 0; }
.list { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.item:last-child { border-bottom: 0; }
.item .main-col { flex: 1; min-width: 0; }
.item .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 11px; border-radius: 999px; padding: 2px 8px; background: var(--code); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); } .badge.bad { background: var(--danger-soft); color: var(--danger); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); margin-bottom: 14px; }
.drop.on { border-color: var(--accent); background: var(--accent-soft); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.toolnames { font: 12px/1.6 var(--mono); color: var(--muted); max-height: 200px; overflow: auto; background: var(--code); border-radius: 8px; padding: 8px 10px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 15; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .topbar { display: flex; }
  .thread { padding: 18px 16px; }
  .composer-wrap { padding: 0 10px 10px; }
}

/* ── Acceso (diseño de omni-rag v1) ── */
.v1-login-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Inter', ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: #f3f4f6;
  background: linear-gradient(rgba(11, 15, 25, .82), rgba(11, 15, 25, .88)), url('/img/fondo.jpg') center/cover no-repeat, #0b0f19; }
.v1-login-card { background: #111827; border: 1px solid #374151; border-radius: 10px; padding: 40px; width: 420px; box-shadow: 0 4px 12px rgba(0,0,0,.35); }
.v1-login-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.v1-login-logo { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; box-shadow: 0 6px 18px rgba(13, 95, 89, .45); }
.wordmark { letter-spacing: .5px; }
.wordmark b { font-weight: 700; }
.wordmark span { font-weight: 300; color: #5eead4; }
.v1-login-brand h1 { margin: 0; font-size: 22px; font-weight: 600; color: #f3f4f6; }
.v1-login-brand p { margin: 4px 0 0; color: #9ca3af; font-size: 13px; }
.v1-field { margin-bottom: 16px; }
.v1-field label { display: block; margin-bottom: 6px; color: #9ca3af; font-size: 13px; font-weight: 500; }
.v1-field input { width: 100%; padding: 10px 12px; background: #1f2937; border: 1px solid #374151; border-radius: 8px; color: #f3f4f6; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
.v1-field input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.25); }
.v1-field input::placeholder { color: #6b7280; }
.v1-login-error { color: #ef4444; font-size: 13px; min-height: 20px; margin: 0 0 8px; }
.v1-btn { display: block; width: 100%; text-align: center; padding: 11px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.v1-btn-primary { background: #3b82f6; color: #fff; }
.v1-btn-primary:hover { background: #2563eb; }
.v1-btn-primary:disabled { opacity: .6; cursor: default; }
.v1-btn-ghost { margin-top: 16px; background: transparent; border-color: #374151; color: #f3f4f6; font-weight: 500; }
.v1-btn-ghost:hover { background: #1f2937; }
.v1-login-footer { text-align: center; color: #9ca3af; font-size: 12px; margin: 24px 0 0; }
@media (max-width: 1024px) { .v1-login-card { width: 92%; max-width: 420px; padding: 28px; } }
@media (max-width: 600px) { .v1-login-card { width: 92%; max-width: 380px; padding: 24px; } .v1-login-brand h1 { font-size: 20px; } }
.field input[type=checkbox] { width: auto; margin: 0; accent-color: var(--accent); }

/* ── Gráficas (```chart) e imágenes en las respuestas ── */
.chartwrap { position: relative; margin: 4px 0 16px; padding: 10px 10px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); max-width: 680px; }
.chartwrap.pending { color: var(--muted); font-size: 13px; padding: 18px; }
.chartwrap .chartdata { position: absolute; top: 8px; right: 8px; opacity: 0; }
.chartwrap:hover .chartdata { opacity: 1; }
svg.chart { width: 100%; height: auto; display: block; font-family: var(--font); }
svg.chart .ct { font-size: 14px; font-weight: 600; fill: var(--text); }
svg.chart .ca { font-size: 11px; fill: var(--muted); }
svg.chart .cl { font-size: 12px; fill: var(--text); }
svg.chart .cv { font-size: 15px; font-weight: 600; fill: var(--text); }
svg.chart .cv2 { font-size: 10.5px; fill: var(--muted); }
svg.chart .cg { stroke: var(--line); stroke-width: 1; }
svg.chart .c0 { stroke: var(--faint); stroke-width: 1; }
svg.chart rect:hover, svg.chart path:hover { opacity: .85; }
.msg img.mdimg { max-width: min(100%, 520px); max-height: 420px; border-radius: 10px; border: 1px solid var(--line); display: block; margin: 6px 0 12px; }
.cite.img { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 2px; }
.cite.img img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }
.attach-thumbs { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 0 6px; }
.attach-thumbs .th { position: relative; }
.attach-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.attach-thumbs button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 9px; border: 0; background: var(--text); color: var(--bg); font-size: 11px; line-height: 18px; padding: 0; cursor: pointer; }
.msg.user img.uimg { max-width: 220px; max-height: 160px; border-radius: 8px; display: block; margin-bottom: 6px; }

/* ── Búsqueda en documentos, lotes, biblioteca y compartición ── */
.searchbox { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; position: relative; }
.searchbox .sico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); display: flex; }
.searchbox input { padding-left: 32px !important; flex: 1; margin: 0 !important; }
.hit { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: var(--panel); }
.hit-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; margin-bottom: 6px; }
.hit-head a { font-weight: 600; color: var(--text); text-decoration: none; }
.hit-head .score { margin-left: auto; }
.hit-text { font-size: 13px; color: var(--muted); line-height: 1.5; white-space: pre-wrap; max-height: 9.5em; overflow: hidden; }
.hit-text mark { background: var(--warn-soft); color: var(--text); border-radius: 3px; padding: 0 2px; }
.hit-thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); flex: none; }
.badge.lib { background: var(--accent-soft); color: var(--accent); border-color: transparent; margin-left: 6px; }
.batch:empty { display: none; }
.batch { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin: 0 0 12px; background: var(--panel); max-height: 260px; overflow: auto; }
.bhead { font-size: 12px; color: var(--muted); padding: 4px 0; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.brow { display: grid; grid-template-columns: 1fr auto 90px auto; gap: 8px; align-items: center; font-size: 12.5px; padding: 4px 0; }
.bname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bsize { color: var(--faint); }
.bbar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-size: 13.5px; cursor: pointer; }
.check input { width: auto !important; margin: 0; }
.check.mini { font-size: 12px; color: var(--muted); margin: 0; }
select.mini { font-size: 12px; padding: 3px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.addmember { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.addmember input { flex: 1; margin: 0 !important; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.me small { display: block; color: var(--faint); font-size: 11.5px; }

/* ── Doble factor ── */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 200; }
.modal { background: var(--panel); color: var(--text); border-radius: 16px; padding: 22px 22px 16px; width: min(92vw, 380px); box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.code-input { font: 600 22px/1.2 var(--mono) !important; letter-spacing: .25em; text-align: center; width: 100%; padding: 10px !important; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); margin: 10px 0; }
.mfa-card { max-width: 440px; }
.mfa-steps { color: #cbd5e1; font-size: 13.5px; padding-left: 18px; margin: 6px 0 12px; line-height: 1.5; }
.mfa-qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 10px; margin: 8px auto; width: max-content; }
.mfa-qr svg { display: block; }
.mfa-secret { text-align: center; font-size: 13px; letter-spacing: .08em; color: #94a3b8; margin-bottom: 12px; word-break: break-all; }
.card .mfa-secret { color: var(--muted); }

/* ── Desarrollo ── */
.devstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.devstats > div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel); }
.devstats b { display: block; font: 600 22px/1.1 var(--serif); }
.devstats span { font-size: 12px; color: var(--muted); }
.modal.wide { width: min(94vw, 860px); max-height: 86vh; overflow: auto; padding-top: 0; }
.modal-head { position: sticky; top: 0; background: var(--panel); display: flex; gap: 10px; align-items: center; padding: 14px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.modal-head b { flex: none; } .modal-head .sub { flex: 1; }
details.card > summary { cursor: pointer; list-style: none; }

/* ── Configuración ── */
details.cfg > summary { margin-bottom: 4px; }
.cfgrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.cfglab .mono { font-size: 12.5px; display: block; }
.cfglab small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; margin-top: 2px; }
.cfgval input, .cfgval select { width: 100%; font-size: 13px; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.cfgmeta { margin-top: 4px; font-size: 11.5px; }
.cfgmeta a { font-size: 11.5px; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); margin-top: 10px; font-size: 13px; }
@media (max-width: 640px) { .cfgrow { grid-template-columns: 1fr; gap: 6px; } }

/* Ficheros que entrega el asistente (CSV/Excel) */
.filecard { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 4px 0; border: 1px solid var(--line, #e5e7eb); border-radius: 10px; text-decoration: none; color: inherit; background: var(--panel, #fff); }
.filecard:hover { border-color: var(--accent, #0f766e); }
.filecard-ico { font: 600 11px/1 ui-monospace, monospace; padding: 6px 7px; border-radius: 6px; background: var(--accent, #0f766e); color: #fff; letter-spacing: .04em; }
/* Fórmulas (MathML) */
.mathblock { overflow-x: auto; margin: 10px 0; text-align: center; }
math { font-size: 1.08em; }
code.tex { color: var(--muted, #6b7280); }
.chartwrap .chartpng { position: absolute; top: 8px; right: 64px; font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: inherit; cursor: pointer; opacity: 0; }
.chartwrap:hover .chartpng { opacity: 1; }

/* Sprint 007: propuestas, valoraciones, skills y agentes */
.proposal { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin: 8px 0 12px; font-size: 14px; }
.proposal .ph { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.proposal .pname { font-family: var(--mono); font-size: 13px; color: var(--text); }
.proposal p { margin: 6px 0; }
.proposal .pedit { margin: 8px 0; }
.proposal .pedit label, .fbrev label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
.proposal .pedit input, .proposal .pedit textarea, .proposal .pedit select { width: 100%; }
.proposal textarea, .drawer textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); padding: 8px 10px; font: 13px/1.45 var(--mono); resize: vertical; }
.proposal .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.muted { color: var(--muted); }
.fb { display: flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 12px; color: var(--faint); flex-wrap: wrap; opacity: .55; transition: opacity .2s; }
.msg.assistant:hover .fb, .fb.ask, .fb:focus-within { opacity: 1; }
.fb .q { color: var(--muted); margin-right: 4px; }
.fbb { border: 1px solid transparent; background: none; border-radius: 8px; padding: 2px 6px; font-size: 14px; cursor: pointer; filter: grayscale(1); }
.fbb:hover, .fbb.on { filter: none; border-color: var(--line); background: var(--panel); }
.fb .fbc { display: flex; gap: 6px; flex: 1 1 100%; margin-top: 4px; }
.fb .fbc input { flex: 1; }
.fbitem pre { white-space: pre-wrap; font: 12px/1.45 var(--mono); max-height: 200px; overflow: auto; }
.fbitem > .grow > div { margin: 3px 0; }
.item.off { opacity: .6; }
.ag-select { margin-top: 6px; }
.drawer label.check { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
