/*
 * public/assets/css/trace-panel.css
 * Panel de trazabilidad visual + modal de informe de navegación.
 * Solo se carga cuando APP_TRACE_COMMENTS=true. Todos los selectores
 * son propios (#trace-*, .trace-*, #trep-*) y no colisionan con el CSS de producción.
 */

/* ── Botón disparador ──────────────────────────────────────────────────────── */

#trace-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #1e293b;
    color: #f8fafc;
    border: 2px solid #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: background 0.2s, transform 0.2s;
    padding: 0;
}

#trace-toggle-btn:hover {
    background: #0f172a;
    transform: scale(1.1);
}

#trace-toggle-btn.is-dragging {
    cursor: grabbing !important;
    transition: none !important;
    transform: scale(1.12);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
    opacity: 0.92;
}

#trace-toggle-btn.is-open {
    background: #6366f1;
    border-color: #818cf8;
}

/* Punto indicador de grabación sobre el botón disparador */
#trace-rec-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.2s;
}

#trace-rec-dot.is-active {
    background: #ef4444;
    animation: trace-pulse 1.2s ease-in-out infinite;
}

/* Borde rojo en el botón durante grabación */
#trace-toggle-btn.is-recording {
    border-color: #ef4444;
}

@keyframes trace-pulse {
    0%, 100% { opacity: 1;   transform: scale(1);   }
    50%       { opacity: 0.4; transform: scale(1.4); }
}

/* ── Panel lateral ─────────────────────────────────────────────────────────── */

#trace-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 96vw;
    height: 100vh;
    z-index: 99998;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.5);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 12px;
    border-left: 2px solid #1e293b;
}

#trace-panel.is-open {
    right: 0;
}

/* ── Cabecera del panel ────────────────────────────────────────────────────── */

.trace-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
    gap: 8px;
}

.trace-panel__title {
    font-size: 13px;
    font-weight: 700;
    color: #a5b4fc;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.trace-panel__title i { color: #6366f1; }

/* Controles de botones en cabecera (panel y modal) */
.trace-panel__controls {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.trace-panel__controls button {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    padding: 0;
}

.trace-panel__controls button:hover {
    background: #334155;
    color: #f1f5f9;
}

.trace-panel__controls button:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Botón Grabar activo */
.trace-panel__controls button#trace-record-btn.is-recording {
    color: #ef4444;
    border-color: #ef4444;
    background: #1e0a0a;
    animation: trace-border-pulse 1.4s ease-in-out infinite;
}

@keyframes trace-border-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
    50%       { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

/* ── Cuerpo scrollable del panel ───────────────────────────────────────────── */

.trace-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.trace-panel__body::-webkit-scrollbar { width: 4px; }
.trace-panel__body::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

/* ── Grupos de datos ───────────────────────────────────────────────────────── */

.trace-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.trace-group__label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #64748b;
    padding-bottom: 4px;
    border-bottom: 1px solid #1e293b;
}

/* ── Filas de dato ─────────────────────────────────────────────────────────── */

.trace-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 3px 5px;
    border-radius: 4px;
    line-height: 1.5;
    flex-direction: column;
}

