/* ============================================================================
   FINANCE DASHBOARD LOMAS 2 - STYLES
   ============================================================================ */

/* CSS Variables */
:root {
    --font-primary: 'Google Sans Text', 'Segoe UI', sans-serif;
    --font-monospace: 'Google Sans Text', sans-serif;
    --bg-color: #f5f6f8;
    --card-bg-color: #ffffff;
    --text-primary: #1f2933;
    --text-secondary: #52606d;
    --border-color: #d9dde3;
    --shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
    --border-radius: 6px;
    --color-ingresos: #20c997;
    --color-gastos: #dc3545;
    --color-per-home: #6f42c1;
    --color-balance: #0d6efd;
    --color-transacciones: #fd7e14;
    --color-saldo-minimo: #0dcaf0;
    --color-header-bg: #f1f3f5;
    --color-total-bg: #2f3944;
    --color-selected: #0d6efd;
    --color-selected-bg: #e7f3ff;
    
    /* Table Header Variables - Sistema Modular */
    --table-header-bg-start: #f1f3f5;
    --table-header-text-color: #3e4c59;
    --table-header-font-weight: 500;
    --table-header-font-size: 13px;
    --table-header-padding: 12px 10px;
    --table-header-border-color: #d9dde3;
    --table-header-hover-bg-start: #e5e8eb;
    
    /* Table Search Icon Variables */
    --table-search-icon-color: #6c757d;
    --table-search-icon-bg: rgba(108, 117, 125, 0.1);
    --table-search-icon-hover-bg: rgba(108, 117, 125, 0.12);
    --table-search-icon-hover-color: #3e4c59;
}

/* Base Styles */
* { 
    box-sizing: border-box; 
}

body {
    font-family: var(--font-primary);
    margin: 0;
    padding: 20px;
    background: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#financial-dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
}

/* Container Styles */
.dashboard-header,
.active-filters,
.db-container,
.kpi-cards,
.chart-grid {
    width: 100%;
}

.db-container {
    background: var(--card-bg-color);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    box-sizing: border-box;
}

.db-container-title {
    margin: 0 0 16px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.db-container-title > span:first-child {
    flex: 0 1 auto;
}

.db-container-title small {
    flex: 0 1 auto;
}

/* Icon Styles for Dashboard */
.db-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    color: var(--text-primary);
    display: inline-block;
}

.label-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    color: var(--text-secondary);
    margin-right: 4px;
    display: inline-block;
    vertical-align: middle;
}

.kpi-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    display: inline-block;
    margin-right: 4px;
}

.action-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
}

/* KPI Cards */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
    width: 100%;
    box-sizing: border-box;
}

.kpi-card {
    background: var(--card-bg-color);
    padding: 18px;
    border-radius: var(--border-radius);
    text-align: left;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: relative;
}

.kpi-card h3 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.kpi-card .value {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-monospace);
    margin-bottom: 8px;
}

.kpi-card .trend {
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 8px;
}

.trend.positive {
    background: #d4edda;
    color: #155724;
}

.trend.negative {
    background: #f8d7da;
    color: #721c24;
}

.kpi-card small {
    color: var(--text-secondary);
    font-size: 11px;
    display: block;
    margin-top: 8px;
}

.kpi-card.ingresos { border-left: 3px solid var(--color-ingresos); }
.kpi-card.ingresos .value { color: var(--color-ingresos); }
.kpi-card.gastos { border-left: 3px solid var(--color-gastos); }
.kpi-card.gastos .value { color: var(--color-gastos); }
.kpi-card.gastos small { color: var(--text-secondary) !important; }
.kpi-card.per-home { border-left: 3px solid var(--color-per-home); }
.kpi-card.per-home .value { color: var(--color-per-home); }
.kpi-card.balance { border-left: 3px solid var(--color-balance); }
.kpi-card.balance .value { color: var(--color-balance); }
.kpi-card.transacciones { border-left: 3px solid var(--color-transacciones); }
.kpi-card.transacciones .value { color: var(--color-transacciones); }

