/* IA Local — UI */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #08090d;
  --bg-elevated: #0f1118;
  --surface: #141820;
  --surface-2: #1a2030;
  --surface-hover: #222a3d;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --accent: #6b8cff;
  --accent-2: #4fd1c5;
  --accent-glow: rgba(107, 140, 255, 0.35);
  --accent-hover: #5a7aef;
  --danger: #f07178;
  --danger-bg: rgba(240, 113, 120, 0.12);
  --success: #4ade80;
  --text: #eef0f6;
  --text-secondary: #9aa3b8;
  --text-muted: #5c6578;
  --bubble-user: linear-gradient(135deg, #1a2e1f 0%, #152418 100%);
  --bubble-ia: linear-gradient(135deg, #1a2238 0%, #141c30 100%);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --sidebar-w: 240px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', Consolas, monospace;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Fondo decorativo */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(107, 140, 255, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(79, 209, 197, 0.08), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100dvh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 20px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-text span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  -webkit-user-select: none;
  user-select: none;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-item.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item .nav-icon {
  font-size: 1.1rem;
  opacity: 0.9;
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar-footer label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
  padding-left: 4px;
}

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(15, 17, 24, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: auto;
  display: none;
}

.page { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.page.active { display: flex; }

/* Controles */
.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

select.modelo-select,
select.mode-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 32px 9px 12px;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239aa3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition);
}

select.modelo-select:focus,
select.mode-select:focus {
  outline: none;
  border-color: var(--accent);
}

select.mode-select { min-width: 128px; }

#team-project { min-width: 190px; }
#team-department { min-width: 170px; }

.reasoning-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color var(--transition);
}

.reasoning-toggle:hover { border-color: var(--border-strong); }
.reasoning-toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ── Chat ── */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar { width: 6px; }
#chat-messages::-webkit-scrollbar-thumb {
  background: var(--surface-hover);
  border-radius: 6px;
}

.msg {
  display: flex;
  gap: 12px;
  max-width: 780px;
  animation: msgIn 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.ia { align-self: flex-start; }

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg.user .msg-avatar {
  background: linear-gradient(135deg, #2d4a32, #1e3322);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.msg.ia .msg-avatar {
  background: linear-gradient(135deg, #2a3560, #1e2848);
  border: 1px solid rgba(107, 140, 255, 0.25);
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.94rem;
  line-height: 1.65;
  max-width: 640px;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg.user .msg-bubble {
  background: var(--bubble-user);
  border: 1px solid rgba(74, 222, 128, 0.15);
  border-bottom-right-radius: 4px;
}

.msg.ia .msg-bubble {
  background: var(--bubble-ia);
  border: 1px solid rgba(107, 140, 255, 0.15);
  border-bottom-left-radius: 4px;
}

.msg-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.msg.user .msg-meta { text-align: right; }
.msg.ia .msg-meta { text-align: left; }

.msg-bubble code {
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.86em;
  color: #a8d4ff;
}

.msg-bubble pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 10px 0;
  border: 1px solid var(--border);
}

.msg-bubble pre code { background: none; padding: 0; }

.reason-box {
  margin-top: 12px;
  border: 1px dashed rgba(107, 140, 255, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(107, 140, 255, 0.06);
  padding: 10px 12px;
}

.reason-box summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.reason-content { margin-top: 8px; color: var(--text-secondary); font-size: 0.86rem; }
.reason-hint { margin-top: 8px; color: var(--text-muted); font-size: 0.78rem; }

.mode-hint {
  margin: 0 4px 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(79, 209, 197, 0.25);
  background: rgba(79, 209, 197, 0.08);
  color: var(--text-secondary);
  font-size: 0.79rem;
}

.structured-team {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
}

.structured-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.structured-title {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.severity-chip {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
}

.severity-chip.info {
  color: #9ad4ff;
  border-color: rgba(154, 212, 255, 0.35);
  background: rgba(154, 212, 255, 0.12);
}

.severity-chip.warning {
  color: #f7c27b;
  border-color: rgba(247, 194, 123, 0.35);
  background: rgba(247, 194, 123, 0.12);
}

.severity-chip.critical {
  color: #ff9aa6;
  border-color: rgba(255, 154, 166, 0.35);
  background: rgba(255, 154, 166, 0.12);
}

.structured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.dept-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.02);
}

.dept-name {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.dept-analysis {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.dept-rec {
  margin-top: 6px;
  font-size: 0.73rem;
  color: var(--accent-2);
}

.input-bar.mode-focused #btn-attach,
.input-bar.mode-focused .hint {
  display: none;
}

.typing .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 3px;
  animation: blink 1.2s infinite;
}

.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* Acciones mensaje */
.msg-outer { position: relative; }
.msg-outer:hover .msg-actions { opacity: 1; pointer-events: auto; }

.msg-actions {
  position: absolute;
  top: -8px;
  right: 0;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 2;
}

.msg-outer:has(.msg.user) .msg-actions { right: auto; left: 0; }

.msg-action-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.msg-action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.msg-action-btn.del:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(240, 113, 120, 0.3);
}

.msg-image {
  max-width: 240px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  display: block;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform var(--transition);
}

.msg-image:hover { transform: scale(1.02); }

/* Composer */
.composer-wrap {
  flex-shrink: 0;
  padding: 0 16px 16px;
  background: linear-gradient(transparent, var(--bg) 24px);
}

#continue-bar {
  display: none;
  gap: 10px;
  align-items: center;
  margin: 0 4px 10px;
  padding: 10px 14px;
  background: rgba(107, 140, 255, 0.1);
  border: 1px solid rgba(107, 140, 255, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

#continue-bar.visible { display: flex; }

#continue-bar .pill {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

#continue-bar .txt {
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#btn-clear-cont { padding: 6px 12px; font-size: 0.78rem; }

#attach-preview {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 10px;
}

#attach-preview.visible { display: flex; }

.attach-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  animation: msgIn 0.25s ease;
}

.attach-item img { width: 72px; height: 72px; object-fit: cover; display: block; }

.attach-item .file-info {
  padding: 8px 28px 8px 10px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: var(--danger);
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-bar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.input-bar textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 4px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 180px;
  line-height: 1.5;
}

.input-bar textarea:focus { outline: none; }
.input-bar textarea::placeholder { color: var(--text-muted); }

.hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  align-self: center;
  white-space: nowrap;
  padding: 4px 6px;
  background: var(--surface-2);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #7c6cf0 100%);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
  padding: 10px 20px;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-primary:disabled {
  background: var(--surface-hover);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.1rem;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(240, 113, 120, 0.25);
}

.btn-danger:hover { background: rgba(240, 113, 120, 0.2); }

/* ── Historial ── */
#page-historial {
  padding: 24px;
  overflow-y: auto;
  gap: 16px;
}

#page-historial::-webkit-scrollbar { width: 6px; }
#page-historial::-webkit-scrollbar-thumb { background: var(--surface-hover); border-radius: 6px; }

.historial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 12px;
}

