:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #18181f;
  --bg4: #1f1f28;
  --border: rgba(255,255,255,0.08);
  --accent: #5b4fff;
  --accent-h: #4a3fee;
  --accent-glow: rgba(91,79,255,0.2);
  --text: #f0f0f8;
  --text-muted: #7a7a9a;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; overflow: hidden; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
a { color: var(--accent); }

/* AUTH */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(91,79,255,0.15) 0%, transparent 70%); }
.auth-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 18px; padding: 44px 40px; width: 400px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.auth-logo { display: block; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.04em; color: var(--text); text-decoration: none; margin-bottom: 28px; text-align: center; }
.auth-logo span { color: var(--accent); }
.auth-box h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 28px; }
.auth-switch { text-align: center; font-size: 0.83rem; color: var(--text-muted); margin-top: 20px; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* FIELDS */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 0.9rem; outline: none; transition: border-color 0.15s; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field-sm { flex: 0 0 100px !important; }
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }
.err { color: var(--danger); font-size: 0.82rem; padding: 8px 12px; background: rgba(239,68,68,0.08); border-radius: 6px; margin-bottom: 12px; }
.hidden { display: none !important; }

/* BUTTONS */
.btn-full { width: 100%; background: var(--accent); color: white; border: none; border-radius: 9px; padding: 12px; font-size: 0.9rem; font-weight: 700; transition: opacity 0.2s; margin-top: 4px; }
.btn-full:hover { opacity: 0.88; }
.btn-primary { background: var(--accent); color: white; border: none; border-radius: 9px; padding: 9px 18px; font-size: 0.84rem; font-weight: 700; transition: opacity 0.15s, transform 0.1s; }
.btn-primary:hover { opacity: 0.88; }
.btn-outline { display: inline-block; background: transparent; color: var(--accent); border: 1.5px solid rgba(91,79,255,0.4); border-radius: 9px; padding: 8px 16px; font-size: 0.84rem; font-weight: 600; text-decoration: none; transition: border-color 0.15s; }
.btn-outline:hover { border-color: var(--accent); }
.btn-sm { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px; padding: 6px 12px; font-size: 0.78rem; font-weight: 600; transition: all 0.15s; }
.btn-sm:hover { border-color: var(--text-muted); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); border-radius: 9px; padding: 9px 18px; font-size: 0.84rem; font-weight: 700; }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }

/* APP LAYOUT */
#app { display: flex; height: 100vh; }

/* SIDEBAR */
.sidebar { width: 220px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 22px 20px 18px; border-bottom: 1px solid var(--border); }
.sidebar-logo { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.04em; color: var(--text); text-decoration: none; display: block; }
.sidebar-logo span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: block; padding: 10px 14px; border-radius: 9px; color: var(--text-muted); text-decoration: none; font-size: 0.87rem; font-weight: 500; transition: all 0.15s; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(91,79,255,0.14); color: var(--accent); font-weight: 600; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); }
.user-info { margin-bottom: 8px; }
.user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-badge { display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(91,79,255,0.15); color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 3px; }
.logout-btn { width: 100%; background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 8px; padding: 7px; font-size: 0.8rem; transition: all 0.15s; }
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* MAIN */
.main-content { flex: 1; overflow-y: auto; padding: 28px 32px; }
.view-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.view-header h2 { font-size: 1.3rem; font-weight: 700; }
.view-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* AGENTS GRID */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.agent-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; cursor: pointer; transition: border-color 0.2s, transform 0.15s, box-shadow 0.15s; position: relative; }
.agent-card:hover { border-color: rgba(91,79,255,0.3); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.2); }
.agent-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.agent-card-name { font-weight: 700; font-size: 0.95rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.status-dot.active { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.inactive { background: var(--text-muted); }
.agent-card-desc { color: var(--text-muted); font-size: 0.82rem; margin-bottom: 12px; min-height: 18px; }
.agent-card-hint { font-size: 0.75rem; color: var(--accent); opacity: 0.7; }
.agent-card-key-warn { font-size: 0.72rem; color: var(--warning); margin-top: 6px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); grid-column: 1/-1; }
.empty-state p { margin-top: 8px; font-size: 0.85rem; }

/* ACCOUNT */
.account-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.card h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.card-help { text-align: center; }
.help-icon { font-size: 2.5rem; margin-bottom: 12px; }
.card-help h3 { font-size: 1rem; color: var(--text); text-transform: none; letter-spacing: 0; margin-bottom: 8px; }
.card-help p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 18px; line-height: 1.5; }
.plan-info-row { display: flex; justify-content: space-between; font-size: 0.88rem; padding: 6px 0; border-bottom: 1px solid var(--border); }
.plan-info-row:last-child { border-bottom: none; }
.plan-info-row span:first-child { color: var(--text-muted); }

