/* ===== Reset & Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f0f0f2;
    --surface: #ffffff;
    --sidebar-bg: #f0f0f2;
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 68px;
    --topbar-h: 64px;
    --primary: #007aff;
    --primary-hover: #0066d6;
    --primary-light: rgba(0,122,255,0.08);
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --border: #d2d2d7;
    --danger: #ff3b30;
    --success: #34c759;
    --warning: #ff9f0a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

/* ===== Dark Mode (Apple-style) ===== */
[data-theme="dark"] {
    --bg: #161618;
    --surface: #2c2c2e;
    --sidebar-bg: #161618;
    --primary: #0a84ff;
    --primary-hover: #409cff;
    --primary-light: rgba(10,132,255,0.15);
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --border: #38383a;
    --danger: #ff453a;
    --success: #30d158;
    --warning: #ffd60a;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
}

[data-theme="dark"] .login-screen {
    background: linear-gradient(160deg, #000000, #1c1c1e 40%, #2c2c2e);
}

[data-theme="dark"] .login-box {
    background: rgba(44,44,46,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
}

[data-theme="dark"] .login-logo h2 {
    color: var(--text);
}

[data-theme="dark"] .input-group label {
    color: var(--text-secondary);
}

[data-theme="dark"] .input-group input {
    background: #0f172a;
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .input-group input:focus {
    background: #1e293b;
}

[data-theme="dark"] .search-bar input {
    color: var(--text);
}

[data-theme="dark"] .upload-area {
    border-color: var(--border);
}

[data-theme="dark"] .upload-area:hover,
[data-theme="dark"] .upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .form-group select {
    background: #0f172a;
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .invoice-item-row input {
    background: #0f172a;
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .section-filters select {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .summary-row select {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .context-menu button:hover {
    background: #334155;
}

[data-theme="dark"] .drop-content {
    background: var(--surface);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

.hidden { display: none !important; }

/* ===== Login ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #1c1c1e, #2c2c2e 40%, #3a3a3c);
    padding: 24px;
}

.login-box {
    width: 100%;
    max-width: 420px;
    background: rgba(255,255,255,0.97);
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 4px;
}

.login-logo h2 {
    font-size: 32px;
    color: var(--text);
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    background: #f8fafc;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.login-box button,
#login-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

#login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(37,99,235,0.3);
}

#error-message {
    margin-top: 12px;
    text-align: center;
    color: var(--danger);
    font-size: 14px;
    min-height: 20px;
}


/* ===== App Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: none;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.28s cubic-bezier(0.4,0,0.2,1), transform 0.3s ease;
    overflow: hidden;
}

/* ===== Sidebar Collapsed ===== */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .upload-btn span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-storage,
.sidebar.collapsed .user-info,
.sidebar.collapsed .logout-btn,
.sidebar.collapsed .nav-divider {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-title {
    display: none;
}

.sidebar.collapsed .upload-btn {
    justify-content: center;
    padding: 12px;
    margin: 8px auto 16px;
    width: calc(var(--sidebar-collapsed-w) - 20px);
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px;
    gap: 0;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
    padding: 14px 10px;
}

.sidebar.collapsed .collapse-icon-open { display: none !important; }
.sidebar.collapsed .collapse-icon-closed { display: block !important; }

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 12px;
}

.sidebar-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 16px 16px;
    padding: 12px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 4px rgba(0,122,255,0.25);
}

.upload-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 10px rgba(0,122,255,0.35);
    transform: scale(1.02);
}

.upload-btn:active {
    transform: scale(0.98);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active svg {
    stroke: var(--primary);
}

.sidebar-storage {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.storage-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.storage-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.storage-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s ease;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-email {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    flex-shrink: 0;
}

.logout-btn:hover {
    background: #fee2e2;
    color: var(--danger);
}

/* Sidebar collapsed → shift main content */
body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-w);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.28s cubic-bezier(0.4,0,0.2,1);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: var(--bg);
    border-bottom: none;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.menu-toggle:hover {
    background: var(--bg);
}

.search-bar {
    flex: 1;
    max-width: 600px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 50px;
    padding: 0 16px;
    transition: var(--transition);
}

.search-bar:focus-within {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.search-bar svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 14px;
    outline: none;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.view-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

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

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

.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
}

.subsection-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 28px 0 14px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header .section-title {
    margin-bottom: 0;
}

.section-filters {
    display: flex;
    gap: 8px;
}

.section-filters select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    outline: none;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.blue svg { stroke: #2563eb; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.green svg { stroke: #16a34a; }
.stat-icon.yellow { background: #fffbeb; color: #f59e0b; }
.stat-icon.yellow svg { stroke: #f59e0b; }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }
.stat-icon.purple svg { stroke: #9333ea; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== File Grid ===== */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.file-grid.list-view {
    display: block !important;
    grid-template-columns: none !important;
    gap: 0 !important;
    padding: 0 !important;
}

.file-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
    box-shadow: var(--shadow);
}

.file-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.file-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-card .file-icon {
    width: 100%;
    height: 120px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    overflow: hidden;
}

.file-card .file-icon img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.file-card .file-icon canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.file-card .file-icon.pdf-thumbnail {
    background: #f8f9fa;
}

[data-theme="dark"] .file-card .file-icon.pdf-thumbnail {
    background: #1e1e2e;
}

.pdf-thumb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-card .file-icon svg {
    color: var(--text-secondary);
}

.file-card .file-name {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-card .file-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.file-card .file-star {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition);
    opacity: 0;
}

.file-card:hover .file-star,
.file-card .file-star.active {
    opacity: 1;
}

.file-card .file-star.active {
    color: var(--warning);
}

.file-card .file-star:hover {
    background: rgba(0,0,0,0.05);
}

/* List view */
.file-grid.list-view .file-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    border-left: none;
    border-right: none;
    border-top: none;
}

.file-grid.list-view .file-card:hover {
    border-color: var(--border);
    background: var(--bg);
    box-shadow: none;
}

.file-grid.list-view .file-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 0;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
}

.file-grid.list-view .file-name {
    flex: 1;
    min-width: 0;
}

.file-grid.list-view .file-meta {
    margin-top: 0;
    white-space: nowrap;
}

.file-grid.list-view .file-star {
    position: static;
    opacity: 1;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state h3 {
    margin: 16px 0 8px;
    font-size: 18px;
    color: var(--text);
}

.empty-state p {
    font-size: 14px;
}

/* ===== Invoice Table ===== */
.invoice-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: 50px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.invoice-table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

.invoice-table th {
    text-align: left;
    padding: 14px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Column widths */
.invoice-table th:nth-child(1) { width: 40%; }   /* Unternehmen/Sache */
.invoice-table th:nth-child(2) { width: 12%; }   /* Datum */
.invoice-table th:nth-child(3) { width: 14%; }   /* Betrag */
.invoice-table th:nth-child(4) { width: 14%; }   /* Kategorie */
.invoice-table th:nth-child(5) { width: 10%; }   /* Status */
.invoice-table th:nth-child(6) { width: 10%; }   /* Aktionen */

.invoice-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
}

.invoice-table td .inv-company {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.invoice-table td .inv-number {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.invoice-table td .inv-amount {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

.invoice-table tbody tr {
    transition: var(--transition);
}

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

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

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.paid { background: #dcfce7; color: #166534; }
.status-badge.pending { background: #fef9c3; color: #854d0e; }
.status-badge.overdue { background: #fee2e2; color: #991b1b; }

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

.table-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.table-actions button:hover {
    background: var(--bg);
    color: var(--text);
}

.table-actions button.danger:hover {
    background: #fee2e2;
    color: var(--danger);
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

.modal-large {
    max-width: 700px;
}

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

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area p {
    margin-top: 12px;
    font-size: 15px;
    color: var(--text);
}

.upload-area strong {
    color: var(--primary);
}

.upload-hint {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.upload-preview-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.upload-preview-item .file-type-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.upload-preview-item .file-type-icon.pdf { background: #fee2e2; color: #dc2626; }
.upload-preview-item .file-type-icon.img { background: #ede9fe; color: #7c3aed; }
.upload-preview-item .file-type-icon.doc { background: #dbeafe; color: #2563eb; }
.upload-preview-item .file-type-icon.other { background: #f1f5f9; color: #64748b; }

.upload-preview-item .preview-info {
    flex: 1;
    min-width: 0;
}

.upload-preview-item .preview-name {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-preview-item .preview-size {
    font-size: 12px;
    color: var(--text-secondary);
}

.upload-preview-item .preview-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

.upload-preview-item .preview-remove:hover {
    color: var(--danger);
}

/* ===== Invoice Form ===== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

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

.form-section-title {
    font-size: 15px;
    font-weight: 700;
    margin: 20px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.invoice-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.invoice-item-row {
    display: grid;
    grid-template-columns: 2fr 80px 100px 80px 36px;
    gap: 8px;
    align-items: center;
}

.invoice-item-row input {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

.invoice-item-row input:focus {
    border-color: var(--primary);
}

.item-total {
    font-size: 14px;
    font-weight: 600;
    text-align: right;
}

.item-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.item-remove:hover {
    color: var(--danger);
    background: #fee2e2;
}

.invoice-summary {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 20px 0;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
}

.summary-row.total {
    border-top: 2px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 18px;
    font-weight: 700;
}

.summary-row select {
    margin-left: 8px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

/* ===== Quick Look Overlay (Apple-style) ===== */
.quicklook-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: qlFadeIn 0.2s ease;
}

.quicklook-overlay.hidden {
    display: none;
}

@keyframes qlFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.quicklook-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.quicklook-window {
    position: relative;
    width: 94vw;
    max-width: 1400px;
    height: 93vh;
    max-height: none;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: qlSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes qlSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Titlebar - macOS style */
.quicklook-titlebar {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.quicklook-traffic {
    display: flex;
    gap: 8px;
    margin-right: 16px;
}

.traffic-btn {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.traffic-close {
    background: #ff5f57;
}
.traffic-close:hover {
    background: #ff3b30;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}
.traffic-close:hover::after {
    content: '\00D7';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: rgba(0,0,0,0.6);
    line-height: 1;
}

.quicklook-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    letter-spacing: -0.01em;
}

.quicklook-titlebar-actions {
    display: flex;
    gap: 6px;
    margin-left: 16px;
}

.quicklook-titlebar-actions button {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
}
.quicklook-titlebar-actions button:hover {
    background: var(--border);
}
.quicklook-titlebar-actions .btn-danger {
    color: var(--danger);
    border-color: rgba(220,38,38,0.3);
}
.quicklook-titlebar-actions .btn-danger:hover {
    background: rgba(220,38,38,0.1);
}

.quicklook-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* Body - main preview area */
.quicklook-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 8px;
    background: var(--bg);
}

.quicklook-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.15);
}

.quicklook-body .pdf-viewer-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    overflow-y: auto;
    padding: 8px;
}

.quicklook-body .file-viewer-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
}

.quicklook-body .file-viewer-icon span {
    font-size: 14px;
}

/* Footer - slim info bar */
.quicklook-footer {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 32px;
}

.quicklook-info {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
}

.quicklook-info .detail-row {
    display: flex;
    gap: 6px;
    font-size: 12px;
    align-items: center;
}

.quicklook-info .detail-row .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.quicklook-info .detail-row .value {
    font-weight: 600;
    color: var(--text);
}

/* Responsive */
@media (max-width: 768px) {
    .quicklook-window {
        width: 95vw;
        height: 90vh;
        border-radius: 10px;
    }
    .quicklook-titlebar-actions {
        display: none;
    }
}

/* ===== Edit Toolbar (Bearbeiten) ===== */
.ql-edit-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ql-toolbar-group {
    display: flex;
    gap: 2px;
}

.ql-toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

.ql-tool {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: none;
    background: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ql-tool:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.ql-tool-close {
    background: var(--primary);
    color: #fff;
    padding: 5px 14px;
    border-radius: 6px;
}

.ql-tool-close:hover {
    background: var(--primary-hover);
    color: #fff;
}

/* Active tool state */
.ql-tool-active {
    background: var(--primary) !important;
    color: #fff !important;
}
.ql-tool-active svg {
    stroke: #fff !important;
}

/* Color & size pickers */
.ql-color-pick {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
    -webkit-appearance: none;
    appearance: none;
}
.ql-color-pick::-webkit-color-swatch-wrapper { padding: 0; }
.ql-color-pick::-webkit-color-swatch { border: none; border-radius: 50%; }

.ql-size-pick {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
}

/* Signature Modal */
.sig-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
}

.sig-modal {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    width: 520px;
}

.sig-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
}

.sig-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sig-close:hover { background: var(--bg); }

.sig-canvas {
    display: block;
    width: 100%;
    height: 200px;
    background: #fff;
    cursor: crosshair;
    border-bottom: 1px solid var(--border);
}

.sig-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
}

.sig-actions button {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    transition: all 0.15s ease;
}
.sig-actions button:hover { background: var(--border); }

.sig-save {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}
.sig-save:hover { background: var(--primary-hover) !important; }

.sig-clear { color: var(--danger) !important; }

/* Stamp picker */
.stamp-picker {
    position: absolute;
    top: 100%;
    right: 80px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    z-index: 10;
    min-width: 240px;
}

.stamp-option {
    padding: 8px 12px;
    border: 2px solid var(--danger);
    border-radius: 6px;
    background: none;
    color: var(--danger);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
}
.stamp-option:hover {
    background: rgba(255,59,48,0.1);
    transform: scale(1.03);
}

/* Annotation overlay */
.annotation-wrapper {
    position: relative;
}
.annotation-overlay {
    touch-action: none;
}

/* Titlebar edit/AI buttons */
.ql-btn-edit, .ql-btn-ai {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    border-color: rgba(0,122,255,0.2) !important;
}

.ql-btn-edit:hover, .ql-btn-ai:hover {
    background: rgba(0,122,255,0.15) !important;
}

/* ===== AI Tools Panel ===== */
.ql-ai-panel {
    width: 300px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    animation: qlSlideLeft 0.2s ease;
}

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

.ql-ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}

.ql-ai-header svg {
    stroke: var(--primary);
    fill: var(--primary);
    opacity: 0.8;
}

.ql-ai-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ql-ai-close:hover {
    background: var(--bg);
    color: var(--text);
}

.ql-ai-tools {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 4px;
}

.ql-ai-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    color: var(--text);
    transition: all 0.15s ease;
}

.ql-ai-action:hover {
    background: var(--primary-light);
}

.ql-ai-action svg {
    flex-shrink: 0;
    stroke: var(--primary);
}

.ql-ai-action div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ql-ai-action strong {
    font-size: 13px;
    font-weight: 600;
}

.ql-ai-action span {
    font-size: 11px;
    color: var(--text-secondary);
}

.ql-ai-action.loading {
    opacity: 0.6;
    pointer-events: none;
}

.ql-ai-loading {
    color: var(--primary);
    font-style: italic;
    font-size: 11px;
    margin-top: 2px;
}

.ql-ai-ocr-preview {
    margin: 8px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    max-height: 150px;
    overflow-y: auto;
}

.ql-ai-ocr-preview strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text);
    font-size: 12px;
}

.ql-ai-ocr-preview p {
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 768px) {
    .ql-ai-panel {
        position: absolute;
        right: 0;
        top: 44px;
        bottom: 32px;
        width: 280px;
        z-index: 10;
        box-shadow: -4px 0 16px rgba(0,0,0,0.2);
    }
    .ql-edit-toolbar .ql-tool span {
        display: none;
    }
}

/* ===== AI Info on Cards ===== */
.file-ai-info {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.doc-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 6px;
}

.badge-rechnung { background: #fee2e2; color: #dc2626; }
.badge-vertrag { background: #dbeafe; color: #2563eb; }
.badge-arztbrief { background: #d1fae5; color: #059669; }
.badge-gehaltsabrechnung { background: #fef3c7; color: #d97706; }
.badge-versicherung { background: #ede9fe; color: #7c3aed; }
.badge-steuer { background: #fce7f3; color: #db2777; }
.badge-angebot { background: #ccfbf1; color: #0d9488; }
.badge-kontoauszug { background: #e0e7ff; color: #4f46e5; }
.badge-lieferschein { background: #fef9c3; color: #ca8a04; }
.badge-mahnung { background: #fee2e2; color: #b91c1c; }
.badge-sonstiges { background: var(--bg); color: var(--text-secondary); }
.badge-elektronik { background: #dbeafe; color: #2563eb; }
.badge-lebensmittel { background: #d1fae5; color: #059669; }
.badge-gesundheit { background: #fce7f3; color: #db2777; }
.badge-kleidung { background: #ede9fe; color: #7c3aed; }
.badge-wohnung { background: #fef3c7; color: #d97706; }
.badge-transport { background: #ccfbf1; color: #0d9488; }
.badge-telekommunikation { background: #e0e7ff; color: #4f46e5; }
.badge-bildung { background: #fef9c3; color: #ca8a04; }
.badge-unterhaltung { background: #fee2e2; color: #dc2626; }
.badge-buero { background: #f1f5f9; color: #475569; }
.badge-analyzing { background: rgba(124,58,237,0.1); color: #7c3aed; animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

[data-theme="dark"] .badge-rechnung { background: rgba(220,38,38,0.15); }
[data-theme="dark"] .badge-vertrag { background: rgba(37,99,235,0.15); }
[data-theme="dark"] .badge-arztbrief { background: rgba(5,150,105,0.15); }
[data-theme="dark"] .badge-gehaltsabrechnung { background: rgba(217,119,6,0.15); }
[data-theme="dark"] .badge-versicherung { background: rgba(124,58,237,0.15); }
[data-theme="dark"] .badge-steuer { background: rgba(219,39,119,0.15); }
[data-theme="dark"] .badge-angebot { background: rgba(13,148,136,0.15); }
[data-theme="dark"] .badge-kontoauszug { background: rgba(79,70,229,0.15); }
[data-theme="dark"] .badge-lieferschein { background: rgba(202,138,4,0.15); }
[data-theme="dark"] .badge-mahnung { background: rgba(185,28,28,0.15); }

/* Validation styles */
.ai-hint {
    font-size: 13px;
    color: #7c3aed;
    background: rgba(124,58,237,0.08);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 6px;
}

.validation-ok { color: var(--success); font-size: 13px; font-weight: 600; }
.validation-error { color: var(--danger); font-size: 13px; font-weight: 600; }
.validation-info { color: var(--text-secondary); font-size: 13px; }

/* Scan field select */
.scan-field select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    width: 100%;
    cursor: pointer;
}

.scan-field select:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.pdf-viewer-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    gap: 12px;
    padding: 20px;
}

.pdf-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* mobile responsive handled in quicklook section above */

/* ===== Drop Overlay ===== */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(37,99,235,0.1);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.drop-content {
    text-align: center;
    background: var(--surface);
    padding: 48px 64px;
    border-radius: 20px;
    border: 3px dashed var(--primary);
    box-shadow: var(--shadow-lg);
}

.drop-content h2 {
    margin-top: 16px;
    color: var(--primary);
}

.drop-content p {
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 6px;
    z-index: 400;
    min-width: 180px;
}

.context-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    border-radius: 6px;
    text-align: left;
    transition: var(--transition);
}

.context-menu button:hover {
    background: var(--bg);
}

.context-menu button.danger {
    color: var(--danger);
}

.context-menu button.danger:hover {
    background: #fee2e2;
}

.context-menu hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--text);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
}

.toast.success { background: #166534; }
.toast.error { background: #991b1b; }

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

/* ===== Invoice Detail Modal ===== */
.inv-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 600px) {
    .inv-detail-grid { grid-template-columns: 1fr; }
}

.inv-detail-section h3 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.inv-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.inv-detail-row .label {
    font-size: 13px;
    color: var(--text-secondary);
}

.inv-detail-row .value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.inv-detail-items-table {
    margin-top: 8px;
}

.inv-detail-totals {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.total-row {
    padding: 6px 0;
}

.grand-total {
    border-top: 2px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
}

.grand-total .value {
    font-size: 18px;
    color: var(--primary);
}

.inv-detail-section p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Invoice table row clickable */
.invoice-table tbody tr {
    cursor: pointer;
    transition: var(--transition);
}

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

/* View button in table */
.table-actions button[data-action="view-invoice"] {
    color: var(--primary);
}

/* ===== Section Header Actions ===== */
.section-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Scan Button ===== */
.btn-scan {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-scan:hover {
    background: linear-gradient(135deg, #6d28d9, #5b21b6);
    box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}

/* ===== Scan Modal ===== */
.scan-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.scan-upload-area:hover {
    border-color: #7c3aed;
    background: rgba(124,58,237,0.05);
}

.scan-upload-area p {
    margin-top: 12px;
    font-size: 15px;
}

.scan-upload-area strong {
    color: #7c3aed;
}

.scan-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.scan-image-wrap {
    width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.scan-image-wrap img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.scan-image-wrap.small {
    max-height: 200px;
    flex-shrink: 0;
}

.scan-image-wrap.small img {
    max-height: 200px;
}

.scan-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(124,58,237,0.08);
    border-radius: var(--radius-sm);
    color: #7c3aed;
    font-weight: 600;
    font-size: 15px;
}

.scan-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(124,58,237,0.2);
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.scan-results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.scan-extracted-data h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.scan-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.scan-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scan-field input {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: var(--transition);
}

.scan-field input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.scan-field input:not(:placeholder-shown) {
    background: var(--surface);
    border-color: var(--success);
}

.scan-raw-text {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.scan-raw-text summary {
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    background: var(--bg);
}

.scan-raw-text summary:hover {
    color: var(--text);
}

.scan-raw-text pre {
    padding: 14px;
    font-size: 12px;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
    background: var(--surface);
    margin: 0;
}

/* ===== Sidebar Divider ===== */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 16px;
}

/* ===== Settings Button (Topbar) ===== */
.settings-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

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

/* ===== Settings Page ===== */
.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.settings-card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.settings-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.settings-select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    min-width: 180px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

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

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

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    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(22px);
}

/* ===== Theme Picker ===== */
.theme-picker {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
}

.theme-option input {
    display: none;
}

.theme-preview {
    width: 130px;
    height: 88px;
    border-radius: 10px;
    overflow: hidden;
    border: 3px solid var(--border);
    display: grid;
    grid-template-columns: 30px 1fr;
    grid-template-rows: 18px 1fr;
    transition: var(--transition);
    position: relative;
}

.theme-option input:checked ~ .theme-label {
    font-weight: 700;
    color: var(--primary);
}

.theme-option:hover .theme-preview,
.theme-option input:checked + span + .theme-label {
    /* fallback */
}

.theme-option:has(input:checked) .theme-preview {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}

.theme-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    transition: var(--transition);
}

/* Titlebar */
.tp-titlebar {
    grid-column: 1 / -1;
    background: #4338ca;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0 6px;
}

.tp-titlebar.light {
    background: #e2e8f0;
}

.tp-titlebar.dark {
    background: #1e293b;
}

.tp-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.tp-dot.red { background: #ef4444; }
.tp-dot.yellow { background: #f59e0b; }
.tp-dot.green { background: #22c55e; }

/* Sidebar preview */
.tp-sidebar-left {
    background: #312e81;
}

.tp-sidebar-left.light {
    background: #f1f5f9;
}

.tp-sidebar-left.dark {
    background: #0f172a;
}

/* Content preview */
.tp-content-right {
    background: #1e1b4b;
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tp-content-right.light {
    background: #ffffff;
}

.tp-content-right.dark {
    background: #1e293b;
}

.tp-line {
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.25);
    width: 100%;
}

.tp-line.short {
    width: 60%;
}

.tp-line.light {
    background: #cbd5e1;
}

.tp-line.dark {
    background: #334155;
}

/* Auto theme preview: split */
.theme-preview-auto {
    position: relative;
}

.theme-preview-auto .tp-titlebar {
    background: linear-gradient(90deg, #e2e8f0 50%, #1e293b 50%);
}

.theme-preview-auto .tp-sidebar-left {
    background: linear-gradient(180deg, #f1f5f9 50%, #0f172a 50%);
}

.theme-preview-auto .tp-content-right {
    background: linear-gradient(135deg, #ffffff 50%, #1e293b 50%);
}

.theme-preview-auto .tp-line {
    background: linear-gradient(90deg, #cbd5e1 50%, #334155 50%);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

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

    .invoice-item-row {
        grid-template-columns: 1fr 60px 80px 60px 30px;
    }

    .modal-content {
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .search-bar {
        max-width: none;
    }

    .topbar {
        padding: 0 12px;
    }

    .content-area {
        padding: 16px;
    }
}

/* ===== Email Module ===== */
.email-connect-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 32px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
    margin-bottom: 20px;
}

.email-connect-icon svg {
    stroke: var(--text-secondary);
    opacity: 0.4;
}

.email-connect-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 4px 0 0;
}

.email-connect-card p {
    max-width: 380px;
    font-size: 13px;
    line-height: 1.5;
}

.email-account-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.email-account-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.email-last-sync {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 8px;
}

.section-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* OAuth buttons */
.email-oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.email-oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    transition: all 0.15s ease;
    width: 100%;
}

.email-oauth-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.gmail-btn:hover { border-color: #4285F4; }
.outlook-btn:hover { border-color: #0078D4; }

.email-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}

.email-divider::before,
.email-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.email-divider span {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.email-connect-form .form-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spin {
    animation: spin 1s linear infinite;
}

.email-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

/* Email List */
.email-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.email-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.email-card:first-child {
    border-radius: var(--radius) var(--radius) var(--radius-sm) var(--radius-sm);
}

.email-card:last-child {
    border-radius: var(--radius-sm) var(--radius-sm) var(--radius) var(--radius);
}

.email-card:only-child {
    border-radius: var(--radius);
}

.email-card:hover {
    background: var(--primary-light);
}

.email-unread {
    background: var(--surface);
}

.email-unread .email-from,
.email-unread .email-subject {
    font-weight: 700;
}

.email-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-new {
    background: var(--primary);
}

.dot-done {
    background: var(--success);
    opacity: 0.4;
}

.email-card-content {
    flex: 1;
    min-width: 0;
}

.email-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.email-from {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-date {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-left: 12px;
}

.email-subject {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.email-preview {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.email-att-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 10px;
}

.email-done-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.15s ease;
    display: flex;
}

.email-done-btn:hover {
    background: var(--bg);
}

/* Email Detail Modal */
.email-det-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.email-det-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.email-det-row .label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.email-det-row .value {
    font-size: 14px;
    font-weight: 500;
}

.email-det-body {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
    word-break: break-word;
}

.email-det-attachments h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.email-att-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.email-att-item svg {
    flex-shrink: 0;
    stroke: var(--text-secondary);
}

.email-att-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.email-att-name {
    font-size: 13px;
    font-weight: 600;
}

.email-att-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.email-att-saved {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--success);
    font-weight: 500;
}

.email-att-pending {
    font-size: 12px;
    color: var(--warning);
    font-style: italic;
}

/* ===== Feature: Notification Center ===== */
.notification-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    position: relative;
}
.notification-btn:hover { background: var(--bg); color: var(--text); }
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.notification-dropdown {
    position: absolute;
    top: calc(var(--topbar-h) - 4px);
    right: 24px;
    width: 360px;
    max-height: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 700;
}
.notification-clear-btn {
    background: none; border: none; color: var(--primary); font-size: 12px; font-weight: 600; cursor: pointer;
}
.notification-list {
    overflow-y: auto;
    flex: 1;
    max-height: 340px;
}
.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    transition: var(--transition);
    cursor: default;
}
.notification-item:hover { background: var(--bg); }
.notification-item .notif-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.notif-icon.warning { background: #fef3c7; }
.notif-icon.warning svg { stroke: #f59e0b; }
.notif-icon.info { background: #dbeafe; }
.notif-icon.info svg { stroke: #2563eb; }
.notification-item .notif-text { flex: 1; }
.notification-item .notif-time { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.notification-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== Feature: Dashboard Widgets ===== */
.dashboard-widgets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}
@media (max-width: 768px) { .dashboard-widgets { grid-template-columns: 1fr; } }
.widget {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.widget-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}
.spending-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.spending-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    padding: 6px 0;
}
.spending-row .spending-cat { font-weight: 500; }
.spending-row .spending-amount { font-weight: 700; }
.spending-total {
    border-top: 2px solid var(--border);
    margin-top: 4px;
    padding-top: 10px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
}
.open-invoices-list { display: flex; flex-direction: column; gap: 6px; }
.open-inv-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}
.open-inv-item:hover { background: var(--primary-light); }
.open-inv-item .inv-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.open-inv-item .inv-due { color: var(--danger); font-weight: 600; font-size: 12px; }
.widget-empty { color: var(--text-secondary); font-size: 13px; text-align: center; padding: 20px 0; }

/* Activity Feed */
.activity-feed { display: flex; flex-direction: column; gap: 4px; }
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 13px;
    box-shadow: var(--shadow);
}
.activity-item .act-icon {
    width: 28px; height: 28px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    background: var(--primary-light);
}
.activity-item .act-icon svg { stroke: var(--primary); width: 14px; height: 14px; }
.activity-item .act-text { flex: 1; }
.activity-item .act-time { font-size: 11px; color: var(--text-secondary); }

/* ===== Feature: Advanced Search Filter Bar ===== */
.advanced-filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filter-group label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.filter-group input, .filter-group select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    min-width: 100px;
}
.filter-group input:focus, .filter-group select:focus { border-color: var(--primary); }

/* ===== Feature: Tags/Labels ===== */
.tag-create-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}
.tag-create-form input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    background: var(--bg);
    color: var(--text);
}
.tag-create-form input[type="color"] {
    width: 36px; height: 36px; border: 2px solid var(--border); border-radius: 8px;
    cursor: pointer; padding: 0; background: none;
}
.tag-list-manage { display: flex; flex-direction: column; gap: 4px; }
.tag-manage-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.tag-manage-item .tag-color-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.tag-manage-item .tag-name { flex: 1; font-size: 14px; font-weight: 500; }
.tag-manage-item .tag-delete-btn {
    background: none; border: none; color: var(--text-secondary); cursor: pointer;
    font-size: 16px; padding: 2px 6px; border-radius: 4px;
}
.tag-manage-item .tag-delete-btn:hover { color: var(--danger); background: #fee2e2; }
.doc-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 4px;
    margin-top: 4px;
}
.tag-assign-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-assign-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface);
}
.tag-assign-chip.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* ===== Feature: Bulk Actions ===== */
.bulk-actions-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}
.file-card .bulk-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: var(--transition);
}
.bulk-mode .file-card .bulk-checkbox { display: flex; }
.file-card .bulk-checkbox.checked {
    background: var(--primary);
    border-color: var(--primary);
}
.file-card .bulk-checkbox.checked::after {
    content: '';
    width: 6px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg); margin-top: -2px;
}

/* ===== Feature: Document Preview Tooltip ===== */
.doc-preview-tooltip {
    position: fixed;
    z-index: 450;
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    max-width: 220px;
    max-height: 280px;
    overflow: hidden;
}
.doc-preview-tooltip img, .doc-preview-tooltip canvas {
    max-width: 200px;
    max-height: 260px;
    object-fit: contain;
    border-radius: 4px;
}

/* ===== Feature: Keyboard Shortcuts Modal ===== */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.shortcut-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.shortcut-item span {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 13px;
}
kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    min-width: 28px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ===== Feature: Data Export ===== */
/* Uses existing btn-secondary styles */

/* ===== Dark mode additions for new features ===== */
[data-theme="dark"] .notification-dropdown { background: var(--surface); }
[data-theme="dark"] .advanced-filter-bar { background: var(--surface); }
[data-theme="dark"] .filter-group input,
[data-theme="dark"] .filter-group select { background: #0f172a; border-color: var(--border); color: var(--text); }
[data-theme="dark"] kbd { background: #1e293b; border-color: var(--border); }
[data-theme="dark"] .tag-create-form input[type="text"] { background: #0f172a; color: var(--text); }
[data-theme="dark"] .doc-preview-tooltip { background: var(--surface); }

/* ===== Doc tags row on file cards ===== */
.doc-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

/* ===== Bulk selected card highlight ===== */
.file-card.bulk-selected {
    outline: 2px solid var(--primary);
    background: var(--primary-light);
}

/* ===== Notification unread item ===== */
.notification-item.unread {
    background: var(--primary-light);
}

/* ===== Sidebar collapsed: nav item tooltip ===== */
.sidebar.collapsed .nav-item {
    position: relative;
}
.sidebar.collapsed .nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-collapsed-w) - 4px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--text);
    color: var(--surface);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 200;
    box-shadow: var(--shadow-md);
}
.sidebar.collapsed .nav-item:hover::after {
    opacity: 1;
}

/* ===== Global Search Results Dropdown ===== */
.global-search-results {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.28);
    z-index: 9999;
    max-height: 420px;
    overflow-y: auto;
    padding: 8px 0;
    min-width: 340px;
}
.global-search-results.hidden { display: none; }
.gsr-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 8px 16px 4px;
}
.gsr-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    cursor: pointer;
    transition: background 0.12s;
}
.gsr-item:hover { background: var(--hover); }
.gsr-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}
.gsr-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gsr-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.gsr-no-results {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.gsr-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* ===== ONEDRIVE-STYLE REDESIGN ===== */

/* Sidebar user greeting at top */
.sidebar-user-greeting {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.sug-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0078d4, #106ebe);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sug-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s, width 0.2s;
}
.sug-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sug-sub {
    font-size: 11px;
    color: var(--text-secondary);
}
/* Hide greeting text when collapsed */
.sidebar.collapsed .sidebar-user-greeting {
    justify-content: center;
    padding: 8px 0 12px;
}
.sidebar.collapsed .sug-info {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

/* Nav section labels */
.nav-section-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding: 12px 20px 4px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s, height 0.2s;
}
.sidebar.collapsed .nav-section-label {
    opacity: 0;
    height: 0;
    padding: 0;
    pointer-events: none;
}

/* Redesigned nav items - OneDrive style */
.nav-item {
    border-radius: 6px !important;
    padding: 9px 14px !important;
    font-size: 13.5px !important;
    font-weight: 400 !important;
    color: var(--text) !important;
    gap: 10px !important;
}
.nav-item:hover {
    background: rgba(0,0,0,0.05) !important;
    color: var(--text) !important;
}
.nav-item.active {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    font-weight: 600 !important;
    position: relative;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

/* Upload button - OneDrive style */
.upload-btn {
    border-radius: 20px !important;
    padding: 10px 20px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(0,120,212,0.25) !important;
    gap: 8px !important;
}

/* Type filter pills bar */
.type-pills-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 28px 0;
    flex-wrap: wrap;
}
.type-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.type-pill:hover {
    background: var(--bg);
    border-color: var(--text-secondary);
}
.type-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* Section header overhaul */
.section-header {
    border-bottom: 1px solid var(--border) !important;
    padding: 16px 28px !important;
    margin-bottom: 0 !important;
}
.section-title {
    font-size: 20px !important;
    font-weight: 600 !important;
    letter-spacing: -0.3px !important;
}

/* Main content: white card area with shadow */
.section {
    padding-top: 0 !important;
    padding: 20px 20px 20px 20px;
}
.section > *:not(.type-pills-bar) {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.section-header {
    border-radius: 12px 12px 0 0 !important;
}
.file-grid:not(.list-view), #documents-list:not(.list-view) {
    padding: 16px !important;
    border-radius: 0 0 12px 12px;
}

/* Settings cards already white - keep */
.settings-section {
    border-radius: 12px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07) !important;
    margin-bottom: 16px !important;
}

/* Topbar search: wider + more prominent */
.search-bar {
    flex: 1 !important;
    max-width: 560px !important;
    background: var(--bg) !important;
    border-radius: 8px !important;
    border: 1px solid var(--border) !important;
    padding: 0 12px !important;
}
.search-bar:focus-within {
    background: var(--surface) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-light) !important;
}
.search-bar input {
    background: transparent !important;
    font-size: 14px !important;
}

/* Topbar: center the search */
.topbar {
    justify-content: space-between !important;
    padding: 0 24px !important;
    gap: 16px !important;
}

/* Dark mode for new elements */
[data-theme="dark"] .nav-section-label { color: var(--text-secondary); }
[data-theme="dark"] .type-pill { background: var(--surface); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .type-pill:hover { background: var(--bg); }
[data-theme="dark"] .sidebar-user-greeting { border-color: var(--border); }
[data-theme="dark"] .nav-item:hover { background: rgba(255,255,255,0.06) !important; }

/* Hide sidebar storage */
.sidebar-storage { display: none !important; }

/* Hide dashboard widgets */
#dashboard-widgets { display: none !important; }

/* ===== OneDrive Dashboard Layout ===== */
.od-section {
    padding: 0 !important;
    background: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}
.od-section > * {
    background: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.od-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-wrap: wrap;
}
.od-topbar-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-right: 4px;
    white-space: nowrap;
}
.od-topbar-pills {
    display: flex;
    gap: 2px;
}
.od-tab {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid transparent;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
}
.od-tab:hover {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}
.od-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}
.od-name-filter {
    margin-left: auto;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    width: 220px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.od-name-filter:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.od-name-filter::placeholder { color: var(--text-secondary); }

/* Dashboard file-grid: full width list, no card padding */
#section-dashboard .file-grid.list-view {
    padding: 0 !important;
    border-radius: 0 !important;
    background: none !important;
    box-shadow: none !important;
}

/* Content area: no extra padding for dashboard */
#section-dashboard {
    min-height: calc(100vh - var(--topbar-h));
}

/* Dark mode */
[data-theme="dark"] .od-topbar { background: var(--bg); }
[data-theme="dark"] .od-name-filter { background: var(--surface); color: var(--text); }
[data-theme="dark"] .od-tab:hover { background: var(--surface); }

/* ===== OneDrive List View ===== */

/* Each row is an independent grid — 6 columns matching header + data cells */
.od-list-header,
.od-list-row {
    display: grid !important;
    grid-template-columns: 44px 1fr 160px 160px 110px 44px !important;
    align-items: center !important;
    padding: 0 16px !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

/* Header */
.od-list-header {
    height: 36px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: var(--text-secondary) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    border-bottom: 1px solid var(--border) !important;
    background: var(--bg) !important;
    position: sticky !important;
    top: var(--topbar-h) !important;
    z-index: 5 !important;
}

/* Data rows */
.od-list-row {
    height: 52px !important;
    border-bottom: 1px solid rgba(0,0,0,0.06) !important;
    cursor: pointer !important;
    background: var(--surface) !important;
    transition: background 0.1s !important;
}
.od-list-row:last-child { border-bottom: none !important; }
.od-list-row:hover { background: #eef4ff !important; }
.od-list-row.bulk-selected { background: var(--primary-light) !important; }

[data-theme="dark"] .od-list-header { background: var(--surface) !important; }
[data-theme="dark"] .od-list-row { background: var(--surface) !important; }
[data-theme="dark"] .od-list-row:hover { background: rgba(10,132,255,0.08) !important; }

/* Column cells — sizes match grid-template-columns above */
.odl-icon-col {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
}
.odl-name-col {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
    padding-right: 8px !important;
}
.odl-date-col {
    font-size: 13px !important;
    color: var(--text-secondary) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-right: 8px !important;
}
.odl-owner-col {
    font-size: 13px !important;
    color: var(--text-secondary) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-right: 8px !important;
}
.odl-activity-col {
    font-size: 13px !important;
    color: var(--text-secondary) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}
.odl-actions-col {
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    opacity: 0;
    transition: opacity 0.12s;
}
.od-list-row:hover .odl-actions-col { opacity: 1; }

/* File icon */
.odl-file-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Filename and subtitle inside name column */
.odl-filename {
    font-size: 14px !important;
    font-weight: 400 !important;
    color: var(--text) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.3 !important;
    display: block !important;
}
.odl-sub {
    font-size: 11.5px !important;
    color: var(--text-secondary) !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
    display: block !important;
}

/* Star button */
.odl-star-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #d1d5db;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.odl-star-btn:hover { color: #f59e0b; }
.odl-star-btn.active { color: #f59e0b; }

/* Sidebar: expand by default — reset collapsed localStorage on first load */

/* ===== Banking Section ===== */

/* Status bar */
.banking-status-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.banking-status-bar.banking-status-active {
    background: linear-gradient(135deg, #007aff14, #34c75910);
    border: 1px solid #007aff22;
}
.bsb-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}
.banking-status-active .bsb-icon { background: #34c75920; color: #34c759; }
.bsb-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bsb-label { font-size: 14px; font-weight: 600; color: var(--text); }
.bsb-sub { font-size: 12px; color: var(--text-secondary); }
.bsb-action { white-space: nowrap; }

/* Cards */
.banking-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.banking-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
}
.banking-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}
.banking-pending-count {
    background: var(--danger);
    color: #fff;
    border-radius: 20px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 700;
}

/* Setup Form */
.banking-setup-form { padding: 24px; }
.banking-setup-step { display: flex; flex-direction: column; gap: 16px; }
.step-indicator {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}
.step-num {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    color: var(--text-secondary);
}
.step-num.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.step-num.done   { border-color: var(--success); color: #fff; background: var(--success); }

.banking-setup-title { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.banking-setup-desc  { font-size: 14px; color: var(--text-secondary); margin: 0; line-height: 1.5; }

.bf-row { display: flex; flex-direction: column; gap: 5px; }
.bf-row label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.bf-row input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
.bf-row input:focus { border-color: var(--primary); background: var(--surface); }

.bf-info-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: #007aff12;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

/* Pending Payments */
.banking-pending-list { display: flex; flex-direction: column; }
.banking-pending-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.banking-pending-item:last-child { border-bottom: none; }
.banking-pending-item:hover { background: var(--bg); }
.bpi-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.bpi-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bpi-name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bpi-ref  { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bpi-amount { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; margin: 0 12px; }
.bpi-actions { display: flex; gap: 8px; }

/* Transactions */
.banking-statements-list { display: flex; flex-direction: column; }
.banking-txn-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.banking-txn-row:last-child { border-bottom: none; }
.banking-txn-row:hover { background: var(--bg); }
.btr-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.btr-in  { background: #34c75920; color: #34c759; }
.btr-out { background: #ff3b3015; color: #ff3b30; }
.btr-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.btr-name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btr-ref  { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btr-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.btr-amount { font-size: 14px; font-weight: 600; }
.btr-amount-in  { color: #34c759; }
.btr-amount-out { color: #ff3b30; }
.btr-date { font-size: 11px; color: var(--text-secondary); }

/* Empty / Loading */
.banking-empty, .banking-loading {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Nav badge (pending count in sidebar) */
.nav-badge {
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

/* "Bezahlen" button in detail panel */
.btn-pay {
    background: #34c759;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 13px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s;
}
.btn-pay:hover { background: #2aaf4f; }

/* Buttons utility */
.btn-sm { padding: 5px 12px !important; font-size: 12px !important; }
.btn-secondary {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.12s;
}
.btn-secondary:hover { background: var(--bg); }

/* ── Bank Search Row ── */
.bank-search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.bank-search-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.bank-search-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--surface);
}
.bank-search-row input::placeholder { color: var(--text-secondary); }

/* ── Bank List (popular / search results) ── */
.bank-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--surface);
}
.bank-list:empty { display: none; }

.bank-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
    user-select: none;
}
.bank-list-item:last-child { border-bottom: none; }
.bank-list-item:hover { background: var(--bg); }
.bank-list-item:active { background: var(--primary-light); }

.bank-list-logo {
    font-size: 20px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bank-list-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}
.bank-list-item > svg { color: var(--text-secondary); flex-shrink: 0; }

/* ── Selected Bank ── */
.bank-selected { margin-top: 4px; }

.bank-selected-display {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--primary);
    margin-bottom: 14px;
}
.bank-selected-logo {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bank-selected-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.bank-selected-bic {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-family: ui-monospace, 'SF Mono', monospace;
    letter-spacing: 0.04em;
}
.bank-change-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.bank-change-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--text-secondary);
}

/* Full-width connect button */
.bank-connect-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
}

/* Dark mode banking */
[data-theme="dark"] .banking-status-bar { background: var(--surface); }
[data-theme="dark"] .banking-card { background: var(--surface); }
[data-theme="dark"] .bank-list { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .bank-list-item { border-color: var(--border); }
[data-theme="dark"] .bank-list-item:hover { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .bank-list-item:active { background: rgba(10,132,255,0.12); }
[data-theme="dark"] .bank-search-row input { background: var(--surface); color: var(--text); }
[data-theme="dark"] .bank-search-row input:focus { background: var(--surface); }
[data-theme="dark"] .bank-selected-display { background: rgba(10,132,255,0.12); border-color: var(--primary); }
[data-theme="dark"] .bank-change-btn { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .bf-row input { background: var(--bg); }
