:root {
  --bg: #0e1526;
  --card: #16203a;
  --card2: #1c2848;
  --line: #2a3a63;
  --text: #e8edf7;
  --muted: #93a3c4;
  --blue: #3b82f6;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans Lao", "Phetsarath OT", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #1b2a55 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

header {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 16, 32, 0.6);
  position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: 44px; height: 44px; background: #fff; border-radius: 10px; padding: 5px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.4px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
.chip.ok    { color: #86efac; border-color: #14532d; background: rgba(34,197,94,0.12); }
.chip.warn  { color: #fcd34d; border-color: #78350f; background: rgba(245,158,11,0.12); }
.chip.bad   { color: #fca5a5; border-color: #7f1d1d; background: rgba(239,68,68,0.12); }

main { max-width: 980px; margin: 26px auto 60px; padding: 0 20px; display: grid; gap: 20px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.card h2 { margin: 0 0 14px; font-size: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

button {
  font: inherit; cursor: pointer; border-radius: 10px;
  border: 1px solid transparent; padding: 10px 18px; font-weight: 600;
  background: var(--blue); color: #fff; transition: filter 0.15s;
}
button:hover { filter: brightness(1.12); }
button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
button.ghost:hover { background: var(--card2); }
button.danger { background: transparent; border-color: #7f1d1d; color: #fca5a5; }
button.small { padding: 6px 12px; font-size: 12px; }
button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

/* ── setup gate ── */
.gate {
  margin-top: 16px; padding: 14px 18px; max-width: 560px;
  background: rgba(245,158,11,0.08); border: 1px solid #78350f;
  border-radius: 12px;
}
.gate > p { margin: 0; font-size: 13px; }
.gate ul { margin: 10px 0; padding: 0; list-style: none; }
.gate li { font-size: 13px; color: var(--muted); margin: 5px 0; }
.gate li.ok { color: #86efac; }


input[type="number"], textarea {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #0d1428; color: var(--text);
}
input[type="number"] { max-width: 220px; font-size: 18px; }
textarea { font-family: ui-monospace, monospace; font-size: 12px; margin-top: 6px; }

/* ── setup ── */
details.setup summary {
  cursor: pointer; font-weight: 700; font-size: 16px; user-select: none;
}
details.setup[open] summary { margin-bottom: 16px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.step {
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px;
}
.step h3 { margin: 0 0 8px; font-size: 14px; color: #9db7ff; }
.step p { margin: 4px 0 10px; font-size: 13px; color: var(--muted); }
.merchant-info { font-size: 13px; margin-bottom: 10px; word-break: break-all; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.msg { font-size: 12px; color: var(--muted); }
.msg.error { color: #fca5a5; }

/* ── QR ── */
.qr-wrap { position: relative; display: inline-block; }
.qr-wrap img.qr {
  display: block; width: 100%; height: auto;
  background: #fff; border-radius: 14px; padding: 8px;
}
.qr-wrap .logo {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 24%; height: 24%;
  background: #fff; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.qr-wrap .logo img { width: 100%; height: 100%; object-fit: contain; padding: 12%; }
.qr-wrap.small { width: 190px; }
.qr-wrap.big   { width: 270px; }

.spinner {
  width: 34px; height: 34px; margin: 60px auto;
  border: 4px solid var(--line); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── pay ── */
.amount-row { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; }
.amount-row label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
#payResult { margin-top: 22px; }
.pay-grid { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-start; }
.pay-info { display: grid; gap: 10px; align-content: start; }
.pay-info .ref { font-size: 13px; color: var(--muted); }
.pay-info .ref code { color: var(--text); background: var(--card2); padding: 2px 8px; border-radius: 6px; }
.pay-info .amt { font-size: 30px; font-weight: 800; letter-spacing: 0.5px; }
.pill {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px; padding: 10px 16px; border-radius: 999px;
  width: fit-content;
}
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.pill.pending { color: #fcd34d; background: rgba(245,158,11,0.12); border: 1px solid #78350f; }
.pill.pending .dot { animation: blink 1.1s ease-in-out infinite; }
.pill.paid    { color: #86efac; background: rgba(34,197,94,0.14); border: 1px solid #14532d; font-size: 18px; }
.pill.expired { color: #cbd5e1; background: rgba(148,163,184,0.12); border: 1px solid #334155; }
@keyframes blink { 50% { opacity: 0.25; } }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.hidden { display: none !important; }

/* ── slip upload ── */
.slip-box {
  margin-top: 18px; padding: 14px 16px;
  background: var(--card2); border: 1px dashed var(--line);
  border-radius: 12px; max-width: 560px;
}
.slip-box p { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.slip-box input[type="file"] { font-size: 12.5px; color: var(--muted); }

/* ── selects / match bar ── */
select {
  font: inherit; font-size: 12.5px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #0d1428; color: var(--text);
  max-width: 340px;
}
#matchBar { margin: 10px 0 4px; align-items: center; }
td.actions { white-space: nowrap; }
td.actions button { margin-right: 6px; }


/* ── tables ── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.tbl td.empty { color: var(--muted); text-align: center; padding: 18px; }
.tag { padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 11px; }
.tag.PAID     { color: #86efac; background: rgba(34,197,94,0.15); }
.tag.PENDING  { color: #fcd34d; background: rgba(245,158,11,0.15); }
.tag.EXPIRED  { color: #cbd5e1; background: rgba(148,163,184,0.15); }
.tag.CANCELLED{ color: #fca5a5; background: rgba(239,68,68,0.15); }
.tag.pending  { color: #fcd34d; background: rgba(245,158,11,0.15); }
.tag.matched  { color: #86efac; background: rgba(34,197,94,0.15); }
.tag.ignored  { color: #cbd5e1; background: rgba(148,163,184,0.15); }
code.mono { font-size: 12px; }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }

