/* ============================================================
   CSS Variables & Reset
   ============================================================ */
:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --success: #10B981;
    --success-light: #D1FAE5;
    --success-dark: #065F46;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --info: #3B82F6;
    --info-light: #DBEAFE;

    --bg-primary: #F8FAFC;
    --bg-secondary: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-hover: #F8FAFC;

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;

    --border-color: #E2E8F0;
    --border-focus: #4F46E5;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

    --navbar-height: 60px;
    --sidebar-width: 260px;
    --radius: 8px;
    --radius-lg: 12px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.5;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--navbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    gap: 12px;
}

/* ── Tab navigation in navbar ─────────────────────────────── */
.navbar-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
}
.nav-tab {
    padding: 6px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.nav-tab:hover { background: var(--bg-secondary); color: var(--text-primary); }
.nav-tab.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

/* ── Navbar quick-add invoice icon button ─────────────────── */
.nav-tab-add-invoice {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    margin-left: 2px;
    flex-shrink: 0;
}
.nav-tab-add-invoice:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* ── Upload Invoices disabled wrapper tooltip ─────────────── */
.inv-upload-wrap {
    position: relative;
    display: inline-block;
}
.inv-upload-wrap[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: var(--text-primary);
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 200;
}

/* ── Invoices tab: hide sidebar, full-width content ──────── */
.app-layout.invoices-active > .sidebar { display: none; }
.app-layout.invoices-active > .main-content { margin-left: 0; }

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-add-file {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    margin-left: 6px;
    white-space: nowrap;
}
.btn-add-file:hover { background: var(--primary-dark, #4f46e5); }

.navbar-user {
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius);
    transition: background 0.15s;
}
.user-info:hover { background: var(--bg-secondary); }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.chevron-icon {
    color: var(--text-muted);
    transition: transform 0.2s;
}
.user-info.open .chevron-icon { transform: rotate(180deg); }

.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 200;
    display: none;
    overflow: hidden;
}
.user-dropdown.open { display: block; }

.dropdown-header {
    padding: 12px 16px;
    background: var(--bg-secondary);
}
.dropdown-email {
    font-size: 12px;
    color: var(--text-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    font-size: 14px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.dropdown-item:hover { background: var(--bg-secondary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-light); }

/* ============================================================
   App Layout
   ============================================================ */
.app-layout {
    display: flex;
    margin-top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 8px;
    margin-bottom: 6px;
}

.sidebar-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 4px;
}
.sidebar-label-row .sidebar-label {
    margin-bottom: 0;
}

.export-zip-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* ── Period arrow navigation ─────────────────────────────── */
.period-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.period-nav-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
.period-nav-btn:hover:not(:disabled) { background: var(--bg-secondary); color: var(--text-primary); }
.period-nav-btn:disabled { opacity: 0.35; cursor: default; }
.period-nav-label {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.period-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-primary);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9L12 15L18 9' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}
.period-select:focus { border-color: var(--border-focus); }

.channel-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: var(--text-primary);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.channel-item:hover { background: var(--bg-secondary); }
.channel-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.channel-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.channel-item.active .channel-icon { background: var(--primary); color: white; }

.channel-info {
    flex: 1;
    min-width: 0;
}
.channel-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.channel-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}
.channel-item.active .channel-meta { color: var(--primary); opacity: 0.75; }

.channel-badge {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.channel-badge.done {
    background: var(--success);
    color: white;
}
.channel-badge.pending {
    background: var(--warning);
    color: white;
}

.loading-placeholder {
    padding: 12px 10px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Welcome state */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
    gap: 12px;
}
.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.welcome-state h2 { color: var(--text-secondary); font-size: 18px; }
.welcome-state p { font-size: 14px; max-width: 320px; }

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #DC2626; }

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-outline:hover:not(:disabled) { background: var(--bg-secondary); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-secondary); color: var(--text-primary); }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-icon {
    padding: 6px;
    border-radius: var(--radius);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.card-body { padding: 20px; }

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}
.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================================
   Table
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 11px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

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

tbody tr {
    transition: background 0.1s;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr.excluded { opacity: 0.5; }
tbody tr.completed { background: #F0FDF4; }

.amount-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.amount-nis { color: var(--text-primary); }
.amount-usd { color: var(--info); }

.expense-desc-cell {
    max-width: 260px;
}
.expense-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: var(--text-primary);
}
.expense-note {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
}
.expense-note-muted { color: #6b7280; }
.note-btn.has-note { color: var(--primary); }
.exp-select-cell { width: 34px; text-align: center; }
.exp-select-cell input[type="checkbox"] { cursor: pointer; }

/* ============================================================
   Status badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-pending { background: var(--warning-light); color: #92400E; }
.badge-completed { background: var(--success-light); color: #065F46; }
.badge-excluded { background: var(--bg-secondary); color: var(--text-muted); }

/* ============================================================
   File thumbnails
   ============================================================ */
.file-thumb-list {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.file-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.15s;
    flex-shrink: 0;
    position: relative;
}
.file-thumb:hover { transform: scale(1.1); z-index: 1; }
.file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.file-thumb-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.15s;
}
.file-thumb-placeholder:hover { transform: scale(1.1); }

/* ============================================================
   Actions column
   ============================================================ */
.row-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 4px;
    border-radius: 4px;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-secondary); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Analysis result inside modal */
.analysis-section {
    margin-bottom: 16px;
}
.analysis-section h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.analysis-field {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 8px 12px;
}
.analysis-field-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.analysis-field-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.match-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 14px;
}
.match-banner.match { background: var(--success-light); color: #065F46; }
.match-banner.mismatch { background: var(--danger-light); color: #991B1B; }

/* Items table inside modal */
.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.items-table th {
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}
.items-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-color);
}