/* Filters */
.filters-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

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

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.filter-select,
.filter-input {
    width: 100%;
    font-size: 14px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    background: linear-gradient(180deg, #f8f9fb 0%, #ffffff 100%);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    appearance: none;
    min-height: 44px;
}

.filter-select {
    padding-right: 44px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2352606d' d='M1.41 0L6 4.58 10.59 0 12 1.41 6 7.41 0 1.41z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px 8px;
    cursor: pointer;
}

.filter-select::-ms-expand {
    display: none;
}

.filter-input {
    padding-right: 16px;
}

.filter-select:hover,
.filter-input:hover {
    border-color: #c3cad3;
    background-color: #ffffff;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--color-balance);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
    background-color: #ffffff;
}

.filter-input::-webkit-calendar-picker-indicator {
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.2s ease;
    width: 24px;
    height: 24px;
}

.filter-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.column-filter-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    padding: 16px;
    z-index: 1000;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.column-filter-dropdown input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(13, 110, 253, 0.12);
    border-radius: 12px;
    font-size: 13px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    background: linear-gradient(180deg, #f4f6fb 0%, #ffffff 100%);
}

.column-filter-dropdown input:focus {
    outline: none;
    border-color: var(--color-balance);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.column-filter-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.filter-action-btn {
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
}

.filter-action-btn.apply {
    background: rgba(32, 201, 151, 0.18);
    color: #0f7a55;
}

.filter-action-btn.apply:hover {
    background: rgba(32, 201, 151, 0.24);
    box-shadow: 0 8px 18px rgba(32, 201, 151, 0.2);
    transform: translateY(-1px);
}

.filter-action-btn.cancel {
    background: rgba(220, 53, 69, 0.15);
    color: #b02a37;
}

.filter-action-btn.cancel:hover {
    background: rgba(220, 53, 69, 0.21);
    box-shadow: 0 8px 18px rgba(220, 53, 69, 0.18);
    transform: translateY(-1px);
}

.filter-action-btn:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.2);
    outline-offset: 2px;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f1f3f5;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-badge .remove {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.filter-badge .remove:hover {
    opacity: 1;
}

.clear-all-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    width: auto;
}

.clear-all-btn:hover {
    background: #f1f3f5;
    color: var(--text-primary);
}

/* Floating Action Buttons */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background-color: var(--text-secondary);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    z-index: 1001;
    transition: background 0.2s ease;
}

.fab:hover {
    background-color: var(--text-primary);
}

.fab-confirm {
    background-color: var(--color-ingresos);
    right: 30px;
    bottom: 170px;
}

.fab-confirm:hover {
    background-color: #1f7e36;
}

.fab-cancel {
    background-color: var(--color-gastos);
    right: 30px;
    bottom: 100px;
}

.fab-cancel:hover {
    background-color: #af2f2d;
}

/* Icon Buttons */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
    min-width: 32px;
    min-height: 32px;
}

.icon-confirm {
    border-color: rgba(40,167,69,0.4);
    color: #1f7e36;
    font-size: 14px;
}

.icon-cancel {
    border-color: rgba(220,53,69,0.4);
    color: #af2f2d;
    font-size: 14px;
}

.icon-btn:focus {
    outline: 3px solid rgba(13,110,253,0.16);
    outline-offset: 2px;
}

.icon-confirm:hover {
    background: rgba(40,167,69,0.08);
    border-color: rgba(40,167,69,0.6);
    color: #1b6d2f;
}

.icon-cancel:hover {
    background: rgba(220,53,69,0.08);
    border-color: rgba(220,53,69,0.6);
    color: #962524;
}

/* Bar Race Animation Controls */
.icon-play {
    border-color: rgba(40,167,69,0.4);
    color: #1f7e36;
    font-size: 14px;
}

.icon-stop {
    border-color: rgba(220,53,69,0.4);
    color: #af2f2d;
    font-size: 14px;
}

