﻿/**
 * Expense Tracker - Notion-style Theme
 * Clean, minimal design with Iconify icons
 */

/* Google Fonts - Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

/* CSS Variables */
:root {
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #22c55e;
    --error: #ef4444;
    --danger: #ef4444;
    --warning: #f59e0b;

    --bg: #ffffff;
    --bg-secondary: #f7f7f5;
    --card-bg: #ffffff;
    --text: #37352f;
    --text-secondary: #787774;
    --text-tertiary: #b4b4b4;
    --border: #e9e9e7;
    --border-light: #f1f1ef;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);

    --nav-height: 60px;
    --bottom-nav-height: 64px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg: #191919;
    --bg-secondary: #202020;
    --card-bg: #252525;
    --text: #e6e6e4;
    --text-secondary: #9b9a97;
    --text-tertiary: #5a5a5a;
    --border: #373737;
    --border-light: #2f2f2f;
    --shadow: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.3);
}

/* Base */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

html, body {
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: calc(var(--bottom-nav-height) + 20px);
}

/* Container */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 16px;
}

@media (min-width: 768px) {
    body {
        padding-bottom: 20px;
    }
    .container {
        max-width: 720px;
        padding: 24px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 960px;
        padding: 32px;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

@media (min-width: 1400px) {
    .container {
        max-width: 1280px;
    }
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 8px;
}

header h1 {
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

header h1 .icon {
    font-size: 28px;
}

/* Desktop Navigation */
nav.desktop-nav {
    display: none;
}

@media (min-width: 768px) {
    nav.desktop-nav {
        display: flex;
        gap: 4px;
    }

    nav.desktop-nav a {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 8px 14px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
        border-radius: var(--radius);
        transition: all 0.15s ease;
    }

    nav.desktop-nav a:hover {
        background: var(--bg-secondary);
        color: var(--text);
    }

    nav.desktop-nav a.active {
        background: var(--primary);
        color: white;
    }
}

/* Mobile Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 1000;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 16px;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.bottom-nav a .icon {
    font-size: 22px;
}

.bottom-nav a.active {
    color: var(--primary);
}

.bottom-nav a:active {
    transform: scale(0.95);
}

@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
}

.card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card h2 .icon {
    font-size: 20px;
    color: var(--text-secondary);
}

/* Accordion sections (Settings page) */
.card-accordion-toggle {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.card-accordion-toggle:focus-visible {
    outline: 2px solid var(--primary, #2563eb);
    outline-offset: 2px;
    border-radius: 4px;
}

.card-accordion-toggle .accordion-chevron {
    margin-left: auto;
    font-size: 18px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.card.collapsed .card-accordion-toggle {
    margin-bottom: 0;
}

.card.collapsed .card-accordion-toggle .accordion-chevron {
    transform: rotate(-90deg);
}

.card.collapsed .card-body {
    display: none;
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 20px 0 12px;
    color: var(--text-secondary);
}

.card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.form-group input[readonly] {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.form-group textarea {
    resize: vertical;
    min-height: 72px;
}

.form-group input[type="file"] {
    padding: 8px;
    font-size: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.help-text {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Return/Refund Toggle */
.return-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    cursor: pointer;
}

.return-toggle input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.return-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--error);
    color: white;
    margin-right: 4px;
    vertical-align: middle;
}

/* Combobox */
.combobox {
    position: relative;
}

.combobox input {
    padding-right: 36px;
}

.combobox-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 34px;
    background: transparent;
    border: none;
    border-left: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border-radius: 0 var(--radius) var(--radius) 0;
    transition: all 0.15s ease;
}

.combobox-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.combobox-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    display: none;
}

.combobox-dropdown.open {
    display: block;
}

.combobox-option {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s ease;
}

.combobox-option:last-child {
    border-bottom: none;
}

.combobox-option:hover,
.combobox-option.highlighted {
    background: var(--bg-secondary);
}

.combobox-option.selected {
    background: var(--primary);
    color: white;
}

.combobox-option .match {
    font-weight: 600;
    color: var(--primary);
}

.combobox-option.selected .match {
    color: white;
}

.combobox-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
}

.combobox-new {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--primary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.combobox-new:hover {
    background: var(--bg-secondary);
}

/* Section header in combobox dropdown */
.combobox-section-header {
    padding: 4px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 2px;
}

/* Inline editable cells */
.inline-editable {
    cursor: text;
    position: relative;
}

.inline-editable:hover::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px dashed var(--border);
    border-radius: 3px;
    pointer-events: none;
}

/* Inline edit input inside cell */
.cell-input {
    width: 100%;
    padding: 2px 4px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid var(--primary);
    border-radius: 3px;
    background: var(--card-bg);
    color: var(--text);
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.cell-input:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn .icon {
    font-size: 18px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border-light);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.btn-large {
    padding: 14px 24px;
    font-size: 15px;
}

.btn-small {
    padding: 6px 10px;
    font-size: 13px;
}

.btn-icon-only {
    padding: 8px;
    min-width: 36px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.form-actions .btn {
    flex: 1;
}

/* Messages */
.message {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message .icon {
    font-size: 18px;
    flex-shrink: 0;
}

.message.success {
    background: #dcfce7;
    color: #166534;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

.message.info {
    background: #dbeafe;
    color: #1e40af;
}

[data-theme="dark"] .message.success {
    background: #14532d;
    color: #86efac;
}

[data-theme="dark"] .message.error {
    background: #450a0a;
    color: #fca5a5;
}

[data-theme="dark"] .message.info {
    background: #1e3a5f;
    color: #93c5fd;
}

/* Summary Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--bg-secondary);
    padding: 14px;
    border-radius: var(--radius);
    text-align: center;
}

.summary-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.summary-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.summary-value.highlight {
    color: var(--success);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    margin: 0 -20px;
    padding: 0 20px;
}

.expenses-table {
    width: 100%;
    /* border-collapse: collapse breaks position:sticky on th in most
       browsers - separate + zero spacing renders identically here since
       the table only uses border-bottom (no vertical borders to double up). */
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.expenses-table th {
    background: var(--card-bg);
    padding: 8px 8px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.expenses-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.expenses-table tbody tr {
    transition: background 0.1s ease;
}

.expenses-table tbody tr:hover {
    background: var(--bg-secondary);
}

.expenses-table .highlight {
    color: var(--success);
    font-weight: 600;
}

.expenses-table .error-row {
    background: #fef2f2;
}

[data-theme="dark"] .expenses-table .error-row {
    background: #450a0a;
}

/* JS-driven sticky header clone (see report.js) — shown/positioned via
   JS only while the table is scrolled past the viewport top. */
.sticky-header-clone {
    display: none;
    position: fixed;
    top: 0;
    z-index: 50;
    overflow: hidden;
    background: var(--card-bg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.sticky-header-clone-inner table {
    border-collapse: separate;
    border-spacing: 0;
}

.receipt-link {
    color: var(--primary);
    text-decoration: none;
}

.receipt-link:hover {
    text-decoration: underline;
}

.no-receipt {
    color: var(--text-tertiary);
    font-size: 13px;
}

.comment-cell {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Truncate long text columns in the table */
.expenses-table .truncate-cell {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: default;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.04);
}

[data-theme="dark"] .drop-zone.drag-over {
    background: rgba(37, 99, 235, 0.1);
}

.drop-zone-icon {
    font-size: 36px;
    color: var(--text-tertiary);
    display: block;
    margin-bottom: 8px;
}

.drop-zone-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.drop-zone-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}

.drop-zone .help-text {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* File Preview (non-image attachments) */
.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-top: 8px;
}

.file-preview-icon {
    font-size: 24px;
    color: var(--primary);
    flex-shrink: 0;
}

#file-preview-name {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

#file-preview-size {
    font-size: 12px;
    flex-shrink: 0;
}

/* Hide drop zone text on mobile (camera is primary) */
@media (max-width: 767px) {
    .drop-zone-text {
        display: none;
    }

    .drop-zone-icon {
        display: none;
    }

    .drop-zone {
        padding: 16px;
        border-style: solid;
    }
}

/* Scanner */
.scanner-preview {
    text-align: center;
    margin: 16px 0;
}

.scanner-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.scanner-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.scanner-actions .btn {
    flex: 1;
    min-width: 70px;
    max-width: 110px;
    font-size: 12px;
    padding: 8px 10px;
}

.scanner-status {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    text-align: center;
    margin-bottom: 16px;
}

.scanner-status.info {
    background: #dbeafe;
    color: #1e40af;
}

.scanner-status.success {
    background: #dcfce7;
    color: #166534;
}

.scanner-status.error {
    background: #fee2e2;
    color: #991b1b;
}

[data-theme="dark"] .scanner-status.info {
    background: #1e3a5f;
    color: #93c5fd;
}

[data-theme="dark"] .scanner-status.success {
    background: #14532d;
    color: #86efac;
}

[data-theme="dark"] .scanner-status.error {
    background: #450a0a;
    color: #fca5a5;
}

/* Camera Viewfinder */
.viewfinder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
    background: #000;
    display: flex;
    flex-direction: column;
}

.viewfinder-overlay video {
    flex: 1;
    width: 100%;
    object-fit: cover;
}

.viewfinder-guide {
    position: absolute;
    top: 15%;
    left: 8%;
    right: 8%;
    bottom: 25%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.25);
}

.viewfinder-message {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    max-width: 80%;
    z-index: 10;
}

.viewfinder-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
    z-index: 5;
}

.viewfinder-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 20px 24px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 100%);
    z-index: 5;
}

.viewfinder-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.viewfinder-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.viewfinder-btn.active {
    background: var(--warning);
    color: #000;
}

.viewfinder-shutter {
    width: 72px;
    height: 72px;
    border: 4px solid #fff;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.viewfinder-shutter:active {
    transform: scale(0.9);
}

.viewfinder-shutter-inner {
    display: block;
    width: 56px;
    height: 56px;
    background: #fff;
    border-radius: 50%;
    transition: background 0.1s ease;
}

.viewfinder-shutter:active .viewfinder-shutter-inner {
    background: #ccc;
}

/* OCR Confidence Indicators */
.ocr-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.ocr-indicator.high {
    background: var(--success);
    color: white;
}

.ocr-indicator.medium {
    background: var(--warning);
    color: white;
}

.ocr-indicator.low {
    background: var(--error);
    color: white;
}

.form-group input.ocr-high { border-left: 3px solid var(--success); }
.form-group input.ocr-medium { border-left: 3px solid var(--warning); }
.form-group input.ocr-low { border-left: 3px solid var(--error); }

/* Admin List */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.admin-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
}

.admin-input:focus {
    outline: none;
    border-color: var(--primary);
}

.admin-actions {
    display: flex;
    gap: 4px;
}

.expense-count {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: auto;
    padding: 0 8px;
}

.gl-code-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

[data-theme="dark"] .gl-code-badge {
    background: rgba(37, 99, 235, 0.2);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.modal-close .icon {
    font-size: 20px;
}

.modal-body {
    padding: 20px;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.theme-toggle .icon {
    font-size: 20px;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* Card Breakdown */
.card-breakdown {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-item small {
    color: var(--text-tertiary);
    margin-left: 8px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state .icon {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: var(--text-secondary);
}

/* Receipt processing indicator — shown during processReceiptOCR() (fast
   path attempt + AI extraction fallback). Indeterminate, since neither
   stage reports real progress percentages. */
.receipt-processing {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    margin-top: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md, 8px);
}

.receipt-processing-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: var(--primary);
    border-radius: 2px;
    animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
    0%   { left: -40%; }
    100% { left: 100%; }
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

/* Pre/Code */
pre {
    background: var(--bg-secondary);
    padding: 14px;
    border-radius: var(--radius);
    font-size: 13px;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* Utility */
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-secondary); }

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    padding: 4px;
}

.lightbox-close:hover {
    color: var(--error);
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 3001;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 14px;
    white-space: nowrap;
}

/* Sortable Admin Lists */
.admin-list.sortable .admin-item {
    cursor: grab;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.admin-list.sortable .admin-item:active {
    cursor: grabbing;
}

.admin-item.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.admin-item.drag-over {
    border-top: 2px solid var(--primary);
    margin-top: -2px;
}

.drag-handle {
    cursor: grab;
    color: var(--text-tertiary);
    padding: 4px;
    margin-right: 4px;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Date Preset Pills */
.date-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.preset-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.preset-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Multiselect Dropdown */
.multiselect {
    position: relative;
}

.multiselect-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
}

.multiselect-trigger:hover {
    border-color: var(--primary);
}

.multiselect.open .multiselect-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.multiselect-chevron {
    font-size: 16px;
    color: var(--text-secondary);
    transition: transform 0.15s ease;
}

.multiselect.open .multiselect-chevron {
    transform: rotate(180deg);
}

.multiselect-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--primary);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
}

.multiselect.open .multiselect-dropdown {
    display: block;
}

.multiselect-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s ease;
    border-bottom: 1px solid var(--border-light);
}

.multiselect-option:last-child {
    border-bottom: none;
}

.multiselect-option:hover {
    background: var(--bg-secondary);
}

.multiselect-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.multiselect-option span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Advanced Filters Toggle */
.toggle-advanced-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 12px;
}

.toggle-advanced-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.toggle-chevron {
    margin-left: auto;
    font-size: 16px;
    transition: transform 0.2s ease;
}

.toggle-advanced-btn.open .toggle-chevron {
    transform: rotate(180deg);
}

/* Advanced Filters Collapsible */
.advanced-filters {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.advanced-filters.open {
    max-height: 800px;
}

/* Filter Actions */
.filter-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.filter-actions .btn {
    flex: 1;
}

/* Checkbox Filter */
.checkbox-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    font-size: 14px;
    cursor: pointer;
    color: var(--text);
}

.checkbox-filter input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Filter Active Badge */
.filter-active-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border-radius: 10px;
}

