/* Custom styles for Budget Tracker - Theme-aware */

/* Body */
body {
    min-height: 100vh;
}

/* Dashboard Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-card h3 {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.summary-card .amount {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--color-success);
    margin: 0;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

.summary-card .amount.negative {
    color: var(--color-danger);
}

.summary-card .percentage {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--accent-primary);
    margin: 0;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

/* Charts Tab Section */
.charts-tabs-section {
    margin-bottom: 3rem;
}

.charts-tabs-section h2 {
    color: var(--text-secondary);
    font-size: 1.75rem;
    font-weight: 600;
}

/* Tab Navigation Styling */
.charts-tabs-section .nav-tabs {
    border-bottom: 0.125rem solid var(--card-border);
    margin-bottom: 2rem;
}

.charts-tabs-section .nav-tabs .nav-link {
    color: var(--text-primary);
    opacity: 0.7;
    border: none;
    border-bottom: 0.1875rem solid transparent;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.charts-tabs-section .nav-tabs .nav-link:hover {
    color: var(--text-primary);
    opacity: 1;
    border-bottom-color: var(--card-border);
}

.charts-tabs-section .nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

.charts-tabs-section .nav-tabs .nav-link i {
    margin-right: 0.5rem;
}

/* Tab Content Styling */
.charts-tabs-section .tab-content {
    padding: 2rem 0;
}

.charts-tabs-section .tab-pane {
    min-height: 30vh;
}

/* Chart Container in Tabs - Dynamic Sizing */
.charts-tabs-section .chart-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    max-width: 90%;
    width: 100%;
    margin: 0 auto;
    min-height: 450px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.charts-tabs-section .chart-container h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.5rem;
    width: 100%;
    flex-shrink: 0;
}

