/* Autogestión de reportes — chat y tableros (sobre el tema de Orchid/Bootstrap). */
:root {
    --rp-border: #e3e7ee;
    --rp-muted: #6b7686;
    --rp-bg-soft: #f6f8fb;
    --rp-accent: #9c0400;
    --rp-user: #fbeceb;

    /* Marca Original Table's */
    --tb-red: #9c0400;
    --tb-red-hover: #7f0300;
    --tb-red-bright: #eb1b24;
    --tb-dark: #1b1b1d;
    --bs-primary: #9c0400;
    --bs-primary-rgb: 156, 4, 0;
    --bs-link-color: #9c0400;
    --bs-link-color-rgb: 156, 4, 0;
    --bs-link-hover-color: #7f0300;
    --bs-link-hover-color-rgb: 127, 3, 0;
}

/* ---------- marca */
.tb-logo { max-width: 100%; height: auto; max-height: 56px; }
.tb-logo-auth { max-height: 72px; }

.tb-footer { color: var(--rp-muted); padding: 1rem 0; }
.aside.bg-dark { background-color: var(--tb-dark) !important; border-top: 4px solid var(--tb-red); }
.aside .nav-link.active, .aside .nav-link.active:hover { background-color: var(--tb-red) !important; color: #fff !important; }
.aside .nav-link:hover { background-color: rgba(255, 255, 255, .06); }
.aside .badge.bg-primary, .aside .badge.text-bg-primary { background-color: var(--tb-red-bright) !important; }
.btn-primary, .btn-success {
    --bs-btn-bg: #9c0400; --bs-btn-border-color: #9c0400;
    --bs-btn-hover-bg: #7f0300; --bs-btn-hover-border-color: #7f0300;
    --bs-btn-active-bg: #6b0200; --bs-btn-active-border-color: #6b0200;
    --bs-btn-disabled-bg: #9c0400; --bs-btn-disabled-border-color: #9c0400;
    --bs-btn-focus-shadow-rgb: 156, 4, 0;
    background-color: #9c0400 !important; border-color: #9c0400 !important; color: #fff !important;
}
.btn-primary:hover, .btn-success:hover, .btn-primary:active, .btn-success:active { background-color: #7f0300 !important; border-color: #7f0300 !important; }
.form-control:focus, .form-select:focus { border-color: #d98a88; box-shadow: 0 0 0 .2rem rgba(156, 4, 0, .15); }
.form-check-input:checked { background-color: var(--tb-red); border-color: var(--tb-red); }
.page-item.active .page-link { background-color: var(--tb-red); border-color: var(--tb-red); }

/* ---------- marco: menú completo ↔ barra de íconos (escritorio) y celular */
.tb-logo-mini { display: none; width: 34px; height: auto; }
.tb-topline { gap: .25rem; }
.tb-topline nav[aria-label="breadcrumb"] .breadcrumb { padding-left: .5rem !important; }
.tb-menu-toggle {
    align-items: center; justify-content: center; width: 34px; height: 34px; margin: 0 0 .5rem .75rem; padding: 0;
    border: 0; border-radius: 50%; background: transparent; color: #4a5260;
}
.tb-menu-toggle:hover { background: rgba(20, 30, 50, .08); color: #1b1b1d; }
.tb-menu-toggle .icon, .tb-menu-toggle svg { width: 1.25rem; height: 1.25rem; }
@media (min-width: 992px) {
    html.tb-menu-hidden .aside { flex: 0 0 76px; max-width: 76px; width: 76px; padding: 0 .5rem; }
    html.tb-menu-hidden .aside + div { flex: 1 1 0; max-width: calc(100% - 76px); width: auto; }
    html.tb-menu-hidden .container-xl { max-width: none; padding: 0 1rem !important; }
    html.tb-menu-hidden .aside > header { justify-content: center; padding: 1rem 0 !important; }
    html.tb-menu-hidden .aside .tb-logo { display: none; }
    html.tb-menu-hidden .aside .tb-logo-mini { display: block; }
    html.tb-menu-hidden .aside .tb-brand { justify-content: center; }
    html.tb-menu-hidden .aside-collapse > .p-3:first-child,
    html.tb-menu-hidden .aside .scroll-to-top,
    html.tb-menu-hidden .aside .nav-link > span,
    html.tb-menu-hidden .aside .profile-container small,
    html.tb-menu-hidden .aside .profile-container > :not(:first-child) { display: none !important; }
    /* Títulos de sección → una línea fina. */
    html.tb-menu-hidden .aside .nav-item > small { display: block; font-size: 0; height: 1px; margin: .25rem .75rem; background: rgba(255, 255, 255, .12); }
    html.tb-menu-hidden .aside .nav-item.mt-3 { margin-top: .5rem !important; }
    html.tb-menu-hidden .aside .nav-link { justify-content: center; padding: .6rem 0; position: relative; }
    html.tb-menu-hidden .aside .nav-link > svg, html.tb-menu-hidden .aside .nav-link > .icon { margin: 0 !important; width: 1.25rem; height: 1.25rem; }
    /* Avisos (badges) → punto en la esquina del ícono. */
    html.tb-menu-hidden .aside .nav-link .badge { position: absolute; top: 4px; right: 10px; font-size: 0; width: 9px; height: 9px; padding: 0; min-width: 0; }
    html.tb-menu-hidden .aside .profile-container { justify-content: center; padding: .75rem 0 !important; }
    html.tb-menu-hidden .aside .profile-container > a { flex: 0 0 auto; width: auto; justify-content: center; }
}
@media (max-width: 991.98px) {
    /* Barra de arriba compacta y fija, con el logo chico (antes se encimaba con el título). */
    .aside { position: sticky; top: 0; z-index: 1020; }
    .aside > header { padding: .5rem .75rem !important; margin: 0 !important; gap: .5rem; }
    .aside .header-toggler { min-width: 0; flex: 1 1 auto; }
    .aside .header-toggler > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1rem; }
    .aside .header-toggler .icon-menu { width: 1.4rem; height: 1.4rem; flex: 0 0 auto; }
    .aside .header-brand { flex: 0 0 auto; }
    .aside .tb-logo { max-height: 30px; width: auto; }
    .aside-collapse { max-height: calc(100vh - 56px); overflow-y: auto; }
    .workspace { padding-left: .5rem; padding-right: .5rem; }
    .breadcrumb { font-size: .8rem; padding-left: .5rem !important; padding-right: .5rem !important; }
    /* Barra de acciones de Orchid (abajo en el celular): sin barra de scroll, botones que se acomodan. */
    .command-bar-wrapper .command-bar { flex-wrap: wrap !important; scrollbar-width: none; }
    .command-bar-wrapper .command-bar::-webkit-scrollbar { display: none; }
    .rp-composer .rp-hint { font-size: 0; }
    .rp-composer .rp-hint .rp-attach { font-size: .85rem; }
    .rp-chart { height: 300px; }
    .rp-filter-form { flex-wrap: wrap; }
    .rp-modal { padding: 0; }
    .rp-modal-box { max-height: 100vh; height: 100vh; border-radius: 0; }
}

/* ---------- reportes */
.rp-empty, .rp-loading { color: var(--rp-muted); padding: 2rem 1rem; text-align: center; }
.rp-error { background: #fff4f4; border: 1px solid #f3c7c7; color: #8a1f1f; border-radius: 8px; padding: .75rem 1rem; font-size: .9rem; white-space: pre-wrap; }
.rp-chart { width: 100%; height: 360px; }
.rp-toggle { padding-left: 0; font-size: .8rem; }
.rp-note { color: var(--rp-muted); font-size: .8rem; padding: .25rem 0; }
.rp-table-wrap { max-height: 460px; overflow: auto; border: 1px solid var(--rp-border); border-radius: 6px; }
.rp-table { margin: 0; font-size: .85rem; }
.rp-table thead th { position: sticky; top: 0; background: var(--rp-bg-soft); cursor: pointer; white-space: nowrap; user-select: none; z-index: 1; }
.rp-table tfoot td { position: sticky; bottom: 0; background: var(--rp-bg-soft); font-weight: 600; }
.rp-table td { white-space: nowrap; }
.rp-num { text-align: right; font-variant-numeric: tabular-nums; }
.rp-table-search { max-width: 260px; margin-bottom: .5rem; }
.rp-kpis { display: flex; flex-wrap: wrap; gap: .75rem; }
.rp-kpi { flex: 1 1 140px; background: var(--rp-bg-soft); border-radius: 8px; padding: 1rem; }
.rp-kpi-value { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.rp-kpi-label { color: var(--rp-muted); font-size: .85rem; margin-top: .25rem; }
.rp-kpi-note { color: var(--rp-muted); font-size: .8rem; margin-top: .5rem; }

/* ---------- tablero */
.rp-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--rp-border); margin-bottom: 1rem; flex-wrap: wrap; }
.rp-tabs a { padding: .5rem 1rem; color: var(--rp-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.rp-tabs a.active { color: var(--rp-accent); border-bottom-color: var(--rp-accent); font-weight: 600; }
.rp-tabs a:hover { color: #222; }
.rp-filters:not(:empty) { background: #fff; border: 1px solid var(--rp-border); border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; }
.rp-filter-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.rp-filter { display: flex; flex-direction: column; font-size: .8rem; color: var(--rp-muted); margin: 0; }
.rp-filter input { min-width: 150px; }
.rp-grid { display: flex; flex-wrap: wrap; margin: 0 -.5rem; }
.rp-widget { padding: 0 .5rem; margin-bottom: 1rem; }
.rp-widget-card { background: #fff; border: 1px solid var(--rp-border); border-radius: 10px; height: 100%; display: flex; flex-direction: column; }
.rp-w-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; padding: .75rem 1rem .25rem; }
.rp-w-title { font-weight: 600; }
.rp-w-desc { color: var(--rp-muted); font-size: .8rem; }
.rp-w-body { padding: .5rem 1rem 1rem; flex: 1; min-width: 0; }
.rp-w-foot { color: var(--rp-muted); font-size: .75rem; padding: 0 1rem .5rem; }
.rp-w-actions .dropdown-toggle::after { display: none; }
.rp-w-actions .btn { padding: .1rem .4rem; color: var(--rp-muted); }
.rp-empty-tab { text-align: center; padding: 3rem 1rem; color: var(--rp-muted); background: #fff; border: 1px dashed var(--rp-border); border-radius: 10px; }

/* ---------- chat */
.rp-chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 520px; background: #fff; border: 1px solid var(--rp-border); border-radius: 10px; }
.rp-chat-context { padding: .5rem 1rem; border-bottom: 1px solid var(--rp-border); font-size: .85rem; color: var(--rp-muted); }
.rp-chat-context:empty { display: none; }
.rp-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.rp-msg { display: flex; flex-direction: column; max-width: 100%; }
.rp-msg-user { align-items: flex-end; }
.rp-msg-user .rp-bubble { background: var(--rp-user); max-width: 75%; }
.rp-bubble { background: var(--rp-bg-soft); border-radius: 10px; padding: .75rem 1rem; max-width: 100%; }
.rp-bubble p:last-child, .rp-bubble ul:last-child { margin-bottom: 0; }
.rp-bubble-error { background: #fff4f4; color: #8a1f1f; }
.rp-meta { color: var(--rp-muted); font-size: .75rem; margin-top: .25rem; }
.rp-thinking { color: var(--rp-muted); }
.rp-steps { margin: .5rem 0 0; padding-left: 1.25rem; font-size: .8rem; max-height: 220px; overflow: auto; }
.rp-steps code { font-size: .75rem; }
.rp-step-tool { font-weight: 600; margin-right: .25rem; }
.rp-dots { display: inline-flex; gap: 4px; margin-right: .5rem; vertical-align: middle; }
.rp-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--rp-accent); animation: rp-blink 1.2s infinite ease-in-out; }
.rp-dots span:nth-child(2) { animation-delay: .2s; }
.rp-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes rp-blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.rp-proposal { border: 1px solid var(--rp-border); border-radius: 10px; padding: 1rem; margin-top: .5rem; background: #fff; box-shadow: 0 1px 3px rgba(20, 30, 50, .05); }
.rp-proposal-old { opacity: .75; }
.rp-proposal-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.rp-proposal-title { font-weight: 600; font-size: 1.05rem; }
.rp-proposal-desc { color: var(--rp-muted); font-size: .85rem; }
.rp-proposal-params { font-size: .8rem; color: var(--rp-muted); margin-bottom: .5rem; }
.rp-sql summary { cursor: pointer; color: var(--rp-muted); font-size: .8rem; margin-top: .5rem; }
.rp-sql pre { background: #1f2430; color: #e6e9ef; padding: .75rem; border-radius: 6px; font-size: .78rem; max-height: 320px; overflow: auto; white-space: pre-wrap; }
.rp-save { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--rp-border); }
.rp-save select { max-width: 280px; }
.rp-save input { max-width: 220px; }
.rp-save-msg { color: #b02a37; font-size: .85rem; }
.rp-composer { border-top: 1px solid var(--rp-border); padding: .75rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
.rp-composer textarea { resize: vertical; width: 100%; max-width: none; }
.rp-composer.rp-drop { outline: 2px dashed var(--rp-accent, #c9201f); outline-offset: -4px; }
.rp-attachments { display: flex; gap: .5rem; flex-wrap: wrap; }
.rp-thumb { position: relative; }
.rp-thumb img { height: 64px; max-width: 120px; object-fit: cover; border-radius: 6px; border: 1px solid var(--rp-border); }
.rp-thumb button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; line-height: 18px; padding: 0; border-radius: 50%;
    border: 0; background: #333; color: #fff; font-size: 14px; }
.rp-file-chip { display: inline-flex; align-items: center; gap: .25rem; max-width: 260px; padding: .35rem .6rem; border-radius: 6px;
    border: 1px solid var(--rp-border); background: #fff; font-size: .8rem; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.rp-thumb-file { display: flex; align-items: center; }
.rp-msg-images { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.rp-msg-images img { max-height: 160px; max-width: 260px; border-radius: 6px; display: block; }
.rp-composer-bar { display: flex; justify-content: space-between; align-items: center; }
.rp-hint { color: var(--rp-muted); font-size: .75rem; }
.rp-conn { max-width: 300px; }
.rp-welcome { color: #333; max-width: 720px; margin: 2rem auto; text-align: center; }
.rp-welcome p { color: var(--rp-muted); }
.rp-examples { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }

/* ---------- refresco automático */
.rp-autorefresh { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--rp-muted); margin: 0 0 .5rem .25rem; }
.rp-autorefresh-dot { width: 8px; height: 8px; border-radius: 50%; background: #2e9d4f; box-shadow: 0 0 0 0 rgba(46, 157, 79, .5); animation: rp-pulse 2s infinite; }
@keyframes rp-pulse { 0% { box-shadow: 0 0 0 0 rgba(46, 157, 79, .5); } 70% { box-shadow: 0 0 0 6px rgba(46, 157, 79, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 157, 79, 0); } }
.rp-w-stale .rp-w-time { color: #b26a00; }

/* ---------- detalle (drill-down) */
.rp-drillable tbody tr, .rp-drillable .rp-kpi { cursor: pointer; }
.rp-drillable tbody tr:hover td { background: var(--rp-user); }
.rp-modal { position: fixed; inset: 0; background: rgba(20, 30, 50, .45); z-index: 2000; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; }
.rp-modal-box { background: #fff; border-radius: 10px; width: min(1200px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.rp-modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--rp-border); }
.rp-modal-count { color: var(--rp-muted); font-size: .8rem; margin-right: .5rem; }
.rp-modal-body { padding: 1rem; overflow: auto; min-height: 120px; }
.rp-modal-body .rp-table-wrap { max-height: calc(92vh - 170px); }

@media (max-width: 768px) {
    .rp-widget { flex: 0 0 100% !important; max-width: 100% !important; }
    .rp-chat { height: calc(100vh - 160px); }
    .rp-msg-user .rp-bubble { max-width: 90%; }
}
.rp-hint .btn-link { font-size: inherit; vertical-align: baseline; text-decoration: none; }

/* Fuentes de las variables externas (IPC, TAMAR, dólar...) debajo del reporte */
.rp-sources { font-size: .78rem; color: var(--rp-muted); margin-top: .5rem; border-top: 1px dashed rgba(0, 0, 0, .1); padding-top: .35rem; }
.rp-sources summary { cursor: pointer; }
.rp-sources ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.rp-sources li { margin-bottom: .35rem; }
.rp-sources strong { color: inherit; }