/* 4-Column Summary Grid */
.summary-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100% - 32px);
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font-family);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    pointer-events: auto;
    animation: toastIn 0.3s ease forwards;
    border: 1px solid transparent;
}

.toast.success {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.toast.error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.toast.info {
    background: #dbeafe;
    color: #1e40af;
    border-color: #bfdbfe;
}

[data-theme="dark"] .toast.success {
    background: #14532d;
    color: #86efac;
    border-color: #166534;
}

[data-theme="dark"] .toast.error {
    background: #450a0a;
    color: #fca5a5;
    border-color: #7f1d1d;
}

[data-theme="dark"] .toast.info {
    background: #1e3a5f;
    color: #93c5fd;
    border-color: #1e40af;
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-text {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    padding: 2px;
    font-size: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.toast-close:hover {
    opacity: 1;
}

.toast.removing {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* Attachment List */
.attachment-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    font-size: 13px;
}

.attachment-item-icon {
    font-size: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.attachment-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.attachment-item-size {
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.attachment-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.15s;
}

.attachment-remove:hover {
    background: var(--error);
    color: white;
}

/* Attachment Count Badge (on paperclip in table) */
.attachment-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    background: var(--primary);
    color: white;
    border-radius: 8px;
}

/* Make the paperclip button position relative for badge */
.btn.btn-ghost.btn-icon-only {
    position: relative;
}

/* Compact action buttons inside tables */
.expenses-table .btn-icon-only {
    padding: 4px;
    min-width: 28px;
    width: 28px;
    height: 28px;
    font-size: 15px;
}

.expenses-table td:last-child {
    padding-right: 4px;
}

.actions-cell {
    white-space: nowrap;
    text-align: right;
}

/* Import Mapping Confidence Badges */
.mapping-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.mapping-badge.exact,
.mapping-badge.alias {
    background: var(--success);
    color: white;
}

.mapping-badge.remembered {
    background: var(--primary);
    color: white;
}

.mapping-badge.suggested {
    background: var(--warning);
    color: white;
}

.mapping-select.confidence-exact,
.mapping-select.confidence-alias {
    border-color: var(--success) !important;
}

.mapping-select.confidence-remembered {
    border-color: var(--primary) !important;
}

.mapping-select.confidence-suggested {
    border-color: var(--warning) !important;
}

.mapping-select.confidence-manual {
    border-color: var(--success) !important;
}

/* Import Confirmation Banner */
.import-confirm-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    background: #fffbeb;
    border: 1px solid #fbbf24;
    color: #92400e;
    font-size: 14px;
}

[data-theme="dark"] .import-confirm-banner {
    background: #451a03;
    border-color: #d97706;
    color: #fbbf24;
}

.import-confirm-banner .btn {
    flex-shrink: 0;
    margin-left: auto;
}

/* Bulk Toolbar */
.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.bulk-toolbar span {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}

/* Row checkbox styling */
.expenses-table .row-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.expenses-table th.bulk-check-col,
.expenses-table td.bulk-check-col {
    width: 36px;
    text-align: center;
    padding: 6px;
}

/* Bulk update modal field hint */
.bulk-field-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.clear-field-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.clear-field-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

/* Selected row highlight */
.expenses-table tbody tr.row-selected {
    background: rgba(37, 99, 235, 0.06);
}

[data-theme="dark"] .expenses-table tbody tr.row-selected {
    background: rgba(37, 99, 235, 0.12);
}

/* Responsive */
@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-actions {
        flex-direction: column;
    }

    .filter-actions {
        flex-direction: column;
    }

    .preset-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .date-presets {
        gap: 4px;
    }
}

/* Users & Authentication */
.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-admin {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.role-user {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.pin-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.pin-badge.pin-locked {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}


/* ============================================================
   My Preferences — toggle switches + layout
   ============================================================ */

.pref-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.pref-toggle-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.pref-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    transition: background 0.15s;
}

.pref-toggle-item:last-child {
    border-bottom: none;
}

.pref-toggle-item:hover {
    background: var(--bg-secondary);
}

.pref-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pref-label > span:first-child {
    font-size: 14px;
    font-weight: 500;
}

.pref-sublabel {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 26px;
    transition: background 0.2s;
    cursor: pointer;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}