/* ══════════════════════════════════════════════════════════════
   INVOICY — Green Dashboard Theme
   Inspired by shadcn/ui + Tailwind 4 design system
   ══════════════════════════════════════════════════════════════ */

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

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

:root {
    /* ── Core palette (green-themed) ── */
    --color-bg: #f5f7f5;
    --color-surface: #ffffff;
    --color-border: #e2e8e2;
    --color-text: #1a2e1a;
    --color-text-secondary: #4a6a4a;
    --color-text-muted: #7a9a7a;

    --color-primary: #059669;
    --color-primary-hover: #047857;
    --color-primary-light: #d1fae5;
    --color-primary-glow: rgba(5, 150, 105, 0.2);

    --color-green: #059669;
    --color-green-light: #d1fae5;
    --color-red: #dc2626;
    --color-red-light: #fee2e2;
    --color-orange: #d97706;
    --color-orange-light: #fef3c7;
    --color-purple: #7c3aed;
    --color-purple-light: #ede9fe;
    --color-blue: #2563eb;
    --color-blue-light: #dbeafe;

    /* ── Layout ── */
    --color-sidebar-bg: #ffffff;
    --color-sidebar-border: #e2e8e2;
    --sidebar-width: 256px;
    --topbar-height: 60px;

    /* ── Shape ── */
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;

    /* ── Shadows ── */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-xl: 0 8px 30px rgba(0,0,0,0.1);

    --transition: 200ms ease;
    --transition-slow: 300ms ease;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
}

/* ── Dark Mode ───────────────────────────────────────────── */
[data-theme="dark"] {
    --color-bg: #0c1a0c;
    --color-surface: #142014;
    --color-border: #1e3a1e;
    --color-text: #e4f0e4;
    --color-text-secondary: #a0c0a0;
    --color-text-muted: #5a8a5a;
    --color-primary: #10b981;
    --color-primary-hover: #059669;
    --color-primary-light: #064e3b;
    --color-primary-glow: rgba(16, 185, 129, 0.25);
    --color-green-light: #064e3b;
    --color-red-light: #450a0a;
    --color-orange-light: #451a03;
    --color-purple-light: #2e1065;
    --color-blue-light: #1e3a5f;
    --color-sidebar-bg: #0f1a0f;
    --color-sidebar-border: #1e3a1e;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-xl: 0 8px 30px rgba(0,0,0,0.5);
}

body {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

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

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

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition), width var(--transition);
    border-right: 1px solid var(--color-sidebar-border);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 34px;
    height: 34px;
    background: var(--color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    box-shadow: 0 2px 8px var(--color-primary-glow);
    transition: transform 300ms ease;
}

.logo:hover .logo-icon {
    transform: scale(1.1);
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--color-text);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    padding: 12px 14px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--radius-xs);
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 13px;
    transition: all 300ms ease;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--color-primary-glow), 0 2px 6px rgba(5,150,105,0.2);
}

.nav-item.active:hover {
    transform: none;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.nav-item:hover svg {
    opacity: 1;
}

.nav-item.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--color-border);
}

.service-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
    transition: all var(--transition);
}

.status-dot.online {
    background: var(--color-green);
    box-shadow: 0 0 8px rgba(5,150,105,0.5);
    animation: pulse-dot 2s infinite;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 99;
}

.sign-out-link {
    margin-top: 8px;
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

.top-bar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.85);
}

[data-theme="dark"] .top-bar {
    background: rgba(20,32,20,0.85);
}

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

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    flex: 1;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Top Bar Search ─────────────────────────────────────── */
.topbar-search {
    position: relative;
    max-width: 400px;
    flex: 1;
}

.topbar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

.topbar-search-input {
    width: 100%;
    padding: 7px 60px 7px 34px;
    font-size: 13px;
    font-family: inherit;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    color: var(--color-text);
    transition: all 300ms ease;
    outline: none;
}

.topbar-search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 4px 16px rgba(5,150,105,0.1);
}

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

.topbar-search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-block;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    line-height: 1.4;
}

