/* macOS-inspired Budget App Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f7;
    /* Mobile-first: allow page to scroll naturally */
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: 0;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f5f5f7;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    overflow: hidden;
}

/* Site-wide footer */
.site-footer {
    border-top: 1px solid var(--border, #e5e7eb);
    background: var(--surface, #ffffff);
    color: var(--text-secondary, #6b7280);
    padding: 12px 16px;
    text-align: center;
    font-size: 13px;
}
.site-footer .footer-inner {
    max-width: 980px;
    margin: 0 auto;
}

/* macOS Title Bar */
.title-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    height: 44px;
    background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 100%);
    border-bottom: 1px solid #d1d1d1;
    padding: 0 16px;
    -webkit-app-region: drag;
}

.traffic-lights {
    display: flex;
    gap: 8px;
    -webkit-app-region: no-drag;
}

.traffic-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.traffic-light.close {
    background: #ff5f57;
    border: 1px solid #e0443e;
}

.traffic-light.minimize {
    background: #ffbd2e;
    border: 1px solid #dea123;
}

.traffic-light.maximize {
    background: #28ca42;
    border: 1px solid #1aad29;
}

.traffic-light:hover {
    transform: scale(1.1);
}

.title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    -webkit-app-region: no-drag;
}

.toolbar {
    display: flex;
    gap: 8px;
    -webkit-app-region: no-drag;
}

/* Unified header toolbar buttons (Payment Log style) */
.title-bar .toolbar .toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    transition: background .2s ease, box-shadow .2s ease, transform .2s ease, color .2s ease, border-color .2s ease;
}

