:root {
    --cb-primary: #0045AC;
    --cb-primary-dark: #112f5c;
    --cb-navy: #1E2637;
    --cb-slate: #869AAC;
    --cb-red: #DA291C;
    --cb-green: #148f3c;
    --cima-blue-dark: #155279;
    --cima-blue-mid: #2874a6;
    --cima-blue-light: #48b2e8;
    --cima-amber: #f39c12;
    --cima-bg-board: #f2f4f8;
    --cima-card-bg: #ffffff;
    --cima-border: #d9e1ec;
    --cima-text: #1c2833;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Google Sans Flex', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    background-color: var(--cima-bg-board);
    color: var(--cima-text);
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LOGO OFICIAL CIMA BOOKING
   ========================================================================== */
.cb-brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.cb-logo-cima {
    height: 30px;
    width: auto;
}

.cb-logo-booking {
    height: 30px;
    width: auto;
}

.cb-brand-logo-sm .cb-logo-cima,
.cb-brand-logo-sm .cb-logo-booking {
    height: 22px;
}

.cb-brand-logo-dark .cb-logo-cima {
    filter: brightness(0) invert(1);
}

.cb-brand-logo-dark .cb-logo-booking {
    filter: brightness(1.35);
}

/* ==========================================================================
   PANTALLA DE LOGIN (/login) - IDENTIDAD CIMA BOOKING
   ========================================================================== */
.login-page-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #eef4ff 0%, #dde7f5 50%, #cfdceb 100%);
    padding: 20px;
}

.login-card {
    background: #ffffff;
    width: 100%;
    max-width: 430px;
    border-radius: 16px;
    padding: 36px 34px;
    box-shadow: 0 16px 40px rgba(17, 47, 92, 0.14);
    border: 1px solid rgba(0, 69, 172, 0.1);
}

.login-brand-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 26px;
}

.login-badge-pill {
    margin-top: 12px;
    background: #EDF4FA;
    color: #0045AC;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 999px;
}

/* ==========================================================================
   TABLERO CARTERA Y RECUPERACIÓN
   ========================================================================== */
.cartera-board {
    background-color: #f3f5f8;
    padding: 18px 24px 24px 24px;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

.cartera-board.embedded-mode {
    padding: 14px 20px;
}

.cartera-header {
    display: grid;
    grid-template-columns: 270px 1fr auto;
    align-items: center;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #d5dce6;
    margin-bottom: 16px;
}

.cartera-main-title {
    text-align: center;
    font-size: 31px;
    font-weight: 800;
    color: #112f5c;
    margin: 0;
    letter-spacing: -0.4px;
}

.cartera-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #4b5563;
    letter-spacing: 0.4px;
    padding-left: 2px;
}

.cima-select {
    appearance: none;
    background-color: #ffffff;
    border: 1.5px solid #94a3b8;
    border-radius: 6px;
    padding: 7px 32px 7px 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    min-width: 155px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231e293b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cima-select:focus {
    outline: none;
    border-color: var(--cb-primary);
    box-shadow: 0 0 0 3px rgba(0, 69, 172, 0.15);
}

.cima-select:disabled {
    background-color: #e2e8f0;
    cursor: not-allowed;
}

.cartera-top-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    margin-bottom: 18px;
}

.panel-box {
    background: #ffffff;
    border: 1px solid #dce3ec;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 2px 6px rgba(15, 37, 55, 0.04);
}

.left-facturacion-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
}

.kpi-headline-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
}

.kpi-title {
    font-size: 21px;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.kpi-big-amount {
    font-size: 40px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.05;
    margin: 4px 0 6px 0;
    letter-spacing: -0.8px;
}

.kpi-sub-Exact {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 8px;
}

.credito-contado-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 6px 0 8px 0;
}

.cc-row {
    display: grid;
    grid-template-columns: 72px 1fr 148px;
    align-items: center;
    gap: 10px;
}

