/* =========================================================================
   BX Brain — sistema de diseño
   Alineado a la identidad visual de bxconsulting.co (tokens tomados del
   sitio: assets/global.css) y al logo oficial de BX Brain.
   ========================================================================= */

:root {
    /* Paleta de marca */
    --bx-ink: #10151f;       /* fondo oscuro de header, exacto al logo */
    --bx-ink-2: #1b2029;
    --bx-paper: #ffffff;
    --bx-paper-2: #f4f6f8;
    --bx-line: #dde1e7;
    --bx-muted: #626874;
    --bx-cyan: #05a1cc;
    --bx-cyan-dark: #078eb5;
    --bx-red: #ed153a;
    --bx-amber: #f5b029;
    --bx-teal: #2cb095;
    --bx-purple: #7440aa;

    /* Alias funcionales (compatibilidad con nombres usados en templates/JS) */
    --azul-titulo: var(--bx-ink);
    --azul-subtitulo: var(--bx-cyan);
    --gris-cuerpo: #2b2f38;
    --gris-secundario: var(--bx-muted);
    --borde: var(--bx-line);
    --fondo: var(--bx-paper-2);
    --ok: #0d7a53;
    --error: var(--bx-red);

    --radius: 14px;
    --radius-sm: 10px;
    --max: 880px;
    --shadow-card: 0 10px 28px rgba(16, 21, 31, .06);
    --shadow-lift: 0 14px 34px rgba(16, 21, 31, .1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--gris-cuerpo);
    background: var(--fondo);
    margin: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: 'Archivo', system-ui, sans-serif;
    letter-spacing: -.02em;
    color: var(--bx-ink);
    line-height: 1.15;
}

a { color: var(--bx-cyan); text-decoration-color: rgba(5, 161, 204, .35); text-underline-offset: 2px; }
a:hover { color: var(--bx-cyan-dark); }

/* ---------------------------------------------------------------------
   Header
   --------------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(16, 21, 31, .97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    color: #fff;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 68px;
}

.topbar-marca {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}
.topbar-marca img {
    display: block;
    height: 30px;
    width: auto;
}

.topbar-menu-boton {
    display: none;
    margin-left: auto;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .22);
    color: #fff;
    border-radius: 9px;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
    padding: 0;
    margin-top: 0;
}
.topbar-menu-boton span,
.topbar-menu-boton span::before,
.topbar-menu-boton span::after {
    content: "";
    display: block;
    width: 19px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .18s, opacity .18s;
}
.topbar-menu-boton span { position: relative; background: transparent; }
.topbar-menu-boton span::before { position: absolute; top: -6px; }
.topbar-menu-boton span::after { position: absolute; top: 6px; }
.topbar-menu-boton[aria-expanded="true"] span { background: transparent; }
.topbar-menu-boton[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.topbar-menu-boton[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.topbar-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    color: #dfe3ea;
    text-decoration: none;
    font: 600 13.5px/1 'Inter', system-ui, sans-serif;
    white-space: nowrap;
    opacity: 1;
    transition: background .15s, color .15s;
}
.topbar-nav a:hover { color: #fff; background: rgba(255, 255, 255, .1); }

/* ---------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------- */
.contenedor {
    max-width: var(--max);
    margin: 0 auto;
    padding: 36px 20px 72px;
}

.aviso {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: .93em;
    border: 1px solid transparent;
}
.aviso-error { background: #fdeced; color: #b3102c; border-color: #f6c3cb; }
.aviso-ok { background: #e9f7f1; color: var(--ok); border-color: #bfe7d5; }

/* ---------------------------------------------------------------------
   Formularios
   --------------------------------------------------------------------- */
form {
    background: var(--bx-paper);
    border: 1px solid var(--borde);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
}

label {
    display: block;
    font: 700 13px/1.3 'Archivo', system-ui, sans-serif;
    margin-bottom: 8px;
    margin-top: 16px;
    color: var(--bx-ink);
}
label:first-child { margin-top: 0; }

input[type=text], input[type=email], input[type=password], select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cfd4dc;
    background: #fff;
    border-radius: var(--radius-sm);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1em;
    color: var(--gris-cuerpo);
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--bx-cyan);
    box-shadow: 0 0 0 3px rgba(5, 161, 204, .14);
}

