:root {
    --bg-main: #f5f6fa;
    --logo-blue: #245799;
    --logo-blue-dark: #194073;
    --kpi-bg: #e6f0fa;
    --kpi-highlight: #d1f0f7;
    --text-dark: #333;
    --text-gray: #666;
    --border-color: #d1d5db;
    --green-up: #10b981;
    --btn-blue: #3b82f6;
    --btn-dark: #1e3a8a;
    --chart-blue: #60a5fa;
    --chart-orange: #f97316;
    --table-header-bg: #1e40af;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-dark);
    font-size: 12px;
}

.dashboard-wrapper {
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px 20px;
}

/* HEADER */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.logo-area {
    text-align: center;
    width: 150px;
}

.logo-title {
    font-size: 28px;
    font-style: italic;
    color: var(--logo-blue);
    font-weight: 900;
    line-height: 1;
}

.logo-light {
    font-weight: 300;
    font-size: 10px;
    display: block;
    margin-top: -4px;
    letter-spacing: 1px;
}

.logo-subtitle {
    background-color: var(--logo-blue-dark);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 4px;
    margin-top: 4px;
}

.kpi-container {
    display: flex;
    gap: 15px;
    flex-grow: 1;
    justify-content: center;
}

.kpi-card {
    background-color: var(--kpi-bg);
    padding: 10px 15px;
    border-radius: 4px;
    text-align: center;
    min-width: 140px;
}

.kpi-card.kpi-highlight {
    background-color: var(--kpi-highlight);
}

.kpi-label {
    font-size: 12px;
    font-weight: bold;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.kpi-value {
    font-size: 24px;
    font-weight: normal;
}

.kpi-sub {
    font-size: 10px;
    color: var(--green-up);
    margin-top: 2px;
}

.kpi-sub.highlight-sub {
    color: #0d9488;
}

.header-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.btn {
    border: none;
    padding: 6px 12px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
}

.btn-dark {
    background-color: var(--logo-blue-dark);
}

.btn-blue {
    background-color: var(--btn-blue);
}

/* FILTERS */
.filters-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    color: var(--text-dark);
    font-size: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.date-filter {
    flex: 1.5;
}

/* ACTIVE FILTERS PILLS */
.active-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    min-height: 0;
}