/* ADMIN */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg3); padding: 4px; border-radius: 10px; width: fit-content; }
.admin-tab { background: transparent; border: none; color: var(--text-muted); padding: 8px 16px; border-radius: 8px; font-size: 0.84rem; font-weight: 600; transition: all 0.15s; }
.admin-tab.active { background: var(--bg2); color: var(--text); }
.admin-panel { }
.admin-user-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; gap: 12px; flex-wrap: wrap; }
.admin-user-info { flex: 1; }
.admin-user-email { font-weight: 600; font-size: 0.9rem; }
.admin-user-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.admin-user-actions { display: flex; gap: 8px; align-items: center; }
.config-form { max-width: 500px; }
.config-form h3 { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 14px; }

/* MODAL AGENT */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.72); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(4px); }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); overflow: hidden; }
.modal-agent { width: 820px; max-width: 96vw; height: 84vh; display: flex; flex-direction: column; }
.modal-agent-header { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.agent-header-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.agent-header-info h3 { font-size: 0.95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-tabs { display: flex; gap: 3px; flex-wrap: wrap; }
.atab { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 7px; padding: 6px 12px; font-size: 0.76rem; font-weight: 600; transition: all 0.15s; }
.atab:hover { background: var(--bg3); color: var(--text); }
.atab.active { background: rgba(91,79,255,0.14); border-color: var(--accent); color: var(--accent); }
.modal-close { background: transparent; border: none; color: var(--text-muted); font-size: 1rem; padding: 6px 10px; border-radius: 6px; transition: color 0.15s; }
.modal-close:hover { color: var(--text); }
.atab-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* CHAT */
.chat-messages { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 76%; display: flex; flex-direction: column; gap: 3px; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.assistant { align-self: flex-start; }
.chat-bubble { padding: 10px 14px; border-radius: 12px; font-size: 0.88rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chat-msg.user .chat-bubble { background: var(--accent); color: white; border-bottom-right-radius: 3px; }
.chat-msg.assistant .chat-bubble { background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-time { font-size: 0.68rem; color: var(--text-muted); padding: 0 4px; }
.chat-msg.user .chat-time { text-align: right; }
.chat-empty { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 0.88rem; }
.chat-typing { align-self: flex-start; display: flex; gap: 4px; align-items: center; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; border-bottom-left-radius: 3px; }
.chat-typing span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: blink 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,60%,100%{opacity:.3;transform:scale(1)} 30%{opacity:1;transform:scale(1.15)} }
.chat-input-bar { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); align-items: flex-end; }
#am-input { flex: 1; background: var(--bg3); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; color: var(--text); font-size: 0.88rem; outline: none; resize: none; max-height: 100px; }
#am-input:focus { border-color: var(--accent); }
#am-send { background: var(--accent); color: white; border: none; border-radius: 9px; width: 38px; height: 38px; font-size: 0.95rem; flex-shrink: 0; }

/* TABS CONTENT */
.tab-info { font-size: 0.82rem; color: var(--text-muted); background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 16px 20px 12px; }
.tab-actions { display: flex; gap: 10px; padding: 12px 20px; }
.big-textarea { flex: 1; margin: 0 20px; background: var(--bg3); border: 1px solid var(--border); border-radius: 9px; padding: 12px; color: var(--text); font-size: 0.85rem; font-family: 'SF Mono', 'Fira Code', monospace; line-height: 1.6; outline: none; resize: none; }
.big-textarea:focus { border-color: var(--accent); }
#atab-prompt { padding-bottom: 0; }
#atab-prompt .big-textarea { height: calc(100% - 120px); }

/* ITEM LIST */
.item-list { padding: 0 20px 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.item-row { background: var(--bg3); border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.item-info h4 { font-size: 0.88rem; font-weight: 600; margin-bottom: 3px; }
.item-info p { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-empty { color: var(--text-muted); font-size: 0.85rem; text-align: center; padding: 30px 20px; }

/* SMTP */
#atab-smtp { overflow-y: auto; }
.smtp-form { padding: 16px 20px; }
.smtp-form h4 { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 14px; }

/* SETTINGS */
#atab-settings { overflow-y: auto; }
.settings-sections { padding: 20px; }
.settings-section { margin-bottom: 24px; }
.settings-section h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 6px; }
.settings-desc { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.key-input-row { display: flex; gap: 8px; }
.key-input-row input { flex: 1; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 0.88rem; outline: none; font-family: monospace; }
.key-input-row input:focus { border-color: var(--accent); }
.key-status { font-size: 0.78rem; margin-top: 8px; padding: 7px 12px; border-radius: 6px; }
.key-status.ok { background: rgba(34,197,94,0.1); color: var(--success); }
.key-status.err { background: rgba(239,68,68,0.1); color: var(--danger); }
.key-status.info { background: rgba(91,79,255,0.1); color: var(--accent); }

/* MODAL GENÉRICO */
.modal:not(.modal-agent) { width: 440px; max-width: 94vw; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 0.95rem; font-weight: 700; }
#modal-body { padding: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.btn-cancel { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 9px; padding: 9px 18px; font-size: 0.84rem; }
.btn-cancel:hover { border-color: var(--text-muted); color: var(--text); }

/* SELECT */
select { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--text); font-family: inherit; font-size: 0.88rem; outline: none; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
}