/* ============================================================
   Bulk confirm modal  (extra-wide)
   ============================================================ */
.modal-xl { max-width: 980px; width: 96vw; }

.bulk-confirm-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.bulk-confirm-preview {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.bulk-confirm-preview-caption {
    width: 100%;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-align: left;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.bulk-confirm-img {
    max-width: 100%;
    max-height: 480px;
    object-fit: contain;
    border-radius: var(--radius);
    display: block;
}

.bulk-confirm-iframe {
    width: 100%;
    height: 480px;
    border: none;
    border-radius: var(--radius);
}

@media (max-width: 700px) {
    .bulk-confirm-img    { max-height: 260px; }
    .bulk-confirm-iframe { height: 260px; }
}

.bulk-confirm-details {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Two-column Invoice ↔ Matched Expense comparison grid */
.bcc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.bcc-col-head {
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.bcc-cell {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

/* Vertical divider: odd-positioned children are left column (skip .bcc-more span) */
.bcc-grid > :nth-child(odd):not(.bcc-more) {
    border-right: 1px solid var(--border);
}

/* Right column cells get secondary background */
.bcc-grid > .bcc-cell:nth-child(even) {
    background: var(--bg-secondary);
}

.bcc-cell-empty {
    min-height: 38px;
}

/* "More fields" collapsible — spans both columns */
.bcc-more {
    grid-column: 1 / -1;
}

.bcc-more > summary {
    list-style: none;
    padding: 5px 12px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.bcc-more > summary::-webkit-details-marker { display: none; }
.bcc-more > summary::marker { display: none; }

.bcc-more-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border);
}

/* Vertical divider inside expanded rows */
.bcc-more-inner > :nth-child(odd) {
    border-right: 1px solid var(--border);
}

/* Right column secondary background inside expanded rows */
.bcc-more-inner > .bcc-cell:nth-child(even) {
    background: var(--bg-secondary);
}

/* Remove bottom border from last row of expanded section */
.bcc-more-inner > .bcc-cell:nth-last-child(-n+2) {
    border-bottom: none;
}

.bulk-confirm-actions {
    display: flex;
    gap: 10px;
}

.bulk-confirm-actions .btn { flex: 1; justify-content: center; }

/* ============================================================
   File Preview modal  (split: file left, analysis right)
   ============================================================ */
.fp-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    min-height: 460px;
}
@media (max-width: 720px) { .fp-layout { grid-template-columns: 1fr; } }

.fp-status-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
}
.fp-status-assigned {
    background: rgba(34,197,94,0.15);
    color: #16a34a;
}
.fp-status-unassigned {
    background: rgba(239,68,68,0.12);
    color: #dc2626;
}

/* Three-dots context menu */
.dots-menu-wrap {
    position: relative;
    display: inline-block;
}
.dots-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}
.dots-menu-wrap.open .dots-menu-dropdown {
    display: block;
}
.dots-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
    transition: background 0.12s;
}
.dots-menu-item:hover { background: var(--bg-hover); }
.dots-menu-item.danger { color: var(--danger); }
.dots-menu-item.danger:hover { background: rgba(239,68,68,0.08); }