.historial-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.historial-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

#historial-lista {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: all var(--transition);
  animation: msgIn 0.3s ease;
}

.conv-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.conv-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 12px;
}

.conv-prompt {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.92rem;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.conv-respuesta {
  font-size: 0.87rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 100px;
  overflow: hidden;
  line-height: 1.55;
}

.conv-respuesta.expanded { max-height: none; }

.conv-expand {
  font-size: 0.78rem;
  color: var(--accent-2);
  cursor: pointer;
  margin-top: 8px;
  display: inline-block;
  font-weight: 600;
}

.conv-expand:hover { text-decoration: underline; }

.conv-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.conv-meta-tag { font-size: 0.75rem; color: var(--text-muted); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(107, 140, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(107, 140, 255, 0.25);
}

#paginacion {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-bottom: 24px;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

#page-historial #historial-lista {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ── Stats ── */
#page-stats {
  padding: 24px;
  overflow-y: auto;
}

#page-stats::-webkit-scrollbar { width: 6px; }
#page-stats::-webkit-scrollbar-thumb { background: var(--surface-hover); border-radius: 6px; }

.stats-header {
  margin-bottom: 24px;
}

.stats-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.stats-header p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.8;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card .num {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.stat-card .lbl {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 500;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition);
}

.chart-card:hover { border-color: var(--border-strong); }

.chart-card h3 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-card canvas { max-height: 240px; }

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 56px 24px;
  font-size: 0.92rem;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ── Overlays ── */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

#lightbox.open { display: flex; }

#lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 99;
  box-shadow: var(--shadow);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 10, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 20px;
}

#confirm-modal.open { display: flex; }

.confirm-card {
  width: min(440px, 95vw);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: msgIn 0.3s ease;
}

.confirm-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.05rem;
}

.confirm-body {
  padding: 18px 20px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.confirm-actions {
  padding: 14px 20px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-confirm-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(240, 113, 120, 0.35);
}

.btn-confirm-danger:hover { background: rgba(240, 113, 120, 0.22); }

/* Mobile */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow);
  }

  .sidebar.open { transform: translateX(0); }

  .mobile-nav-toggle { display: flex; align-items: center; justify-content: center; }

  .topbar-title { display: block; }

  .hint { display: none; }

  .charts-grid { grid-template-columns: 1fr; }

  .control-group { width: 100%; }

  select.modelo-select,
  select.mode-select { flex: 1; min-width: 0; }

  #chat-messages { padding: 16px 12px; }

  .composer-wrap { padding: 0 10px 12px; }
}

@media (max-width: 480px) {
  .reasoning-toggle span:last-child { display: none; }
  .input-bar { padding: 10px; }
}
