:root {
  --primary: #4f6ef7;
  --primary-2: #675af9;
  --bg: #f7f9ff;
  --surface: rgba(255, 255, 255, 0.92);
  --text: #111827;
  --muted: #64748b;
  --border: #dbe3ef;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #ca8a04;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border), 0 4px 20px rgba(15, 23, 42, 0.07);
  display: flex;
  gap: 0;
  height: 62px;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { align-items: center; display: flex; gap: 11px; text-decoration: none; }
.brand img { display: block; height: 36px; width: auto; }
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name { color: var(--text); font-size: 14px; font-weight: 900; letter-spacing: -.01em; line-height: 1; }
.brand-sub { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
nav { align-items: center; display: flex; flex: 1; gap: 2px; margin-left: 28px; }
nav a { align-items: center; border-radius: 8px; color: var(--muted); display: flex; font-size: 13px; font-weight: 700; padding: 7px 13px; transition: background .15s, color .15s; }
nav a:hover { background: #f1f5f9; color: var(--text); }
nav a.nav-active { background: #eef2ff; color: var(--primary); }
.topbar-right { align-items: center; display: flex; gap: 10px; }
.user-chip { align-items: center; background: #f8fafc; border: 1px solid var(--border); border-radius: 999px; display: flex; gap: 8px; padding: 4px 12px 4px 4px; }
.user-avatar { align-items: center; background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-radius: 50%; color: #fff; display: flex; font-size: 11px; font-weight: 900; height: 26px; justify-content: center; width: 26px; flex-shrink: 0; }
.user-email { color: var(--text); font-size: 12px; font-weight: 700; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; padding: 7px 13px; text-decoration: none; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.logout-btn:hover { background: #fef2f2; border-color: #fca5a5; color: var(--danger); }
.page { padding: 28px; }
.signed-out-page { padding: 0; }

.login-bg {
  align-items: center;
  background:
    radial-gradient(ellipse 60% 40% at 18% 22%, rgba(103, 90, 249, 0.13), transparent 70%),
    radial-gradient(ellipse 50% 35% at 82% 78%, rgba(8, 202, 151, 0.11), transparent 65%),
    radial-gradient(ellipse 40% 30% at 70% 15%, rgba(139, 92, 246, 0.07), transparent 60%),
    linear-gradient(180deg, #f8f7ff 0%, #f2f4ff 50%, #edf7f4 100%);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  padding: 28px;
  position: relative;
}
.login-bg::before {
  background-image:
    linear-gradient(rgba(103, 90, 249, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 90, 249, 0.18) 1px, transparent 1px);
  background-size: 48px 48px;
  content: '';
  inset: 0;
  opacity: 0.75;
  pointer-events: none;
  position: absolute;
}
.login-bg::after {
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.92), transparent 22%),
    linear-gradient(32deg, transparent 38%, rgba(103, 90, 249, 0.06) 42%, rgba(103, 90, 249, 0.04) 44%, transparent 48%),
    linear-gradient(32deg, transparent 52%, rgba(8, 202, 151, 0.05) 56%, rgba(8, 202, 151, 0.03) 58%, transparent 62%);
  content: '';
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.login-card {
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(103, 90, 249, 0.14);
  border-radius: 22px;
  box-shadow: 0 32px 80px rgba(56, 45, 120, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.92), 0 0 0 1px rgba(103, 90, 249, 0.04);
  max-width: 430px;
  padding: 34px 32px;
  position: relative;
  width: 100%;
  z-index: 1;
}
.auth-logo-img { display: block; filter: drop-shadow(0 8px 18px rgba(56, 45, 120, 0.12)); height: auto; margin: 0 auto 24px; max-height: 72px; max-width: 260px; width: auto; }
.login-card h1 { font-size: 34px; letter-spacing: -0.04em; line-height: 1; margin: 0 0 8px; text-align: center; }
.login-card p { color: var(--muted); font-size: 18px; margin: 0 0 42px; text-align: center; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.06);
  padding: 24px;
}
h1, h2, h3 { margin-top: 0; }
h2 { color: var(--muted); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
p, .muted { color: var(--muted); }
label { color: #334155; display: block; font-size: 13px; font-weight: 800; margin: 18px 0 8px; }
input, select, textarea { background: #fff; border: 1px solid #cbd5e1; border-radius: 12px; color: #0f172a; font: inherit; padding: 13px 14px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.14); outline: none; }
button { background: var(--primary); border: 0; border-radius: 14px; color: white; cursor: pointer; font-size: 16px; font-weight: 900; margin-top: 20px; padding: 14px 16px; width: 100%; }
button:hover { background: #6b86fa; }
.small-btn { border-radius: 8px; font-size: 12px; margin: 0; padding: 7px 10px; width: auto; }
.inline-form { display: inline; }
.security-note, .flash, .warn { border-radius: 10px; margin-top: 18px; padding: 12px; }
.security-note, .secret-box { background: #f1f5ff; color: var(--primary); }
.flash.error, .warn { background: #fef2f2; color: #b91c1c; }
.flash.success { background: #dcfce7; color: #15803d; }
.flash.warning { background: #fef3c7; color: var(--warning); }

.layout { display: grid; gap: 24px; grid-template-columns: 380px 1fr; align-items: stretch; }
.admin-grid { display: grid; gap: 24px; grid-template-columns: 380px 1fr; margin-bottom: 24px; }
.row2, .grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.grid { grid-template-columns: repeat(4, 1fr); }
.grid div { background: #f8fafc; border-radius: 10px; padding: 12px; }
.grid span { color: var(--muted); display: block; font-size: 11px; }
.status { border-radius: 999px; display: inline-block; font-weight: 900; margin-bottom: 16px; padding: 6px 14px; text-transform: uppercase; }
.status.valid { background: #dcfce7; color: var(--success); }
.status.not_found, .status.date_fail { background: #fee2e2; color: var(--danger); }
.status.never_dialed, .status.partial_match { background: #fef3c7; color: var(--warning); }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; }
th { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 80px 20px; text-align: center; }
.checkbox { align-items: center; display: flex; gap: 8px; }
.checkbox input { width: auto; }
.qr-box { background: white; border: 1px solid var(--border); border-radius: 18px; display: flex; justify-content: center; margin: 0 auto 18px; padding: 16px; width: fit-content; }
.secret-box { border-radius: 12px; margin: 18px 0; padding: 12px; }
.secret-box span { color: var(--muted); display: block; font-size: 12px; font-weight: 800; margin-bottom: 6px; text-transform: uppercase; }
.secret-box code { color: var(--text); word-break: break-all; }

/* ── Batch upload ─────────────────────────────────────────────────────── */
.batch-wrap { display: flex; flex-direction: column; gap: 24px; }
.batch-upload-panel { max-width: 780px; }
.batch-form { margin-bottom: 28px; }

.file-drop-area { border: 2px dashed var(--border); border-radius: 14px; cursor: pointer; margin-top: 8px; padding: 28px 20px; position: relative; text-align: center; transition: border-color .15s, background .15s; }
.file-drop-area:hover { background: #f1f5ff; border-color: var(--primary); }
.file-input { height: 100%; left: 0; opacity: 0; position: absolute; top: 0; width: 100%; }
.file-label { cursor: pointer; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.file-icon { color: var(--primary); font-size: 32px; line-height: 1; }
.file-text { font-size: 14px; font-weight: 700; }
.file-hint { color: var(--muted); font-size: 12px; }
.file-chosen { color: var(--primary); display: block; font-size: 13px; font-weight: 700; margin-top: 6px; }

.csv-sample { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; margin-top: 24px; padding: 16px; }
.csv-sample > span { color: var(--muted); display: block; font-size: 11px; font-weight: 800; letter-spacing: .08em; margin-bottom: 10px; text-transform: uppercase; }
.csv-pre { background: #fff; border: 1px solid var(--border); border-radius: 8px; font-family: monospace; font-size: 12px; margin: 12px 0 0; overflow-x: auto; padding: 12px; white-space: pre; }
.sample-table th, .sample-table td { font-size: 12px; padding: 7px 10px; }
.sample-table td code { background: #eef2ff; border-radius: 4px; color: var(--primary); font-size: 11px; padding: 2px 6px; }

.batch-results-wrap { display: flex; flex-direction: column; gap: 18px; }

.batch-summary { align-items: center; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; padding: 18px 24px; }
.summary-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-pill { border-radius: 10px; min-width: 72px; padding: 10px 14px; text-align: center; }
.stat-pill span { color: inherit; display: block; font-size: 10px; font-weight: 800; letter-spacing: .06em; opacity: .75; text-transform: uppercase; }
.stat-pill strong { display: block; font-size: 22px; font-weight: 900; line-height: 1.1; }
.stat-pill.total { background: #f1f5f9; color: var(--text); }
.stat-pill.valid { background: #dcfce7; color: var(--success); }
.stat-pill.never_dialed, .stat-pill.partial_match, .stat-pill.date_fail { background: #fef3c7; color: var(--warning); }
.stat-pill.not_found { background: #fee2e2; color: var(--danger); }
.stat-pill.error { background: #fee2e2; color: var(--danger); }

.btn-download { background: var(--primary); border-radius: 12px; color: white; font-size: 14px; font-weight: 800; padding: 12px 20px; text-decoration: none; white-space: nowrap; }
.btn-download:hover { background: #6b86fa; }

.batch-table-panel { padding: 24px; }
.table-scroll { overflow-x: auto; }
.batch-table { font-size: 13px; min-width: 720px; }
.batch-table th { font-size: 11px; white-space: nowrap; padding: 12px 16px; }
.batch-table td { vertical-align: middle; white-space: nowrap; padding: 14px 16px; }
.batch-table .status { font-size: 10px; padding: 3px 8px; margin-bottom: 0; }

/* Pagination — Primer-style connected single-line bar */
.pagination { align-items: center; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 0; justify-content: center; padding: 14px 0 2px; }
.pg-btn { align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 0; color: var(--text); cursor: pointer; display: inline-flex; font-size: 13px; font-weight: 500; height: 32px; justify-content: center; margin: 0 0 0 -1px; min-width: 32px; padding: 0 12px; position: relative; transition: background .12s, color .12s; width: auto; z-index: 0; }
.pg-btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.pg-btn:last-of-type { border-radius: 0 6px 6px 0; }
.pg-btn:hover:not(:disabled):not(.active) { background: #f0f3ff; color: var(--primary); z-index: 2; }
.pg-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; z-index: 1; }
.pg-btn:disabled { background: #f6f8fa; color: #bbb; cursor: default; }
.pg-ellipsis { align-items: center; background: #fff; border: 1px solid var(--border); color: var(--muted); display: inline-flex; font-size: 13px; height: 32px; justify-content: center; margin-left: -1px; min-width: 32px; padding: 0 8px; }
.pg-count { color: var(--muted); font-size: 12px; margin-left: 12px; }
.audit-table .status { font-size: 11px; margin-bottom: 0; padding: 3px 9px; }
.note-col { max-width: 220px; white-space: normal; }
.row-error { color: var(--danger); font-size: 12px; }
.row-warn { color: var(--warning); font-size: 12px; }

/* Batch right-panel layout */
.batch-right-panel { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.batch-right-header { align-items: center; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; margin-bottom: 20px; flex-shrink: 0; }
.batch-polling { align-items: center; display: flex; flex: 1; justify-content: center; }
.table-scroll { overflow-x: auto; }

/* Button spinner (inline, replaces label text) */
.btn-spin { animation: spin 0.7s linear infinite; border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; display: inline-block; height: 16px; width: 16px; vertical-align: middle; }

/* Inline loading card — sits in the results area, upload panel stays usable */
.batch-loading-panel { align-items: center; display: flex; justify-content: center; min-height: 180px; }
.batch-loading-spinner { animation: spin 0.75s linear infinite; border: 3px solid rgba(255,255,255,0.08); border-top-color: #7c86fa; border-radius: 50%; height: 40px; width: 40px; }

/* Results fade-in */
.results-ready { animation: fadeUp 0.35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Finmo enrichment panel (kept for reference) */
.finmo-panel { margin-top: 16px; padding: 24px; }
.finmo-panel h2 { align-items: center; display: flex; gap: 10px; }
.finmo-badge { background: rgba(124,195,126,0.18); border: 1px solid rgba(124,195,126,0.4); border-radius: 20px; color: #7cc37e; font-size: 11px; font-weight: 700; padding: 3px 10px; }
.finmo-badge.pending { background: rgba(255,193,7,0.15); border-color: rgba(255,193,7,0.4); color: #ffc107; }
.finmo-pending p { color: var(--muted); font-size: 13px; }
.btn-reload { background: transparent; border: 1px solid rgba(124,195,126,0.4); border-radius: 8px; color: #7cc37e; cursor: pointer; font-size: 13px; padding: 8px 16px; transition: background .2s; }
.btn-reload:hover { background: rgba(124,195,126,0.12); }
.finmo-pending-panel { margin-top: 16px; padding: 32px 24px; }
.finmo-pending-inner { align-items: center; display: flex; gap: 20px; }
.finmo-pending-inner h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.finmo-spinner { animation: spin 1s linear infinite; border: 3px solid rgba(255,255,255,0.1); border-top-color: #7c86fa; border-radius: 50%; flex-shrink: 0; height: 36px; width: 36px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Error pages */
.error-page { align-items: center; display: flex; flex-direction: column; justify-content: center; min-height: 60vh; text-align: center; gap: 12px; }
.error-code { color: var(--primary); font-size: 96px; font-weight: 800; line-height: 1; opacity: 0.15; }
.error-title { font-size: 24px; font-weight: 700; margin: 0; }
.error-desc { color: var(--muted); font-size: 15px; margin: 0; max-width: 420px; }
.btn-primary { background: var(--primary); border-radius: 8px; color: #fff; font-size: 14px; font-weight: 600; padding: 10px 24px; text-decoration: none; }
.btn-primary:hover { background: var(--primary-2); }

@media (max-width: 900px) { .layout, .admin-grid, .grid, .row2 { grid-template-columns: 1fr; } .topbar { align-items: flex-start; flex-direction: column; gap: 12px; } .batch-summary { flex-direction: column; align-items: flex-start; } }

/* ── Evidence card (single lookup result) ─────────────────────────────── */
.ec-loading { align-items: center; display: flex; flex-direction: column; gap: 16px; justify-content: center; min-height: 200px; }
.ec-loading p { color: var(--muted); font-size: 14px; margin: 0; }
.ec-spinner { animation: spin 0.85s linear infinite; border: 3px solid rgba(79,110,247,0.15); border-top-color: var(--primary); border-radius: 50%; height: 36px; width: 36px; }

.ec-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; gap: 0; overflow: hidden; }

.ec-header { align-items: center; display: flex; justify-content: space-between; padding: 18px 20px 14px; }
.ec-verdict { border-radius: 8px; font-size: 13px; font-weight: 600; padding: 6px 14px; }
.ec-found  { background: #d1fae5; color: #065f46; }
.ec-nob    { background: #fee2e2; color: #991b1b; }
.ec-never  { background: #fef3c7; color: #92400e; }
.ec-other  { background: #f1f5f9; color: var(--muted); }
.ec-complaint-date { color: var(--muted); font-size: 13px; }

.ec-borrower { align-items: center; display: flex; gap: 14px; padding: 6px 20px 18px; }
.ec-avatar { align-items: center; background: #dbeafe; border-radius: 50%; color: #1d4ed8; display: flex; flex-shrink: 0; font-size: 14px; font-weight: 800; height: 44px; justify-content: center; width: 44px; }
.ec-name { font-size: 17px; font-weight: 700; line-height: 1.2; }
.ec-org-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.ec-grid { border-top: 1px solid var(--border); display: grid; gap: 1px; grid-template-columns: 1fr 1fr; }
.ec-cell { background: #f8fafc; padding: 16px 20px; }
.ec-cell:nth-child(odd) { border-right: 1px solid var(--border); }
.ec-cell + .ec-cell:nth-child(3) { border-top: 1px solid var(--border); }
.ec-cell + .ec-cell:nth-child(4) { border-top: 1px solid var(--border); }
.ec-cell span { color: var(--muted); display: block; font-size: 10px; font-weight: 800; letter-spacing: .08em; margin-bottom: 6px; text-transform: uppercase; }
.ec-cell strong { color: var(--text); font-size: 14px; font-weight: 600; }

.ec-footer-note { align-items: center; border-top: 1px solid var(--border); color: var(--muted); display: flex; font-size: 13px; gap: 8px; padding: 14px 20px; }
.ec-checkbox-icon { color: var(--muted); font-size: 16px; line-height: 1; }

.ec-download-btn { background: var(--primary); border-radius: 10px; color: #fff; display: block; font-size: 13px; font-weight: 700; margin: 0 20px 20px; padding: 11px 18px; text-align: center; text-decoration: none; transition: background .15s; }
.ec-download-btn:hover { background: var(--primary-2); color: #fff; }

@media print {
  .topbar, .panel:first-child, .ec-print-btn, .ec-footer-note { display: none !important; }
  .layout { display: block; }
  .ec-card { border: none; box-shadow: none; }
}