.icon-play:hover {
    background: rgba(40,167,69,0.08);
    border-color: rgba(40,167,69,0.6);
    color: #1b6d2f;
}

.icon-stop:hover {
    background: rgba(220,53,69,0.08);
    border-color: rgba(220,53,69,0.6);
    color: #962524;
}

/* Bar Race Refresh Button */
.icon-refresh {
    border-color: rgba(13,110,253,0.4);
    color: #0d6efd;
    font-size: 14px;
}

.icon-refresh:hover {
    background: rgba(13,110,253,0.08);
    border-color: rgba(13,110,253,0.6);
    color: #0854ca;
}

#top-confirm-icon, #top-cancel-icon,
#cat-confirm-icon, #cat-cancel-icon,
#monthly-confirm-icon, #monthly-cancel-icon,
#expenses-confirm-icon, #expenses-cancel-icon,
#all-confirm-icon, #all-cancel-icon {
    display: none;
}

.pending-selected { 
    background-color: rgba(13,110,253,0.08); 
}

/* Table Styles */
.table-scroll-wrapper {
    width: 100%;
    max-height: 600px; /* Altura máxima para activar scroll vertical */
    overflow-x: auto;
    overflow-y: auto; /* Scroll vertical también */
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
    position: relative;
    box-sizing: border-box;
    scrollbar-width: thin;
}

.table-scroll-wrapper .db-table {
    width: 100%;
    min-width: 100%;
    table-layout: auto; /* Auto-ajuste de columnas */
}

.table-scroll-wrapper::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: #edf0f3;
    border-radius: 3px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #b0b6bd;
    border-radius: 3px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #959da6;
}

/* Charts */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

.chart-grid-double {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

.chart-wrapper {
    position: relative;
    height: 350px;
    min-height: 280px;
    width: 100%;
    box-sizing: border-box;
}

#monthly-flow-chart,
#expenses-chart {
    width: 100%;
    height: 100%;
}

/* Tables */
.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}

.db-table th, .db-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: normal; /* Permitir saltos de línea */
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 200px; /* Ancho máximo antes de forzar salto */
}

.db-table th:first-child,
.db-table td:first-child {
    width: 10%;
}

.db-table .text-right {
    text-align: right;
    width: 12%;
}

.db-table th:nth-child(2),
.db-table td:nth-child(2) {
    width: 15%;
}

.db-table th:nth-child(3),
.db-table td:nth-child(3) {
    width: 25%;
}

.db-table thead tr {
    background: var(--table-header-bg-start);
    border-bottom: 1px solid var(--table-header-border-color);
}

.db-table th {
    font-weight: var(--table-header-font-weight);
    color: var(--table-header-text-color);
    border-bottom: 1px solid var(--table-header-border-color);
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--table-header-bg-start);
    white-space: normal;
    word-wrap: break-word;
    padding: var(--table-header-padding);
    font-size: var(--table-header-font-size);
}

/* Contenedor del header con label y lupa */
.th-content {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    position: relative;
}

/* Alineamiento específico para headers */
.th-content.text-left,
.text-left .th-content {
    justify-content: flex-start;
}

.th-content.text-center,
.text-center .th-content {
    justify-content: center;
}

.th-content.text-right,
.text-right .th-content {
    justify-content: flex-end;
}

.th-label {
    flex: 1;
    cursor: pointer;
    transition: color 0.2s;
    min-width: 0; /* Permite que el texto se ajuste correctamente */
    color: inherit; /* Hereda el color del th */
    font-weight: inherit; /* Hereda el peso del th */
}

.th-label:hover {
    color: var(--text-primary);
}

.th-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    position: relative;
    flex-shrink: 0;
}

.th-sort-icon {
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    color: var(--table-search-icon-color);
    display: inline-flex;
    align-items: center;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.2s ease, color 0.2s ease;
}

.th-sort-icon:hover {
    background: var(--table-search-icon-hover-bg);
    color: var(--table-search-icon-hover-color);
}

