/* StreetPay
   Two very different surfaces in one stylesheet:
   - the PUBLIC payment page, which is used outdoors, in sunlight, at arm's
     length, often on a cheap phone. Big type, huge tap targets, maximum
     contrast, no thin greys.
   - the OPERATOR workspace, which is used at a desk and can be denser.
*/

:root {
  --ink: #0b1220;
  --ink-2: #1c2637;
  --muted: #5b6880;
  --line: #dde3ec;
  --bg: #f4f6fa;
  --card: #ffffff;

  /* Brand, taken from the StreetPay logo. */
  --brand: #013c44;
  --brand-dark: #002a30;
  --brand-tint: #e6f1f2;

  /* The logo's green. Bright enough to be a graphic accent, far too light to
     be text on white — it is never used for type on a light background. */
  --accent: #57f48d;
  --accent-tint: #e9fcf1;

  --good: #15803d;
  --good-tint: #e8f6ed;
  --warn: #b45309;
  --warn-tint: #fdf2e3;
  --bad: #b91c1c;
  --bad-tint: #fdeceb;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(11, 18, 32, 0.06), 0 8px 24px rgba(11, 18, 32, 0.08);
  --shadow-lg: 0 24px 64px rgba(11, 18, 32, 0.22);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================ PUBLIC PAY */

.pay-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 40px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand) 190px, var(--bg) 190px);
}

.pay-brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; letter-spacing: -0.02em;
  margin-bottom: 18px; align-self: flex-start;
}
.pay-brand img { height: 38px; width: auto; display: block; }

.pay-card {
  width: 100%; max-width: 460px; min-width: 0;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0 0 24px;
  overflow: hidden;
}

.partner-head { padding: 24px 24px 20px; text-align: center; border-bottom: 1px solid var(--line); }

.partner-photo {
  width: 104px; height: 104px; border-radius: 50%;
  object-fit: cover; display: block; margin: 0 auto 14px;
  border: 4px solid #fff; box-shadow: 0 4px 14px rgba(11,18,32,.16);
  background: var(--brand-tint);
}
.partner-photo-fallback {
  width: 104px; height: 104px; border-radius: 50%;
  margin: 0 auto 14px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand);
  font-size: 38px; font-weight: 700;
  border: 4px solid #fff; box-shadow: 0 4px 14px rgba(11,18,32,.16);
}

.partner-name { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; margin: 0 0 8px; }

.partner-cat {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-tint); color: var(--brand-dark);
  padding: 5px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
}

.pay-body { padding: 22px 24px 0; }

.field-label {
  display: block; font-size: 15px; font-weight: 650;
  color: var(--muted); margin-bottom: 8px;
}

.amount-wrap { position: relative; margin-bottom: 14px; }
.amount-prefix {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  font-size: 32px; font-weight: 700; color: var(--muted); pointer-events: none;
}
.amount-input {
  width: 100%; padding: 16px 18px 16px 48px;
  font-size: 34px; font-weight: 700; letter-spacing: -0.02em;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: #fff; outline: none;
}
.amount-input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--accent-tint); }
.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-input[type=number] { -moz-appearance: textfield; }

/* min-width:0 on both the tracks and the buttons is load-bearing. Grid items
   default to min-width:auto, so without it the widest label ("R50.00") sets a
   floor that pushes the whole card wider than a phone screen. */
.quick-amounts {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px; margin-bottom: 18px;
}
.quick-amount {
  min-width: 0; padding: 12px 2px; border: 2px solid var(--line); background: #fff;
  border-radius: 12px; font-weight: 700; font-size: 15px; color: var(--ink);
  transition: border-color .12s, background .12s;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.quick-amount:hover { border-color: var(--brand); }
.quick-amount[aria-pressed='true'] { border-color: var(--brand); background: var(--accent-tint); color: var(--brand); }

.split-note {
  background: var(--bg); border-radius: 12px; padding: 12px 14px;
  font-size: 14px; color: var(--muted); margin-bottom: 18px; line-height: 1.5;
}
.split-note strong { color: var(--ink); }

.btn-pay {
  width: 100%; padding: 18px; border: 0; border-radius: var(--radius);
  background: var(--brand); color: #fff; font-size: 19px; font-weight: 700;
  letter-spacing: -0.01em; box-shadow: 0 6px 16px rgba(1,60,68,.26);
  transition: background .12s, transform .06s;
}
.btn-pay:hover:not(:disabled) { background: var(--brand-dark); }
.btn-pay:active:not(:disabled) { transform: translateY(1px); }
.btn-pay:disabled { background: #a9b4c4; box-shadow: none; cursor: not-allowed; }

.lang-row { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }
.lang-btn {
  padding: 8px 16px; border: 1.5px solid var(--line); background: #fff;
  border-radius: 999px; font-size: 14px; font-weight: 650; color: var(--muted);
}
.lang-btn[aria-pressed='true'] { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-dark); }

.pay-foot { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; max-width: 460px; line-height: 1.55; }

.alert {
  border-radius: 12px; padding: 14px 16px; font-size: 15px;
  line-height: 1.5; margin-bottom: 16px;
}
.alert-bad { background: var(--bad-tint); color: var(--bad); border: 1px solid #f3c9c6; }
.alert-warn { background: var(--warn-tint); color: var(--warn); border: 1px solid #f0dcbc; }

/* ============================================================ SUCCESS POPUP */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 18, 32, 0.55);
  display: grid; place-items: center; padding: 20px; z-index: 100;
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px; overflow: hidden;
  animation: pop .24s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: translateY(14px) scale(.96); opacity: 0 } to { transform: none; opacity: 1 } }

