:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --ink: #0f1412;
  --ink-2: #4a524e;
  --ink-3: #868d89;
  --line: #e7e5df;
  --line-2: #d3d0c8;
  --accent: #0b7a45;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ea;
  --warn: #8a5300;
  --warn-soft: #fbf0dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow: 0 1px 2px rgba(15, 20, 18, .04), 0 12px 32px -16px rgba(15, 20, 18, .18);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0f0e;
    --surface: #151a18;
    --ink: #eef1ef;
    --ink-2: #aeb6b1;
    --ink-3: #737c77;
    --line: #232a27;
    --line-2: #313a36;
    --accent: #2fbf74;
    --accent-ink: #04140b;
    --accent-soft: #10291b;
    --warn: #e7a74a;
    --warn-soft: #2a2010;
    --danger: #f2766b;
    --danger-soft: #2c1513;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.muted { color: var(--ink-2); margin: 0; }
.small { font-size: 13px; }
.center { text-align: center; }

.shell {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 16px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Merchant header */
.merchant { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.logo { color: var(--ink); flex: none; }
.merchant-name { font-weight: 650; }
.secure {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--ink-3); white-space: nowrap;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
}
@media (max-width: 380px) { .card { padding: 20px 16px; } }
.view.center { padding: 48px 0; }

.summary { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px dashed var(--line-2); }
.h1 { font-size: 17px; font-weight: 600; margin: 2px 0 10px; line-height: 1.35; overflow-wrap: anywhere; }
.h2 { font-size: 19px; font-weight: 650; margin: 14px 0 6px; letter-spacing: -.01em; }
.figure { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.figure .ccy { font-size: 16px; font-weight: 600; color: var(--ink-3); }
.figure .num { font-size: 38px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
#c-order { display: block; margin-top: 8px; }

/* Fields */
.field { display: block; margin-bottom: 14px; }
.label { display: block; font-size: 13px; font-weight: 550; color: var(--ink-2); margin-bottom: 6px; }
.input {
  display: flex; align-items: center;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.input input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  padding: 13px 14px; font-size: 17px; font-variant-numeric: tabular-nums;
}
.prefix { padding-left: 14px; color: var(--ink-3); font-size: 17px; font-variant-numeric: tabular-nums; }
.prefixed input { padding-left: 8px; letter-spacing: .02em; }
.field.invalid .input { border-color: var(--danger); }

.hint { font-size: 13px; color: var(--ink-3); text-align: center; margin: 12px 0 0; }

.alert {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  background: var(--warn-soft); color: var(--warn);
}
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--accent-soft); color: var(--accent); }

/* Buttons */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 12px 18px; font-weight: 600; font-size: 15px; cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, filter .15s, opacity .15s;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.block { width: 100%; padding: 14px 18px; }
.btn.block + .btn.block, .hint + .btn.block { margin-top: 10px; }
.btn:disabled { opacity: .65; cursor: progress; }
.btn.loading .btn-label { visibility: hidden; }
.btn.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.link { border: 0; background: none; padding: 4px 0; color: var(--accent); font-weight: 550; font-size: 14px; cursor: pointer; }
.link:disabled { color: var(--ink-3); cursor: default; font-weight: 500; }
.links { display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: wrap; }
.sep { width: 1px; height: 14px; background: var(--line-2); }

/* Pending */
.phone-icon {
  width: 72px; height: 72px; margin: 4px auto 0; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink); background: var(--bg); position: relative;
}
.phone-icon::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent); animation: ring 1.8s ease-out infinite;
}
.timer { margin: 20px 0 16px; }
.timer .bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.timer .bar span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transition: transform 1s linear; }
.timer small { display: block; margin-top: 8px; color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Paid / closed */
.tick {
  width: 56px; height: 56px; margin: 4px auto 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
}
.tick.off { background: var(--danger-soft); color: var(--danger); }
#s-paid .muted, #s-closed .muted { margin-bottom: 20px; }
.receipt { margin: 0 0 18px; border: 1px solid var(--line); border-radius: 12px; padding: 2px 14px; }
.receipt div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.receipt div:last-child { border-bottom: 0; }
.receipt dt { color: var(--ink-2); }
.receipt dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.spinner {
  display: inline-block; width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite;
  margin-bottom: 10px;
}

.foot {
  margin-top: auto; padding-top: 24px;
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-3);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ring { from { transform: scale(.9); opacity: .6; } to { transform: scale(1.35); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  body { background: #fff; color: #000; }
  .card { border: 0; box-shadow: none; }
  .btn, .hint, .secure { display: none !important; }
}

#p-phone, #p-amount { white-space: nowrap; }
@media (min-width: 640px) and (min-height: 760px) { .shell { padding-top: 7vh; } }