.trace-row:hover { background: #1e293b; }

.trace-key {
    color: #64748b;
    min-width: 88px;
    flex-shrink: 0;
    font-size: 11px;
}

.trace-val {
    color: #e2e8f0;
    word-break: break-all;
    flex: 1;
    font-size: 11px;
}

.trace-val.highlight { color: #a5b4fc; font-weight: 600; }

.trace-val.tag {
    display: inline-block;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 0 6px;
    line-height: 1.8;
    color: #7dd3fc;
    margin: 0 3px 3px 0;
    font-size: 11px;
}

/* ── Lista de archivos ─────────────────────────────────────────────────────── */

.trace-file-list { display: flex; flex-direction: column; gap: 2px; }

.trace-file-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 5px;
    border-radius: 3px;
}

.trace-file-item:hover { background: #1e293b; }
.trace-file-item i { font-size: 10px; flex-shrink: 0; }
.trace-file-item.is-css i { color: #38bdf8; }
.trace-file-item.is-js  i { color: #fbbf24; }
.trace-file-item.is-ext   { opacity: 0.4;  }

.trace-file-name {
    color: #cbd5e1;
    font-size: 11px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ── Pie del panel ─────────────────────────────────────────────────────────── */

.trace-panel__footer {
    padding: 10px 14px;
    background: #1e293b;
    border-top: 1px solid #334155;
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

.trace-btn {
    flex: 1;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #94a3b8;
    cursor: pointer;
    font-size: 11px;
    font-family: 'Consolas', 'Menlo', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.15s, color 0.15s;
}

.trace-btn:hover { background: #334155; color: #f1f5f9; }

.trace-btn.trace-btn--copy.copied {
    background: #14532d;
    border-color: #16a34a;
    color: #86efac;
}

/* ── Overlay de fondo ──────────────────────────────────────────────────────── */

#trace-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99997;
}

#trace-overlay.is-open { display: block; }

/* ── Modal informe de navegación ───────────────────────────────────────────── */

#trace-report-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    padding: 16px;
}

#trace-report-modal.is-open {
    opacity: 1;
    pointer-events: all;
}

.trace-report__inner {
    background: #0f172a;
    color: #e2e8f0;
    width: 100%;
    max-width: 860px;
    /* height fija para que .trace-report__body (flex:1) tenga un techo y pueda hacer overflow:auto */
    height: 88vh;
    max-height: 88vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
    border: 1px solid #1e293b;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 12px;
    overflow: hidden;
}

.trace-report__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
    gap: 10px;
}

.trace-report__header-title {
    font-size: 14px;
    font-weight: 700;
    color: #a5b4fc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.trace-report__header-title i { color: #6366f1; }

/* Cuerpo del modal — scroll directo en el body, no en las panes */
.trace-report__body {
    flex: 1;
    overflow: auto;
    min-height: 0; /* imprescindible para que flex-child pueda contraerse y scrollear */
    /* scrollbar fina */
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.trace-report__body::-webkit-scrollbar       { width: 5px; }
.trace-report__body::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

/* Resumen superior */
.trace-report__summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: #1e293b;
    border-radius: 8px;
    border: 1px solid #334155;
    font-size: 12px;
    color: #94a3b8;
}

.trace-report__summary span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #cbd5e1;
}

.trace-report__summary i { color: #6366f1; }

/* Entrada de página */
.trace-report__entry {
    border: 1px solid #1e293b;
    border-radius: 8px;
    overflow: hidden;
}

.trace-report__entry-hdr {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: #1e293b;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.trace-report__entry-hdr:hover { background: #273549; }

/* Cuerpo de la entrada: colapsable — oculto por defecto */
.trace-report__entry-body {
    display: none;
    padding: 10px 14px;
}

.trace-report__entry-body.is-open {
    display: block;
}

/* Chevron de entrada */
.trep-entry-chevron {
    flex-shrink: 0;
    margin-left: auto;
    color: #475569;
    font-size: 11px;
    transition: color 0.15s;
}

.trace-report__entry-hdr:hover .trep-entry-chevron { color: #94a3b8; }

.trace-report__num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #6366f1;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.trace-report__entry-title {
    font-weight: 700;
    color: #e2e8f0;
    font-size: 12px;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.trace-report__entry-ts {
    font-size: 10px;
    color: #64748b;
    flex-shrink: 0;
}

.trace-report__entry-url {
    padding: 4px 14px 10px;
    font-size: 10px;
    color: #475569;
    border-bottom: 1px solid #1e293b;
    word-break: break-all;
}

/* ── Flujo de pasos Vista→Controlador→Modelo→JS→AJAX ───────────────────────── */

.tflow {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 4px 0;
}

.tflow-empty {
    color: #475569;
    font-size: 11px;
    padding: 6px 4px;
}

/* Flecha entre pasos */
.tflow-arrow {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 1px 0 1px 11px;
    color: #334155;
    font-size: 10px;
    line-height: 1;
}

/* Un paso del flujo */
.tflow-step {
    border-left: 2px solid #1e293b;
    margin-left: 10px;
    padding: 6px 8px 6px 10px;
    border-radius: 0 6px 6px 0;
    transition: background 0.15s;
}

.tflow-step:hover { background: #0f172a; }

.tflow-step--vista        { border-left-color: #38bdf8; }
.tflow-step--controlador  { border-left-color: #a78bfa; }
.tflow-step--util         { border-left-color: #fb923c; }
.tflow-step--modelo       { border-left-color: #34d399; }
.tflow-step--js           { border-left-color: #fbbf24; }
.tflow-step--ajax         { border-left-color: #f87171; }

/* Cabecera del paso */
.tflow-step__head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tflow-step__icon {
    font-size: 11px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.tflow-step__meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.tflow-step__type {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    opacity: 0.8;
}

.tflow-step__label {
    font-size: 11px;
    font-weight: 600;
    color: #e2e8f0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ── Árbol colapsable de pasos ─────────────────────────────────────────────── */

/* El cursor pointer solo en pasos que tienen cuerpo colapsable */
.tflow-step--has-body .tflow-step__head {
    cursor: pointer;
    user-select: none;
}

.tflow-step--has-body .tflow-step__head:hover { background: rgba(255,255,255,0.03); border-radius: 4px; }
.tflow-step--has-body .tflow-step__head:focus-visible {
    outline: 1px solid #6366f1;
    border-radius: 4px;
}

/* Botón chevron */
.tflow-toggle {
    flex-shrink: 0;
    margin-left: auto;
    color: #334155;
    font-size: 10px;
    width: 16px;
    text-align: center;
    transition: color 0.15s;
}

.tflow-step__head:hover .tflow-toggle { color: #64748b; }

/* Cuerpo colapsable del paso */
.tflow-step__body {
    display: none;
    flex-direction: column;
    gap: 5px;
}

.tflow-step__body.is-open {
    display: flex;
}

/* Bloque de comentario del paso */
.tflow-step__comment {
    margin-top: 5px;
    padding: 6px 8px;
    background: #0f172a;
    border-radius: 4px;
    border: 1px solid #1e293b;
}

.tflow-step__comment pre {
    margin: 0;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 10px;
    color: #94a3b8;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.55;
}

/* ── Tabs Resumen / Flujo ──────────────────────────────────────────────────── */

.trace-panel__tabs {
    display: flex;
    flex-shrink: 0;
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
}

.trace-tab {
    flex: 1;
    padding: 8px 6px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #475569;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Consolas', 'Menlo', monospace;
    letter-spacing: 0.4px;
    transition: color 0.15s, border-color 0.15s;
}

.trace-tab:hover:not(.is-active) { color: #94a3b8; }

.trace-tab.is-active {
    color: #a5b4fc;
    border-bottom-color: #6366f1;
}

/* Cada tab tiene su propio contenedor scrollable que ocupa el espacio restante del panel */
.trace-panel__tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0; /* necesario para que flex-child pueda hacer scroll */
}

.trace-panel__tab-content::-webkit-scrollbar       { width: 4px; }
.trace-panel__tab-content::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

/* ── Símbolos por paso del flujo ───────────────────────────────────────────── */

.tflow-step__symbols {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tflow-sym-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 3px;
    row-gap: 3px;
}

.tflow-sym-key {
    font-size: 9px;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    flex-shrink: 0;
    padding-top: 2px;
    min-width: 62px;
}

.tflow-sym-tag {
    font-size: 10px;
    font-family: 'Consolas', 'Menlo', monospace;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 1.7;
}

/* Colores por categoría de símbolo */
.tflow-sym--used   { background: #1a2e0a; color: #a3e635; border: 1px solid #4d7c0f; font-weight: 700; }
.tflow-sym--method { background: #1e1a3a; color: #a78bfa; border: 1px solid #3d2fa3; }
.tflow-sym--call   { background: #0f2010; color: #4ade80; border: 1px solid #166534; }
.tflow-sym--fn     { background: #231a00; color: #fbbf24; border: 1px solid #78450a; }
.tflow-sym--fetch  { background: #250a0a; color: #f87171; border: 1px solid #7f1d1d; }
.tflow-sym--dom    { background: #061820; color: #7dd3fc; border: 1px solid #0c4a6e; }

/* Label especial para la fila "En uso aquí" */
.tflow-sym-key--used {
    color: #84cc16;
    font-weight: 700;
}

/* ── Nota de flujo parcial ─────────────────────────────────────────────────── */

.tflow-partial-note {
    font-size: 10px;
    color: #64748b;
    padding: 4px 8px;
    background: #0f172a;
    border-left: 2px solid #475569;
    border-radius: 0 4px 4px 0;
    margin-bottom: 6px;
}

/* ── Tabs del modal informe (Páginas / Línea temporal / AJAX) ──────────────── */

.trep-tabs {
    display: flex;
    flex-shrink: 0;
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
    padding: 0 20px;
    gap: 0;
}

.trep-tab {
    padding: 9px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #475569;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Consolas', 'Menlo', monospace;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.trep-tab:hover:not(.is-active) { color: #94a3b8; }

.trep-tab.is-active {
    color: #a5b4fc;
    border-bottom-color: #6366f1;
}

.trep-tab-pane {
    display: none; /* el JS activa con display:flex */
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.trep-empty {
    color: #475569;
    font-size: 12px;
    padding: 24px 0;
    text-align: center;
}

/* ── Línea temporal ────────────────────────────────────────────────────────── */

.trep-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.trep-tl-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 5px;
    transition: background 0.12s;
    font-size: 11px;
}

.trep-tl-item:hover { background: #1e293b; }

.trep-tl-ts {
    color: #475569;
    font-size: 10px;
    flex-shrink: 0;
    min-width: 64px;
    padding-top: 1px;
}

.trep-tl-icon {
    font-size: 10px;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
    padding-top: 1px;
}

.trep-tl-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.trep-tl-label {
    color: #e2e8f0;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.trep-tl-detail {
    color: #64748b;
    font-size: 10px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.trep-tl-item--page   .trep-tl-label { color: #a78bfa; }
.trep-tl-item--user   .trep-tl-label { color: #38bdf8; }
.trep-tl-item--ajax   .trep-tl-label { color: #f87171; }
.trep-tl-item--error  .trep-tl-label { color: #ef4444; }

/* ── Tabla AJAX capturado ──────────────────────────────────────────────────── */

.trep-ajax-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.trep-ajax-table thead th {
    padding: 6px 8px;
    text-align: left;
    color: #64748b;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    border-bottom: 1px solid #1e293b;
    background: #0f172a;
}

.trep-ajax-table tbody td {
    padding: 5px 8px;
    color: #cbd5e1;
    border-bottom: 1px solid #0f172a;
    vertical-align: top;
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.trep-ajax-table tbody tr:hover td { background: #1e293b; }

.trep-ajax-ts     { color: #475569; min-width: 60px; }
.trep-ajax-method { color: #fbbf24; font-weight: 700; }
.trep-ajax-url    { color: #a5b4fc; max-width: 180px !important; }
.trep-ajax-ok     { color: #4ade80; font-weight: 700; }
.trep-ajax-err    { color: #f87171; font-weight: 700; }
.trep-ajax-trigger{ color: #94a3b8; font-size: 10px; }
.trep-ajax-resp   { color: #64748b; font-size: 10px; }

/* ── Acciones del usuario en la vista de páginas ───────────────────────────── */

.trep-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #38bdf8;
    margin-top: 10px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.trep-user-log {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
}

.trep-user-ev {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    color: #94a3b8;
}

.trep-user-ev:hover { background: #1e293b; }
.trep-user-ts     { color: #475569; min-width: 56px; flex-shrink: 0; }
.trep-user-action { color: #38bdf8; font-weight: 600; }
.trep-user-sel    { color: #64748b; font-style: italic; }
.trep-user-label  { color: #e2e8f0; }
.trep-user-ev--error .trep-user-action { color: #ef4444; }

/* ── Mini resumen mejorado en cabecera de cada página ──────────────────────── */

.trace-report__mini-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 6px 0 8px;
    font-size: 11px;
    color: #64748b;
}

.trace-report__mini-summary span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.trace-report__mini-summary i { color: #6366f1; }

/* ── Tabla AJAX: scroll horizontal en pantallas estrechas ──────────────────── */

.trep-ajax-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

/* Tablet ancha: reducir ancho máximo del modal */
@media (max-width: 900px) {
    .trace-report__inner { max-width: 100%; }
}

/* Tablet estrecha / móvil horizontal */
@media (max-width: 768px) {
    /* Panel lateral ocupa todo el ancho */
    #trace-panel {
        width: 100vw;
        max-width: 100vw;
        right: -100vw;
    }
    /* Modal: bottom-sheet que sube desde abajo */
    #trace-report-modal {
        padding: 0;
        align-items: flex-end;
    }
    .trace-report__inner {
        width: 100%;
        max-width: 100%;
        /* altura fija para que los panes internos puedan hacer scroll */
        height: 92vh;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
    }
    .trace-report__header {
        border-radius: 16px 16px 0 0;
        padding: 12px 16px;
    }
    /* Cabecera del modal: título más pequeño para que quepan los botones */
    .trace-report__header-title { font-size: 12px; }
    /* Tabs del modal más compactos */
    .trep-tabs { padding: 0 10px; }
    .trep-tab  { padding: 8px 10px; font-size: 10px; }
    /* Tab panes: padding reducido */
    .trep-tab-pane { padding: 12px; }
    /* Cabecera del panel lateral compacta */
    .trace-panel__title { font-size: 12px; }
}

/* Móvil vertical */
@media (max-width: 520px) {
    /* Botón flotante más pegado a la esquina */
    #trace-toggle-btn { bottom: 14px; right: 14px; }
    /* Modal: bottom-sheet casi pantalla completa */
    .trace-report__inner {
        height: 96vh;
        max-height: 96vh;
        border-radius: 12px 12px 0 0;
    }
    /* Tabs del modal: ocultar iconos para ganar espacio */
    .trep-tab i { display: none; }
    .trep-tab   { padding: 7px 8px; font-size: 10px; gap: 2px; }
    .trep-tabs  { padding: 0 6px; gap: 0; }
    /* Tab panes: padding mínimo */
    .trep-tab-pane { padding: 10px 8px; }
    /* Flujo: label más pequeño */
    .tflow-step__label { font-size: 10px; }
    /* Entradas del informe: título truncado */
    .trace-report__entry-title { font-size: 11px; }
    /* Timestamp de entrada oculto en pantallas muy pequeñas */
    .trace-report__entry-ts { display: none; }
    /* Ocultar columnas AJAX menos importantes */
    .trep-ajax-table th:nth-child(5),
    .trep-ajax-table td:nth-child(5),
    .trep-ajax-table th:nth-child(6),
    .trep-ajax-table td:nth-child(6) { display: none; }
    /* Línea temporal: timestamps compactos */
    .trep-tl-ts { min-width: 48px; font-size: 9px; }
    /* Panel lateral: cabecera compacta */
    .trace-panel__header { padding: 8px 10px; }
    .trace-panel__controls button { padding: 4px 7px; font-size: 10px; }
}