/* ── Top Bar Icon Buttons ──────────────────────────────── */
.topbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: none;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 300ms ease;
    position: relative;
}

.topbar-icon-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
    transform: scale(1.1);
}

.topbar-notif-btn {
    position: relative;
}

.topbar-notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    background: var(--color-red);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

.topbar-divider {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    margin: 0 4px;
}

.content {
    flex: 1;
    padding: 24px 28px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-slow), transform var(--transition-slow);
    animation: slideInUp 0.5s ease-out both;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--color-border);
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.card-body {
    padding: 22px;
    overflow: hidden;
}

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

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 500ms ease-out;
    animation: slideInUp 0.5s ease-out both;
}

.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 100ms; }
.stat-card:nth-child(3) { animation-delay: 200ms; }
.stat-card:nth-child(4) { animation-delay: 300ms; }

.stat-card-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.stat-card-primary .stat-value,
.stat-card-primary .stat-label,
.stat-card-primary .stat-comparison {
    color: #fff;
}

.stat-card-primary .stat-icon {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.stat-card:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl);
}

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

.stat-card:hover .stat-icon {
    transform: scale(1.05);
}

.stat-icon-blue { background: var(--color-blue-light); color: var(--color-blue); }
.stat-icon-green { background: var(--color-green-light); color: var(--color-green); }
.stat-icon-purple { background: var(--color-purple-light); color: var(--color-purple); }
.stat-icon-orange { background: var(--color-orange-light); color: var(--color-orange); }

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

.stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

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

.stat-comparison {
    display: block;
    margin-top: 2px;
    line-height: 1.3;
}

/* ── Quick Actions ────────────────────────────────────────── */
.quick-actions {
    margin-bottom: 24px;
}

.quick-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-primary);
    background: var(--color-primary-light);
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    text-decoration: none;
    transition: all var(--transition-slow);
    cursor: pointer;
}

.quick-action-btn:hover {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--color-primary-glow);
    transform: translateY(-1px);
}

.quick-action-btn:active {
    transform: scale(0.97);
}

.quick-action-btn svg {
    flex-shrink: 0;
}

/* ── Grids ───────────────────────────────────────────────── */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.settings-grid .card:last-child {
    grid-column: 1 / -1;
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

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

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

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}

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

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

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

.table-empty {
    text-align: center;
    padding: 32px 12px !important;
    color: var(--color-text-muted);
}

.table-footer {
    padding: 12px 20px;
    font-size: 13px;
    color: var(--color-text-secondary);
    border-top: 1px solid var(--color-border);
}

.sortable {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
}

.sortable:hover {
    color: var(--color-primary);
}

.row-review {
    background: var(--color-orange-light) !important;
}

.row-wrong-invoice {
    background: rgba(239, 68, 68, 0.06) !important;
    border-left: 3px solid #dc2626;
}

[data-theme="dark"] .row-wrong-invoice {
    background: rgba(239, 68, 68, 0.1) !important;
}

[data-theme="dark"] .row-wrong-invoice span[style*="background:#fee2e2"] {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
}

.text-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.text-mono {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
}

/* ── Vendor column ───────────────────────────────────────── */
.vendor-cell {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vendor-cell:hover {
    overflow: visible;
    white-space: normal;
    word-break: break-word;
}

/* ── Confidence dot ──────────────────────────────────────── */
.confidence-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
    flex-shrink: 0;
}