.fp-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}
.fp-delete-btn {
    color: var(--danger);
    gap: 5px;
    display: flex;
    align-items: center;
}
.fp-delete-btn:hover {
    background: rgba(239,68,68,0.08);
}

/* left panel */
.fp-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.fp-rotation-bar {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 5px 8px;
    min-height: 36px;
}

/* zoom control group inside the rotation bar */
.fp-zoom-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1px 2px;
}
.fp-zoom-label {
    min-width: 40px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    border: none;
    background: transparent;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}
.fp-zoom-label:hover { background: var(--bg-secondary); }
.fp-zoom-label.fp-zoom-active { color: var(--primary); }
.fp-zoom-group .btn-icon {
    padding: 3px;
    width: 26px;
    height: 26px;
}

.fp-img-wrap {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    min-height: 320px;
}

.fp-img {
    max-width: 100%;
    max-height: 58vh;
    object-fit: contain;
    transition: transform 0.22s ease;
    display: block;
}
.fp-img.fp-img-sideways {
    max-width: 58vh;
    max-height: 100%;
}

.fp-iframe {
    width: 100%;
    height: 60vh;
    border: none;
    border-radius: var(--radius);
    display: block;
}

/* right panel */
.fp-right {
    border-left: 1px solid var(--border-color);
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
@media (max-width: 720px) { .fp-right { border-left: none; padding-left: 0; border-top: 1px solid var(--border-color); padding-top: 14px; } }

/* tabs */
.fp-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}
.fp-tab {
    background: none;
    border: none;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.fp-tab:hover { color: var(--primary); }
.fp-tab.fp-tab-active { color: var(--primary); border-bottom-color: var(--primary); }

.fp-tab-pane {
    overflow-y: auto;
    flex: 1;
    max-height: 64vh;
}

/* analysis panel */
.fp-analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.fp-analysis-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px 0;
}
.fp-no-analysis {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* assign panel — channel picker */
.fp-channel-picker {
    margin-bottom: 10px;
}
.fp-channel-picker select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}
.fp-channel-picker select:focus { outline: none; border-color: var(--border-color); }

/* assign panel */
.fp-assign-sort {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.fp-sort-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.fp-sort-btn:hover, .fp-sort-btn.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.fp-expense-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.fp-expense-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: border-color 0.15s;
}
.fp-expense-row:hover { border-color: var(--primary); }
.fp-expense-info { flex: 1; min-width: 0; }
.fp-expense-row.fp-expense-match {
    border-color: var(--success);
    background: var(--success-light);
}
.fp-expense-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fp-expense-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.fp-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.fp-date-edit {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}
.fp-date-edit:hover { color: var(--primary); border-color: var(--primary); }
.fp-manual-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: rgba(37, 99, 235, 0.12);
    color: #2563eb;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.fp-ai-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
.fp-date-dialog {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fp-date-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
}
.fp-date-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 18px;
    width: 340px;
    max-width: calc(100% - 32px);
    z-index: 1;
    border: 1px solid var(--border-color);
}
.fp-date-title {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 10px;
}
.fp-date-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}
.fp-date-card input[type=date] {
    width: 100%;
}
.fp-date-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}
.fp-date-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

