:root {
    --bg: #000000;
    --panel: #0b0b10;
    --panel2: #14141b;
    --line: #24242e;
    --txt: #f5f5f7;
    --muted: #8a8a96;
    --accent: #ffffff;
    --maria: #e7a6c9;
    --raul: #7fb8e0;
    --vivo: #6ee7a0;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--txt);
    font-family: 'Space Grotesk', system-ui, -apple-system, Segoe UI, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

/* ---------- Fondo estrellado (sutil, fijo) ---------- */
.estrellas {
    position: fixed;
    inset: 0;
    width: 1px;
    height: 1px;
    background: transparent;
    opacity: .35;
    pointer-events: none;
    z-index: 0;
}

/* ---------- Login ---------- */
.pantalla-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-caja {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.login-marca { margin-bottom: 32px; }
.login-marca h1 {
    margin: 12px 0 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: .04em;
}

.marca-circulo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--txt);
    flex-shrink: 0;
}
.login-sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-form input[type="password"] {
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--txt);
    border-radius: 14px;
    padding: 16px;
    font-size: 22px;
    text-align: center;
    letter-spacing: .5em;
    outline: none;
}
.login-form input[type="password"]:focus {
    border-color: var(--accent);
}
.login-form input[type="password"]::placeholder {
    letter-spacing: normal;
    color: #45454f;
}

.login-form button {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 14px;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.login-form button:disabled,
.login-form input:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.login-error {
    margin-top: 16px;
    color: #ff8a8a;
    font-size: 13px;
}

/* ---------- Header común ---------- */
.panel-header, .bot-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
}

.panel-header h1 {
    font-size: 20px;
    margin: 0;
    font-weight: 600;
}

.link-salir {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    border: 1px solid var(--line);
    padding: 6px 12px;
    border-radius: 100px;
}

.bot-header {
    gap: 12px;
}
.bot-header strong { font-size: 16px; }

.btn-volver {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--txt);
    text-decoration: none;
    font-size: 18px;
    flex-shrink: 0;
    cursor: pointer;
}

/* ---------- Flujo en vivo ---------- */
.flujo-vivo {
    position: relative;
    z-index: 1;
    max-width: 480px;
    margin: 0 auto;
    padding: 4px 20px 18px;
    border-bottom: 1px solid var(--line);
}

.flujo-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 10px;
}
.flujo-meta-activo { color: var(--vivo); }

.flujo-pasos {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}
.flujo-pasos::-webkit-scrollbar { display: none; }

.flujo-pasos li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 62px;
    text-align: center;
}

.flujo-punto {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line);
    transition: background .2s, box-shadow .2s;
}

.flujo-pasos li.activo .flujo-punto {
    background: var(--vivo);
    box-shadow: 0 0 0 4px rgba(110, 231, 160, .18);
}

.flujo-etiqueta {
    font-size: 10px;
    line-height: 1.25;
    color: var(--muted);
}
.flujo-pasos li.activo .flujo-etiqueta { color: var(--txt); }

/* ---------- Pestañas ---------- */
.tabs {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 8px;
    max-width: 480px;
    margin: 0 auto;
    padding: 14px 20px 0;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 100px;
    padding: 7px 16px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}
.tab-btn.activo {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: 600;
}

.tab-panel.oculto { display: none !important; }

/* ---------- Dashboard ---------- */
.bot-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 12px 20px 40px;
    max-width: 480px;
    margin: 0 auto;
}

.bot-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    color: var(--txt);
    text-decoration: none;
}
.bot-card:active { background: var(--panel2); }
.bot-nombre { font-size: 16px; font-weight: 500; }

/* ---------- Bot / CRM ---------- */
.bot-main {
    position: relative;
    z-index: 1;
    max-width: 480px;
    margin: 0 auto;
}

.oculto { display: none !important; }

.aviso-error {
    position: relative;
    z-index: 1;
    margin: 16px 20px;
    padding: 14px;
    background: #2a1414;
    border: 1px solid #4a2222;
    border-radius: 12px;
    font-size: 13px;
    color: #ffb0b0;
    max-width: 440px;
}
.aviso-error code { color: #fff; }

.lista-contactos {
    display: flex;
    flex-direction: column;
}

.lista-vacia {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.item-contacto {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line);
    padding: 14px 20px;
    color: var(--txt);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.item-contacto:active { background: var(--panel); }

.item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-numero { font-size: 14px; font-weight: 500; }
.item-preview {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-hora { font-size: 11px; color: var(--muted); flex-shrink: 0; }

.persona-badge {
    font-size: 11px;
    padding: 4px 9px;
    border-radius: 100px;
    border: 1px solid var(--line);
    white-space: nowrap;
    flex-shrink: 0;
}
.persona-maria { color: var(--maria); border-color: rgba(231,166,201,.35); }
.persona-raul { color: var(--raul); border-color: rgba(127,184,224,.35); }
.persona-flujo { color: var(--vivo); border-color: rgba(110,231,160,.35); }
.persona-buzon { color: var(--muted); border-color: var(--line); }

.hilo-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.hilo-header-info { display: flex; flex-direction: column; gap: 4px; }
.hilo-header-info strong { font-size: 15px; }

.hilo-mensajes {
    padding: 16px 20px 90px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 50vh;
    max-height: 75vh;
    overflow-y: auto;
}

.burbuja {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.burbuja-cliente {
    align-self: flex-start;
    background: var(--panel2);
    border: 1px solid var(--line);
    border-bottom-left-radius: 4px;
}
.burbuja-bot {
    align-self: flex-end;
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 4px;
}

/* ---------- Ingresos ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px 20px 4px;
}

.stat-tile {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-num {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.stat-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.form-venta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 16px 20px;
}
.form-venta input {
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--txt);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}
.form-venta input:focus { border-color: var(--accent); }
.form-venta button {
    grid-column: 1 / -1;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 10px;
    padding: 11px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.lista-ventas { padding-bottom: 40px; }

.item-venta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
}
.item-venta-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-venta-nombre { font-size: 14px; font-weight: 500; }
.item-venta-fecha { font-size: 12px; color: var(--muted); }
.item-venta-monto { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.btn-borrar-venta {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
}

/* ---------- Análisis con IA ---------- */
.analisis-caja {
    padding: 16px 20px 40px;
}
.analisis-intro {
    font-size: 13px;
    color: var(--muted);
    margin: 0 0 16px;
    line-height: 1.5;
}
.btn-analisis {
    width: 100%;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 12px;
    padding: 13px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.btn-analisis:disabled { opacity: .5; cursor: wait; }
.analisis-resultado {
    margin-top: 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--txt);
    white-space: normal;
}

@media (min-width: 640px) {
    .bot-grid { grid-template-columns: 1fr 1fr; }
}