.confidence-high { background: #22c55e; }
.confidence-medium { background: #eab308; }
.confidence-low { background: #ef4444; }

/* ── Inline edit cell ────────────────────────────────────── */
.inline-edit-cell {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    transition: background var(--transition);
}

.inline-edit-cell:hover {
    background: var(--color-primary-light);
}

.inline-edit-input {
    width: 100%;
    padding: 4px 8px;
    font-size: 13px;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-xs);
    background: var(--color-surface);
    color: var(--color-text);
    outline: none;
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.badge-green { background: var(--color-green-light); color: var(--color-green); }
.badge-red { background: var(--color-red-light); color: var(--color-red); }
.badge-orange { background: var(--color-orange-light); color: var(--color-orange); }
.badge-blue { background: var(--color-blue-light); color: var(--color-blue); }
.badge-purple { background: var(--color-purple-light); color: var(--color-purple); }
.badge-muted { background: var(--color-bg); color: var(--color-text-secondary); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-slow);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 2px 8px var(--color-primary-glow);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 16px var(--color-primary-glow);
    transform: translateY(-1px) scale(1.05);
}

.btn-secondary {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
}

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

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

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

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
    border-radius: var(--radius-xs);
}

.btn-xs {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
}

.btn-danger:hover {
    color: var(--color-red);
    background: var(--color-red-light);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Forms ────────────────────────────────────────────────── */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.input {
    padding: 9px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-family: inherit;
    transition: all var(--transition);
    background: var(--color-surface);
    color: var(--color-text);
}

.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.input-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.form-feedback {
    font-size: 13px;
    margin-top: 4px;
}

.form-feedback.success { color: var(--color-green); }
.form-feedback.error { color: var(--color-red); }

/* ── Vendors ─────────────────────────────────────────────── */
.vendor-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vendor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.vendor-item:hover {
    background: var(--color-bg);
    transform: translateX(2px);
}

.vendor-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vendor-name {
    text-transform: capitalize;
    font-size: 14px;
    font-weight: 500;
}

.vendor-aliases {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.alias-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--color-bg);
    border-radius: 6px;
    font-size: 11px;
    color: var(--color-text-secondary);
}

.alias-hidden { display: none; }
.alias-toggle-btn {
    display: inline-block;
    padding: 2px 8px;
    background: none;
    border: 1px dashed var(--color-border);
    border-radius: 6px;
    font-size: 11px;
    color: var(--color-primary);
    cursor: pointer;
    vertical-align: middle;
    transition: all var(--transition);
}
.alias-toggle-btn:hover { background: var(--color-primary-light); }

.vendor-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.vendor-spend-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-green);
    background: var(--color-green-light);
    padding: 2px 8px;
    border-radius: 6px;
}

.vendor-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
    font-size: 11px;
    color: var(--color-text-muted);
}

.vendor-last-date { }
.vendor-inv-count { }

.vendor-notes-preview {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--color-text-muted);
    font-style: italic;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unmapped-count-clickable:hover {
    background: rgba(234,179,8,0.4) !important;
    transform: scale(1.1);
    transition: all 0.15s;
}

/* ── Upload / Dropzone ───────────────────────────────────── */
.upload-page-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .upload-page-grid {
        grid-template-columns: 1fr;
    }
}

.upload-container {
    max-width: 640px;
}

.upload-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 12px 0;
}

.upload-step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.upload-step .step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-border);
    transition: all var(--transition-slow);
}

.upload-step.active .step-dot { background: var(--color-primary); box-shadow: 0 0 8px var(--color-primary-glow); }
.upload-step.active { color: var(--color-primary); font-weight: 600; }
.upload-step.completed .step-dot { background: #22c55e; }
.upload-step.completed { color: #22c55e; }

.step-line {
    width: 32px;
    height: 2px;
    background: var(--color-border);
    margin: 0 8px;
}

/* ── Batch upload ────────────────────────────────────────── */
.batch-step-indicators { display: flex; gap: 4px; align-items: center; }
.batch-step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-border); transition: all var(--transition); }
.batch-step-dot.active { background: var(--color-primary); }
.batch-step-dot.completed { background: #22c55e; }
.batch-step-dot.error { background: #ef4444; }

.batch-summary-stats { display: flex; gap: 24px; margin: 12px 0; }
.batch-stat { text-align: center; }
.batch-stat-num { display: block; font-size: 28px; font-weight: 700; line-height: 1.2; }
.batch-stat-label { font-size: 12px; color: var(--color-text-muted); }

/* ── Recent uploads panel ────────────────────────────────── */
.recent-uploads-panel .card-body { padding: 0; }
.recent-upload-list { display: flex; flex-direction: column; }

.recent-upload-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition);
}

.recent-upload-item:last-child { border-bottom: none; }
.recent-upload-item:hover { background: var(--color-bg); }