.charts-tabs-section .chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Wrapper for canvas to enforce size constraints */
.charts-tabs-section .chart-wrapper {
    width: 100%;
    height: 400px;
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Quick Stats */
.quick-stats {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 1rem;
}

.quick-stats .stat span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.quick-stats .stat strong {
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* Tables */
.table-responsive {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
}

/* Badges */
.badge-active {
    background-color: var(--color-success);
}

.badge-inactive {
    background-color: var(--text-secondary);
}

/* Financial Values */
.positive {
    color: var(--color-success);
}

.negative {
    color: var(--color-danger);
}

/* Forms */
.form-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    max-width: 600px;
    margin: 0 auto;
}

/* Messages */
.messages {
    margin-bottom: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .summary-card .amount,
    .summary-card .percentage {
        font-size: 1.5rem;
        word-break: break-word;
    }

    .summary-card h3 {
        font-size: 0.8rem;
    }
}

/* Extra safety for very small screens */
@media (max-width: 576px) {
    .summary-card .amount,
    .summary-card .percentage {
        font-size: 1.25rem;
    }

    /* Charts tabs responsive */
    .charts-tabs-section .nav-tabs {
        flex-wrap: wrap;
    }

    .charts-tabs-section .nav-tabs .nav-link {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }

    .charts-tabs-section .tab-pane {
        min-height: 20vh;
    }

    .charts-tabs-section .chart-container {
        padding: 1rem;
        max-width: 100%;
        min-height: 350px;
    }

    .charts-tabs-section .chart-wrapper {
        height: 300px;
    }
}

/* Navbar gradient — kept for .gradient-header modals only */

/* Gradient header for modals and dialogs */
.gradient-header {
    background: linear-gradient(135deg, var(--navbar-gradient-start) 0%, var(--navbar-gradient-end) 100%) !important;
    color: white !important;
}

.gradient-header .btn-close {
    filter: brightness(0) invert(1);
}

/* Footer */
footer {
    margin-top: auto;
    background-color: var(--muted-bg);
    color: var(--muted-text);
}

/* Button spacing */
.btn-group-spacing {
    gap: 0.5rem;
}

/* Card spacing */
.card + .card {
    margin-top: 1rem;
}

/* List group item hover */
.list-group-item:hover {
    background-color: var(--bg-secondary);
    cursor: pointer;
}

/* Theme-aware Bootstrap component overrides */
.card {
    background-color: var(--card-bg);
    border-color: var(--card-border);
    color: var(--text-primary);
}

/* Dark theme: make muted/help text readable */
[data-theme^="dark-"] .form-text,
[data-theme^="dark-"] .text-muted {
    color: var(--text-tertiary) !important;
}

/* Dark theme: Bootstrap alerts — override to use custom semantic vars so they
   don't render as bright light boxes against dark backgrounds.
   Also fixes WCAG failure: color-danger #f87171 on dark-danger #7f1d1d = 3.62:1.
   Bump danger text to #fca5a5 (5.5:1 on #7f1d1d). */
[data-theme^="dark-"] .alert-info {
    --bs-alert-bg: var(--color-info-light);
    --bs-alert-color: var(--color-info);
    --bs-alert-border-color: color-mix(in srgb, var(--color-info) 30%, var(--color-info-light));
}
[data-theme^="dark-"] .alert-success {
    --bs-alert-bg: var(--color-success-light);
    --bs-alert-color: var(--color-success);
    --bs-alert-border-color: color-mix(in srgb, var(--color-success) 30%, var(--color-success-light));
}
[data-theme^="dark-"] .alert-warning {
    --bs-alert-bg: var(--color-warning-light);
    --bs-alert-color: var(--color-warning);
    --bs-alert-border-color: color-mix(in srgb, var(--color-warning) 30%, var(--color-warning-light));
}
[data-theme^="dark-"] .alert-danger {
    --bs-alert-bg: var(--color-danger-light);
    --bs-alert-color: #fca5a5; /* WCAG fix: #fca5a5 on #7f1d1d = 5.5:1 (was 3.62:1) */
    --bs-alert-border-color: color-mix(in srgb, #fca5a5 30%, var(--color-danger-light));
}
/* Alert links inherit the alert text color */
[data-theme^="dark-"] .alert .alert-link {
    color: inherit;
    filter: brightness(1.2);
}
/* Alert close button — white tint so it's visible on dark alert backgrounds */
[data-theme^="dark-"] .alert .btn-close {
    filter: brightness(2) invert(0.2);
}

/* Dark theme: form-control-plaintext — many form partials hardcode #f8f9fa inline.
   !important needed to beat inline style specificity. */
[data-theme^="dark-"] .form-control-plaintext {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Dark theme: Bootstrap bg-light / bg-white utility classes */
[data-theme^="dark-"] .bg-light,
[data-theme^="dark-"] .card.bg-light {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
[data-theme^="dark-"] .bg-white {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

/* Dark theme: make outline-secondary buttons readable */
[data-theme^="dark-"] .btn-outline-secondary {
    --bs-btn-color: var(--text-primary);
    --bs-btn-border-color: var(--text-primary);
    --bs-btn-hover-color: var(--bg-primary);
    --bs-btn-hover-bg: var(--text-primary);
    --bs-btn-hover-border-color: var(--text-primary);
    --bs-btn-active-color: var(--bg-primary);
    --bs-btn-active-bg: var(--text-primary);
    --bs-btn-active-border-color: var(--text-primary);
}

.table {
    color: var(--text-primary);
    background-color: var(--card-bg);
}

.table th {
    color: var(--text-primary);
    font-weight: 600;
    border-color: var(--border-color);
}

.table td {
    border-color: var(--border-color);
}

/* Table row backgrounds for dark themes */
.table tbody tr {
    background-color: var(--card-bg);
}

/* Striped table rows */
.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--bg-secondary);
}

/* Hover state for table rows */
.table-hover tbody tr:hover {
    background-color: var(--bg-tertiary);
}

/* Footer row (table-active) */
.table .table-active,
.table-active > th,
.table-active > td {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Dark theme: override Bootstrap table CSS variables */
[data-theme^="dark-"] .table {
    --bs-table-bg: color-mix(in srgb, var(--card-bg), white 2%);
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: var(--bg-tertiary);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-hover-bg: var(--bg-tertiary);
    --bs-table-hover-color: var(--text-secondary);
    --bs-table-active-bg: var(--bg-tertiary);
    --bs-table-active-color: var(--text-primary);
}

[data-theme^="dark-"] .table-responsive {
    background: color-mix(in srgb, var(--card-bg), white 2%);
}

.form-control,
.form-select {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-primary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.modal-content {
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.modal-header,
.modal-footer {
    border-color: var(--border-color);
}

.list-group-item {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Debug Table Styling */
.debug-table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.debug-table-wrapper h5 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--card-border);
}

.debug-table-wrapper .table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.debug-table-wrapper .table th {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-table-wrapper .table td {
    color: var(--text-primary);
}

.color-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    vertical-align: middle;
    margin-right: 4px;
}

/* Page headers - softer color in dark themes */
h1 {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Card titles - softer color */
.card-title {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Responsive - Stack on mobile */
@media (max-width: 767px) {
    .debug-table-wrapper {
        margin-top: 1rem;
    }
}

/* Chartist label styling - Bold labels for better visibility */
.ct-label {
    fill: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
}

/* Ensure labels are readable in charts */
.ct-chart .ct-label {
    font-weight: bold;
}

/* Investment Cards Grid Layout */
.investment-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.investment-card {
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.investment-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.investment-card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--card-border);
    background: var(--bg-secondary);
}

.investment-card-title h5 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.investment-card-title .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

.investment-card-body {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.metric-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-label i {
    margin-right: 0.25rem;
    opacity: 0.7;
}

.metric-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-primary {
    font-size: 1.25rem;
    color: var(--color-success);
}

.trend-metric {
    background: var(--bg-tertiary);
    margin: -0.5rem;
    padding: 0.75rem 0.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

.investment-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--card-border);
    background: var(--bg-secondary);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.investment-card-footer .btn {
    flex: 0 0 auto;
}

.investment-total-summary .summary-card {
    max-width: 100%;
}

.investment-total-summary .amount {
    font-size: 2rem;
}

@media (max-width: 768px) {
    .investment-cards-grid {
        grid-template-columns: 1fr;
    }

    .investment-card-header,
    .investment-card-body,
    .investment-card-footer {
        padding: 1rem;
    }

    .metric-primary {
        font-size: 1.1rem;
    }

    .investment-total-summary .amount {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .investment-cards-grid {
        gap: 1rem;
    }

    .investment-card-title h5 {
        font-size: 1rem;
    }

    .metric-label,
    .metric-value {
        font-size: 0.8rem;
    }

    .metric-primary {
        font-size: 1rem;
    }
}

/* ===== Investment View Toggle (User-Controlled) ===== */
/* No longer using responsive media queries - user controls view */

/* View toggle button styling */
.view-toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-toggle-container .btn-group {
    box-shadow: var(--shadow-sm);
}

/* Table view enhancements */
.investment-table-view .table-responsive {
    margin-bottom: 2rem;
}

.investment-table-view .table th {
    white-space: nowrap;
    vertical-align: middle;
}

.investment-table-view .table td {
    vertical-align: middle;
}

.investment-table-view .table td .btn {
    margin-right: 0.25rem;
}

.investment-table-view .table td .btn:last-child {
    margin-right: 0;
}

/* Tablet optimization (768px - 991px): 2-column card layout */
@media (min-width: 768px) and (max-width: 991px) {
    .investment-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive toggle button on mobile */
@media (max-width: 768px) {
    .view-toggle-container .btn-group label {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    .view-toggle-container .btn-group i {
        margin-right: 0.25rem;
    }
}

/* ===== Investment Page Header Layout ===== */

/* Desktop layout (default) */
.investment-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-title h1 {
    margin: 0;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* New wrapper styles for better button organization */
.view-toggle-wrapper,
.manage-types-wrapper,
.add-investment-wrapper {
    display: flex;
    align-items: center;
}

.view-toggle-wrapper span,
.manage-types-wrapper span,
.add-investment-wrapper span {
    display: inline-flex;
}

/* Tablet and below (< 768px) */
@media (max-width: 767px) {
    .investment-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-title {
        width: 100%;
    }

    .header-title h1 {
        font-size: 1.5rem;
        white-space: normal;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .view-toggle-container {
        flex-shrink: 0;
    }

    .manage-types-wrapper,
    .add-investment-wrapper {
        display: flex;
        gap: 0.5rem;
    }

    /* Ensure buttons don't shrink too much */
    .manage-types-wrapper .btn,
    .add-investment-wrapper .btn {
        white-space: nowrap;
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }
}

/* Extra small screens (< 576px) */
@media (max-width: 575px) {
    .header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .view-toggle-container {
        width: 100%;
    }

    .view-toggle-container .btn-group {
        width: 100%;
    }

    .view-toggle-container .btn-group label {
        flex: 1;
    }

    .manage-types-wrapper,
    .add-investment-wrapper {
        flex: 1;
    }

    .manage-types-wrapper .btn,
    .add-investment-wrapper .btn {
        width: 100%;
    }
}

/* ===== Credit/Debt View Toggle ===== */

/* Credit Page Header Layout */
.credit-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Credit Cards Grid Layout */
.credit-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Credit Card Styling */
.credit-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.2s ease;
}

.credit-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.credit-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.credit-card-title h5 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.credit-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-grow: 1;
}

.credit-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.credit-card-footer .btn {
    flex: 0 0 auto;
}

/* Tablet optimization */
@media (min-width: 768px) and (max-width: 991px) {
    .credit-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive credit page header on tablet */
@media (max-width: 767px) {
    .credit-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .credit-page-header .header-title {
        width: 100%;
    }

    .credit-page-header .header-title h1 {
        font-size: 1.5rem;
        white-space: normal;
    }
}

/* Mobile optimization */
@media (max-width: 575px) {
    .credit-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* Credit Total Summary */
.credit-total-summary .summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.credit-total-summary .summary-card-highlight {
    border-left: 4px solid var(--bs-danger);
}

.credit-total-summary .amount {
    font-size: 1.75rem;
    font-weight: 700;
}

/* ===== Monthly Services View Toggle ===== */

/* Monthly Services Page Header Layout */
.monthly-services-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Monthly Services Cards Grid Layout */
.monthly-services-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Monthly Services Card Styling */
.monthly-services-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.2s ease;
}

.monthly-services-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.monthly-services-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.monthly-services-card-title h5 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.monthly-services-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-grow: 1;
}

.monthly-services-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.monthly-services-card-footer .btn {
    flex: 0 0 auto;
}

/* Tablet optimization */
@media (min-width: 768px) and (max-width: 991px) {
    .monthly-services-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive monthly services page header on tablet */
@media (max-width: 767px) {
    .monthly-services-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .monthly-services-page-header .header-title {
        width: 100%;
    }

    .monthly-services-page-header .header-title h1 {
        font-size: 1.5rem;
        white-space: normal;
    }
}

/* Mobile optimization */
@media (max-width: 575px) {
    .monthly-services-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Passive Income View Toggle ===== */

/* Passive Income Page Header Layout */
.passive-income-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Passive Income Cards Grid Layout */
.passive-income-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Passive Income Card Styling - slightly different background for contrast */
.passive-income-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.2s ease;
}

.passive-income-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.passive-income-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.passive-income-card-title h5 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.passive-income-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-grow: 1;
}

.passive-income-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.passive-income-card-footer .btn {
    flex: 0 0 auto;
}

/* Tablet optimization */
@media (min-width: 768px) and (max-width: 991px) {
    .passive-income-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive passive income page header on tablet */
@media (max-width: 767px) {
    .passive-income-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .passive-income-page-header .header-title {
        width: 100%;
    }

    .passive-income-page-header .header-title h1 {
        font-size: 1.5rem;
        white-space: normal;
    }
}

/* Mobile optimization */
@media (max-width: 575px) {
    .passive-income-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* Passive Income Total Summary */
.passive-income-total-summary .summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.passive-income-total-summary .summary-card-highlight {
    border-left: 4px solid var(--bs-success);
}

.passive-income-total-summary .amount {
    font-size: 1.75rem;
    font-weight: 700;
}

/* ===== Depreciating Assets View Toggle ===== */

/* Depreciating Assets Page Header Layout */
.depreciating-assets-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Depreciating Assets Cards Grid Layout */
.depreciating-assets-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Depreciating Assets Card Styling - slightly different background for contrast */
.depreciating-assets-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.2s ease;
}

.depreciating-assets-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.depreciating-assets-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.depreciating-assets-card-title h5 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.depreciating-assets-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-grow: 1;
}

.depreciating-assets-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.depreciating-assets-card-footer .btn {
    flex: 0 0 auto;
}

/* Tablet optimization */
@media (min-width: 768px) and (max-width: 991px) {
    .depreciating-assets-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive depreciating assets page header on tablet */
@media (max-width: 767px) {
    .depreciating-assets-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .depreciating-assets-page-header .header-title {
        width: 100%;
    }

    .depreciating-assets-page-header .header-title h1 {
        font-size: 1.5rem;
        white-space: normal;
    }
}

/* Mobile optimization */
@media (max-width: 575px) {
    .depreciating-assets-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* Depreciating Assets Total Summary */
.depreciating-assets-total-summary .summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.depreciating-assets-total-summary .summary-card-highlight {
    border-left: 4px solid var(--bs-info);
}

.depreciating-assets-total-summary .amount {
    font-size: 1.75rem;
    font-weight: 700;
}

/* ===== Floating Help Button ===== */
.floating-help-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bs-info);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 1000;
}

.floating-help-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.floating-help-btn:focus {
    outline: none;
    box-shadow: var(--shadow-lg);
}

/* Mobile adjustment */
@media (max-width: 576px) {
    .floating-help-btn {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
}

/* ===== Shared Dashboard Zone Components ===== */

/* Hero Net Worth card */
.hero-net-worth {
    text-align: center;
    padding: 2.5rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary-light), var(--card-bg));
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.hero-net-worth .hero-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.hero-net-worth .hero-amount {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.hero-net-worth .hero-amount.positive { color: var(--color-success); }
.hero-net-worth .hero-amount.negative { color: var(--color-danger); }

.hero-net-worth .hero-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Zone section header */
.zone-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--card-border);
}

/* Primary zone headers (Balance Sheet, Performance & Costs) */
.zone-header--primary {
    font-weight: 700;
    color: var(--text-primary);
    border-bottom-width: 2px;
}

/* Insight / zone cards */
.insight-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--card-border);
    transition: box-shadow var(--transition-base);
}

.insight-card:hover {
    box-shadow: var(--shadow-md);
}

.insight-card.card-own     { border-left-color: var(--color-success); }
.insight-card.card-owe     { border-left-color: var(--color-danger); }
.insight-card.card-costs   { border-left-color: var(--color-warning); }
.insight-card.card-income  { border-left-color: var(--color-info); }
.insight-card.card-neutral { border-left-color: var(--accent-primary); }

/* Tier-specific gauge card border colours */
.insight-card.stability-excellent { border-left-color: #198754; }
.insight-card.stability-good      { border-left-color: #20c997; }
.insight-card.stability-fair      { border-left-color: #ffc107; }
.insight-card.stability-at_risk   { border-left-color: #fd7e14; }
.insight-card.stability-critical  { border-left-color: #dc3545; }

.insight-card .card-icon {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.insight-card.card-own    .card-icon { color: var(--color-success); }
.insight-card.card-owe    .card-icon { color: var(--color-danger); }
.insight-card.card-costs  .card-icon { color: var(--color-warning); }
.insight-card.card-income .card-icon { color: var(--color-info); }
.insight-card.card-neutral .card-icon { color: var(--accent-primary); }

.insight-card .card-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}

.insight-card .card-amount {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    word-break: break-word;
    line-height: 1.2;
}

.insight-card .card-amount.negative { color: var(--color-danger); }
.insight-card .card-amount.warning  { color: var(--color-warning); }

.insight-card .card-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Asset subtotal row (bottom of asset column) */
/* Total Assets Hero — full-width motivational banner below the balance sheet grid */
.total-assets-hero {
    margin-top: 1rem;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, #0d6b3b 0%, #1a9e5c 60%, #22c55e 100%);
    padding: 1.75rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.25);
}

.total-assets-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 80% 50%, rgba(255,255,255,0.08) 0%, transparent 65%);
    pointer-events: none;
}

.total-assets-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.total-assets-amount {
    font-size: 2.6rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.total-assets-subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.65);
    margin-top: 0.35rem;
    margin-bottom: 1rem;
}

.total-assets-breakdown {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ta-chip {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255,255,255,0.15);
    border-radius: 2rem;
    padding: 0.2rem 0.7rem;
    backdrop-filter: blur(4px);
}

.ta-chip-icon { font-size: 0.75rem; color: rgba(255,255,255,0.8); }
.ta-chip-label { font-size: 0.72rem; color: rgba(255,255,255,0.75); }
.ta-chip-value { font-size: 0.75rem; font-weight: 700; color: #ffffff; }

.ta-chip-sep { color: rgba(255,255,255,0.35); font-size: 1.1rem; line-height: 1; }

[data-theme^="dark-"] .total-assets-hero {
    background: linear-gradient(135deg, #064e29 0%, #0d6b3b 60%, #16a34a 100%);
    box-shadow: 0 4px 20px rgba(22, 163, 74, 0.3);
}

/* Balance sheet mini progress bars */
.ratio-bar-bg {
    height: 5px;
    background: var(--card-border);
    border-radius: 3px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.ratio-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--color-danger);
    transition: width 0.5s ease;
}

.ratio-bar-asset  { background: var(--color-success); }
.ratio-bar-liability { background: var(--color-warning, #f59e0b); }

.bar-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
    opacity: 0.8;
}

/* Balance sheet equal 2-column grid */
.balance-sheet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.balance-sheet-grid .asset-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.balance-sheet-grid .liability-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* 2-column grid for metric / cost cards */
.zone-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Hero rows: Net Worth + Budget Stability side by side */
.hero-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

/* Beginner: Net Worth + Gauge side by side */
.beginner-hero-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: stretch;
}

/* Beginner hero: make the insight-card gauge match hero-net-worth visually */
.beginner-hero-row .insight-card {
    background: linear-gradient(135deg, var(--accent-primary-light), var(--card-bg));
    border-left-width: 1px;
    border-top: 4px solid var(--card-border);
}
.beginner-hero-row .insight-card.stability-excellent { border-top-color: #198754; border-left-color: var(--card-border); }
.beginner-hero-row .insight-card.stability-good      { border-top-color: #20c997; border-left-color: var(--card-border); }
.beginner-hero-row .insight-card.stability-fair      { border-top-color: #ffc107; border-left-color: var(--card-border); }
.beginner-hero-row .insight-card.stability-at_risk   { border-top-color: #fd7e14; border-left-color: var(--card-border); }
.beginner-hero-row .insight-card.stability-critical  { border-top-color: #dc3545; border-left-color: var(--card-border); }

/* KPI stat cards: border-top accent + equal height */
.insight-card.stat-card {
    border-left: none;
    border-top: 4px solid var(--card-border);
    display: flex;
    flex-direction: column;
}
.insight-card.stat-card.card-own     { border-top-color: var(--color-success); }
.insight-card.stat-card.card-owe     { border-top-color: var(--color-danger);  }
.insight-card.stat-card.card-neutral { border-top-color: var(--accent-primary); }
.insight-card.stat-card .card-detail { margin-top: auto; padding-top: 0.5rem; }

/* Responsive: stack layouts on mobile */
@media (max-width: 768px) {
    .balance-sheet-grid {
        grid-template-columns: 1fr;
    }

    .hero-row {
        grid-template-columns: 1fr;
    }

    .hero-net-worth .hero-amount {
        font-size: 2.2rem;
    }
}

@media (max-width: 600px) {
    .beginner-hero-row {
        grid-template-columns: 1fr;
    }
}

/* ── Dashboard V2 ─────────────────────────────────────────────────────── */

/* Three-column hero: Net Worth + Stability + Health */
.hero-row-3col {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.hero-row-3col > * {
    height: 100%;
    margin-bottom: 0;
}

@media (max-width: 992px) {
    .hero-row-3col {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 576px) {
    .hero-row-3col {
        grid-template-columns: 1fr;
    }
}

/* Detailed dashboard: three equal-width hero cards */
.hero-row-equal {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.hero-row-equal > * {
    height: 100%;
    margin-bottom: 0;
}

@media (max-width: 992px) {
    .hero-row-equal { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 576px) {
    .hero-row-equal { grid-template-columns: 1fr; }
}

/* Action items panel */
.action-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.action-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-left-width: 4px;
}

.action-item.urgency-critical { border-left-color: #dc3545; }
.action-item.urgency-warning  { border-left-color: #fd7e14; }
.action-item.urgency-ok       { border-left-color: #198754; }

.action-item__label {
    font-weight: 600;
    flex: 1;
    min-width: 0;
}

.action-item__detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* KPI sparkline cards */
.kpi-sparkline-card {
    display: flex;
    flex-direction: column;
}

.kpi-sparkline-card .sparkline-canvas {
    height: 42px !important;
    width: 100% !important;
    margin-top: 0.5rem;
}

/* Debt-ratio contextual badge */
.debt-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.debt-badge.sustainable { background: #d1e7dd; color: #0f5132; }
.debt-badge.monitor     { background: #fff3cd; color: #664d03; }
.debt-badge.action      { background: #f8d7da; color: #842029; }

[data-theme^="dark-"] .debt-badge.sustainable { background: #0f5132; color: #d1e7dd; }
[data-theme^="dark-"] .debt-badge.monitor     { background: #664d03; color: #fff3cd; }
[data-theme^="dark-"] .debt-badge.action      { background: #842029; color: #f8d7da; }

/* Freedom Ratio badge */
.freedom-ratio-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-freedom-full  { background: rgba(25,135,84,0.15);  color: #198754; border: 1px solid #198754; }
.badge-freedom-half  { background: rgba(255,193,7,0.15);  color: #856404; border: 1px solid #ffc107; }
.badge-freedom-low   { background: rgba(220,53,69,0.15);  color: #dc3545; border: 1px solid #dc3545; }

[data-theme^="dark-"] .badge-freedom-full { background: rgba(25,135,84,0.25);  color: #75b798; border-color: #198754; }
[data-theme^="dark-"] .badge-freedom-half { background: rgba(255,193,7,0.20);  color: #ffc107; border-color: #ffc107; }
[data-theme^="dark-"] .badge-freedom-low  { background: rgba(220,53,69,0.20);  color: #ea868f; border-color: #dc3545; }

/* ===== Left Sidebar Navigation Layout ===== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    background: linear-gradient(180deg, var(--navbar-gradient-start) 0%, var(--navbar-gradient-end) 100%);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    color: white;
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-brand:hover { color: white; }

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.sidebar-section-btn {
    width: 100%;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.8);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    text-align: left;
    transition: background .15s ease, color .15s ease;
}

.sidebar-section-btn:hover,
.sidebar-section-btn:not(.collapsed) {
    background: rgba(255,255,255,0.1);
    color: white;
}

.sidebar-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform .2s ease;
}

.sidebar-section-btn:not(.collapsed) .sidebar-chevron {
    transform: rotate(-180deg);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 1rem 0.45rem 2.5rem;
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background .15s ease, color .15s ease;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(255,255,255,0.18);
    color: white;
    font-weight: 600;
}

.sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.15);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-footer-fy {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.2rem 0;
}

.sidebar-footer-fy:hover { color: white; }

.sidebar-footer-lang {
    display: flex;
    gap: 0.4rem;
}

.sidebar-lang-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.75);
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.sidebar-lang-btn:hover,
.sidebar-lang-btn.active {
    background: rgba(255,255,255,0.25);
    color: white;
}

.sidebar-user-btn {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.85);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background .15s ease;
}

.sidebar-user-btn:hover { background: rgba(255,255,255,0.2); color: white; }

.sidebar-footer .dropdown-menu {
    min-width: 270px;
    white-space: nowrap;
}

.main-wrapper {
    margin-left: 240px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

.topbar {
    height: 52px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 99;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
    margin-right: 0.75rem;
    line-height: 1;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.content-area {
    flex: 1;
    padding: 1.5rem;
}

/* Mobile: sidebar slides in over content */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-240px);
        z-index: 1050;
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1049;
    }
    .sidebar-backdrop.show {
        display: block;
    }
    .sidebar-toggle {
        display: block;
    }
}

@media (min-width: 992px) {
    .topbar {
        display: none;
    }
}

input[type="color"] {
    width: 60px;
    height: 36px;
    padding: 2px;
    cursor: pointer;
}

.form-card-wide {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    max-width: 800px;
    margin: 0 auto;
}