.title-bar .toolbar .toolbar-btn:hover {
    background: var(--surface-muted);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Active page indicator for toolbar buttons */
.title-bar .toolbar .toolbar-btn.active {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
    box-shadow: 0 4px 10px rgba(44,160,28,0.25);
}

.title-bar .toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Center group for title + toolbar */
.title-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-center .toolbar { margin-left: 0; }

/* Top tabs bar in sidebar */
.sidebar .top-tabs-bar {
    background: linear-gradient(135deg, #f7f8fa 0%, rgba(255,255,255,0.05) 100%);
    border-bottom: 2px solid #e5e5e7;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.sidebar .tabs {
    display: flex;
    gap: 4px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
    width: 100%;
}

/* Welcome text inside tabs bar */
.sidebar .welcome-title {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    color: #333;
    font-weight: 600;
    margin-right: 6px;
}

.sidebar .tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #666;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    flex: 1;
    text-align: center;
}

.sidebar .tab:hover {
    background: rgba(255,255,255,0.1);
    color: #333;
    transform: translateY(-1px);
}

.sidebar .tab.active {
    background: var(--brand-primary, #2ca01c);
    color: white;
    box-shadow: 0 4px 12px rgba(44,160,28,0.3);
    transform: translateY(-1px);
}

.sidebar .action-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    padding: 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}

.sidebar .action-btn {
    padding: 12px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 60px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    border: none;
    position: relative;
    overflow: hidden;
    text-align: center;
}

.sidebar .action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.sidebar .action-btn:hover::before {
    left: 100%;
}

.sidebar .action-btn.primary {
    background: linear-gradient(135deg, var(--accent-color) 0%, #0056b3 100%);
    color: white;
    font-weight: 600;
}

.sidebar .action-btn.primary:hover {
    background: linear-gradient(135deg, #0056b3 0%, var(--accent-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,123,255,0.4);
}

.sidebar .action-btn.secondary {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e5e5e7;
    color: #495057;
}

.sidebar .action-btn.secondary:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: var(--accent-color);
    color: #333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Excel-themed green buttons for Import/Export */
.sidebar .action-btn.excel {
    background: linear-gradient(135deg, #19b24d 0%, #107c41 100%);
    border: 1px solid #0e6b39;
    color: white;
    font-weight: 600;
}
.sidebar .action-btn.excel .icon { color: white; }
.sidebar .action-btn.excel:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 124, 65, 0.35);
}

.sidebar .action-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar .action-btn .icon {
    font-size: 18px;
    line-height: 1;
}

.sidebar .action-btn span {
    font-size: 11px;
    white-space: nowrap;
    font-weight: 600;
}

/* Enhanced button icons */
.action-group button i {
    font-size: 14px;
    opacity: 0.8;
}

/* Responsive tabs */
@media (max-width: 768px) {
    .top-tabs-bar {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
        padding: 16px;
    }
    
    .tabs {
        justify-content: center;
        width: 100%;
    }
    
    .tab {
        flex: 1;
        min-width: 0;
    }
    
    .action-group {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .action-group button {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .action-group button {
        padding: 8px 12px;
        font-size: 12px;
        min-width: 100px;
    }
    
    .tab {
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 560px) {
    .title-center {
        position: static;
        transform: none;
        margin: 0 auto;
        justify-content: center;
        gap: 8px;
    }
}

/* Main Layout */
.app-container {
    /* Mobile-first default: stack vertically */
    flex-direction: column;
}

/* Desktop/tablet layout at 769px+ */
@media (min-width: 769px) {
    .app-container { flex-direction: row; }
    .sidebar { width: 280px; }
}

.sidebar {
    background: #f8f9fa;
    border-right: 1px solid #e5e5e7;
    padding: 16px;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

/* Sidebar Styles */
.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 16px;
}

.overview-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e5e7;
}

.overview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.overview-item:last-child {
    margin-bottom: 0;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.overview-item .label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.overview-item .value {
    font-size: 16px;
    font-weight: 600;
}

.value.income {
    color: #34c759;
}

.value.expense {
    color: #ff3b30;
}

.value.balance {
    color: #007aff;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-separator {
    margin: 16px 0 8px 0;
    padding: 8px 0;
    border-top: 1px solid #e5e5e7;
}

.category-separator h4 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e5e5e7;
}

.category-item:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.category-item.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.category-item.active i,
.category-item.active span {
    color: white;
}

.category-item.income-category {
    border-left: 4px solid #34c759;
}

.category-item.income-category.active {
    border-left: 4px solid #28a745;
}

.category-item.expense-category {
    border-left: 4px solid #ff3b30;
}

.category-item.expense-category.active {
    border-left: 4px solid #dc3545;
}

.category-item i {
    font-size: 16px;
    color: #666;
}

.category-item span {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.category-item img.logo {
    height: 1.2em;
    width: auto;
    object-fit: contain;
    border-radius: 4px;
    background: #fff;
}

/* Spreadsheet Header */
.spreadsheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px;
    border-bottom: 1px solid #e5e5e7;
    background: #fafafa;
}

.add-row-btn {
    display: flex;
    gap: 8px;
    align-items: center;
}

.month-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.month-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
}

.month-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.current-month {
    font-size: 18px;
    font-weight: 600;
    color: #1d1d1f;
    min-width: 140px;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #007aff 0%, #0056cc 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-subscription {
    background: linear-gradient(135deg, #8e44ad 0%, #6f2da8 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-subscription:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(143, 68, 173, 0.3);
}

.subscription-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.subscription-search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e5e7;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}
.subscription-search:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.subscription-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e5e7;
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Column sizing */
    flex: 1 1 auto;
    min-width: 80px;
    max-width: 120px;
}

.subscription-option:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.subscription-option img.logo {
    height: 1.2em;
    width: auto;
    border-radius: 4px;
    object-fit: contain;
    background: #fff;
}

.subscription-option .fallback-icon {
    width: 24px;
    height: 24px;
    font-size: 20px;
    color: #666;
    display: inline-block;
}

.subscription-option .name {
    flex: 1;
    font-weight: 500;
}

.subscription-option .price {
    font-size: 12px;
    color: #555;
    background: #eef2ff;
    border: 1px solid #dbe2ff;
    padding: 2px 6px;
    border-radius: 6px;
}

/* Spreadsheet Styles */
.spreadsheet-container {
    flex: 1;
    overflow: auto;
    padding: 12px;
}

.spreadsheet {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    table-layout: fixed; /* ensure columns consume full width evenly */
}

.spreadsheet th {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 14px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
    vertical-align: middle;
}

.spreadsheet th:first-child {
    border-top-left-radius: 12px;
}

.spreadsheet th:last-child {
    border-top-right-radius: 12px;
}

.spreadsheet td {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #333;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.spreadsheet tr:hover td {
    background: #f8f9fa;
}

.spreadsheet tr:last-child td {
    border-bottom: none;
}

.editable-cell {
    background: none;
    border: none;
    width: 100%;
    padding: 4px;
    font-size: 14px;
    color: #333;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.editable-cell:focus {
    outline: 2px solid #007aff;
    background: #f0f8ff;
}

.date-cell {
    min-width: 120px;
}

.description-cell {
    min-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-cell {
    min-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.amount-cell {
    min-width: 100px;
    text-align: right;
}

.type-cell {
    min-width: 100px;
}

.balance-cell {
    min-width: 120px;
    text-align: right;
    font-weight: 600;
}

.actions-cell {
    min-width: 80px;
    text-align: center;
}

/* Column width map: equal widths for all 7 columns */
.spreadsheet th:nth-child(1), .spreadsheet td:nth-child(1) { width: calc(100% / 7); }
.spreadsheet th:nth-child(2), .spreadsheet td:nth-child(2) { width: calc(100% / 7); }
.spreadsheet th:nth-child(3), .spreadsheet td:nth-child(3) { width: calc(100% / 7); }
.spreadsheet th:nth-child(4), .spreadsheet td:nth-child(4) { width: calc(100% / 7); }
.spreadsheet th:nth-child(5), .spreadsheet td:nth-child(5) { width: calc(100% / 7); }
.spreadsheet th:nth-child(6), .spreadsheet td:nth-child(6) { width: calc(100% / 7); }
.spreadsheet th:nth-child(7), .spreadsheet td:nth-child(7) { width: calc(100% / 7); }

/* Align Balance column header to the right to match cells */
.spreadsheet th:nth-child(6) { text-align: right; }

/* Center align Actions column header and cells */
.spreadsheet th:nth-child(7), .spreadsheet td:nth-child(7) { text-align: center; }

.delete-btn {
    background: #ff3b30;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    background: #d70015;
    transform: scale(1.05);
}

.income-row {
    border-left: 4px solid #34c759;
}

.expense-row {
    border-left: 4px solid #ff3b30;
}

.positive-balance {
    color: #34c759;
}

.negative-balance {
    color: #ff3b30;
}

/* Dragging visual cue */
tr.dragging {
    opacity: 0.7;
}

/* Frequency selector alignment next to Add Income */
.income-add-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.frequency-select {
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* Ensure balance cell color overrides generic td color specificity */
.spreadsheet td.positive-balance { color: #34c759; }
.spreadsheet td.negative-balance { color: #ff3b30; }

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    /* Use stable viewport height to avoid mobile address bar shifts */
    height: 100vh;
    height: 100svh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    width: 80%;
    max-width: 800px;
    /* Cap modal height to stable viewport to prevent jump */
    max-height: 85vh;
    max-height: 85svh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e7;
    background: #fafafa;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1d1d1f;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    font-size: 16px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.modal-body {
    padding: 24px;
    /* Allow inner scrolling for tall content to prevent layout shift */
    overflow: auto;
    max-height: calc(85vh - 84px);
    max-height: calc(85svh - 84px);
}

/* Ensure chart canvas has a visible height */
#budgetChart {
    width: 100%;
    height: 380px;
}

/* Crazy gradient background for chart modal */
#chartModal .modal-body {
    background: radial-gradient(1200px 400px at 10% 10%, rgba(44,160,28,0.08), transparent 40%),
                radial-gradient(800px 300px at 90% 20%, rgba(0,122,255,0.08), transparent 50%),
                radial-gradient(900px 500px at 50% 100%, rgba(255,159,64,0.08), transparent 55%);
    animation: chartGlowShift 20s linear infinite;
}

@keyframes chartGlowShift {
    0%   { filter: hue-rotate(0deg) saturate(1); }
    50%  { filter: hue-rotate(20deg) saturate(1.1); }
    100% { filter: hue-rotate(0deg) saturate(1); }
}

/* Receipt Modal Emphasis */
#receiptModal .modal-content {
    max-width: 520px;
}

.receipt-preview {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.receipt-preview .overview-item .label {
    font-size: 13px;
    color: #666;
}

#receiptMerchant {
    font-size: 18px;
    font-weight: 600;
    color: #1d1d1f;
}

#receiptTotal {
    font-size: 22px;
    font-weight: 700;
    color: #ff3b30;
}

.report-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.report-tab {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #e5e5e7;
    border-radius: 6px;
    background: #f7f7f8;
    cursor: pointer;
    transition: all 0.2s ease;
}

.report-tab:hover { background: #fff; }
.report-tab.active {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        margin: 0;
        border-radius: 0;
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e5e7;
        padding: 12px;
    }
    
    .spreadsheet-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .month-selector {
        justify-content: center;
    }
    
    .title-bar {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .title-bar .toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }
    .main-content {
        overflow: visible;
    }
    
    .spreadsheet {
        font-size: 13px;
    }
    .spreadsheet td {
        padding: 10px;
    }
    .modal-content {
        width: 95%;
        max-width: none;
        max-height: 90%;
    }
    .add-row-btn {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .current-month {
        font-size: 16px;
        min-width: auto;
    }
    .btn-primary, .btn-success, .btn-subscription {
        padding: 10px 14px;
        font-size: 13px;
    }
    .month-selector { gap: 8px; }
    .category-item { padding: 10px 12px; }
}

/* Mobile-first responsive utilities */
img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

.toolbar, .action-group, .report-tabs {
    display: flex;
    flex-wrap: wrap;
}

/* Ultra nav wrapping for mobile */
.ultra-nav .nav-shell { flex-wrap: wrap; }

/* Mobile-specific: enlarge Import Receipt icon for iOS/Android */
body.mobile #importReceiptBtn {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.mobile #importReceiptBtn i {
    font-size: 26px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spreadsheet tr {
    animation: fadeIn 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Enterprise Theme Overrides (QuickBooks-like) */
:root {
    --brand-primary: #2ca01c;
    --brand-primary-dark: #238814;
    --brand-accent: #0069d9;
    --surface: #ffffff;
    --surface-muted: #f7f8fa;
    --border: #e1e4e8;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --danger: #e53935;
}


body {
    background: var(--surface-muted);
    color: var(--text-primary);
}

.title-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.title {
    font-size: 15px;
    color: var(--text-primary);
}

.toolbar-btn { color: var(--text-secondary); }
.toolbar-btn:hover { color: var(--text-primary); }

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.sidebar-section h3 { color: var(--text-primary); }

.overview-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: none;
}
.overview-item .label { color: var(--text-secondary); }

.category-item {
    background: var(--surface);
    border: 1px solid var(--border);
}
.category-item:hover { background: var(--surface-muted); }
.category-item.active {
    background: #e8f5e9;
    border-color: #cdeccd;
}
.category-item.income-category { border-left: 4px solid var(--brand-primary); }
.category-item.expense-category { border-left: 4px solid #ff3b30; }

.btn-primary {
    background: var(--brand-primary);
    box-shadow: none;
}
.btn-primary:hover { background: var(--brand-primary-dark); box-shadow: none; }

.btn-success {
    background: var(--brand-primary-dark);
    box-shadow: none;
}
.btn-success:hover { background: #1e6f10; box-shadow: none; }

.btn-subscription {
    background: var(--brand-accent);
    box-shadow: none;
}
.btn-subscription:hover { background: #0054ad; box-shadow: none; }

.spreadsheet { background: var(--surface); }
.spreadsheet th {
    background: #f3f4f6;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.spreadsheet td { border-bottom: 1px solid var(--border); }
.spreadsheet tr:hover td { background: #f9fafb; }
.spreadsheet tbody tr:nth-child(odd) td { background: #fcfcfd; }

.delete-btn { background: var(--danger); }
.delete-btn:hover { background: #c62828; }

.modal-content { background: var(--surface); }
.modal-header { background: #f8fafc; border-bottom: 1px solid var(--border); }
.modal-body { color: var(--text-primary); }

/* Due Items modal aesthetics */
#dueItemsModal .modal-content {
  max-width: 740px;
  border-radius: 16px;
  overflow: hidden;
}

#dueItemsModal .methods-group { margin-top: 16px; }
#dueItemsModal .methods-group:first-child { margin-top: 0; }
#dueItemsModal .methods-group h3 {
  margin: 8px 0 6px;
  font-weight: 600;
  color: var(--text-primary);
}

#dueItemsModal .methods-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

#dueItemsModal .method-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  transition: transform 0.08s ease, box-shadow 0.2s ease;
  position: relative;
  animation: cardIn 0.2s ease;
}

#dueItemsModal .method-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.07);
}

/* Accent bar per type */
#dueItemsModal .method-item::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
  background: #e5e7eb;
}
#dueItemsModal .method-item.bill::before { background: #10b981; }
#dueItemsModal .method-item.subscription::before { background: #2563eb; }
#dueItemsModal .method-item.overdue::before { background: #ef4444; }

#dueItemsModal .method-brand {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  color: #111827;
  font-weight: 700;
}

#dueItemsModal .method-meta { flex: 1; }

#dueItemsModal .method-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Overdue visual emphasis */
#dueItemsModal .method-item.overdue {
  border-color: #fecaca;
  background: #fff5f5;
}

.status-pill.status-overdue {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-pill.status-soon {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.status-pill.status-scheduled {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

/* Summary bar */
#dueItemsModal .due-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
#dueItemsModal .due-summary .summary-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
#dueItemsModal .due-summary .summary-item i { color: var(--brand-primary); }
#dueItemsModal .due-summary .section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e5f5e3;
  color: #0b5e18;
  border: 1px solid #cbe8c6;
  font-size: 12px;
}
#dueItemsModal .due-summary .section-total {
  font-weight: 600;
  color: var(--text-primary);
}
#dueItemsModal .due-summary .dot { color: var(--text-secondary); }

/* Empty state card */
#dueItemsModal .empty-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: #fafafa;
  color: var(--text-secondary);
}
#dueItemsModal .empty-state i { color: #10b981; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Title bar traffic lights subtle tweak for enterprise */
.traffic-light { border: none; }

/* Bank logo preview next to Import Bank button */
.bank-logo-preview {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    margin-left: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
    object-fit: contain;
}
/* Admin Panel styles */
.admin-key-input {
    padding: 8px 10px;
    border: 1px solid #d1d1d1;
    border-radius: 8px;
    font-size: 12px;
    margin-right: 8px;
}

.admin-users-form {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.admin-users-form input, .admin-users-form select {
    padding: 8px 10px;
    border: 1px solid #d1d1d1;
    border-radius: 8px;
    font-size: 12px;
}

.admin-users-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-users-table th, .admin-users-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
    font-size: 13px;
}
.admin-users-table tbody tr:hover {
    background: rgba(0,0,0,0.03);
}

/* Admin secure gate: blur protected sections until login */
.secure-blur {
    filter: blur(5px);
    pointer-events: none;
}

/* Global gate blur for entire main content until login */
#adminContent.gate-blur {
    filter: blur(6px);
    pointer-events: none;
}
/* Toggle Switch (QuickBooks-style) */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input { display: none; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #e5e7eb;
  transition: .2s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

input:checked + .slider {
  background-color: #2563eb;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }
/* QuickBooks-style green icon helpers */
.qb-green { color: var(--brand-primary); }

/* Global icon colors: use per-component styles (no forced color) */

/* Icon pill style: outline with green and green glyph */
.icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(44, 160, 28, 0.3);
}
.icon-circle i { font-size: 14px; line-height: 1; }

.toolbar-btn .icon-circle { margin-right: 6px; }
.action-btn .icon-circle { margin-right: 6px; }

/* Smaller toolbar buttons: compact icon and label */
.toolbar-btn.toolbar-small {
  font-size: 12px;
  padding: 6px 10px;
}
.toolbar-btn.toolbar-small .icon-circle {
  width: 22px;
  height: 22px;
}
.toolbar-btn.toolbar-small .icon-circle i {
  font-size: 12px;
}

/* Billing toolbar icon: white circle with green glyph */
.title-bar .toolbar a[href="/billing.html"] .icon-circle {
  background: #fff;
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary);
  box-shadow: 0 2px 8px rgba(44, 160, 28, 0.15);
}

/* Billing Page enhancements (QuickBooks-like) */
.billing-content {
  padding: 24px;
  max-width: 1000px;
  margin: 0 auto;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.section-header .icon-circle { width: 24px; height: 24px; }

.muted { color: var(--text-secondary); }
.status { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }

.stack { display: flex; flex-direction: column; gap: 12px; }

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-danger:hover { background: #c62828; }

/* New income row animation */
@keyframes incomeRowPop {
  0% { background-color: #e6fffa; transform: translateY(-2px); }
  50% { background-color: #ccfbf1; transform: translateY(0); }
  100% { background-color: transparent; transform: none; }
}

tr.income-added-animate {
  animation: incomeRowPop 900ms ease-out;
  will-change: background-color, transform;
}

@media (prefers-reduced-motion: reduce) {
  tr.income-added-animate { animation: none; }
}
/* Income Due Modal — colorful, modern cards */
#incomeDueModal .modal-content { max-width: 820px; }
#incomeDueModal .methods-list { display: grid; grid-template-columns: 1fr; gap: 12px; }
#incomeDueModal .method-item.income-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px 12px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
#incomeDueModal .method-item.income-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.12); border-color: var(--brand-primary); }
#incomeDueModal .method-item.income-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  background: #10b981; /* default income green */
}
#incomeDueModal .method-item.income-card.is-overdue::before { background: #ef4444; }
#incomeDueModal .method-item.income-card.is-due-soon::before { background: #f59e0b; }
#incomeDueModal .method-item.income-card.is-scheduled::before { background: #0ea5e9; }
#incomeDueModal .method-item.income-card.is-received::before { background: #16a34a; }

#incomeDueModal .method-brand {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: linear-gradient(135deg,#ecfccb,#d9f99d);
  color: #14532d;
  border-radius: 10px;
  font-weight: 700; font-size: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
#incomeDueModal .method-meta { flex: 1; }
#incomeDueModal .method-actions { display: flex; align-items: center; gap: 8px; }

/* Mark as Received button */
#incomeDueModal .mark-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
  color: var(--text-primary);
  cursor: pointer; transition: all 140ms ease;
}
#incomeDueModal .mark-btn:hover { border-color: #16a34a; color: #14532d; background: #ecfccb; }

/* Status pills for income (reuses global .status-pill base) */
#incomeDueModal .status-pill.status-soon { background: #fff7ed; color: #9a3412; border-color: #fdba74; }
#incomeDueModal .status-pill.status-scheduled { background: #eff6ff; color: #1e40af; border-color: #93c5fd; }

/* Income summary (mirrors due-summary styling) */
#incomeDueModal .due-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px; margin-bottom: 12px;
}
#incomeDueModal .due-summary .summary-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
}
#incomeDueModal .due-summary .summary-label { color: var(--text-secondary); font-weight: 600; }
#incomeDueModal .due-summary .summary-value { color: var(--text-primary); }

/* Empty state card */
#incomeDueModal .empty-state-card {
  display: grid; place-items: center; text-align: center;
  padding: 20px; border-radius: 12px;
  background: var(--panel-bg);
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
}
#incomeDueModal .empty-state-card i { font-size: 24px; color: #16a34a; margin-bottom: 6px; }
/* Subscription Gate polish */
.subscription-gated #subscriptionGateOverlay .sg-card a:hover,
.subscription-gated #subscriptionGateOverlay .sg-card button:hover {
    opacity: 0.92;
}
.subscription-gated #subscriptionGateOverlay .sg-card a:active,
.subscription-gated #subscriptionGateOverlay .sg-card button:active {
    transform: translateY(1px);
}
/* Admin: make logout button visually striking */
#adminLogoutBtn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  color: #fff;
  box-shadow: 0 6px 14px rgba(220, 38, 38, 0.25);
}
#adminLogoutBtn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}