.recent-upload-icon { color: var(--color-text-muted); flex-shrink: 0; }
.recent-upload-info { flex: 1; min-width: 0; }
.recent-upload-vendor { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-upload-meta { font-size: 11px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-upload-status { font-size: 11px; font-weight: 500; flex-shrink: 0; padding: 2px 8px; border-radius: 10px; }
.recent-upload-ok { background: rgba(34,197,94,0.1); color: #16a34a; }
.recent-upload-paid { background: rgba(34,197,94,0.1); color: #16a34a; }
.recent-upload-review { background: rgba(234,179,8,0.1); color: #b45309; }

.dropzone {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 52px 24px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-slow);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    box-shadow: 0 0 0 4px var(--color-primary-glow);
}

.dropzone-content { text-align: center; }
.dropzone-icon { color: var(--color-text-muted); margin-bottom: 12px; }
.dropzone-text { font-size: 16px; font-weight: 600; color: var(--color-text); }
.dropzone-subtext { font-size: 13px; color: var(--color-text-secondary); margin-top: 4px; }
.dropzone-formats { font-size: 12px; color: var(--color-text-muted); margin-top: 12px; }

.file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.file-preview svg { color: var(--color-primary); flex-shrink: 0; }
.file-info { flex: 1; display: flex; flex-direction: column; }
.file-name { font-weight: 600; font-size: 14px; }
.file-size { font-size: 12px; color: var(--color-text-muted); }
.upload-actions { display: flex; justify-content: center; }
.upload-status { text-align: center; font-size: 13px; color: var(--color-text-secondary); margin-top: 8px; }

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #10b981);
    border-radius: 3px;
    transition: width 300ms ease;
}

/* ── Upload Result ───────────────────────────────────────── */
.upload-result { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 28px;
    border-radius: var(--radius);
    width: 100%;
    text-align: center;
}

.result-success { background: var(--color-green-light); color: var(--color-green); }
.result-success h3 { color: var(--color-green); }
.result-error { background: var(--color-red-light); color: var(--color-red); }
.result-error h3 { color: var(--color-red); }

.result-details { display: flex; flex-direction: column; gap: 8px; width: 100%; color: var(--color-text); }
.result-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.result-row span { color: var(--color-text-secondary); }

/* ── Settings ────────────────────────────────────────────── */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.setting-row:last-child {
    border-bottom: none;
}

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

.setting-value {
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.about-info p {
    color: var(--color-text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
}

/* ── Utility ─────────────────────────────────────────────── */
.text-muted {
    color: var(--color-text-muted);
    font-size: 13px;
}

.link-subtle {
    font-size: 13px;
    color: var(--color-primary);
    font-weight: 500;
}

/* ── Bar Chart ───────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.bar-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-label { width: 80px; font-size: 12px; color: var(--color-text-secondary); flex-shrink: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; min-width: 0; height: 8px; background: var(--color-bg); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--color-primary), #10b981); border-radius: 4px; transition: width 800ms ease; min-width: 4px; }
.bar-value { flex-shrink: 0; font-size: 11px; font-weight: 600; color: var(--color-text); text-align: right; white-space: nowrap; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    .stats-grid, .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-2col,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid .card:last-child {
        grid-column: auto;
    }
}

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

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

    .sidebar-toggle {
        display: block;
    }

    .sidebar-overlay.visible {
        display: block;
    }

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

    .menu-toggle {
        display: block;
    }

    .content {
        padding: 16px;
    }

    .stats-grid, .grid-4 {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

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

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 20px;
    }

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

    .topbar-search {
        display: none;
    }

    .topbar-search-kbd {
        display: none;
    }

    .top-bar-actions .btn span {
        display: none;
    }

    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
    }

    .grid-2col {
        grid-template-columns: 1fr;
    }

    .filter-tabs {
        flex-wrap: wrap;
    }

    .top-bar-actions .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }
}

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

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xl);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    animation: toastIn 300ms ease forwards;
    max-width: 380px;
}

.toast.removing {
    animation: toastOut 200ms ease forwards;
}

.toast-success { border-left: 4px solid var(--color-green); }
.toast-error { border-left: 4px solid var(--color-red); }
.toast-info { border-left: 4px solid var(--color-primary); }
.toast-warning { border-left: 4px solid var(--color-orange); }

/* ── Empty States ────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 52px 24px;
    text-align: center;
    color: var(--color-text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    margin-bottom: 16px;
}

.empty-state .btn {
    margin-top: 16px;
}

/* ── Collapsible Sidebar (Desktop) ───────────────────────── */
.sidebar-collapse-btn {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

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

@media (min-width: 769px) {
    .sidebar-collapse-btn { display: block; }

    .sidebar.collapsed {
        width: 68px;
    }

    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .nav-section-label,
    .sidebar.collapsed .sidebar-footer .service-status .status-text,
    .sidebar.collapsed .sign-out-link span {
        display: none;
    }

    .sidebar.collapsed .sidebar-header {
        padding: 18px;
        justify-content: center;
    }

    .sidebar.collapsed .sidebar-nav {
        padding: 12px 8px;
    }

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

    .sidebar.collapsed .sidebar-footer {
        padding: 16px 8px;
    }

    .sidebar.collapsed .service-status {
        justify-content: center;
    }

    .sidebar.collapsed .sign-out-link {
        justify-content: center;
    }

    .sidebar.collapsed + .main-content,
    .sidebar.collapsed ~ .main-content {
        margin-left: 68px;
    }

    .sidebar.collapsed .sidebar-collapse-btn svg {
        transform: rotate(180deg);
    }

    .sidebar.collapsed .nav-item {
        position: relative;
    }

    .sidebar.collapsed .nav-item:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        background: var(--color-text);
        color: var(--color-surface);
        padding: 5px 12px;
        border-radius: var(--radius-xs);
        font-size: 12px;
        white-space: nowrap;
        margin-left: 8px;
        z-index: 101;
        box-shadow: var(--shadow-lg);
    }
}

/* ── Dark Mode Toggle Button (legacy alias, now uses .topbar-icon-btn) ── */
.theme-toggle {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    padding: 7px;
    cursor: pointer;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--color-bg);
    color: var(--color-text);
    transform: rotate(15deg);
}

/* ── Clickable Stat Cards ────────────────────────────────── */
.stat-card[data-href] {
    cursor: pointer;
}

.stat-card[data-href]:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-primary);
}

/* ── Date Range Bar ──────────────────────────────────────── */
.date-range-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn-group {
    display: inline-flex;
    border-radius: var(--radius-xs);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.btn-group .btn {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    padding: 7px 16px;
    font-size: 12px;
}

.btn-group .btn:last-child {
    border-right: none;
}

.btn-group .btn.active {
    background: var(--color-primary);
    color: #fff;
}

.btn-group .btn:hover:not(.active) {
    background: var(--color-bg);
}

/* ── Sort Indicators ─────────────────────────────────────── */
.sortable.asc::after {
    content: ' ▲';
    font-size: 10px;
    color: var(--color-primary);
}

.sortable.desc::after {
    content: ' ▼';
    font-size: 10px;
    color: var(--color-primary);
}

/* ── Filter Bar & Tabs ──────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 4px;
}

.filter-tab {
    padding: 7px 16px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.filter-tab:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.filter-tab.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px var(--color-primary-glow);
}

/* ── Bulk Actions Bar ────────────────────────────────────── */
.bulk-bar {
    position: sticky;
    bottom: 0;
    background: var(--color-primary);
    color: #fff;
    padding: 14px 22px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    box-shadow: var(--shadow-xl);
}

.bulk-bar .btn {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
}

.bulk-bar .btn:hover {
    background: rgba(255,255,255,0.25);
}

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

/* ── Slide Panel ─────────────────────────────────────────── */
.slide-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
}

.slide-panel-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 440px;
    max-width: 90vw;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    z-index: 150;
    transform: translateX(100%);
    transition: transform 250ms ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: -8px 0 30px rgba(0,0,0,0.08);
}

.slide-panel.open {
    transform: translateX(0);
}

.slide-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.slide-panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.slide-panel-body {
    padding: 22px;
    flex: 1;
    overflow-y: auto;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}

.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--color-text-secondary); flex-shrink: 0; width: 120px; }
.detail-value { font-weight: 500; text-align: right; word-break: break-word; }

