:root { color: #1c2430; font: 15px/1.45 "Segoe UI", sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #f4f6f8; color: #1c2430; }
button, input, select, textarea { font: inherit; color: inherit; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 18px; background: #14352c; color: #fff; }
.header-actions { display: flex; gap: 8px; }
.brand { margin: 0; font-weight: 700; letter-spacing: .02em; }
.brand span { color: #9ddeb8; }
.brand small { display: block; font-weight: 500; color: #d5ebe1; letter-spacing: 0; }
header button, .primary { background: #1f8a5b; color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
button { background: #e7ece9; border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
body:has(.report-layout) { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.report-layout { display: grid; flex: 1; min-height: 0; overflow: hidden; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); }
.report-layout .chat-side { border-left: 0; border-right: 1px solid #e1e6ea; }
.history-item { display: flex; gap: 4px; align-items: center; }
.history-item.active .history-open { background: #e7f6ee; }
.history-open { flex: 1; width: 100%; text-align: left; background: transparent; border-radius: 8px; padding: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-delete { padding: 4px 8px; }
.canvas-wrap, .chat-side { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.canvas-wrap { padding: 12px; gap: 8px; }
.canvas-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.canvas-note { flex: 1; min-width: 180px; margin: 0; font-size: 13px; color: #40515c; }
.anchos button { padding: 4px 10px; font-size: 12px; }
.anchos button[aria-pressed="true"] { background: #14352c; color: #fff; }
.zoom { display: inline-flex; align-items: center; gap: 2px; }
.zoom button { padding: 4px 8px; font-size: 12px; min-width: 28px; }
#zoom-valor { min-width: 52px; font-variant-numeric: tabular-nums; }
#conversaciones { width: min(420px, calc(100vw - 24px)); }
#new-chat { width: 100%; }
#history { max-height: min(60vh, 480px); overflow: auto; margin-top: 12px; }
#history:empty::before { content: 'Todavía no hay conversaciones.'; color: #5d6b76; font-size: 13px; }
.stage { flex: 1; min-height: 0; overflow: auto; background: #e6ebef; border-radius: 12px; display: flex; justify-content: safe center; padding: 16px; }
.stage.sin-reporte { align-items: center; }
.vacio { display: none; max-width: 360px; margin: 0; text-align: center; color: #40515c; }
.sin-reporte .vacio { display: block; }
.marco { --z: 1; width: 100%; max-width: 100%; height: 100%; flex: none; overflow: hidden; background: #0b1220; box-shadow: 0 10px 28px rgba(20, 32, 40, .12); }
.marco.movil { width: calc(768px * var(--z)); }
.marco.con-zoom { max-width: none; }
#lienzo { display: block; width: calc(100% / var(--z)); height: calc(100% / var(--z)); border: 0; background: #0b1220; transform: scale(var(--z)); transform-origin: 0 0; }
.sin-reporte .marco { display: none; }
.chat-side { border-left: 1px solid #e1e6ea; background: #fff; padding: 12px; font-size: 12px; }
.messages { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.message { max-width: 95%; }
.message.user { align-self: flex-end; }
.bubble { background: #eceff1; border-radius: 12px; padding: 8px 10px; }
.message.user .bubble { background: #b7e4fa; }
.message.error .bubble { background: #fdecec; }
.bubble table { border-collapse: collapse; width: 100%; }
.bubble th, .bubble td { border: 1px solid #d5dee4; padding: 4px 6px; text-align: left; }
.activity { display: flex; gap: 8px; align-items: center; color: #40515c; margin: 8px 0 0; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #1f8a5b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
#message-form { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
textarea { width: 100%; border: 1px solid #c9d2d8; border-radius: 10px; padding: 8px; resize: vertical; }
.composer-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.notice { color: #8a3b3b; margin: 8px 0 0; }
.notice:empty { display: none; }
dialog { border: 0; border-radius: 16px; padding: 18px; width: min(720px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(16, 24, 32, .35); }
.dialog-head, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
dialog label { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 13px; }
dialog input, dialog select, #codigo-texto { width: 100%; border: 1px solid #c9d2d8; border-radius: 8px; padding: 8px; background: #fff; }
#codigo-texto { font: 12px/1.4 Consolas, monospace; }
#guardar { width: min(440px, calc(100vw - 24px)); }
dialog label.check { flex-direction: row; align-items: center; }
dialog label.check input { width: auto; }
.pestanas { display: flex; gap: 8px; margin: 0 0 8px; }
.pestanas button[aria-selected="true"] { background: #14352c; color: #fff; }
#chat-toggle, .chat-velo, .chat-cerrar { display: none; }
@media (max-width: 900px) {
  #chat-toggle { display: inline-block; }
  .canvas-note { min-width: 0; }
  .report-layout { position: relative; grid-template-columns: minmax(0, 1fr); }
  .report-layout .chat-side { position: absolute; z-index: 20; top: 0; bottom: 0; left: 0; width: min(400px, 88vw); transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: 4px 0 24px rgba(16, 24, 32, .18); }
  .report-layout.chat-abierto .chat-side { transform: none; visibility: visible; transition: transform .2s ease; }
  .chat-velo { position: absolute; inset: 0; z-index: 10; background: rgba(16, 24, 32, .35); }
  .report-layout.chat-abierto .chat-velo { display: block; }
  #chat-toggle[aria-expanded="true"] { background: #14352c; }
  .chat-cerrar { display: block; align-self: flex-end; padding: 2px 10px; margin-bottom: 6px; font-size: 18px; line-height: 1.2; }
}