.modal-head { padding: 30px 24px 22px; text-align: center; background: var(--good-tint); }

.tick {
  width: 72px; height: 72px; border-radius: 50%; background: var(--good);
  display: grid; place-items: center; margin: 0 auto 16px;
  animation: tickIn .35s cubic-bezier(.2,.9,.3,1.4) .08s both;
}
@keyframes tickIn { from { transform: scale(.3); opacity: 0 } to { transform: none; opacity: 1 } }
.tick svg { width: 38px; height: 38px; stroke: #fff; stroke-width: 3.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round; }

.modal-title { font-size: 24px; font-weight: 750; margin: 0 0 6px; color: var(--good); letter-spacing: -0.02em; }
.modal-sub { font-size: 15px; color: var(--ink-2); margin: 0; }

.modal-body { padding: 22px 24px 24px; }

.receipt-partner { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.receipt-partner img, .receipt-partner .rp-fallback {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none;
}
.receipt-partner .rp-fallback {
  background: var(--brand-tint); color: var(--brand); display: grid;
  place-items: center; font-weight: 700; font-size: 18px;
}
.receipt-partner-name { font-weight: 700; font-size: 17px; }
.receipt-partner-cat { font-size: 14px; color: var(--muted); }

.receipt-rows { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.receipt-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 14px; font-size: 15px; border-bottom: 1px solid var(--line);
}
.receipt-row:last-child { border-bottom: 0; }
.receipt-row.total { background: var(--bg); font-weight: 700; font-size: 17px; }
.receipt-row .label { color: var(--muted); }
.receipt-row.total .label { color: var(--ink); }
.receipt-row .value { font-weight: 650; font-variant-numeric: tabular-nums; }

.receipt-ref {
  text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em;
}

.btn-done {
  width: 100%; padding: 16px; border: 0; border-radius: var(--radius);
  background: var(--ink); color: #fff; font-size: 17px; font-weight: 700;
}
.btn-done:hover { background: var(--ink-2); }

/* ============================================================== OPERATOR */

.op-shell { display: flex; min-height: 100dvh; }

.op-nav {
  width: 232px; flex: none; background: var(--ink); color: #fff;
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
}
.op-brand { display: flex; align-items: center; gap: 9px; padding: 6px 8px 20px; font-weight: 750; }
.op-brand img { height: 32px; width: auto; display: block; }

.op-nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; border: 0; border-radius: 10px; text-align: left;
  background: transparent; color: #aab6c8; font-size: 15px; font-weight: 600;
}
.op-nav-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.op-nav-btn[aria-current='true'] { background: var(--brand); color: #fff; }
.op-nav-spacer { flex: 1; }
.op-nav-foot { font-size: 12px; color: #6b7a91; padding: 10px 10px 0; line-height: 1.5; }

.op-main { flex: 1; padding: 30px 34px 60px; min-width: 0; }
.op-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.op-title { font-size: 27px; font-weight: 750; letter-spacing: -0.025em; margin: 0 0 5px; }
.op-subtitle { color: var(--muted); font-size: 15px; margin: 0; }

.btn {
  padding: 10px 16px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; font-weight: 650; font-size: 15px; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--bad); border-color: #f0c9c6; }
.btn-danger:hover { background: var(--bad-tint); }
.btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px;
}
.stat-label { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.stat-value { font-size: 27px; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
.stat.accent { border-color: var(--brand); background: var(--brand-tint); }
.stat.warn { border-color: #f0dcbc; background: var(--warn-tint); }
.stat.warn .stat-value, .stat.warn .stat-label { color: var(--warn); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #e9edf4; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  padding: 7px 14px; border: 0; background: transparent; border-radius: 8px;
  font-size: 14px; font-weight: 650; color: var(--muted);
}
.seg button[aria-pressed='true'] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(11,18,32,.1); }

.input, .select {
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 15px; outline: none; width: 100%;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

.partner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.pcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.pcard-top { display: flex; gap: 12px; align-items: flex-start; }
.pcard-photo, .pcard-fallback { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex: none; }
.pcard-fallback { background: var(--brand-tint); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.pcard-name { font-weight: 700; font-size: 16px; margin-bottom: 3px; }
.pcard-meta { font-size: 13px; color: var(--muted); }
.pcard-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill-active { background: var(--good-tint); color: var(--good); }
.pill-paused { background: var(--warn-tint); color: var(--warn); }
.pill-flagged { background: var(--warn-tint); color: var(--warn); }
.pill-blocked { background: var(--bad-tint); color: var(--bad); }
.pill-paid { background: var(--good-tint); color: var(--good); }
.pill-pending { background: #e9edf4; color: var(--muted); }
.pill-refunded { background: var(--warn-tint); color: var(--warn); }
.pill-failed { background: var(--bad-tint); color: var(--bad); }
.pill-cancelled { background: #e9edf4; color: var(--muted); }
.pill-sent { background: var(--good-tint); color: var(--good); }

.owed { font-size: 13px; color: var(--muted); }
.owed strong { color: var(--brand-dark); font-size: 15px; }

table.tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.tbl th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 12px 14px;
  border-bottom: 1px solid var(--line); background: #fbfcfe; white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--ink); margin: 0 0 8px; font-size: 18px; }
.empty p { margin: 0 auto; max-width: 380px; line-height: 1.6; }

/* Lanyard card preview */
.lanyard-stage { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-start; }
.lanyard {
  width: 320px; flex: none; border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow); background: #fff; border: 1px solid var(--line);
}
.lanyard-head { background: var(--brand); color: #fff; padding: 16px; text-align: center; }
.lanyard-head img { height: 34px; width: auto; display: block; margin: 0 auto; }
.lanyard-body { padding: 18px; text-align: center; }
.lanyard-photo, .lanyard-fallback {
  width: 84px; height: 84px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 10px; display: block; border: 3px solid var(--brand-tint);
}
.lanyard-fallback { background: var(--brand-tint); color: var(--brand); display: grid; place-items: center; font-size: 30px; font-weight: 700; }
.lanyard-name { font-size: 19px; font-weight: 750; margin-bottom: 3px; }
.lanyard-cat { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.lanyard-qr { width: 180px; height: 180px; margin: 0 auto 10px; }
.lanyard-qr svg { width: 100%; height: 100%; display: block; }
.lanyard-tap { font-size: 13px; font-weight: 750; color: var(--brand); letter-spacing: .03em; }

.side-panel { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.panel h4 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.panel p { margin: 0 0 12px; font-size: 14px; color: var(--muted); line-height: 1.55; }
.panel .row { display: flex; gap: 8px; flex-wrap: wrap; }

.nfc-status { font-size: 14px; padding: 10px 12px; border-radius: 10px; margin-top: 10px; line-height: 1.5; }
.nfc-idle { background: var(--bg); color: var(--muted); }
.nfc-waiting { background: var(--brand-tint); color: var(--brand-dark); font-weight: 650; }
.nfc-ok { background: var(--good-tint); color: var(--good); font-weight: 650; }
.nfc-err { background: var(--bad-tint); color: var(--bad); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 650; margin-bottom: 6px; }
.field .help { font-size: 13px; color: var(--muted); margin-top: 5px; line-height: 1.5; }

.photo-drop {
  border: 2px dashed var(--line); border-radius: 12px; padding: 20px; text-align: center;
  color: var(--muted); font-size: 14px; cursor: pointer; background: #fbfcfe;
}
.photo-drop:hover { border-color: var(--brand); background: var(--brand-tint); }
.photo-preview { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px; display: block; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 12px;
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 200;
  animation: pop .2s ease-out; max-width: 90vw;
}
.toast.bad { background: var(--bad); }
.toast.good { background: var(--good); }

.spinner {
  width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg) } }

.center-note { text-align: center; padding: 60px 20px; color: var(--muted); }

@media (max-width: 860px) {
  .op-shell { flex-direction: column; }
  .op-nav { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; gap: 6px; align-items: center; }
  .op-brand { padding: 0 10px 0 6px; }
  .op-nav-spacer, .op-nav-foot { display: none; }
  .op-nav-btn { width: auto; white-space: nowrap; }
  .op-main { padding: 20px 16px 50px; }
}

@media print {
  body * { visibility: hidden; }
  .lanyard, .lanyard * { visibility: visible; }
  .lanyard { position: absolute; left: 0; top: 0; box-shadow: none; border: 1px solid #999; }
}