/* ── Print Styles ────────────────────────────────────────── */
@media print {
    .sidebar, .top-bar, .filter-bar, .bulk-bar, .date-range-bar,
    .header-actions, .toast-container, .slide-panel, .slide-panel-overlay {
        display: none !important;
    }
    .main-content { margin-left: 0 !important; }
    .content { padding: 0 !important; }
}

/* ── Inline Edit Form ────────────────────────────────────── */
.inline-edit-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.inline-edit-form .form-group { gap: 2px; }
.inline-edit-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ── Batch Upload ────────────────────────────────────────── */
.batch-file-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.batch-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: background var(--transition);
}

.batch-file-item .file-info { flex: 1; }
.batch-file-status { font-size: 12px; font-weight: 500; }
.batch-file-status.pending { color: var(--color-text-muted); }
.batch-file-status.processing { color: var(--color-orange); }
.batch-file-status.done { color: var(--color-green); }
.batch-file-status.error { color: var(--color-red); }

/* ── Activity Filter ─────────────────────────────────────── */
.activity-filter-bar { display: flex; gap: 8px; margin-bottom: 12px; }

/* ── Auto-refresh Indicator ──────────────────────────────── */
.auto-refresh-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.auto-refresh-bar label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* ── Keyboard Shortcuts Modal ────────────────────────────── */
.shortcuts-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
}

