:root {
    /* Premium Color Palette */
    --primary-color: #007bff;
    /* Blue for actions */
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    /* Green for Income */
    --danger-color: #dc3545;
    /* Red for Expenses */
    --warning-color: #ffc107;
    --info-color: #17a2b8;

    --bg-color: #f4f6f9;
    /* Light gray background */
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #6c757d;
    --border-color: #e0e0e0;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.10);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
    font-weight: 600;
    color: #2c3e50;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-10 {
    gap: 10px;
}

.gap-20 {
    gap: 20px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 30px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
    /* Important for width: 100% */
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: #f8f9fa;
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Sidebar Layout (for Dashboard) */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100%;
    left: 0;
    top: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 10px;
    margin: 0;
    flex-grow: 1;
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    gap: 10px;
    font-weight: 500;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background-color: #eef2ff;
    color: var(--primary-color);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.main-content {
    flex-grow: 1;
    margin-left: 250px;
    /* Width of sidebar */
    padding: 40px;
}

/* --- SETTINGS PAGE STYLES --- */
.settings-section {
    margin-bottom: 40px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.setting-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    flex-wrap: wrap;
}

.setting-card .cat-actions,
.setting-card .cta-actions {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.setting-card .cat-edit-form,
.setting-card .cta-edit-form {
    flex: 1;
    margin-right: 10px;
}

.setting-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-color);
}

.setting-card.income {
    border-left: 4px solid var(--success-color);
}

.setting-card.expense {
    border-left: 4px solid var(--danger-color);
}

.setting-card.account {
    border-left: 4px solid var(--info-color);
}

.btn-icon-del {
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.btn-icon-del:hover {
    background-color: #ffebee;
    color: var(--danger-color);
}

/* --- ADVANCED UI STYLES --- */

/* Toggle Switch */
.toggle-container {
    display: flex;
    background: #f1f3f5;
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
}

.toggle-option {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
}

.toggle-option.active {
    background: white;
    box-shadow: var(--shadow-sm);
    color: var(--text-color);
}

.toggle-option.active[data-value="egreso"] {
    color: var(--danger-color);
}

.toggle-option.active[data-value="ingreso"] {
    color: var(--success-color);
}

/* Form Grid in Modal */
.form-row {
    display: flex;
    gap: 15px;
}

.form-col {
    flex: 1;
}

/* Hero Add Button */
.btn-add-hero {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    /* Pill shape */
    font-weight: 600;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-add-hero:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 123, 255, 0.4);
}

.btn-add-hero .plus-icon {
    font-size: 1.4rem;
    line-height: 1;
    font-weight: 300;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1em;
    width: 1em;
    margin-top: 2px;
    /* Slight adjustment to improve visual centering */
}

/* --- MOBILE RESPONSIVENESS --- */

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
    display: none;
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

/* SVG Icons */
.svg-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
    vertical-align: middle;
}

.btn-icon-del {
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-del:hover {
    background-color: #ffebee;
    color: var(--danger-color);
}

/* Media Queries */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        z-index: 999;
        width: 250px;
        /* Fixed width */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
        width: 100%;
        box-sizing: border-box;
        /* Prevent overflow */
    }

    .mobile-header {
        display: flex;
    }

    /* Adjust Grid for Mobile */
    .settings-grid,
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Adjust Form Grid in Modal */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Hide Sidebar Header on Mobile since we have Mobile Header */
    .sidebar-header {
        display: flex;
        justify-content: space-between;
    }
}

/* === FIXES FOR TRANSACTIONS TABLE === */

/* Update badge classes - text only, no background */
.badge-income {
    background-color: transparent !important;
    color: var(--success-color) !important;
    font-weight: 700;
}

.badge-expense {
    background-color: transparent !important;
    color: var(--danger-color) !important;
    font-weight: 700;
}

/* Category styling with colored underlines - Minimalist rounded style */
.cat-income {
    color: var(--text-color);
    border-bottom: 3px solid rgba(40, 167, 69, 0.4);
    border-radius: 2px;
    padding-bottom: 4px;
    padding-left: 2px;
    padding-right: 2px;
    display: inline-block;
    transition: border-color 0.2s;
}

.cat-income:hover {
    border-bottom-color: rgba(40, 167, 69, 0.6);
}

.cat-expense {
    color: var(--text-color);
    border-bottom: 3px solid rgba(220, 53, 69, 0.4);
    border-radius: 2px;
    padding-bottom: 4px;
    padding-left: 2px;
    padding-right: 2px;
    display: inline-block;
    transition: border-color 0.2s;
}

.cat-expense:hover {
    border-bottom-color: rgba(220, 53, 69, 0.6);
}

/* Action buttons in tables */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
}

.btn-icon:hover {
    background-color: #f0f0f0;
    color: var(--primary-color);
}

