:root {
    --primary: #1a4d8f;
    --primary-soft: #e7f0fb;
    --border: #e5e7eb;
    --muted: #6b7280;
    --bg: #f3f4f6;
    --ok: #166534;
    --err: #991b1b;
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: #111827;
    min-height: 100vh;
}

.card {
    max-width: 460px;
    margin: 2rem auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .08);
    overflow: hidden;
}

.card-head {
    padding: 1.5rem 1.5rem .75rem;
    border-bottom: 1px solid var(--border);
}
.card-head h1 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--primary);
}
.muted { color: var(--muted); font-size: .85rem; margin: .25rem 0 0; }

/* ── Order summary ─────────────────────────────────────────────────── */
.summary { padding: 1rem 1.5rem; }
.line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .45rem 0;
    font-size: .95rem;
}
.line + .line { border-top: 1px dashed var(--border); }
.line.total {
    margin-top: .5rem;
    padding-top: .65rem;
    border-top: 2px solid var(--border);
    font-size: 1.15rem;
}

/* ── Apple Pay button — official spec ──────────────────────────────── */
.pay { padding: 0 1.5rem 1.25rem; }

/* Default rendering = native Apple Pay button. Only Safari understands
   `-apple-pay-button` as a value for -webkit-appearance; every other
   browser ignores it and would otherwise paint an invisible button. The
   `.forced` modifier below replaces the native paint with a styled
   fallback so the button is visible on Chrome / Firefox / Edge during
   the demo. */
.apple-pay-button {
    display: block;
    width: 100%;
    min-height: 48px;
    -webkit-appearance: -apple-pay-button;
    -apple-pay-button-type: pay;        /* values: plain, buy, pay, donate, … */
    -apple-pay-button-style: black;     /* values: black, white, white-outline */
    border: 0;
    cursor: pointer;
    border-radius: 8px;
    background: transparent;
    color: transparent;                 /* hides the <span> on Safari */
}
.apple-pay-button:active { transform: scale(.99); }

/* The forced fallback — applied by JS when FORCE_APPLE_PAY is on AND
   the browser doesn't have native Apple Pay. Paints a black button
   with the Apple logo + "Pay" label so it actually shows up on
   Chrome / Firefox / Edge / Linux / Windows. */
.apple-pay-button.forced {
    -webkit-appearance: none;
    appearance: none;
    background: #000;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -.01em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
}
.apple-pay-button.forced::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 22px;
    background: no-repeat center/contain url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512' fill='white'><path d='M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z'/></svg>");
}
.apple-pay-button.forced .apple-pay-fallback-label { display: inline; }

/* Fallback "Use another card" shown when Apple Pay is unavailable */
.fallback-button {
    display: block;
    width: 100%;
    margin-top: .75rem;
    padding: .85rem 1rem;
    background: var(--primary);
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

/* Demo simulator button — runs the backend flow without the real
   Apple Pay sheet. Distinct colour (purple) so it's obvious it's a
   simulation, not a real charge. */
.simulate-button {
    display: block;
    width: 100%;
    margin-top: .75rem;
    padding: .85rem 1rem;
    background: #7c3aed;
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s, transform .08s;
}
.simulate-button:hover  { background: #6d28d9; }
.simulate-button:active { transform: scale(.99); }
.simulate-button:disabled {
    opacity: .55;
    cursor: wait;
}

/* Mode toggle — flip between canned-demo routes and live Moneris+eShipper */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: .55rem 0 .15rem;
    padding: .45rem .7rem;
    background: #fff3cd;
    border: 1px solid #f6c757;
    border-radius: 8px;
    font-size: .85rem;
    color: #6a4a02;
    cursor: pointer;
}
.mode-toggle input { transform: scale(1.1); cursor: pointer; }

/* ── Status / debug ────────────────────────────────────────────────── */
.status {
    margin: .85rem 0 0;
    text-align: center;
    font-size: .95rem;
    min-height: 1.2em;
}
.status.ok  { color: var(--ok); font-weight: 600; }
.status.err { color: var(--err); }

.debug {
    padding: 0 1.5rem 1.25rem;
}
.debug details {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .55rem .75rem;
}
.debug summary {
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    color: #374151;
}
.debug pre {
    margin: .65rem 0 0;
    padding: .55rem .65rem;
    background: #0f172a;
    color: #d1d5db;
    font-size: .75rem;
    line-height: 1.45;
    max-height: 260px;
    overflow-y: auto;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
}
