/* Budget Revolution - Main Stylesheet */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow);
    width: 100%;
}

.navbar-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin-left: auto;
}

.navbar-nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.navbar-nav a:hover {
    color: var(--primary-color);
}

.navbar-nav a.active {
    color: var(--primary-color);
}

/* Global account selector in nav bar */
.navbar-account-sel {
    padding: 0.35rem 0.7rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 140px;
}
.navbar-account-sel:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
}

.table thead {
    background-color: var(--bg-color);
}

.table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background-color: var(--bg-color);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #2563eb;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utilities */
.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-secondary { color: var(--text-secondary); }

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .navbar-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .navbar-nav {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Enhanced Dashboard Styles */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.dashboard-controls {
    display: flex;
    gap: 0.5rem;
}

/* Enhanced stat cards with status colors */
.stat-value.positive {
    color: #10b981;
}

.stat-value.negative {
    color: #ef4444;
}

.stat-value.neutral {
    color: #6b7280;
}

/* Progress indicator styles */
.progress-container {
    margin: 1rem 0;
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background-color: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-bar.success {
    background-color: #10b981;
}

.progress-bar.warning {
    background-color: #f59e0b;
}

.progress-bar.danger {
    background-color: #ef4444;
}

.progress-text {
    font-weight: 600;
    color: #374151;
    text-align: center;
}

.progress-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

/* Charts grid layout */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.chart-card {
    min-height: 400px;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container.large {
    height: 400px;
}

/* Categories list widget */
.categories-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.category-name {
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.category-amount {
    font-weight: 700;
    color: #1f2937;
    margin-right: 1rem;
}

.category-transactions {
    font-size: 0.875rem;
    color: #6b7280;
    text-align: right;
}

/* Dashboard-specific loading styles */
#dashboard-page .loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    color: #6b7280;
}

#dashboard-page .spinner {
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin-bottom: 0.5rem;
}

/* Enhanced responsive styles for dashboard */
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .chart-container.large {
        height: 300px;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .dashboard-controls {
        justify-content: center;
    }
}

/* Enhanced Transaction Management Styles */
.transactions-page .card-header {
    flex-wrap: wrap;
    gap: 1rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Filters Section */
.filters-section {
    border-top: 1px solid #e5e7eb;
    padding: 1.5rem;
    margin: 0 -1.5rem;
    background-color: #f9fafb;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.date-range-inputs, .amount-range-inputs {
    display: flex;
    gap: 0.5rem;
}

.date-range-inputs input, .amount-range-inputs input {
    flex: 1;
}

.filters-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    flex-wrap: wrap;
}

/* Classification Tools */
.classification-tools {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    margin: 1rem 0;
    background-color: #f9fafb;
}

.tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #d1d5db;
    background-color: #f3f4f6;
    border-radius: 8px 8px 0 0;
}

.tools-content {
    padding: 1rem;
}

.bulk-actions {
    margin-bottom: 1.5rem;
}

.bulk-selectors {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.bulk-classification {
    display: flex;
    gap: 0.5rem;
    align-items: end;
    flex-wrap: wrap;
}

.bulk-classification .form-input {
    min-width: 150px;
}

.smart-suggestions {
    border-top: 1px solid #d1d5db;
    padding-top: 1rem;
}

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.suggestion-description {
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.suggestion-details {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin: 0 1rem;
}

.suggestion-category, .suggestion-subcategory {
    background-color: #dbeafe;
    color: #1e40af;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.suggestion-confidence {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
}

/* Transaction Statistics */
.transaction-stats {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    background-color: #f9fafb;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.stat-value {
    font-weight: 700;
    color: #1f2937;
}

/* Enhanced Transactions Table */
.transactions-table {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.transactions-header {
    display: grid;
    grid-template-columns: 40px 1fr 120px;
    gap: 1rem;
    padding: 1rem;
    background-color: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    color: #374151;
}

.transactions-body {
    max-height: 600px;
    overflow-y: auto;
}

.transaction-row {
    display: grid;
    grid-template-columns: 40px 1fr 120px;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s ease;
}

.transaction-row:hover {
    background-color: #f9fafb;
}

.transaction-row.selected {
    background-color: #eff6ff;
    border-left: 4px solid #3b82f6;
}

.transaction-select {
    display: flex;
    align-items: center;
    justify-content: center;
}

.transaction-checkbox {
    width: 16px;
    height: 16px;
}

.transaction-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.transaction-primary {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.transaction-description {
    font-weight: 600;
    color: #1f2937;
    flex: 1;
    margin-right: 1rem;
}

.transaction-amount {
    font-weight: 700;
    font-size: 1rem;
}

.transaction-secondary {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
    flex-wrap: wrap;
}

.transaction-metadata {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background-color: #dcfce7;
    color: #16a34a;
}

.badge-warning {
    background-color: #fef3c7;
    color: #d97706;
}

.badge-info {
    background-color: #dbeafe;
    color: #2563eb;
}

.badge-secondary {
    background-color: #f3f4f6;
    color: #6b7280;
}

.transaction-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.transaction-menu {
    position: relative;
}

/* No data state */
.no-data {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

/* Responsive styles for transactions */
@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-actions {
        justify-content: center;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .transactions-header {
        grid-template-columns: 30px 1fr 80px;
        font-size: 0.875rem;
    }
    
    .transaction-row {
        grid-template-columns: 30px 1fr 80px;
    }
    
    .transaction-secondary {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .transaction-actions {
        gap: 0.25rem;
    }
    
    .transaction-actions .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .stats-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .bulk-classification {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Reports Page Styles */
.reports-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.date-inputs {
    display: flex;
    gap: 0.5rem;
}

.config-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
}

/* Report Tabs */
.report-tabs {
    margin-top: 2rem;
}

.tab-nav {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 2rem;
    overflow-x: auto;
}

.tab-button {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-button:hover {
    color: #374151;
    background-color: #f9fafb;
}

.tab-button.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    text-align: center;
}

.metric-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.metric-change {
    font-size: 0.75rem;
    font-weight: 600;
}

.metric-change.positive {
    color: #10b981;
}

.metric-change.negative {
    color: #ef4444;
}

/* Spending Grid */
.spending-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Analysis Table */
.analysis-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.analysis-table th,
.analysis-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.analysis-table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.analysis-table .trend-indicator {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.analysis-table .trend-indicator.increasing {
    background-color: #fef3c7;
    color: #d97706;
}

.analysis-table .trend-indicator.decreasing {
    background-color: #dcfce7;
    color: #16a34a;
}

.analysis-table .trend-indicator.stable {
    background-color: #f3f4f6;
    color: #6b7280;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.template-options, .format-options, .data-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.checkbox-label, .radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* Tagging Page Styles */
.tagging-page .stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
}

.tagging-tabs {
    margin-top: 2rem;
}

/* Rules List */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rule-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    background: white;
}

.rule-item.inactive {
    opacity: 0.6;
    background-color: #f9fafb;
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.rule-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.rule-pattern {
    font-weight: 600;
    color: #1f2937;
    font-family: monospace;
    background-color: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.rule-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.rule-details {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.rule-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    flex-wrap: wrap;
}

.detail-label {
    font-weight: 600;
    margin-right: 0.25rem;
}

.detail-value {
    color: #1f2937;
}

/* Suggestions */
.suggestions-controls {
    display: flex;
    gap: 1rem;
    align-items: end;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-range {
    width: 150px;
}

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.suggestion-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    background: white;
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.suggestion-pattern {
    font-family: monospace;
    font-weight: 600;
    background-color: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.suggestion-confidence {
    font-size: 0.875rem;
    color: #16a34a;
    font-weight: 600;
}

.suggestion-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.suggestion-target {
    font-weight: 500;
    color: #1f2937;
}

.suggestion-count {
    font-size: 0.875rem;
    color: #6b7280;
}

.suggestion-actions {
    display: flex;
    gap: 0.5rem;
}

/* Test Results */
.test-controls {
    display: grid;
    grid-template-columns: 1fr 150px auto;
    gap: 1rem;
    align-items: end;
    margin-bottom: 2rem;
}

.test-results {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    background-color: #f9fafb;
    margin-top: 1rem;
}

.results-summary {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.result-stat {
    font-size: 0.875rem;
    color: #6b7280;
}

.matching-transactions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.matching-transaction {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.txn-description {
    flex: 1;
    font-weight: 500;
}

.txn-amount {
    font-weight: 600;
    color: #1f2937;
}

/* Training Data */
.training-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.training-quality {
    margin-top: 2rem;
}

.quality-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.quality-metric {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    background: white;
}

.quality-metric.good {
    border-left: 4px solid #10b981;
}

.quality-metric.warning {
    border-left: 4px solid #f59e0b;
}

.quality-metric.error {
    border-left: 4px solid #ef4444;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.metric-name {
    font-weight: 600;
    color: #1f2937;
}

.metric-description {
    font-size: 0.875rem;
    color: #6b7280;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-options {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.form-help {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-state p {
    margin-bottom: 1rem;
}

/* Responsive Design for New Pages */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions {
        justify-content: center;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .spending-grid {
        grid-template-columns: 1fr;
    }

    .tab-nav {
        flex-wrap: wrap;
    }

    .test-controls {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .rule-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .rule-details,
    .rule-stats,
    .results-summary {
        flex-direction: column;
        gap: 0.5rem;
    }

    .suggestions-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   Subcategory Context Bars - Budget Contextualization
   Per PDF specification: Color-coded spending vs avg/budget
   ===================================================== */

:root {
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-grey: #9ca3af;
}

/* Sort Controls */
.sort-controls { display: flex; gap: 0.75rem; align-items: center; }
.sort-controls label { font-size: 0.8rem; color: #64748b; font-weight: 600; }
.sort-dropdown {
    padding: 0.4rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-size: 0.8rem;
    color: #334155;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sort-dropdown:hover { border-color: #cbd5e1; }
.sort-dropdown:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* ---- Category Group ---- */
.category-group {
    margin-bottom: 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    border-left: 4px solid #3b82f6;
    transition: box-shadow 0.2s ease;
}
.category-group:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

.category-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
.category-group-header:hover { background: linear-gradient(135deg, #f1f5f9 0%, #e8edf4 100%); }

.category-group-title {
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}
.category-group-toggle {
    color: #94a3b8;
    transition: transform 0.25s ease;
    font-size: 0.6rem;
}
.category-group.collapsed .category-group-toggle { transform: rotate(-90deg); }
.category-group-content { padding: 0.25rem 1.25rem 0.5rem; }
.category-group.collapsed .category-group-content { display: none; }

/* Category Group Summary (right side) */
.category-group-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.375rem;
}
.category-group-total {
    font-size: 0.8rem;
    color: #475569;
    font-weight: 600;
}
.category-group-progress {
    width: 120px;
    height: 5px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}
.category-group-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* ---- Subcategory Item ---- */
.subcategory-item {
    padding: 1rem 0.25rem;
    border-bottom: 1px solid #f1f5f9;
    border-left: 3px solid transparent;
    transition: border-color 0.2s ease, background 0.2s ease;
    border-radius: 0;
}
.subcategory-item:last-child { border-bottom: none; }
.subcategory-item:hover {
    background: #fafbfd;
}
.subcategory-item:hover[data-color-case="1"] { border-left-color: var(--color-success); }
.subcategory-item:hover[data-color-case="2"] { border-left-color: var(--color-warning); }
.subcategory-item:hover[data-color-case="3"] { border-left-color: var(--color-danger); }
.subcategory-item:hover[data-color-case="4"] { border-left-color: var(--color-grey); }

/* Header: name + amount */
.subcategory-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.625rem;
}
.subcategory-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}
.subcategory-amount {
    font-weight: 700;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
}
.subcategory-amount.under { color: var(--color-success); }
.subcategory-amount.warning { color: var(--color-warning); }
.subcategory-amount.over { color: var(--color-danger); }
.subcategory-amount.grey { color: var(--color-grey); }

/* ---- Bar Track (the progress bar container) ---- */
.subcategory-bars { position: relative; margin-bottom: 0.375rem; }

.bar-track {
    position: relative;
    height: 10px;
    background: #f1f5f9;
    border-radius: 99px;
    overflow: visible;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}

/* Bar fills */
.bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
    position: relative;
}
.bar-fill.bar-green { background: linear-gradient(90deg, #22c55e, #4ade80); }
.bar-fill.bar-yellow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-fill.bar-red { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar-fill.bar-grey { background: linear-gradient(90deg, #d1d5db, #e5e7eb); opacity: 0.6; }

/* Case 3: Two-segment bar (yellow + red gradient) */
.bar-fill.bar-split {
    display: flex;
    overflow: hidden;
    background: none;
}
.bar-split-yellow {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.bar-split-red {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #f87171);
    border-radius: 0 99px 99px 0;
}

/* ---- AVG / Budget Reference Markers (overlaid on track) ---- */
.bar-avg-marker, .bar-budget-marker {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 0;
    transform: translateX(-50%);
    z-index: 2;
}
.bar-avg-marker {
    border-left: 2px dashed #3b82f6;
}
.bar-budget-marker {
    border-left: 2px dashed #8b5cf6;
}
.bar-avg-label, .bar-budget-label {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    background: white;
    padding: 1px 5px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 5;
}
.bar-avg-label { color: #3b82f6; }
.bar-budget-label { color: #8b5cf6; }

/* Show labels on hover */
.subcategory-item:hover .bar-avg-label,
.subcategory-item:hover .bar-budget-label {
    opacity: 1;
}

/* Flip label when marker is near right edge */
.bar-avg-marker.near-edge .bar-avg-label,
.bar-budget-marker.near-edge .bar-budget-label {
    left: auto;
    right: 0;
    transform: none;
}

/* ---- Footer: status badge + trend ---- */
.subcategory-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.color-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    letter-spacing: 0.01em;
}
.color-indicator.under { background: #dcfce7; color: #166534; }
.color-indicator.warning { background: #fef3c7; color: #92400e; }
.color-indicator.over { background: #fee2e2; color: #991b1b; }
.color-indicator.grey { background: #f3f4f6; color: #6b7280; }

/* Trend indicator */
.trend {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #6b7280;
    font-size: 0.8rem;
}
.trend.increasing { color: #f59e0b; }
.trend.decreasing { color: #22c55e; }
.trend.stable { color: #6b7280; }

.trend-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
}
.trend-dot-up { background: #f59e0b; }
.trend-dot-down { background: #22c55e; }
.trend-dot-stable { background: #94a3b8; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .subcategory-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    .subcategory-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    .category-group-progress { width: 80px; }
}

/* =====================================================
   Print Styles - Reports Page
   Hides UI chrome, shows only report preview content
   ===================================================== */
@media print {
    /* Hide navigation and UI controls */
    .navbar,
    .config-panel,
    .section-selector,
    .page-header,
    .page-actions,
    .modal,
    #export-modal {
        display: none !important;
    }

    /* Reset body for clean print */
    body {
        background: white !important;
        color: black !important;
        font-size: 11pt;
        line-height: 1.4;
    }

    .container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .reports-page {
        max-width: 100% !important;
        margin: 0 !important;
    }

    /* Report preview fills the page */
    #report-preview {
        margin: 0;
        padding: 0;
    }

    /* Report section cards */
    .report-section {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
        margin-bottom: 1rem;
        padding: 1rem;
    }

    /* Major sections start on new page */
    .report-section + .report-section {
        page-break-before: auto;
    }

    .report-section-title {
        font-size: 14pt;
        border-bottom-color: #333 !important;
    }

    /* Metrics cards print cleanly */
    .metrics-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .metric-card {
        border: 1px solid #ccc !important;
        background: white !important;
        padding: 0.5rem !important;
    }

    .metric-value.positive { color: #166534 !important; }
    .metric-value.negative { color: #991b1b !important; }

    /* Charts - use fixed dimensions for consistent output */
    .chart-container,
    .chart-container.large,
    .chart-container.medium {
        height: 300px !important;
        page-break-inside: avoid;
    }

    /* Tables print cleanly */
    .report-table {
        font-size: 9pt;
    }

    .report-table th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .report-table tr {
        page-break-inside: avoid;
    }

    /* Status badges preserve color in print */
    .status-badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .status-badge.ahead { background: #dcfce7 !important; color: #166534 !important; }
    .status-badge.behind { background: #fee2e2 !important; color: #991b1b !important; }
    .status-badge.even { background: #dbeafe !important; color: #1e40af !important; }

    /* Ensure chart images (converted for print) display correctly */
    .chart-container img {
        max-width: 100%;
        height: auto;
    }

    /* Hide interactive elements */
    .preview-empty {
        display: none !important;
    }

    /* Links show as plain text */
    a {
        color: black !important;
        text-decoration: none !important;
    }
}

/* ============================================================
   TAB SWITCHER  (/transactions page)
   ============================================================ */
.tab-switcher {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color, #e2e8f0);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn.active {
    color: var(--primary-color, #3b82f6);
    border-bottom-color: var(--primary-color, #3b82f6);
}

.tab-btn:hover {
    color: var(--primary-color, #3b82f6);
}

/* ============================================================
   LEDGER VIEW
   ============================================================ */

/* Control bar */
.ledger-control-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.ledger-select {
    width: auto;
    min-width: 160px;
}

/* Account Legend */
.ledger-legend {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.ledger-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.75rem;
    border-radius: 0px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.15s;
    position: relative;
}

.ledger-chip:hover {
    opacity: 0.85;
}

.ledger-chip--nested {
    background-color: #4852e4 !important;
    color: #f8fafc !important;
    cursor: default;
}

.ledger-color-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* Year banner */
.ledger-year-banner {
    background-color: #ffe599;
    color: black;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0.4rem 1rem;
    border-radius: 0;
    margin-bottom: 0;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
}

.ledger-year-section {
    width: max-content;
    margin-bottom: 2rem;
}

/* Single horizontal scroll wrapper for all years — fills remaining flex space */
.ledger-scroll-container {
    overflow: auto;
    height: 100%;
}

/* Scrollbar styling */
.ledger-scroll-container::-webkit-scrollbar {
    height: 12px;
}

.ledger-scroll-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 0;
}

.ledger-scroll-container::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 0;
}

/* Month row: no longer scrolls individually */
.ledger-months-row {
    display: flex;
    gap: 0;
    align-items: flex-start;
}

/* Individual month column */
.ledger-month-col {
    flex: 0 0 auto;
    border: 1.2px solid #000;
    border-radius: 0;
    overflow: hidden;
    background-color: var(--card-bg, #fff);
}

.ledger-month-header {
    background-color: #2563eb;
    color: white;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0;
    letter-spacing: 0.03em;
}

.ledger-month-body {
    display: flex;
    flex-direction: column;
}

.ledger-empty-month {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary, #64748b);
    font-size: 0.875rem;
}

/* Transaction Row */
.ledger-txn-row {
    display: grid;
    grid-template-columns: 20px 110px 84px var(--desc-col-width, 1fr) 92px;
    gap: 0.2rem;
    align-items: stretch;
    padding: 0.28rem 0.5rem;
    border-bottom: 1px solid #000;
    font-size: 0.8rem;
    min-height: 28px;
}

.ledger-txn-row:last-child {
    border-bottom: none;
}

.ledger-txn-row--nested {
    font-style: italic;
}

/* Transaction row columns */
.ledger-col-suppress {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ledger-col-subcat {
    overflow: hidden;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    display: flex;
    align-items: stretch;
}

.ledger-col-date {
    white-space: nowrap;
    color: #1e293b;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
}

.ledger-col-name {
    color: #1e293b;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.ledger-col-amount {
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Category select inside rows */
.ledger-cat-select {
    width: 100%;
    height: 100%;
    font-size: 0.78rem;
    padding: 0.12rem 0.2rem;
    border: none;
    border-radius: 0;
    background-color: transparent;
    cursor: pointer;
    max-width: 108px;
    text-align: center;
    text-align-last: center;
}

.ledger-cat-select optgroup {
    font-weight: bold;
    font-size: 14px;
    text-align: left;
}

.ledger-cat-select option {
    font-weight: normal;
    font-size: 0.78rem;
    text-align: left;
}

/* Amount colors */
.ledger-amount--positive {
    color: #22c55e;
}

/* Suppress checkbox */
.ledger-suppress-chk {
    cursor: pointer;
    accent-color: #000000;
    width: 20px;
    height: 20px;
}

/* Suppressed row styling */
.ledger-txn-row--suppressed {
    background-color: #969696 !important;
    color: white !important;
    font-weight: bold !important;
}

.ledger-txn-row--suppressed .ledger-col-date,
.ledger-txn-row--suppressed .ledger-col-name {
    color: white !important;
}

/* Suppressed legend chip */
.ledger-chip--suppressed {
    background: #969696;
    color: white;
    font-weight: bold;
}

.projection-stale-banner {
    background: #fff8e1;
    border: 1px solid #ffd54f;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #5d4037;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.projection-stale-banner a {
    color: #5d4037;
    text-decoration: underline;
    font-weight: 600;
}
.projection-stale-banner button {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #5d4037;
    padding: 0 4px;
}
.projection-stale-banner button:hover,
.projection-stale-banner button:focus,
.projection-stale-banner a:hover,
.projection-stale-banner a:focus {
    outline: 2px solid #5d4037;
    outline-offset: 2px;
}

.db-last-updated {
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
    letter-spacing: 0.01em;
}