.sort-order-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    padding: 0 5px;
    font-size: 10px;
    line-height: 16px;
    border-radius: 999px;
    background-color: rgba(13, 110, 253, 0.12);
    color: var(--color-balance);
    min-width: 16px;
}
.th-sort-icon.sorted-asc,
.th-sort-icon.sorted-desc {
    color: var(--table-header-text-color);
    font-weight: 600;
}

.th-search-icon {
    font-size: 13px;
    cursor: pointer;
    padding: 4px 6px;
    opacity: 0.45;
    transition: background 0.2s ease, color 0.2s ease;
    user-select: none;
    border-radius: 4px;
    background-color: var(--table-search-icon-bg);
    color: var(--table-search-icon-color);
    display: inline-flex;
    align-items: center;
}

.th-search-icon:hover {
    opacity: 1;
    background-color: var(--table-search-icon-hover-bg);
    color: var(--table-search-icon-hover-color);
}

/* Dropdown de filtro */

.column-filter-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow);
    padding: 10px;
    z-index: 1000;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.column-filter-dropdown input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    transition: border 0.2s ease, background 0.2s ease;
    background-color: #f8f9fa;
}

.column-filter-dropdown input:focus {
    outline: none;
    border-color: var(--color-balance);
    background-color: white;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.12);
}

.column-filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.filter-action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
    min-width: 32px;
}

.filter-action-btn.apply {
    border-color: rgba(32, 201, 151, 0.6);
    color: var(--color-ingresos);
}

.filter-action-btn.apply:hover {
    background: rgba(32, 201, 151, 0.12);
}

.filter-action-btn.cancel {
    border-color: rgba(220, 53, 69, 0.5);
    color: var(--color-gastos);
}

.filter-action-btn.cancel:hover {
    background: rgba(220, 53, 69, 0.1);
}

.db-table th:hover {
    background: var(--table-header-hover-bg-start);
}

.db-table .text-right { text-align: right; }
.db-table .text-center { text-align: center; }
.db-table .weight-medium { font-weight: 500; }
.db-table .color-ingresos { color: var(--color-ingresos); }
.db-table .color-gastos { color: var(--color-gastos); }
.db-table .color-per-home { color: var(--color-per-home); }
.db-table .color-secondary { color: var(--text-secondary); }

.db-table tbody tr:hover {
    background-color: #f8f9fa;
}

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

.db-table tbody tr.selected {
    background-color: var(--color-selected-bg);
    border-left: 3px solid var(--color-selected);
}

.db-table tfoot tr {
    background-color: #e9ecef;
    color: var(--text-primary);
    font-weight: 600;
}

.db-table tfoot td {
    border-top: 1px solid var(--border-color);
}

.db-table.compact th, .db-table.compact td {
    padding: 8px 10px;
    font-size: 12px;
}

.db-table.compact tbody tr { 
    line-height: 1.15; 
}

/* Search and Actions */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}

.search-box {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    position: relative;
    box-sizing: border-box;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-balance);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.search-box::after {
    content: '🔍';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}

.action-btn {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.action-btn:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Loading & Error */
#loading {
    text-align: center;
    padding: 60px 20px;
    color: #7f8c8d;
    font-size: 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

#error {
    display: none;
    background: #fff5f5;
    color: #c53030;
    padding: 16px 20px;
    border-radius: 4px;
    text-align: center;
    margin-top: 20px;
    border: 1px solid #fed7d7;
    font-weight: 500;
}

/* Secret Column Toggle */
.col-secreta {
    display: table-cell;
}

.col-concepto-original {
    display: none;
}

#all-transactions-table.show-secret-col .col-secreta {
    display: none;
}

#all-transactions-table.show-secret-col .col-concepto-original {
    display: table-cell;
}

/* Dashboard Header */
.dashboard-header { 
    display: flex; 
    align-items: flex-start; 
    gap: 12px; 
    margin-bottom: 24px;
    width: 100%;
    box-sizing: border-box;
}