.shortcuts-modal-overlay.visible { display: flex; }

.shortcuts-modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    padding: 28px;
    max-width: 480px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.shortcuts-modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.shortcut-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }

.shortcut-row kbd {
    display: inline-block;
    padding: 3px 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.shortcut-row span { color: var(--color-text-secondary); font-size: 13px; }

/* ── Spending Chart Colors ───────────────────────────────── */
.bar-fill-green { background: var(--color-green); }
.bar-fill-blue { background: var(--color-blue); }
.bar-fill-purple { background: var(--color-purple); }
.bar-fill-orange { background: var(--color-orange); }

/* ── Category link ───────────────────────────────────────── */
.category-link { cursor: pointer; transition: color var(--transition); }
.category-link:hover { color: var(--color-primary); }

/* ── Admin Tabs ─────────────────────────────────────────── */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0;
}

.admin-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    margin-bottom: -1px;
}

.admin-tab:hover { color: var(--color-text); }

.admin-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.admin-tab-panel { display: none; }
.admin-tab-panel.active { display: block; }

/* ── Permission Matrix ──────────────────────────────────── */
.permission-matrix td, .permission-matrix th { text-align: center; }
.permission-matrix td:first-child, .permission-matrix th:first-child { text-align: left; }

/* ── Invite Modal ───────────────────────────────────────── */
.invite-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
}

.invite-modal-overlay.visible { display: flex; }

.invite-modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    padding: 28px;
    max-width: 440px;
    width: 90vw;
}

.invite-modal h3 { font-size: 16px; font-weight: 600; }

/* ── Status Badges ──────────────────────────────────────── */
.status-active { background: var(--color-green-light); color: var(--color-green); }
.status-pending { background: var(--color-orange-light); color: var(--color-orange); }
.status-suspended { background: var(--color-red-light); color: var(--color-red); }

/* ── View Toggle ────────────────────────────────────────── */
.view-toggle-btn.active { background: var(--color-primary-light); color: var(--color-primary); }

/* ── Grid Size Control ─────────────────────────────────── */
.grid-size-control { display: flex; align-items: center; }
.grid-col-btn { min-width: 28px; font-size: 12px; font-weight: 600; }
.grid-col-btn.active { background: var(--color-primary-light); color: var(--color-primary); }

/* ── Split View ─────────────────────────────────────────── */
#splitBody tr.split-active { background: var(--color-primary-light); }
#splitPreview img { max-width: 100%; max-height: 300px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); }