.cc-label {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.cc-track {
    height: 22px;
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.cc-fill-credito {
    height: 100%;
    background: linear-gradient(90deg, #0045AC 0%, #1f6ca0 100%);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.cc-fill-contado {
    height: 100%;
    background: linear-gradient(90deg, #43a6c6 0%, #5bc0de 100%);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.cc-value {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

.donut-container-wrap {
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.donut-header-title {
    font-size: 14px;
    font-weight: 700;
    color: #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.donut-visual-grid {
    display: grid;
    grid-template-columns: 155px 1fr;
    align-items: center;
    gap: 10px;
}

.donut-chart-box {
    width: 155px;
    height: 155px;
}

.donut-legend-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.donut-stat-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
}

.donut-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-top: 3px;
    flex-shrink: 0;
}

.donut-stat-text {
    font-size: 12.5px;
    line-height: 1.3;
    color: #1e293b;
}

.donut-stat-text strong {
    display: block;
    font-size: 14px;
    font-weight: 800;
    color: #0f172a;
    margin-top: 2px;
}

.right-cartera-panel {
    display: grid;
    grid-template-columns: 1fr 290px;
    gap: 20px;
    align-items: center;
}

.aging-bars-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.aging-row {
    display: grid;
    grid-template-columns: 88px 1fr 165px;
    align-items: center;
    gap: 12px;
}

.aging-label {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    text-align: right;
}

.aging-track {
    height: 24px;
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.aging-fill-15 { height: 100%; background-color: #48b2e8; transition: width 0.4s ease; }
.aging-fill-30 { height: 100%; background-color: #145889; transition: width 0.4s ease; }
.aging-fill-45 { height: 100%; background-color: #f39c12; transition: width 0.4s ease; }
.aging-fill-mas45 { height: 100%; background-color: #DA291C; transition: width 0.4s ease; }

.aging-value {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
}

.variacion-box {
    background: #f8fafc;
    border: 1px solid #dce3ec;
    border-radius: 10px;
    padding: 18px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.variacion-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 12px 0;
}

.variacion-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}

.variacion-arrow { font-size: 46px; font-weight: 900; line-height: 1; }
.variacion-pct { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.variacion-good { color: #138a36; }
.variacion-bad { color: #DA291C; }

.variacion-desc {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    margin: 4px 0 8px 0;
}

.variacion-diff-amount {
    font-size: 32px;
    font-weight: 800;
    color: #111827;
    margin: 2px 0;
}

.variacion-prev-ref {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    margin-top: 4px;
}

.cartera-bottom-grid {
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    gap: 20px;
}

.section-card-title {
    font-size: 21px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 12px 0;
    text-align: center;
}

.unidad-bar-chart-container {
    width: 100%;
    height: 340px;
}

.top-clientes-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 18px;
    padding: 4px 6px;
}

.top-cliente-row {
    display: grid;
    grid-template-columns: 185px 1fr 110px;
    align-items: center;
    gap: 12px;
}

.top-cliente-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-cliente-track {
    height: 26px;
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
}

.top-cliente-bar {
    height: 100%;
    background: linear-gradient(90deg, #112f5c 0%, #0045AC 100%);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.top-cliente-amount {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
}

.top-cliente-row.clickable {
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.top-cliente-row.clickable:hover {
    background-color: #EDF4FA;
    transform: translateX(3px);
}

.top-cliente-row.clickable:hover .top-cliente-name {
    color: #0045AC;
}

.drilldown-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border: 1px solid #d5dce6;
    border-left: 5px solid #0045AC;
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 6px rgba(17, 47, 92, 0.05);
}

.drilldown-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.drilldown-kpi-card {
    background: #ffffff;
    border: 1px solid #dce3ec;
    border-radius: 10px;
    padding: 14px 18px;
    box-shadow: 0 1px 4px rgba(15, 37, 55, 0.04);
}

.drilldown-kpi-label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.drilldown-kpi-value {
    font-size: 26px;
    font-weight: 800;
    color: #112f5c;
    line-height: 1.1;
}

.drilldown-kpi-sub {
    font-size: 12px;
    color: #475569;
    font-weight: 600;
    margin-top: 4px;
}

.drilldown-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 18px;
}

.drilldown-chart-box {
    width: 100%;
    height: 380px;
}

.drilldown-client-row {
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.drilldown-client-row:hover {
    background-color: #f0f7ff;
}

.drilldown-client-row.selected-client {
    background-color: #e0edff;
}

.search-input-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.search-input-wrap .search-svg-icon {
    position: absolute;
    left: 11px;
    pointer-events: none;
    color: var(--cb-primary);
    display: flex;
    align-items: center;
}

.search-input-wrap .form-control-cima {
    padding-left: 34px;
}

.client-link-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    font-weight: 700;
    color: #112f5c;
    cursor: pointer;
    text-align: left;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s ease;
}

.client-link-btn:hover {
    color: #0045AC;
    text-decoration: underline;
}

.client-profile-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    background: linear-gradient(135deg, #112f5c 0%, #0045AC 100%);
    color: #ffffff;
    border-radius: 12px;
    padding: 18px 22px;
    margin-bottom: 18px;
    box-shadow: 0 6px 18px rgba(0, 69, 172, 0.16);
}

.client-profile-meta-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.client-meta-pill {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
}

.profile-tab-bar {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 14px;
}

.profile-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.profile-tab-btn:hover {
    color: #0045AC;
}

.profile-tab-btn.active {
    color: #0045AC;
    border-bottom-color: #0045AC;
}

.cartera-footer-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #dce3ec;
    font-size: 12px;
    color: #64748b;
}

/* ==========================================================================
   PORTAL ADMINISTRATIVO MULTI-TABLERO (/admin) - CIMA BOOKING
   ========================================================================== */
.admin-shell {
    display: grid;
    grid-template-columns: 278px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: #112f5c;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    border-right: 1px solid #0b2142;
}

.admin-sidebar-brand {
    padding: 6px 10px 16px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 14px;
}

.admin-section-label {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: #A1B5D3;
    padding: 10px 12px 6px 12px;
}

.active-dashboard-selector-box {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(161, 181, 211, 0.25);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 4px 4px 10px 4px;
}

.active-dashboard-select {
    width: 100%;
    background: #1E2637;
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 4px;
}

.admin-nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: #dbeafe;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.15s ease;
}

.admin-nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.admin-nav-btn.active {
    background: #0045AC;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.admin-main {
    background: #f1f5f9;
    padding: 24px 28px;
    overflow-y: auto;
}

.admin-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(17, 47, 92, 0.04);
}

.admin-card h3 {
    margin-top: 0;
    font-size: 18px;
    color: #112f5c;
}

/* Grid de Tarjetas del Catálogo de Tableros */
.dashboard-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-catalog-card {
    background: #ffffff;
    border: 1.5px solid #dbe3ef;
    border-radius: 12px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.dashboard-catalog-card:hover {
    border-color: #0045AC;
    box-shadow: 0 8px 20px rgba(0, 69, 172, 0.08);
}

.dashboard-catalog-card.selected-board {
    border-color: #0045AC;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.btn-cima-primary {
    background: #0045AC;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.btn-cima-primary:hover {
    background: #112f5c;
}

.btn-cima-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.btn-cima-outline {
    background: #ffffff;
    color: #0045AC;
    border: 1.5px solid #0045AC;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-cima-outline:hover {
    background: #EDF4FA;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.admin-table th, .admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

.admin-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #475569;
    font-size: 11.5px;
    text-transform: uppercase;
}

.badge-status {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-running { background: #C4DAFF; color: #0045AC; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: #e2e8f0; color: #475569; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.form-control-cima {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13.5px;
}

.code-snippet-box {
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px;
    border-radius: 8px;
    font-family: Consolas, Monaco, monospace;
    font-size: 12.5px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

@media (max-width: 1200px) {
    .cartera-top-grid,
    .right-cartera-panel,
    .cartera-bottom-grid {
        grid-template-columns: 1fr;
    }
    .cartera-header {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .cb-brand-logo, .cartera-filters {
        justify-content: center;
    }
}