/* sortable table headers */
.sortable-th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.sortable-th:hover { background: var(--bg-secondary); }
.sortable-th.sort-active { color: var(--primary); }
.sort-indicator { font-size: 11px; margin-left: 3px; color: var(--text-muted); }
.sort-active .sort-indicator { color: var(--primary); }

/* ============================================================
   Expenses filter bar
   ============================================================ */
.expenses-filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 6px 10px;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}

.search-box input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-primary);
    width: 100%;
}

.search-box input::placeholder { color: var(--text-muted); }

/* ============================================================
   Segmented control (Apple-style pill selector)
   ============================================================ */
.seg-control {
    display: inline-flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}
.seg-btn {
    padding: 5px 13px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* ============================================================
   Ignore badge with reason tooltip
   ============================================================ */
.ignore-badge-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ignore-edit-btn {
    opacity: 0;
    pointer-events: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    transition: opacity 0.15s, color 0.15s;
    border-radius: 3px;
}
.ignore-edit-btn:hover { color: var(--primary); }
.ignore-badge-wrap:hover .ignore-edit-btn {
    opacity: 1;
    pointer-events: auto;
}
.ignore-reason-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 260px;
    white-space: normal;
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    line-height: 1.4;
}
.ignore-reason-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
}
.ignore-badge-wrap:hover .ignore-reason-tooltip {
    display: block;
}

/* ============================================================
   File viewer modal (large)
   ============================================================ */
.modal-lg { max-width: 800px; }
.file-preview-img {
    max-width: 100%;
    border-radius: var(--radius);
    display: block;
    margin: 0 auto;
}