.filter-pill {
    background-color: var(--btn-blue);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-pill span {
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
}

.filter-pill span:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

/* GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
}

.span-col-4 {
    grid-column: span 4;
}

.span-col-8 {
    grid-column: span 8;
}

.span-col-12 {
    grid-column: span 12;
}

.flex-grow {
    flex-grow: 1;
}

/* Dashboard Panels */
.panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.panel-header {
    text-align: center;
    color: var(--logo-blue-dark);
    font-weight: bold;
    font-size: 13px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.chart-container {
    position: relative;
    padding: 10px;
    width: 100%;
    height: 220px;
    flex-grow: 1;
}

.h-150 {
    height: 160px;
}

.h-250 {
    height: 250px;
}

/* TABLAS */
.table-container {
    padding: 5px;
    overflow-x: auto;
    flex-grow: 1;
}

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

thead th {
    background-color: var(--table-header-bg);
    color: white;
    padding: 6px;
    text-align: left;
    font-weight: bold;
    position: sticky;
    top: 0;
}

thead th.num {
    text-align: right;
}

tbody td {
    padding: 6px;
    border-bottom: 1px solid #eee;
}

tbody td.num {
    text-align: right;
}

tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

tbody tr.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

tbody tr.clickable-row:hover {
    background-color: #e0f2fe;
}

tbody tr.total-row {
    font-weight: bold;
    background-color: #f3f4f6;
    border-top: 2px solid #ccc;
}

.bg-profit-cell {
    background-color: #4ade80;
    /* light green */
    color: #166534;
    font-weight: bold;
    border-radius: 2px;
}

/* CUSTOM LEGEND TIME CHARTS */
.panel-time {
    position: relative;
    padding-top: 20px;
}

.chart-legend-custom {
    position: absolute;
    top: 5px;
    left: 20px;
    display: flex;
    gap: 15px;
    font-weight: bold;
    font-size: 11px;
    z-index: 10;
}

.leg-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.box {
    width: 15px;
    height: 3px;
    display: inline-block;
}

.bg-blue {
    background-color: #3b82f6;
}

.bg-green {
    background-color: #10b981;
}

.bg-red {
    background-color: #ef4444;
}


/* PRINT STYLES */
@media print {
    @page {
        size: landscape;
        margin: 10mm;
    }

    body {
        background-color: white;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        padding: 0;
        margin: 0;
    }

    .no-print {
        display: none !important;
    }

    .dashboard-wrapper {
        max-width: 100%;
        padding: 0;
    }

    .panel {
        border: 1px solid #ccc;
        box-shadow: none;
        break-inside: avoid;
    }

    .dashboard-grid {
        gap: 8px;
    }

    .chart-container {
        padding: 0;
    }

    .no-break {
        break-inside: avoid;
        page-break-inside: avoid;
        display: block;
    }
}

/* COMPLEX HEADER TABLE */
.complex-header-table thead tr.header-group-row th {
    background-color: var(--table-header-bg);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.complex-header-table thead tr.header-sub-row th {
    background-color: white;
    color: var(--text-dark);
    font-size: 10px;
    border-bottom: 2px solid #ddd;
    border-right: 1px solid #eee;
}

.complex-header-table tbody td {
    border-right: 1px solid #f3f4f6;
}

.complex-header-table tbody td:nth-child(2) {
    background-color: #f3f4f6;
    font-weight: bold;
}

.complex-header-table .num {
    text-align: right;
    padding-right: 12px;
}

/* STICKY TABLE & HORIZONTAL SCROLL */
.sticky-table {
    border-collapse: separate;
    border-spacing: 0;
}

.sticky-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Fixed left columns */
.sticky-table th:nth-child(1),
.sticky-table td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 5;
    background-color: white;
    border-right: 1px solid #ddd;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

.sticky-table th:nth-child(2),
.sticky-table td:nth-child(2) {
    position: sticky;
    left: 120px;
    /* Adjust based on column 1 width */
    z-index: 5;
    background-color: #f3f4f6;
    border-right: 2px solid #ccc;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

.sticky-table thead th:nth-child(1),
.sticky-table thead th:nth-child(2) {
    z-index: 15;
    /* Higher than other sticky headers */
}

/* Header colors for fixed columns */
.sticky-table thead tr.header-group-row th:nth-child(1),
.sticky-table thead tr.header-group-row th:nth-child(2) {
    background-color: var(--table-header-bg);
    color: white;
}

.sticky-table thead tr.header-sub-row th:nth-child(1),
.sticky-table thead tr.header-sub-row th:nth-child(2) {
    background-color: #e2e8f0;
}

/* Adjust column widths for fixed columns */
.sticky-table th:nth-child(1),
.sticky-table td:nth-child(1) {
    min-width: 120px;
    max-width: 120px;
}

.sticky-table th:nth-child(2),
.sticky-table td:nth-child(2) {
    min-width: 150px;
    max-width: 150px;
}

/* MONTH BLOCKS STYLING */
.month-block-header {
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    font-size: 11px;
}

.cum-block-header {
    background-color: #1e3a8a !important;
    border-left: 3px solid #fff;
}

.num-cell {
    min-width: 80px;
    text-align: right;
}


/* NAVIGATION TABS */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: -1px;
    border-bottom: 2px solid #e2e8f0;
    padding: 0;
}

.nav-tab {
    padding: 8px 16px;
    text-decoration: none;
    color: #64748b;
    font-weight: 600;
    border: 2px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #f1f5f9;
    transition: all 0.2s;
    font-size: 12px;
}

.nav-tab:hover {
    background: #e2e8f0;
    color: var(--text-dark);
}

.nav-tab.active {
    background: white;
    color: var(--logo-blue);
    border-color: #e2e8f0;
    margin-bottom: -2px;
    border-bottom: 2px solid white;
}

/* ADVANCED TABLE FEATURES */
.advanced-table th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px;
}

.advanced-table th.sortable:hover {
    background-color: #1e3a8a !important;
}

.advanced-table .search-row th {
    background-color: #f8fafc;
    padding: 4px 8px;
    border-bottom: 1px solid #e2e8f0;
}

.advanced-table .search-row input {
    width: 100%;
    padding: 4px 8px;
    font-size: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    outline: none;
}

.advanced-table .search-row input:focus {
    border-color: var(--btn-blue);
}