.btn-icon.delete:hover {
    background-color: #ffebee;
    color: var(--danger-color);
}

/* === DATE FILTER STYLES === */
.date-filter-container {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-btn {
    padding: 10px 18px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-color);
    transition: all 0.2s;
    font-size: 0.95rem;
}

.filter-btn:hover {
    background-color: #f8f9fa;
    border-color: var(--primary-color);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.custom-range-wrapper {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.custom-range-wrapper.active {
    display: flex;
}

.custom-range-wrapper input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.custom-range-wrapper button {
    padding: 8px 16px;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.custom-range-wrapper button:hover {
    background-color: #218838;
}

/* === INSIGHTS SECTION === */
.insights-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.insight-card {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.insight-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.insight-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.insight-icon.expense {
    background-color: #ffebee;
    color: var(--danger-color);
}

.insight-icon.income {
    background-color: #d4edda;
    color: var(--success-color);
}

.insight-icon.month {
    background-color: #e3f2fd;
    color: #1976d2;
}

.insight-icon.category {
    background-color: #fff3e0;
    color: #f57c00;
}

.insight-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 5px;
}

.insight-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.insight-card.empty {
    opacity: 0.6;
}

.insight-card.empty .insight-value {
    font-size: 1rem;
    font-weight: 400;
}

/* Loading state */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Mobile responsiveness for date filter */
@media (max-width: 768px) {
    .filter-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-btn {
        text-align: center;
    }

    .custom-range-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .custom-range-wrapper input,
    .custom-range-wrapper button {
        width: 100%;
    }

    .insights-container {
        grid-template-columns: 1fr;
    }
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f2f5;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.auth-header p {
    color: var(--text-muted);
}

.auth-footer {
    text-align: center;
    margin-top: 25px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.btn-full-width {
    width: 100%;
    margin-top: 10px;
}

/* === SETTINGS PAGE FORM STYLES === */
.settings-form {
    display: flex;
    gap: 10px;
    background: white;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.settings-form .form-control {
    flex: 1;
    min-width: 150px;
}

.settings-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 50px 0;
    opacity: 0.5;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.5rem;
}

.category-section-title {
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover {
    background-color: #fcfcfc;
}

.text-center {
    text-align: center;
}

.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-income {
    background-color: #d4edda;
    color: #155724;
}

.badge-expense {
    background-color: #f8d7da;
    color: #721c24;
}

/* Icons (using emoji for now, can switch to FontAwesome/SVG later) */
.icon {
    font-style: normal;
}

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background-color: white;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #aaa;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Account badges with custom colors */
.account-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-block;
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Account badges with custom colors */
.account-badge {
    padding: 3px 8px;
    /* Reduced padding from 6px 12px */
    border-radius: 4px;
    /* Tighter radius from 6px */
    font-size: 0.85rem;
    /* Slightly smaller font */
    font-weight: 500;
    display: inline-block;
    color: #333;
    /* Dark text for legibility */
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.02);
    white-space: nowrap;
    /* Forces text to stay in one line (prevents boxy look) */
    vertical-align: middle;
    /* Aligns better in table cells */
    max-width: 100%;
    /* Prevents overflow */
    text-overflow: ellipsis;
    /* Adds '...' if it really doesn't fit */
    overflow: hidden;
}

/* Custom Account Selector in Modal */
/* Using .category-grid for container consistency */

.account-badge-option {
    cursor: pointer;
    padding: 6px 12px;
    /* Identical to cat-badge-option */
    border-radius: 4px;
    /* Identical radius */
    font-size: 0.9rem;
    transition: all 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* Standard border like categories */
    display: inline-block;
    color: #333;
    background-color: #fff;
    /* Fallback */
}

.account-badge-option:hover {
    filter: brightness(0.95);
    /* Slight darken on hover */
    transform: translateY(-1px);
}

.account-badge-option.selected {
    border-color: #333;
    /* Dark border for selection */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    font-weight: 500;
    transform: translateY(-1px);
}

/* Category Selector in Modal */
.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
    /* Added padding to prevent clipping of selected items */
}

.cat-badge-option {
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background-color: #f8f9fa;
    color: #555;
}

.cat-badge-option:hover {
    background-color: #e9ecef;
}

/* Selected State - Income (Green) */
.cat-badge-option.type-ingreso.selected {
    background-color: rgba(40, 167, 69, 0.1);
    border-color: #28a745;
    color: #28a745;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.1);
}

/* Selected State - Expense (Red) */
.cat-badge-option.type-egreso.selected {
    background-color: rgba(220, 53, 69, 0.1);
    border-color: #dc3545;
    color: #dc3545;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.1);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar .form-control {
    margin: 0;
    /* Override default margins */
    padding: 8px 12px;
    /* Compact padding */
    font-size: 0.9rem;
    height: 38px;
    /* Fixed compact height */
    border: 1px solid #e0e0e0;
    min-width: 130px;
    box-shadow: none;
}

.filter-bar input[type="text"] {
    flex: 2;
    /* Search bar takes more space */
    min-width: 180px;
}

.filter-bar input[type="date"] {
    min-width: 130px;
}

.date-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.date-filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.date-filter-group .form-control {
    margin: 0;
    padding: 8px 12px;
    font-size: 0.9rem;
    height: 38px;
    border: 1px solid #e0e0e0;
    min-width: 130px;
    box-shadow: none;
}

.filter-bar select {
    flex: 1;
    cursor: pointer;
    background-color: #fff;
}

.filter-btn-search {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.filter-btn-search:hover {
    background-color: #0056b3;
}

.filter-link-clear {
    color: #666;
    font-size: 0.9rem;
    text-decoration: none;
    padding: 0 8px;
    white-space: nowrap;
}

.filter-link-clear:hover {
    color: var(--danger-color);
}

/* Color picker styles */
.color-palette {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(0, 0, 0, 0.1);
    /* Visible border for light colors */
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
}

.color-option.selected {
    border-color: #555;
    /* Darker border for selected state */
    transform: scale(1.15);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 0 0 4px rgba(0, 0, 0, 0.1);
    /* Ring effect */
}

/* Edit button styles */
.btn-edit {
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-edit:hover {
    background-color: #e3f2fd;
}

/* =========================================
   COMPACT SETTINGS LAYOUT (NEW)
   ========================================= */

.settings-cols-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    align-items: start;
}

.settings-col {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
    padding: 20px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.settings-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f7f7f7;
}

.settings-col-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: #333;
}

/* Compact Forms */
.form-compact {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: #fdfdfd;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}

.form-compact input {
    flex: 1;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.9rem;
    outline: none;
    transition: border 0.3s;
}

.form-compact input:focus {
    border-color: var(--primary-color);
}

.btn-mini-add {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-mini-add:hover {
    opacity: 0.9;
}

/* Mini Lists */
.mini-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mini-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.1s;
    border-radius: 6px;
}

.mini-list-item:last-child {
    border-bottom: none;
}

.mini-list-item:hover {
    background-color: #f9fcff;
}

.item-visual {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    flex: 1;
}

.item-text {
    font-size: 0.95rem;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-actions {
    display: flex;
    gap: 4px;
    margin-left: 8px;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.2s;
}

.mini-list-item:hover .item-actions {
    opacity: 1;
}

.btn-action-mini {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #bbb;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.btn-action-mini:hover {
    color: var(--primary-color);
}

.btn-action-mini.del:hover {
    color: var(--danger-color);
}

/* Edit Inline Form */
.form-inline-edit {
    display: flex;
    gap: 5px;
    flex: 1;
}

/* Account Summary Grid in Dashboard */
.accounts-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.account-card-mini {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: transform 0.2s;
}

.account-card-mini:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.acc-name {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 6px;
    font-weight: 500;
}

.acc-balance {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
}


/* =========================================
   AUTHENTICATION PAGES (Pastel Minimalist)
   ========================================= */

/* Auth Container - Centered layout with gradient background */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fe 0%, #e8ecff 100%);
    padding: 20px;
}

/* Auth Card - White card with soft shadows */
.auth-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(108, 138, 239, 0.12);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.4s ease-out;
}

/* Auth Header */
.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: #2d3436;
}

.auth-header p {
    margin: 0;
    color: #6c757d;
    font-size: 0.95rem;
}

/* Auth Footer */
.auth-footer {
    text-align: center;
    margin-top: 25px;
    font-size: 0.9rem;
    color: #6c757d;
}

.auth-footer a {
    color: #6c8aef;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-footer a:hover {
    color: #5a78dd;
    text-decoration: underline;
}

/* Form Elements for Auth Pages */
.auth-card .form-group {
    margin-bottom: 20px;
}

.auth-card .form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2d3436;
    font-size: 0.9rem;
}

.auth-card .form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e8ecff;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s;
    box-sizing: border-box;
    background-color: #f8f9fe;
}

.auth-card .form-control:focus {
    border-color: #6c8aef;
    background-color: #ffffff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(108, 138, 239, 0.1);
}

/* Buttons for Auth Pages */
.btn-full-width {
    width: 100%;
    padding: 14px 24px;
    border-radius: 24px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.auth-card .btn-primary {
    background: linear-gradient(135deg, #6c8aef 0%, #8b9ef5 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(108, 138, 239, 0.3);
}

.auth-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(108, 138, 239, 0.4);
}

.auth-card .btn-primary:active {
    transform: translateY(0);
}

.auth-card .btn-success {
    background: linear-gradient(135deg, #6fcf97 0%, #7ee5a8 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(111, 207, 151, 0.3);
}

.auth-card .btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(111, 207, 151, 0.4);
}

/* Alerts for Auth Pages */
.auth-card .alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    border: none;
}

.auth-card .alert-danger {
    background-color: #ffe8e8;
    color: #d63031;
    border-left: 4px solid #f66d6d;
}

.auth-card .alert-success {
    background-color: #e8f8f0;
    color: #00b894;
    border-left: 4px solid #6fcf97;
}

/* Animation */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness for Auth Pages */
@media (max-width: 480px) {
    .auth-card {
        padding: 30px 25px;
        border-radius: 12px;
    }

    .auth-header h2 {
        font-size: 1.5rem;
    }

    .auth-card .form-control {
        padding: 11px 14px;
        font-size: 0.95rem;
    }

    .btn-full-width {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
}

/* =========================================
   RESPONSIVE MÓVIL — COMPLETO
   ========================================= */
@media (max-width: 768px) {

    /* ── Layout general ── */
    .main-content {
        margin-left: 0;
        padding: 16px;
        width: 100%;
        box-sizing: border-box;
    }

    /* ── Sidebar deslizable ── */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 998;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* ── Header móvil ── */
    .mobile-header {
        display: flex;
    }

    /* ── Títulos de página ── */
    h1 {
        font-size: 1.4rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    h3 {
        font-size: 1rem;
    }

    /* ── Header de página con botones ── */
    .d-flex.justify-between.align-center.mb-20 {
        flex-wrap: wrap;
        gap: 10px;
    }

    .d-flex.justify-between.align-center.mb-20>div {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    /* ── Botones de acción (Transferir / Agregar) ── */
    .btn-add-hero,
    .btn-transfer-hero {
        padding: 9px 14px;
        font-size: 0.88rem;
        gap: 6px;
    }

    .btn-add-hero .plus-icon {
        font-size: 1.1rem;
    }

    /* ── Cards de métricas ── */
    .card {
        padding: 18px;
    }

    div[style*="grid-template-columns: repeat(auto-fit, minmax(250px"] {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    div[style*="grid-template-columns: repeat(auto-fit, minmax(350px"] {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    /* ── Cuentas ── */
    .accounts-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .account-card-mini {
        padding: 12px;
    }

    .acc-balance {
        font-size: 1rem;
    }

    /* ── Filtro de fechas dashboard ── */
    .date-filter-container {
        padding: 14px;
    }

    .filter-buttons {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .filter-btn {
        padding: 8px 6px;
        font-size: 0.8rem;
        text-align: center;
    }

    .filter-btn i {
        display: none;
    }

    /* oculta icono para ahorrar espacio */
    .custom-range-wrapper {
        flex-direction: column;
    }

    .custom-range-wrapper input,
    .custom-range-wrapper button {
        width: 100%;
        box-sizing: border-box;
    }

    /* ── Barra filtros transactions ── */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .filter-bar input[type="text"],
    .filter-bar select,
    .date-filter-group,
    .date-filter-group .form-control {
        width: 100%;
        min-width: unset;
        box-sizing: border-box;
    }

    .date-filter-group {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .date-filter-label {
        min-width: 42px;
    }

    .filter-btn-search {
        width: 100%;
        height: 40px;
        border-radius: 8px;
    }

    /* ── Tabla de transacciones ── */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 540px;
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 0.82rem;
    }

    th {
        font-size: 0.72rem;
    }

    /* Ocultar columna "Cuenta" en móvil para ahorrar espacio */
    table th:nth-child(4),
    table td:nth-child(4) {
        display: none;
    }

    .btn-icon {
        padding: 4px 6px;
        font-size: 0.9rem;
    }

    .account-badge {
        font-size: 0.75rem;
        padding: 2px 6px;
    }

    /* ── Gráfica diaria ── */
    #dailyChart {
        min-height: 220px;
    }

    /* ── Insights ── */
    .insights-container {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .insight-card {
        padding: 14px;
    }

    .insight-value {
        font-size: 1.1rem;
    }

    /* ── Modal ── */
    .modal-content {
        width: 96%;
        max-width: 100%;
        max-height: 92vh;
        display: flex;
        flex-direction: column;
        border-radius: 16px;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        padding: 16px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .category-grid {
        max-height: 140px;
    }

    /* ── Settings ── */
    .settings-cols-3 {
        grid-template-columns: 1fr;
    }

    .settings-col {
        padding: 14px;
    }

    .section-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* ── Form grid modal ── */
    .form-col {
        flex: unset;
        width: 100%;
    }
}

/* Pantallas muy pequeñas (≤ 400px) */
@media (max-width: 400px) {
    .main-content {
        padding: 12px;
    }

    .accounts-summary-grid {
        grid-template-columns: 1fr;
    }

    .insights-container {
        grid-template-columns: 1fr;
    }

    .filter-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    h1 {
        font-size: 1.2rem;
    }
}