/* ============================================================
   Files grid
   ============================================================ */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.file-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow 0.15s, transform 0.15s;
    cursor: pointer;
}
.file-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.file-card-thumb {
    width: 100%;
    height: 120px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.file-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.file-card-thumb .file-icon {
    font-size: 36px;
    color: var(--text-muted);
}
.file-card-info {
    padding: 10px 12px;
}
.file-card-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}
.file-card-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}
.file-card-note {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}
.file-card {
    position: relative;
}
.file-card-checkbox {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.15s;
    cursor: pointer;
    background: rgba(255,255,255,0.85);
    border-radius: 4px;
    padding: 2px;
    line-height: 0;
}
.file-card:hover .file-card-checkbox,
.file-card-selected .file-card-checkbox {
    opacity: 1;
}
.file-card-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.25);
}
.files-select-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
}
.file-card-ai {
    padding: 5px 10px 4px;
    background: var(--primary-light);
    border-top: 1px solid rgba(99,102,241,0.15);
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.fc-ai-vendor {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fc-ai-meta {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.fc-ai-amount {
    font-weight: 600;
    color: var(--text-primary);
}
.fc-ai-date {
    color: var(--text-muted);
}
.fc-manual-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    background: rgba(37, 99, 235, 0.12);
    color: #2563eb;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.inv-no-period-msg {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.file-card-actions {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* ============================================================
   Filter tabs
   ============================================================ */
.filter-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 3px;
    width: fit-content;
}
.filter-tab {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.filter-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}
.filter-tab:hover:not(.active) { color: var(--text-primary); }

/* ============================================================
   Invoice sort & search
   ============================================================ */
.files-sort-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.files-sort-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.files-sort-btn.active {
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.files-search {
    min-width: 220px;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    font-size: 13px;
}

/* ============================================================
   Invoice grouping
   ============================================================ */
.files-group-header {
    font-weight: 700;
    color: var(--text-secondary);
    margin: 6px 0 2px;
    letter-spacing: 0.2px;
}

/* ============================================================
   Progress bar
   ============================================================ */
.progress-bar-wrap {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* ============================================================
   Upload drop zone
   ============================================================ */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.drop-zone-icon { font-size: 36px; margin-bottom: 10px; }
.drop-zone-text { font-size: 14px; font-weight: 500; }
.drop-zone-sub { font-size: 12px; margin-top: 4px; }

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
}
.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.empty-state p { font-size: 13px; }

/* ============================================================
   Toast notifications
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    min-width: 260px;
    max-width: 380px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    pointer-events: all;
    animation: toastIn 0.25s ease;
    font-size: 13px;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-info { border-left: 3px solid var(--info); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-message { flex: 1; color: var(--text-primary); line-height: 1.4; }
.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

/* ============================================================
   Loading spinner
   ============================================================ */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-dark {
    border-color: var(--border-color);
    border-top-color: var(--primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
}

/* ============================================================
   Channel complete banner
   ============================================================ */
.channel-complete-banner {
    background: var(--success-light);
    border: 1px solid #A7F3D0;
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #065F46;
    font-weight: 500;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { width: 220px; }
    .main-content { padding: 16px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 220px;
    }
}

/* ============================================================
   Utility
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary-color { color: var(--primary); }
.fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ============================================================
   New Expense modal form
   ============================================================ */
.ne-ai-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: var(--radius);
    padding: 7px 12px;
    margin-bottom: 16px;
}
.ne-ai-badge-empty {
    color: var(--text-muted);
    background: var(--bg-secondary);
}
.ne-ai-badge-empty .btn-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    text-decoration: underline;
}
.ne-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.ne-span2 { grid-column: span 2; }
.ne-field { display: flex; flex-direction: column; gap: 5px; }
.ne-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ne-input {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.ne-input:focus { outline: none; border-color: var(--border-focus); }

/* ============================================================
   Quick-add modal expense assignment list
   ============================================================ */
.qa-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}
.qa-action-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    justify-content: center;
}

.qa-expense-list-wrap {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 4px;
}
.qa-expense-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    margin-top: 6px;
}
.qa-expense-row {
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.12s;
}
.qa-expense-row:last-child { border-bottom: none; }
.qa-expense-row:hover { background: var(--primary-light); }
.qa-sort-th {
    user-select: none;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-secondary);
}
.qa-sort-th:hover { color: var(--primary); }
.qa-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.qa-divider::before, .qa-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ============================================================
   Category filter select (in the expenses filter bar)
   ============================================================ */
.cat-filter-select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    min-width: 150px;
    transition: border-color 0.15s;
}
.cat-filter-select:focus { outline: none; border-color: var(--border-color); }

/* ============================================================
   Category select (inline in expense rows)
   ============================================================ */
.cat-select {
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 120px;
    max-width: 160px;
    transition: border-color 0.15s;
}
.cat-select:focus { outline: none; border-color: var(--border-focus); }
.cat-select:disabled { opacity: 0.45; cursor: default; }
.cat-select option[value=""] { color: var(--text-muted); }

/* ============================================================
   Categories management modal
   ============================================================ */
.cat-modal-body { display: flex; flex-direction: column; gap: 16px; }

.cat-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.cat-add-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
}
.cat-add-input:focus { outline: none; border-color: var(--border-focus); }

.cat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cat-table th {
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}
.cat-table td { padding: 8px 10px; vertical-align: middle; border-bottom: 1px solid var(--border-color); }
.cat-table tbody tr:last-child td { border-bottom: none; }
.cat-table tbody tr:hover td { background: var(--bg-hover); }
.cat-mappings-row td { border-bottom: 1px solid var(--border-color); }
.cat-mappings-row:hover td { background: transparent !important; }

.cat-name-display { font-weight: 500; }
.cat-name-input {
    padding: 4px 8px;
    border: 1px solid var(--border-focus);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg-primary);
}
.cat-name-input:focus { outline: none; }

.cat-mappings-wrap { display: flex; flex-wrap: wrap; gap: 4px; }
.cat-mapping-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}
.cat-mapping-del {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
    font-size: 13px;
    line-height: 1;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.cat-mapping-del:hover { opacity: 1; }