/* ── Grid View Cards ────────────────────────────────────── */
.invoice-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-slow);
    background: var(--color-surface);
}

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

.invoice-card-thumb {
    height: 160px;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.invoice-card-thumb img { width: 100%; height: 100%; object-fit: cover; }

.invoice-card-body { padding: 14px; }
.invoice-card-vendor { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invoice-card-amount { font-size: 13px; color: var(--color-text-secondary); margin-top: 4px; }
.invoice-card .badge { margin-top: 6px; }
.invoice-card.card-review { border-color: rgba(234,179,8,0.4); }

.row-split-pending { background: rgba(5,150,105,0.06) !important; }
.invoice-card.card-split-pending { border-color: rgba(5,150,105,0.3); }
.badge-split-pending { background: rgba(5,150,105,0.12); color: #059669; }

/* ── Loading Skeletons ──────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--color-border) 25%, var(--color-bg) 50%, var(--color-border) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-xs);
}

.skeleton-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.skeleton-cell { height: 16px; border-radius: 4px; }

/* ── Undo Toast ─────────────────────────────────────────── */
.toast-undo { display: flex; align-items: center; gap: 12px; }
.toast-undo-btn { background: none; border: none; color: #fff; text-decoration: underline; cursor: pointer; font-weight: 600; font-size: 13px; padding: 0; }

/* ── Integration Cards ───────────────────────────────────── */
.integration-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.integration-card {
    transition: all var(--transition-slow);
}

.integration-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* ── Dark mode completions ──────────────────────────────── */
[data-theme="dark"] .card {
    background: var(--color-surface);
    border-color: var(--color-border);
}

[data-theme="dark"] .table thead th {
    background: rgba(255,255,255,0.02);
}

[data-theme="dark"] .table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

[data-theme="dark"] .input,
[data-theme="dark"] select.input {
    background: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text);
}

[data-theme="dark"] .badge-muted {
    background: rgba(255,255,255,0.08);
    color: var(--color-text-muted);
}

[data-theme="dark"] .btn-secondary {
    background: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text);
}

[data-theme="dark"] .btn-ghost:hover {
    background: rgba(255,255,255,0.06);
}

[data-theme="dark"] .stat-card {
    background: var(--color-surface);
    border-color: var(--color-border);
}

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

[data-theme="dark"] .modal-overlay {
    background: rgba(0,0,0,0.6);
}

[data-theme="dark"] .slide-panel {
    background: var(--color-surface);
    border-color: var(--color-border);
}

[data-theme="dark"] .toast {
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

[data-theme="dark"] code {
    background: rgba(255,255,255,0.08);
    color: var(--color-text);
}

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

[data-theme="dark"] .topbar-search-input:focus {
    box-shadow: 0 4px 16px rgba(16,185,129,0.15);
}

[data-theme="dark"] .topbar-search-kbd {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

[data-theme="dark"] .topbar-icon-btn {
    color: var(--color-text-muted);
}

[data-theme="dark"] .topbar-icon-btn:hover {
    background: rgba(255,255,255,0.06);
    color: var(--color-text);
}

[data-theme="dark"] .topbar-divider {
    background: var(--color-border);
}

[data-theme="dark"] .nav-section-label {
    color: var(--color-text-muted);
}

[data-theme="dark"] .sidebar {
    background: var(--color-sidebar-bg);
    border-color: var(--color-sidebar-border);
}

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

[data-theme="dark"] .nav-item {
    color: var(--color-text-muted);
}

[data-theme="dark"] .nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--color-text);
}

[data-theme="dark"] .nav-item.active {
    background: var(--color-primary);
    color: #fff;
}

[data-theme="dark"] .sidebar-collapse-btn {
    color: var(--color-text-muted);
}

[data-theme="dark"] .sidebar-collapse-btn:hover {
    color: var(--color-text);
    background: rgba(255,255,255,0.05);
}

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

[data-theme="dark"] .filter-tab {
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

[data-theme="dark"] .filter-tab:hover {
    background: rgba(255,255,255,0.05);
    color: var(--color-text);
}
