/* =====================================================================
   ExpensePro web theme - corporate blue, light surfaces.
   Built on Bootstrap 5 (wwwroot/lib/bootstrap). No external fonts/CDNs.
   ===================================================================== */
:root {
    --ep-primary: #1d4ed8;
    --ep-primary-600: #1e40af;
    --ep-primary-50: #eff6ff;
    --ep-primary-100: #dbeafe;
    --ep-ink: #0f172a;
    --ep-text: #334155;
    --ep-muted: #64748b;
    --ep-border: #e2e8f0;
    --ep-bg: #f4f6fa;
    --ep-surface: #ffffff;
    --ep-success: #15803d;
    --ep-warning: #b45309;
    --ep-danger: #b91c1c;
    --ep-sidebar-w: 248px;
    --bs-primary: #1d4ed8;
    --bs-primary-rgb: 29, 78, 216;
    --bs-link-color: #1d4ed8;
    --bs-link-hover-color: #1e40af;
    --bs-body-font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

html { font-size: 14.5px; }
body { background: var(--ep-bg); color: var(--ep-text); font-family: var(--bs-body-font-family); }
h1, h2, h3, h4, h5, h6 { color: var(--ep-ink); font-weight: 600; }
a { text-decoration: none; }
.text-muted { color: var(--ep-muted) !important; }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -3px; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Buttons ---------- */
.btn { border-radius: 8px; font-weight: 500; display: inline-flex; align-items: center; gap: .4rem; }
.btn-primary { background: var(--ep-primary); border-color: var(--ep-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--ep-primary-600); border-color: var(--ep-primary-600); }
.btn-outline-primary { color: var(--ep-primary); border-color: var(--ep-primary); }
.btn-outline-primary:hover { background: var(--ep-primary); border-color: var(--ep-primary); }
.btn-light { background: #fff; border-color: var(--ep-border); color: var(--ep-text); }
.btn-sm { border-radius: 6px; }

/* ---------- Shell ---------- */
.ep-shell { display: flex; min-height: 100vh; }
.ep-sidebar {
    width: var(--ep-sidebar-w); background: #0b1f4b; color: #c7d2fe; position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column; z-index: 1040; transition: transform .2s ease;
}
.ep-brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; font-size: 1.2rem; font-weight: 700; letter-spacing: .2px; }
.ep-brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); display: grid; place-items: center; color: #fff; font-weight: 800; }
.ep-nav { list-style: none; padding: .5rem .75rem; margin: 0; flex: 1; overflow-y: auto; }
.ep-nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7c8db5; padding: 1rem .75rem .35rem; }
.ep-nav a {
    display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 8px; color: #c7d2fe; font-weight: 500; margin-bottom: 2px;
}
.ep-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.ep-nav a.active { background: var(--ep-primary); color: #fff; box-shadow: 0 4px 12px rgba(29,78,216,.35); }
.ep-nav .badge { margin-left: auto; background: #f59e0b; color: #111; }
.ep-sidebar-footer { padding: 1rem 1.25rem; font-size: .75rem; color: #7c8db5; border-top: 1px solid rgba(255,255,255,.08); }

.ep-main { margin-left: var(--ep-sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ep-topbar {
    height: 64px; background: var(--ep-surface); border-bottom: 1px solid var(--ep-border); display: flex; align-items: center;
    gap: 1rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 1030;
}
.ep-search { flex: 1; max-width: 520px; position: relative; }
.ep-search input { padding-left: 2.25rem; border-radius: 10px; background: var(--ep-bg); border-color: transparent; height: 40px; }
.ep-search input:focus { background: #fff; border-color: var(--ep-primary-100); box-shadow: 0 0 0 .2rem rgba(29,78,216,.12); }
.ep-search .icon { position: absolute; left: .75rem; top: 11px; color: var(--ep-muted); }
.ep-topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.ep-icon-btn { position: relative; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--ep-text); border: 1px solid var(--ep-border); background: #fff; }
.ep-icon-btn:hover { color: var(--ep-primary); border-color: var(--ep-primary-100); }
.ep-dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--ep-danger); color: #fff; font-size: .68rem; display: grid; place-items: center; padding: 0 4px; font-weight: 600; }
.ep-user { display: flex; align-items: center; gap: .65rem; padding: .25rem .5rem; border-radius: 10px; cursor: pointer; border: 0; background: transparent; }
.ep-user:hover { background: var(--ep-bg); }
.ep-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ep-primary-100); color: var(--ep-primary); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.ep-user-meta { line-height: 1.15; text-align: left; }
.ep-user-name { font-weight: 600; color: var(--ep-ink); font-size: .9rem; }
.ep-user-role { font-size: .75rem; color: var(--ep-muted); }
.ep-menu-toggle { display: none; }

.ep-content { padding: 1.5rem; flex: 1; }
.ep-page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.ep-page-header h1 { font-size: 1.45rem; margin: 0; }
.ep-page-header .subtitle { color: var(--ep-muted); margin-top: .2rem; }
.ep-breadcrumb { font-size: .8rem; color: var(--ep-muted); margin-bottom: .25rem; }
.ep-breadcrumb a { color: var(--ep-muted); }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--ep-border); border-radius: 14px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--ep-border); padding: 1rem 1.25rem; font-weight: 600; color: var(--ep-ink); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-body { padding: 1.25rem; }
.stat-card { padding: 1.1rem 1.25rem; display: flex; gap: 1rem; align-items: flex-start; height: 100%; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon.blue { background: var(--ep-primary-50); color: var(--ep-primary); }
.stat-icon.green { background: #ecfdf5; color: var(--ep-success); }
.stat-icon.amber { background: #fffbeb; color: var(--ep-warning); }
.stat-icon.red { background: #fef2f2; color: var(--ep-danger); }
.stat-icon.violet { background: #f5f3ff; color: #6d28d9; }
.stat-label { color: var(--ep-muted); font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--ep-ink); line-height: 1.2; margin-top: .15rem; }
.stat-sub { font-size: .8rem; color: var(--ep-muted); }

.welcome { background: linear-gradient(120deg, #1d4ed8 0%, #2563eb 55%, #3b82f6 100%); color: #e0e7ff; border: 0; }
.welcome h2 { color: #fff; font-size: 1.35rem; }

.quick-action { display: flex; gap: .85rem; align-items: center; padding: 1rem; border: 1px solid var(--ep-border); border-radius: 12px; background: #fff; color: var(--ep-text); height: 100%; transition: all .15s; }
.quick-action:hover { border-color: var(--ep-primary); box-shadow: 0 6px 18px rgba(29,78,216,.12); transform: translateY(-1px); color: var(--ep-text); }
.quick-action .qa-title { font-weight: 600; color: var(--ep-ink); }
.quick-action .qa-desc { font-size: .8rem; color: var(--ep-muted); }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; color: var(--ep-text); }
.table > thead th { background: #f8fafc; color: var(--ep-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; border-bottom: 1px solid var(--ep-border); padding: .75rem 1rem; white-space: nowrap; }
.table > tbody td { padding: .75rem 1rem; vertical-align: middle; border-color: var(--ep-border); }
.table-hover > tbody > tr:hover > * { background: #f8fbff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-card { overflow: hidden; }
.table-responsive { border-radius: 0 0 14px 14px; }

/* ---------- Status badges ---------- */
.badge-status { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-paid { background: #dbeafe; color: #1e40af; }
.badge-returned { background: #ede9fe; color: #5b21b6; }
.policy-ok { color: var(--ep-success); font-weight: 600; font-size: .8rem; }
.policy-bad { color: var(--ep-danger); font-weight: 600; font-size: .8rem; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; color: var(--ep-ink); font-size: .87rem; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: 8px; border-color: #cbd5e1; }
.form-control:focus, .form-select:focus { border-color: #93c5fd; box-shadow: 0 0 0 .2rem rgba(29,78,216,.12); }
.field-validation-error, .validation-summary-errors { color: var(--ep-danger); font-size: .82rem; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }
.required::after { content: " *"; color: var(--ep-danger); }
.form-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ep-muted); font-weight: 600; margin: 1rem 0 .6rem; }

/* ---------- Misc ---------- */
.alert { border-radius: 10px; border: 0; display: flex; gap: .6rem; align-items: flex-start; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info { background: var(--ep-primary-50); color: #1e3a8a; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ep-muted); }
.empty-state .icon { width: 40px; height: 40px; color: #cbd5e1; margin-bottom: .5rem; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: .5rem 1rem; }
.kv dt { color: var(--ep-muted); font-weight: 500; }
.kv dd { margin: 0; color: var(--ep-ink); }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 1rem 1.5rem; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--ep-primary); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 2px; background: var(--ep-border); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: .75rem; color: var(--ep-muted); }
.receipt-thumb { width: 100%; max-height: 220px; object-fit: contain; border: 1px solid var(--ep-border); border-radius: 10px; background: #f8fafc; }
.receipt-frame { width: 100%; height: 480px; border: 1px solid var(--ep-border); border-radius: 10px; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.nav-tabs .nav-link { color: var(--ep-muted); font-weight: 500; border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--ep-primary); border-bottom-color: var(--ep-primary); background: transparent; }
.pill-filter a { display: inline-block; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--ep-border); color: var(--ep-text); margin: 0 .35rem .35rem 0; font-size: .85rem; background: #fff; }
.pill-filter a.active { background: var(--ep-primary); color: #fff; border-color: var(--ep-primary); }
.provider-pending { border: 1px dashed #93c5fd; background: var(--ep-primary-50); border-radius: 12px; padding: 1.25rem; }
.dropdown-menu { border-radius: 10px; border-color: var(--ep-border); box-shadow: 0 10px 30px rgba(15,23,42,.12); }
.notif-item { padding: .65rem 1rem; border-bottom: 1px solid var(--ep-border); display: block; color: var(--ep-text); white-space: normal; }
.notif-item.unread { background: var(--ep-primary-50); }
.notif-item .t { font-weight: 600; color: var(--ep-ink); font-size: .85rem; }
.notif-item .m { font-size: .8rem; color: var(--ep-muted); }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(140deg, #0b1f4b 0%, #1d4ed8 70%, #3b82f6 100%); color: #dbeafe; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { color: #fff; font-size: 2.1rem; max-width: 520px; }
.auth-hero ul { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.auth-hero li { display: flex; gap: .6rem; align-items: center; margin-bottom: .75rem; }
.auth-panel { display: grid; place-items: center; padding: 2rem; background: #fff; }
.auth-card { width: 100%; max-width: 400px; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .ep-sidebar { transform: translateX(-100%); }
    body.sidebar-open .ep-sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
    body.sidebar-open .ep-backdrop { display: block; }
    .ep-main { margin-left: 0; }
    .ep-menu-toggle { display: grid; }
    .ep-user-meta { display: none; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .kv { grid-template-columns: 1fr; }
}
.ep-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1035; }
@media (max-width: 575.98px) {
    .ep-content { padding: 1rem; }
    .ep-topbar { padding: 0 .75rem; }
    .ep-search { display: none; }
}
@media print {
    .ep-sidebar, .ep-topbar, .no-print { display: none !important; }
    .ep-main { margin: 0; }
}

/* ---------- AI invoice extraction & line-level matching ---------- */
.ai-filled { background: #f5f3ff !important; border-color: #a78bfa !important; }
.alert-ai { background: #f5f3ff; border: 1px solid #ddd6fe; color: #4c1d95; }
.badge-ai { display: inline-block; margin-left: .5rem; padding: .15rem .5rem; border-radius: 999px; background: #ede9fe; color: #5b21b6; font-size: .72rem; font-weight: 600; }
.match-table th.grp { border-bottom: 1px solid var(--ep-border); }
.match-table td.cell-bad { background: #fef2f2; color: var(--ep-danger); font-weight: 700; }
.match-table tr.row-bad > td { border-bottom: 0; }
.match-table tr.row-bad-detail > td { padding-top: 0; background: #fffafa; }
.match-issue { font-size: .82rem; color: #7f1d1d; margin: .15rem 0 .35rem; }

.validation-summary-valid { display: none !important; }
