:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2128;
  --text-muted: #6b7280;
  --brand: #2f5fda;
  --brand-dark: #24469f;
  --brand-bg: #eaf0ff;
  --ok: #157a4a;
  --ok-bg: #e5f6ec;
  --warn: #a15c00;
  --warn-bg: #fff2df;
  --danger: #b3261e;
  --danger-bg: #fbe7e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
}

.brand-text { font-weight: 650; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 550;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  font-size: 13.5px;
  width: 100%;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--brand-bg); color: var(--brand-dark); }
.nav-item .icon { width: 16px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 6px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.fixture-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 100px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
}

.fixture-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.logout-link {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}

.logout-link:hover { color: var(--danger); }

/* ---------- Main ---------- */

.main { padding: 26px 32px 60px; max-width: 1180px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
}

.page-title { font-size: 20px; font-weight: 650; margin: 0 0 4px; }
.page-desc { color: var(--text-muted); font-size: 13px; margin: 0; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { border-color: #c7cbd3; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- KPI cards ---------- */

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

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 550; margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 650; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Panels / tables ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

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

.panel-title { font-weight: 600; font-size: 14px; }

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

th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.report-name { font-weight: 600; }
.report-meta { font-size: 12px; color: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-neutral { background: var(--bg); color: var(--text-muted); }

.link-btn {
  background: none;
  border: none;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

/* ---------- Upload zone ---------- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--brand);
  background: var(--brand-bg);
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--brand-bg);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 20px;
}

.dropzone-title { font-weight: 600; margin-bottom: 4px; }
.dropzone-sub { color: var(--text-muted); font-size: 12.5px; }
.dropzone input[type=file] { display: none; }

.upload-queue { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }

.upload-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.upload-item .name { font-weight: 550; flex: 1; font-size: 13px; }
.upload-item .status { font-size: 12px; color: var(--text-muted); }

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

.progress-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 100px;
  transition: width 0.2s;
}

/* ---------- Review panel ---------- */

.review-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

select, .select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.merchant-group { margin-bottom: 14px; }

.merchant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.merchant-name { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.merchant-count { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.merchant-total { font-weight: 600; font-size: 13.5px; }

.txn-desc { color: var(--text-muted); font-size: 12px; }

.confidence-bar {
  width: 54px;
  height: 5px;
  border-radius: 100px;
  background: var(--bg);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.confidence-fill { height: 100%; border-radius: 100px; }

.cat-select { min-width: 190px; }

.amount { font-variant-numeric: tabular-nums; font-weight: 550; }
.amount.neg { color: var(--danger); }
.amount.pos { color: var(--ok); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.hidden { display: none !important; }

.view { display: none; }
.view.active { display: block; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Login ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(560px circle at 15% 8%, var(--brand-bg), transparent 60%),
    radial-gradient(560px circle at 85% 95%, var(--brand-bg), transparent 60%),
    var(--bg);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 368px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 2px 4px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.10);
  padding: 32px 28px 26px;
  animation: login-card-in 0.35s ease both;
}

@keyframes login-card-in {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand { justify-content: center; margin-bottom: 24px; }
.login-brand .brand-mark { width: 34px; height: 34px; font-size: 14px; }
.login-brand .brand-text { font-size: 15px; }

.login-error[hidden] { display: none; }

.login-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.4;
  margin-bottom: 16px;
  animation: login-error-in 0.18s ease both;
}

.login-error::before {
  content: "!";
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

@keyframes login-error-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-form { display: flex; flex-direction: column; gap: 4px; }

.login-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 14px;
  margin-bottom: 5px;
}

.login-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}

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

.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 22px;
  padding: 11px;
  font-size: 14px;
  position: relative;
}

.login-submit:disabled { opacity: 0.75; cursor: default; }

.login-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  animation: login-spin 0.6s linear infinite;
}

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

.login-note {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}