textarea {
    min-height: 220px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: .96em;
    line-height: 1.55;
    resize: vertical;
}

/* ---------------------------------------------------------------------
   Botones
   --------------------------------------------------------------------- */
button, .boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bx-cyan);
    color: #fff;
    border: 1px solid transparent;
    padding: 0 22px;
    min-height: 46px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: 700 14px/1 'Archivo', system-ui, sans-serif;
    letter-spacing: -.005em;
    margin-top: 18px;
    text-decoration: none;
    transition: background .15s, transform .15s, box-shadow .15s;
    box-shadow: 0 8px 20px rgba(5, 161, 204, .18);
}
button:hover, .boton:hover { background: var(--bx-cyan-dark); transform: translateY(-1px); }

button.secundario, .boton.secundario {
    background: #fff;
    color: var(--bx-ink);
    border-color: var(--borde);
    box-shadow: none;
}
button.secundario:hover, .boton.secundario:hover {
    background: var(--bx-paper-2);
    border-color: #c6ccd6;
}

.boton-chico { min-height: 38px; padding: 0 16px; font-size: 12.5px; margin-top: 0; }

button:disabled, .boton:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------------
   Tablas
   --------------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    margin-bottom: 24px;
    border: 1px solid var(--borde);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
th, td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--borde);
    font-size: .92em;
}
tr:last-child td { border-bottom: none; }
th {
    background: var(--bx-paper-2);
    color: var(--bx-ink);
    font-family: 'Archivo', system-ui, sans-serif;
    font-weight: 700;
    font-size: .78em;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .78em;
    font-weight: 700;
}
.badge-activo { background: #e9f7f1; color: var(--ok); }
.badge-inactivo { background: #fdeced; color: #b3102c; }

/* ---------------------------------------------------------------------
   Chequeo de calidad (QA)
   --------------------------------------------------------------------- */
.hallazgo {
    border: 1px solid #f3c6cf;
    background: #fff6f7;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 10px;
}
.hallazgo .regla { font-family: 'Archivo', system-ui, sans-serif; font-weight: 700; color: #b3102c; margin-bottom: 4px; }
.hallazgo .fragmento { font-style: italic; color: var(--gris-secundario); }

.sin-hallazgos {
    border: 1px solid #bfe7d5;
    background: #f0faf5;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 16px;
    color: var(--ok);
    font-weight: 600;
}

.ayuda { color: var(--gris-secundario); font-size: .89em; margin-top: 6px; line-height: 1.55; }

.cargando-caja {
    display: none;
    background: #eef8fb;
    border: 1px solid #bfe4ef;
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-top: -6px;
    margin-bottom: 24px;
}
.cargando-caja.visible { display: block; }
.cargando-caja .spinner-azul {
    display: inline-block;
    width: 17px;
    height: 17px;
    border: 3px solid #cdeaf3;
    border-top-color: var(--bx-cyan);
    border-radius: 50%;
    animation: girar .8s linear infinite;
    vertical-align: middle;
    margin-right: 10px;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------
   Vista previa legible del analisis (pantalla de revision)
   --------------------------------------------------------------------- */
.vista-previa {
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: var(--radius);
    padding: 32px clamp(20px, 5vw, 40px);
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}
.vista-titulo-doc {
    font-family: 'Archivo', system-ui, sans-serif;
    color: var(--bx-ink);
    font-weight: 800;
    font-size: 1.5em;
    margin: 0 0 2px;
}
.vista-modalidad {
    color: var(--bx-cyan);
    font-weight: 700;
    margin: 0 0 12px;
}
.vista-nombre {
    font-weight: 700;
    font-size: 1.1em;
    margin: 0 0 2px;
    color: var(--bx-ink);
}
.vista-subtitulo {
    color: var(--gris-secundario);
    font-size: .9em;
    margin: 0 0 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--borde);
}
.vista-previa .seccion-titulo {
    font-family: 'Archivo', system-ui, sans-serif;
    color: var(--bx-ink);
    font-size: 1.18em;
    font-weight: 700;
    margin-top: 30px;
    margin-bottom: 12px;
    padding-top: 6px;
    border-top: 1px solid var(--borde);
}
.vista-previa .seccion-titulo:first-of-type { border-top: none; padding-top: 0; }
.vista-previa .subseccion-titulo { font-weight: 700; margin-top: 16px; margin-bottom: 4px; color: var(--bx-ink); }
.vista-previa p { line-height: 1.65; margin: 0 0 10px; }

.tabla-puntajes th:not(:first-child), .tabla-puntajes td:not(:first-child) { text-align: center; }
.tabla-puntajes .celda-inclinacion { font-weight: 700; }

.badges-estilo { margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.badge-inclinacion {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .84em;
    letter-spacing: .02em;
}
/* Colores oficiales de las 5 energias de The GC Index — sin modificar */
.badge-game-changer { background: #8BCEB6; color: #1A5C49; }
.badge-strategist    { background: #4EC0D1; color: #0A4A56; }
.badge-play-maker    { background: #A01E58; color: #FFFFFF; }
.badge-implementer   { background: #EA2227; color: #FFFFFF; }
.badge-polisher      { background: #FCE406; color: #5C4A00; }
td.badge-game-changer, td.badge-strategist, td.badge-play-maker,
td.badge-implementer, td.badge-polisher { border-radius: 0; }

/* ---------------------------------------------------------------------
   Seccion tecnica (JSON) colapsada por defecto
   --------------------------------------------------------------------- */
.json-avanzado {
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-card);
}
.json-avanzado summary {
    cursor: pointer;
    font-family: 'Archivo', system-ui, sans-serif;
    font-weight: 700;
    color: var(--bx-cyan);
}
.json-avanzado textarea {
    margin-top: 16px;
    font-family: 'ui-monospace', 'SFMono-Regular', Consolas, monospace;
    font-size: .85em;
}

.acciones-revisar { margin-bottom: 20px; }
.acciones-revisar button { font-size: 1.02em; padding: 0 28px; min-height: 50px; }

/* ---------------------------------------------------------------------
   Historial de conversacion (chat) en /generar
   --------------------------------------------------------------------- */
.historial-conversacion { margin-bottom: 26px; }
.historial-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.historial-cabecera h2 { margin: 0; font-size: 1.25em; }
.form-nueva-conversacion { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.burbuja {
    border-radius: 16px;
    padding: 14px 18px;
    margin-bottom: 12px;
    max-width: 85%;
}
.burbuja-etiqueta {
    font: 700 11px/1 'Archivo', system-ui, sans-serif;
    color: var(--gris-secundario);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.burbuja-texto { line-height: 1.6; white-space: pre-wrap; }
.burbuja-usuario {
    background: var(--bx-ink);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
.burbuja-usuario .burbuja-etiqueta { color: rgba(255,255,255,.6); }
.burbuja-bx {
    background: #fff;
    margin-right: auto;
    border: 1px solid var(--borde);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-card);
}

/* Respuestas de BX Brain renderizadas desde markdown (ver markdown_chat en
   app.py): reemplaza el modo "solo negrita" anterior, que dejaba
   encabezados "##" y tablas con "|" literales en la burbuja. */
.burbuja-texto-md { white-space: normal; }
.burbuja-texto-md .md-parrafo { margin: 0 0 10px; }
.burbuja-texto-md .md-parrafo:last-child { margin-bottom: 0; }
.burbuja-texto-md .md-titulo {
    margin: 16px 0 6px;
    font-family: 'Archivo', system-ui, sans-serif;
    font-weight: 700;
    color: var(--bx-ink);
    line-height: 1.3;
}
.burbuja-texto-md .md-titulo:first-child { margin-top: 0; }
.burbuja-texto-md .md-titulo-1 { font-size: 1.15em; }
.burbuja-texto-md .md-titulo-2 { font-size: 1.05em; color: var(--bx-cyan-dark); }
.burbuja-texto-md .md-titulo-3 { font-size: .98em; }
.burbuja-texto-md .md-separador {
    border: none;
    border-top: 1px solid var(--borde);
    margin: 16px 0;
}
.burbuja-texto-md .md-cita {
    margin: 0 0 10px;
    padding-left: 12px;
    border-left: 3px solid var(--bx-cyan);
    color: var(--gris-secundario);
    font-style: italic;
}
.burbuja-texto-md .md-lista {
    margin: 0 0 10px;
    padding-left: 22px;
}
.burbuja-texto-md .md-lista li { margin-bottom: 4px; }
.burbuja-texto-md .md-tabla-scroll {
    overflow-x: auto;
    margin: 4px 0 14px;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--borde);
    border-radius: var(--radius-sm);
}
.burbuja-texto-md .md-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: .85em;
}
.burbuja-texto-md .md-tabla th,
.burbuja-texto-md .md-tabla td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--borde);
    border-right: 1px solid var(--borde);
    text-align: left;
    vertical-align: top;
}
.burbuja-texto-md .md-tabla th:last-child,
.burbuja-texto-md .md-tabla td:last-child { border-right: none; }
.burbuja-texto-md .md-tabla tbody tr:last-child td { border-bottom: none; }
.burbuja-texto-md .md-tabla thead th {
    background: var(--bx-paper-2);
    color: var(--bx-ink);
    font-weight: 700;
    font-family: 'Archivo', system-ui, sans-serif;
    font-size: .78em;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
}
.burbuja-texto-md .md-tabla tbody tr:nth-child(even) { background: var(--bx-paper-2); }

.form-descargar-respuesta { margin: 12px 0 0; }
.entrega-documento { margin-top: 12px; }
.entrega-documento .ayuda { margin-bottom: 8px; }

/* ---------------------------------------------------------------------
   Confirmacion propia (sin dialogo nativo del navegador)
   --------------------------------------------------------------------- */
.confirmacion-inline {
    display: none;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.confirmacion-inline.visible { display: inline-flex; }
.confirmacion-texto {
    font-size: .82em;
    color: var(--gris-secundario);
    max-width: 260px;
    text-align: right;
}
.boton-peligro { background: var(--bx-red); color: #fff; border-color: var(--bx-red); box-shadow: 0 8px 20px rgba(237,21,58,.18); }
.boton-peligro:hover { background: #c8112f; }

/* ---------------------------------------------------------------------
   Lista de conversaciones anteriores
   --------------------------------------------------------------------- */
.aviso-revision-pendiente {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: #eef8fb;
    border: 1px solid #bfe4ef;
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 22px;
}
.aviso-revision-pendiente strong { display: block; color: var(--bx-ink); font-size: .95em; }
.aviso-revision-pendiente span { display: block; color: var(--gris-secundario); font-size: .88em; margin-top: 2px; }
.aviso-revision-pendiente .boton { flex: 0 0 auto; }

.volver-conversacion { margin: 0 0 14px; }
.volver-conversacion a { font-weight: 600; font-size: .92em; }

.barra-conversaciones-guardadas { margin-bottom: 18px; }
.lista-conversaciones { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.tarjeta-conversacion {
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-card);
    transition: box-shadow .15s, border-color .15s;
}
.tarjeta-conversacion:hover { box-shadow: var(--shadow-lift); }
.tarjeta-conversacion-activa { border-color: var(--bx-cyan); }
.tarjeta-conversacion-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 10px;
}
.tarjeta-conversacion-fecha { font-size: .82em; color: var(--gris-secundario); }
.etiqueta-activa {
    font-size: .72em;
    font-weight: 700;
    color: var(--bx-cyan);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.tarjeta-conversacion-vista-previa { margin: 0 0 6px; font-weight: 600; color: var(--bx-ink); }

/* ---------------------------------------------------------------------
   Pantalla de login
   --------------------------------------------------------------------- */
.pantalla-login {
    min-height: calc(100vh - 68px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.tarjeta-login { width: 100%; max-width: 380px; }
.tarjeta-login h1 { text-align: center; font-size: 1.5em; margin-bottom: 4px; }
.tarjeta-login form { margin-bottom: 14px; }
.tarjeta-login .ayuda { text-align: center; }

.marca-metodologia {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 0 26px;
}
.marca-metodologia img { height: 44px; width: auto; }

.vista-previa-logo { height: 52px; width: auto; display: block; margin-bottom: 16px; }

.kicker-metodologia {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}
.kicker-metodologia img { height: 38px; width: auto; }

/* ---------------------------------------------------------------------
   Panel de uso de IA (solo admin)
   --------------------------------------------------------------------- */
.panel-uso-ia {
    margin-bottom: 36px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--borde);
}

.tarjetas-stat {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0 28px;
}
.tarjeta-stat {
    flex: 1 1 160px;
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tarjeta-stat-valor {
    font-family: 'Archivo', system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.5em;
    color: var(--bx-ink);
    line-height: 1.1;
}
.tarjeta-stat-etiqueta {
    font-size: .76em;
    color: var(--gris-secundario);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.tarjeta-stat-costo .tarjeta-stat-valor { color: var(--bx-cyan-dark); }

.grafico-uso-ia {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 200px;
    padding: 26px 4px 0;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--borde);
    overflow-x: auto;
}
.barra-uso-ia-columna {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    width: 20px;
    height: 100%;
    position: relative;
}
.barra-uso-ia {
    width: 20px;
    height: 100%;
    display: flex;
    align-items: flex-end;
    cursor: default;
}
.barra-uso-ia-relleno {
    width: 100%;
    min-height: 2px;
    background: var(--bx-cyan);
    border-radius: 4px 4px 0 0;
}
.barra-uso-ia-fecha {
    display: block;
    height: 14px;
    font-size: .62em;
    color: var(--gris-secundario);
    margin-top: 6px;
    white-space: nowrap;
    transform: rotate(-40deg);
    transform-origin: top left;
}
.barra-uso-ia-nota {
    margin-top: 4px;
    margin-bottom: 20px;
    font-size: .82em;
}

.detalle-tabla-uso-ia {
    margin-bottom: 28px;
}
.detalle-tabla-uso-ia summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--bx-cyan-dark);
    margin-bottom: 12px;
}
.detalle-tabla-uso-ia table { margin-bottom: 0; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 760px) {
    .topbar { padding: 0 16px; min-height: 60px; }
    .topbar-marca img { height: 24px; }
    .topbar-menu-boton { display: flex; }
    .topbar-nav {
        display: none;
        position: absolute;
        left: 0; right: 0; top: 60px;
        background: var(--bx-ink);
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 10px 14px 18px;
        border-bottom: 1px solid rgba(255,255,255,.1);
        margin-left: 0;
        max-height: calc(100vh - 60px);
        overflow: auto;
    }
    .topbar-nav.abierto { display: flex; }
    .topbar-nav a { min-height: 46px; padding: 0 14px; font-size: 14.5px; }

    .contenedor { padding: 24px 16px 56px; }
    form, .vista-previa, .json-avanzado { padding: 18px; }
    .vista-previa { padding: 22px 18px; }

    .burbuja { max-width: 94%; }

    .historial-cabecera { flex-direction: column; align-items: stretch; }
    .form-nueva-conversacion { justify-content: flex-start; }

    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .tarjetas-stat { gap: 8px; }
    .tarjeta-stat { flex: 1 1 130px; padding: 12px 14px; }
    .tarjeta-stat-valor { font-size: 1.25em; }
    .grafico-uso-ia { -webkit-overflow-scrolling: touch; }

    button, .boton { width: 100%; }
    .boton-chico, .form-descargar-respuesta button, .acciones-revisar button,
    .confirmacion-inline button, .form-nueva-conversacion button,
    .tarjeta-conversacion button, .tarjeta-conversacion .boton { width: auto; }
    .acciones-revisar button { width: 100%; }
}

@media (max-width: 480px) {
    .badges-estilo { gap: 6px; }
    .badge-inclinacion { padding: 7px 14px; font-size: .78em; }
}
