:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --gray: #6b7280;
  --gray-soft: #f3f4f6;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.brand .dot { color: var(--accent); }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  text-decoration: none; color: var(--muted); font-size: 14px;
  padding: 6px 12px; border-radius: 8px;
}
.nav a:hover { background: var(--gray-soft); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.spacer { flex: 1; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

/* ---- Cards ---- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.card .count { font-size: 24px; font-weight: 700; margin: 6px 0 2px; }
.card .amount { font-size: 13px; color: var(--muted); }
.card.accent .count { color: var(--accent); }
.card.green .count { color: var(--green); }
.card.amber .count { color: var(--amber); }
.card.red .count { color: var(--red); }

/* ---- Toolbar ---- */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px;
}
.toolbar input[type=search], .toolbar select {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: var(--text);
}
.toolbar input[type=search] { min-width: 220px; flex: 1; }
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 9px 14px; border-radius: 10px;
}
.btn:hover { background: var(--gray-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---- Table ---- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .3px;
  color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
.num { font-variant-numeric: tabular-nums; }

/* ---- Badges ---- */
.badge {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.badge.PAID { background: var(--green-soft); color: var(--green); }
.badge.PENDING { background: var(--amber-soft); color: var(--amber); }
.badge.EXPIRED { background: var(--red-soft); color: var(--red); }
.badge.FAILED { background: var(--gray-soft); color: var(--gray); }
.wa-yes { color: var(--green); font-weight: 600; }
.wa-no { color: var(--muted); }
.link { color: var(--accent); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; }
.pagination .info { color: var(--muted); font-size: 13px; }

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

/* ---- Upload page ---- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 40px 20px; text-align: center; color: var(--muted); transition: .15s;
  cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone strong { color: var(--text); }
.dropzone .file { margin-top: 12px; font-size: 14px; color: var(--text); font-weight: 600; }

.steps { display: grid; gap: 16px; grid-template-columns: 1fr; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.panel h3 { margin: 0 0 4px; font-size: 15px; }
.panel p.hint { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

.result-summary { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.result-summary .pill { font-size: 14px; }
.result-summary b { font-size: 18px; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

/* ---- Login modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 50;
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.2);
  padding: 26px; width: 90%; max-width: 340px;
}
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.modal input {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
}
.modal .err { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.modal .btn { width: 100%; margin-top: 14px; }
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 460px) {
  .cards { grid-template-columns: 1fr; }
  .nav a { padding: 6px 9px; }
}
