:root {
  --bg: #f4f6fa; --card: #ffffff; --ink: #131a29; --muted: #66708a; --line: #e2e6ef;
  --brand: #2f5bea; --brand-ink: #ffffff; --ok: #10894e; --ok-bg: #e4f6ec; --warn: #a86400; --warn-bg: #fdf1dc;
  --err: #c0322b; --err-bg: #fde9e7; --idle: #5b6479; --idle-bg: #eceff5; --info-bg: #e7edff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e121b; --card: #171c28; --ink: #e8ecf5; --muted: #8c96ad; --line: #283044;
    --brand: #6f8dff; --brand-ink: #0b1020; --ok: #4cd591; --ok-bg: #12301f; --warn: #f0b252; --warn-bg: #35280f;
    --err: #ff8078; --err-bg: #3a1917; --idle: #a2abc0; --idle-bg: #222938; --info-bg: #1a2447;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
body.jp { font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", Meiryo, system-ui, sans-serif; line-height: 1.7; }
body.jp h1 { line-height: 1.4; margin-bottom: 8px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.btn { display: inline-block; border: 0; border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); text-decoration: none; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: transparent; color: var(--err); border: 1px solid var(--line); font-weight: 500; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.block { display: block; width: 100%; text-align: center; padding: 14px; font-size: 16px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); font: inherit; }
textarea { font-family: var(--mono); font-size: 13px; min-height: 150px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
label .muted { font-weight: 400; }
.flash { padding: 10px 14px; border-radius: 9px; margin: 0 0 10px; font-size: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ready, .pill.pending { background: var(--info-bg); color: var(--brand); }
.pill.busy, .pill.confirming { background: var(--warn-bg); color: var(--warn); }
.pill.ok, .pill.paid, .pill.proven { background: var(--ok-bg); color: var(--ok); }
.pill.disabled, .pill.expired, .pill.untested { background: var(--idle-bg); color: var(--idle); }

/* ---------- trang khách ---------- */
.pay-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.pay-card { width: 100%; max-width: 420px; }
.pay-card .brand { font-weight: 700; font-size: 15px; color: var(--muted); margin-bottom: 18px; }
.pay-card .amount { font-size: 40px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 2px; }
.pay-card .secure { margin-top: 16px; font-size: 12.5px; color: var(--muted); text-align: center; }
.hp { position: absolute; left: -5000px; width: 1px; height: 1px; overflow: hidden; }
.state-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; margin-bottom: 14px; }
.state-icon.paid { background: var(--ok-bg); color: var(--ok); }
.state-icon.wait { background: var(--info-bg); color: var(--brand); }
.state-icon.expired { background: var(--idle-bg); color: var(--idle); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv span:first-child { color: var(--muted); }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- admin ---------- */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 4px; height: 54px; overflow-x: auto; }
.top .logo { font-weight: 700; margin-right: 14px; white-space: nowrap; }
.top a.nav { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.top a.nav:hover { text-decoration: none; color: var(--ink); }
.top a.nav.on { background: var(--info-bg); color: var(--brand); }
.top form { margin-left: auto; }
.page { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; animation: pulse 1.6s ease-in-out infinite; }
.live-dot.off { background: var(--err); animation: none; }
@keyframes pulse { 50% { opacity: .35; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--muted); }
.stat.good .n { color: var(--ok); }
.stat.alert { border-color: var(--err); }
.stat.alert .n { color: var(--err); }
.cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 560px; overflow-y: auto; }
.feed li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; display: flex; gap: 10px; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; padding-top: 1px; }
.feed li.order_paid { color: var(--ok); font-weight: 600; }
.feed li.pool_empty, .feed li.provider_warn, .feed li.offchain_funds, .feed li.ipn_reject, .feed li.gateway_error, .feed li.login_fail { color: var(--err); }
.feed li.order_confirming { color: var(--warn); }
.feed li.visit, .feed li.login { color: var(--muted); }
.feed li.new { animation: flashin 2.4s ease-out; }
@keyframes flashin { from { background: var(--info-bg); } to { background: transparent; } }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input[type=search] { width: 260px; max-width: 100%; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 18px; }
.pager { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.break { word-break: break-all; }

.pill.failed { background: var(--err-bg); color: var(--err); }

/* ================================================================
   STRIPE CHECKOUT 2026 — pixel-perfect với Stripe mới nhất
   Card trắng giữa trang, nền xám nhạt, nút xanh #0570DE
   ================================================================ */
.stripe-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: #f6f9fc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.stripe-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0px 2px 5px rgba(0,0,0,.07), 0px 1px 1px rgba(0,0,0,.03), 0px 0px 0px 1px rgba(0,0,0,.02);
  padding: 40px 36px 36px;
}

/* Header: lock icon + tên cửa hàng */
.stripe-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}
.stripe-lock {
  flex-shrink: 0;
  opacity: .65;
}
.stripe-merchant-name {
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  letter-spacing: .01em;
}

/* Tên sản phẩm */
.stripe-product-name {
  font-size: 20px;
  font-weight: 700;
  color: #1a1f36;
  margin: 0 0 6px;
  letter-spacing: -.01em;
  line-height: 1.3;
}

/* Giá */
.stripe-price-tag {
  font-size: 16px;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 0;
}

/* Divider */
.stripe-divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 24px 0;
}

/* Email field */
.stripe-field {
  margin-bottom: 20px;
}
.stripe-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 6px;
}
.stripe-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #1a1f36;
  font-size: 16px;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
  -webkit-appearance: none;
  appearance: none;
}
.stripe-input:focus {
  outline: none;
  border-color: #0570DE;
  box-shadow: 0 0 0 3px rgba(5,112,222,.15), 0 1px 2px rgba(0,0,0,.03);
}
.stripe-input::placeholder {
  color: #9ca3af;
}

/* Nút Pay — xanh Stripe #0570DE */
.stripe-pay-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  margin-top: 4px;
  background: #0570DE;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
  letter-spacing: .01em;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  -webkit-font-smoothing: antialiased;
}
.stripe-pay-btn:hover {
  background: #0059b8;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
.stripe-pay-btn:active {
  transform: scale(.99);
  background: #004a9e;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
}
.stripe-btn-lock {
  flex-shrink: 0;
}

/* Error */
.stripe-err {
  background: #fef2f2;
  color: #b91c1c;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
  border: 1px solid #fecaca;
  line-height: 1.5;
}

/* Terms text */
.stripe-terms {
  margin-top: 18px;
  font-size: 12.5px;
  color: #9ca3af;
  text-align: center;
  line-height: 1.6;
}
.stripe-terms a {
  color: #0570DE;
  text-decoration: none;
}
.stripe-terms a:hover {
  text-decoration: underline;
}

/* Powered by footer */
.stripe-powered {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: #bcc3d0;
  letter-spacing: .01em;
}
.stripe-powered strong {
  color: #9ca3af;
  font-weight: 600;
}

/* Spinner */
.stripe-spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 3px solid #e5e7eb;
  border-top-color: #0570DE;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive mobile */
@media (max-width: 480px) {
  .stripe-page {
    padding: 20px 12px;
    align-items: flex-start;
  }
  .stripe-card {
    padding: 28px 20px 24px;
    border-radius: 14px;
  }
  .stripe-product-name {
    font-size: 18px;
  }
  .stripe-price-tag {
    font-size: 15px;
  }
}