.dashboard-title { 
    margin: 0 0 6px 0; 
    font-size: 22px; 
    font-weight: 700; 
    color: var(--text-primary); 
    letter-spacing: 0.2px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-subtitle { 
    margin: 8px 0 0 0; 
    color: var(--text-secondary); 
    font-size: 13px;
    font-weight: 400;
}

#all-transactions-table,
#category-summary-table,
#expected-movements-table { 
    font-family: var(--font-primary);
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.db-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 992px) {
    .chart-grid-double {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .chart-grid {
        gap: 16px;
    }
    
    .db-container {
        width: 100%;
        padding: 16px;
        margin-bottom: 16px;
        box-sizing: border-box;
    }
    
    .db-table th,
    .db-table td {
        padding: 10px 6px;
        font-size: 12px;
    }
    
    .table-scroll-wrapper .db-table {
        min-width: 100%;
    }
    
    .db-table thead,
    .db-table tbody,
    .db-table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    #financial-dashboard {
        max-width: 100%;
    }
    
    .dashboard-header {
        margin-bottom: 16px;
    }
    
    .dashboard-title {
        font-size: 28px;
        margin-bottom: 4px;
    }
    
    .dashboard-subtitle {
        font-size: 13px;
    }
    
    .kpi-cards {
        width: 100%;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        box-sizing: border-box;
    }
    
    .kpi-card {
        padding: 16px;
    }
    
    .kpi-card h3 {
        font-size: 11px;
        padding-bottom: 6px;
        margin-bottom: 10px;
    }
    
    .kpi-card .value {
        font-size: 22px;
        font-weight: 700;
    }
    
    .kpi-card small {
        font-size: 10px;
    }
    
    .filters-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .filter-group label {
        font-size: 11px;
    }
    
    .filter-select,
    .filter-input {
        font-size: 14px;
        padding: 10px;
    }
    
    .chart-wrapper {
        height: 320px;
        min-height: 250px;
    }
    
    .chart-grid-double {
        grid-template-columns: 1fr;
    }
    
    .db-container {
        padding: 14px;
        margin-bottom: 14px;
    }
    
    .db-container-title {
        font-size: 15px;
        margin-bottom: 12px;
        flex-wrap: wrap;
    }
    
    .db-container-title small {
        font-size: 11px;
        width: 100%;
    }
    
    .db-icon {
        width: 16px;
        height: 16px;
    }
    
    #all-transactions-table {
        max-height: 500px;
        overflow-y: auto;
        overflow-x: auto;
    }
    
    .db-table {
        font-size: 12px;
    }
    
    .db-table th,
    .db-table td {
        padding: 10px 6px;
    }
    
    .db-table.compact th,
    .db-table.compact td {
        padding: 8px 6px;
        font-size: 11px;
    }
    
    .actions-bar {
        width: 100%;
        flex-direction: column;
        gap: 12px;
        box-sizing: border-box;
    }
    
    .search-box {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 576px) {
    body {
        padding: 10px;
        padding-bottom: 80px;
        overflow-x: hidden;
    }
    
    #financial-dashboard {
        max-width: 100vw;
    }
    
    .dashboard-title {
        font-size: 24px;
        margin-bottom: 4px;
    }
    
    .dashboard-subtitle {
        font-size: 12px;
    }
    
    .chart-grid,
    .chart-grid-double {
        width: 100%;
        grid-template-columns: 1fr;
        gap: 12px;
        box-sizing: border-box;
    }
    
    .kpi-cards {
        width: 100%;
        grid-template-columns: 1fr;
        gap: 10px;
        box-sizing: border-box;
    }
    
    .kpi-card {
        padding: 14px;
    }
    
    .kpi-card h3 {
        font-size: 11px;
        padding-bottom: 6px;
        margin-bottom: 10px;
    }
    
    .kpi-card .value {
        font-size: 24px;
        font-weight: 700;
    }
    
    .kpi-card small {
        font-size: 10px;
    }
    
    .filters-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .filter-group label {
        font-size: 10px;
    }
    
    .filter-select,
    .filter-input {
        font-size: 14px;
        padding: 10px 8px;
        width: 100%;
    }
    
    .db-container {
        width: 100%;
        padding: 12px;
        margin-bottom: 12px;
        box-sizing: border-box;
    }
    
    .db-container-title {
        font-size: 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding-bottom: 8px;
        margin-bottom: 14px;
    }
    
    .db-container-title small {
        font-size: 10px;
        width: 100%;
    }
    
    .db-icon {
        width: 16px;
        height: 16px;
    }
    
    .chart-wrapper {
        height: 280px;
        min-height: 220px;
    }
    
    
    .db-table {
        font-size: 11px;
        table-layout: fixed;
    }
    
    .db-table th,
    .db-table td {
        padding: 10px 6px;
        font-size: 11px;
        word-break: break-word;
    }
    
    .db-table th {
        font-weight: 600;
        background-color: #f9f9f9;
        position: sticky;
        top: 0;
    }
    
    .table-scroll-wrapper {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        overflow-y: visible;
    }
    
    .table-scroll-wrapper .db-table {
        min-width: 100%;
    }
    
    .db-table.compact th,
    .db-table.compact td {
        padding: 8px 5px;
        font-size: 10px;
    }
    
    .fab {
        width: 50px;
        height: 50px;
        right: 16px;
        bottom: 16px;
        font-size: 12px;
    }
    
    .fab-confirm {
        bottom: 80px;
    }
    
    .fab-cancel {
        bottom: 144px;
    }
    
    
    .active-filters {
        width: 100%;
        padding: 12px;
        gap: 8px;
        box-sizing: border-box;
    }
    
    .filter-badge {
        font-size: 12px;
        padding: 4px 10px;
    }
    
    .clear-all-btn {
        width: 100%;
        justify-content: center;
        margin-top: 4px;
    }
    
    .db-container p {
        font-size: 12px !important;
    }
    
    .dashboard-header {
        width: 100%;
        margin-bottom: 16px;
        box-sizing: border-box;
    }
    
    .dashboard-title {
        font-size: 18px;
        padding-bottom: 6px;
    }
    
    .dashboard-subtitle {
        font-size: 12px;
        margin-top: 6px;
    }
}

@media (max-width: 400px) {
    body {
        padding: 8px;
        overflow-x: hidden;
    }
    
    #financial-dashboard {
        max-width: 100vw;
    }
    
    .dashboard-title {
        font-size: 22px;
        margin-bottom: 4px;
    }
    
    .dashboard-subtitle {
        font-size: 11px;
    }
    
    .kpi-cards {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .kpi-card {
        padding: 12px;
    }
    
    .kpi-card h3 {
        font-size: 10px;
    }
    
    .kpi-card .value {
        font-size: 20px;
    }
    
    .kpi-card small {
        font-size: 9px;
    }
    
    .filters-container {
        gap: 8px;
    }
    
    .filter-select,
    .filter-input {
        font-size: 14px;
        padding: 8px;
    }
    
    .db-container {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .db-container-title {
        font-size: 14px;
        gap: 6px;
        margin-bottom: 12px;
    }
    
    .db-container-title small {
        font-size: 9px;
    }
    
    .chart-wrapper {
        height: 240px;
        min-height: 200px;
    }
    
    .db-table {
        font-size: 10px;
    }
    
    .db-table th,
    .db-table td {
        padding: 8px 4px;
    }
    
    .db-table.compact th,
    .db-table.compact td {
        padding: 6px 3px;
        font-size: 9px;
    }
    
    .action-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .active-filters {
        padding: 10px;
        gap: 6px;
    }
    
    .filter-badge {
        font-size: 11px;
        padding: 3px 8px;
    }
    
    .fab {
        width: 48px;
        height: 48px;
        right: 12px;
        bottom: 12px;
        font-size: 11px;
    }
    
    .fab-confirm {
        bottom: 68px;
    }
    
    .fab-cancel {
        bottom: 128px;
    }
}

/* Loading Spinner Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
