/* bcos-terminal — payment terminal (admin), customer pay page, and paired
   customer displays. Tokens come from bcos.css :root; the few colours with no
   token are defined here once. */
:root {
  --tm-radius: 18px;
  --tm-shadow: 0 1px 0 rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.05);
  --tm-green-soft: #eef8f1;
  --tm-red-soft: #fff3f2;
  --tm-amber: #8a5a00;
  --tm-amber-soft: #fff6e5;
}

/* Component display rules (grid/flex) would otherwise beat the hidden attribute. */
.tm [hidden], .tm-screen [hidden], .tm-pay [hidden] { display: none !important; }

/* ── Admin terminal ─────────────────────────────────────────────────────── */
.tm { padding: 1.2rem 1.4rem 2.5rem; color: var(--ink); }
.tm-head { margin-bottom: 1.2rem; }
.tm-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.tm-grid-lo { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 1.1rem; }
.tm-card { background: var(--bg); border-radius: var(--tm-radius); box-shadow: var(--tm-shadow); padding: 1.2rem 1.25rem; min-width: 0; }
.tm-card-h { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .9rem; flex-wrap: wrap; }
.tm-card-h h3 { margin: 0; font-size: 1.05rem; letter-spacing: -.02em; }
.tm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tm-seg { display: inline-flex; background: var(--surface-3); border-radius: 999px; padding: 3px; }
.tm-seg button { border: 0; background: transparent; font: inherit; font-size: .8rem; font-weight: 600; padding: .38rem .8rem; border-radius: 999px; color: var(--ink-4); cursor: pointer; }
.tm-seg button.is-on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tm-seg button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

.tm-amount { display: block; font-size: clamp(2.4rem, 5vw, 3.2rem); font-weight: 800; letter-spacing: -.04em; text-align: right; font-variant-numeric: tabular-nums; padding: .4rem .2rem .8rem; border-bottom: 1px solid var(--line); margin-bottom: .8rem; }
.tm-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; margin-bottom: 1rem; }
.tm-keys button { font: inherit; font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; min-height: 3.4rem; border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; cursor: pointer; color: var(--ink); transition: background .12s, border-color .12s, transform .08s; }
.tm-keys button:hover { border-color: var(--ink); background: var(--bg); }
.tm-keys button:active { transform: scale(.97); }
.tm-keys button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.tm-field { display: grid; gap: .3rem; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .8rem; }
.tm-field input, .tm-field select { font: inherit; font-size: 1rem; letter-spacing: 0; text-transform: none; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: .65rem .75rem; background: var(--bg); width: 100%; }
.tm-field input:focus, .tm-field select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.tm-opt { text-transform: none; letter-spacing: 0; color: var(--muted-2); font-size: .78rem; margin-left: .3rem; }
.tm-go { width: 100%; min-height: 3.2rem; font-size: .95rem; border-radius: 14px; }
.tm-go:disabled { opacity: .35; cursor: not-allowed; }

.tm-orders { display: grid; gap: .45rem; max-height: 22rem; overflow: auto; margin-bottom: 1rem; padding: 2px; }
.tm-order { display: grid; grid-template-columns: 1fr auto; gap: .15rem .8rem; text-align: left; font: inherit; border: 1px solid var(--line); border-radius: 14px; padding: .7rem .85rem; background: var(--bg); cursor: pointer; color: var(--ink); }
.tm-order:hover { border-color: var(--ink); }
.tm-order[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--surface-2); }
.tm-order strong { font-variant-numeric: tabular-nums; }
.tm-order em { font-style: normal; color: var(--ink-4); font-size: .82rem; }
.tm-order b { grid-row: span 2; align-self: center; font-variant-numeric: tabular-nums; font-size: 1.05rem; }

/* Live charge */
.tm-live { min-height: 30rem; }
.tm-idle { text-align: center; padding: 2rem 1rem 1rem; }
.tm-idle-mark { display: inline-grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%; background: var(--surface-3); font-size: 1.4rem; margin-bottom: .8rem; }
.tm-idle-t { font-size: 1.25rem; font-weight: 750; letter-spacing: -.02em; margin: 0 0 .3rem; }
.tm-railist { list-style: none; padding: 0; margin: 1.6rem auto 0; max-width: 30rem; text-align: left; display: grid; gap: .55rem; }
.tm-railist li { display: grid; grid-template-columns: 2.4rem 1fr; gap: .7rem; align-items: center; padding: .6rem .7rem; border-radius: 14px; background: var(--surface-2); }
.tm-railist li.is-off { opacity: .55; }
.tm-railist-i { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 12px; background: var(--bg); }
.tm-railist strong { display: block; font-size: .92rem; }
.tm-railist em { display: block; font-style: normal; font-size: .8rem; color: var(--ink-4); }

.tm-charge-h { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.tm-num { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.tm-pill { font-size: .72rem; font-weight: 700; letter-spacing: .04em; padding: .3rem .65rem; border-radius: 999px; background: var(--surface-3); color: var(--ink-3); }
.tm-pill.is-pending { background: var(--tm-amber-soft); color: var(--tm-amber); }
.tm-pill.is-paid { background: var(--tm-green-soft); color: var(--green); }
.tm-pill.is-failed, .tm-pill.is-review { background: var(--tm-red-soft); color: var(--red); }
.tm-charge-amt { font-size: clamp(2.6rem, 6vw, 3.8rem); font-weight: 800; letter-spacing: -.045em; margin: .5rem 0 0; font-variant-numeric: tabular-nums; line-height: 1.05; }
.tm-charge-desc { color: var(--ink-4); margin: .3rem 0 1rem; }
.tm-alert { border-radius: 12px; padding: .65rem .8rem; font-size: .9rem; margin: 0 0 .9rem; }
.tm-alert.is-err { background: var(--tm-red-soft); color: var(--red); }
.tm-alert.is-warn { background: var(--tm-amber-soft); color: var(--tm-amber); }

.tm-rails { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.tm-rail { display: grid; justify-items: center; gap: .4rem; font: inherit; font-size: .82rem; padding: .85rem .4rem; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); cursor: pointer; color: var(--ink); text-align: center; }
.tm-rail:hover:not(:disabled) { border-color: var(--ink); }
.tm-rail.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--surface-2); }
.tm-rail:disabled { opacity: .38; cursor: not-allowed; }
.tm-rail.is-busy, .tm-reader button.is-busy { opacity: .55; pointer-events: none; }
.tm-rail:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.tm-rail-i { font-size: 1.25rem; }

.tm-panel { border-top: 1px solid var(--line); padding-top: 1rem; margin-bottom: 1rem; }
.tm-panel p { margin: 0 0 .8rem; }
.tm-qr { width: 12.5rem; max-width: 100%; aspect-ratio: 1; background: #fff; border-radius: 14px; padding: .5rem; border: 1px solid var(--line); flex: 0 0 auto; }
.tm-qr-svg { display: block; width: 100%; height: auto; }
.tm-panel[data-tm-panel="qr"]:not([hidden]) { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.tm-qr-side { flex: 1 1 14rem; min-width: 0; }
.tm-linkrow { display: flex; gap: .4rem; }
.tm-linkrow input { flex: 1; min-width: 0; font: inherit; font-size: .82rem; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; color: var(--ink-3); background: var(--surface-2); }
.tm-mini { padding: .45rem .75rem; font-size: .7rem; }
.tm-tapbtns { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.tm-readers { display: grid; gap: .45rem; margin-bottom: .7rem; }
.tm-reader { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; align-items: center; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 14px; }
.tm-reader em { font-style: normal; font-size: .8rem; color: var(--ink-4); }
.tm-reader .tm-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted-3); margin-right: .35rem; }
.tm-reader .tm-dot.is-on { background: var(--green); }
.tm-reader button { grid-row: span 2; }
.tm-reader button:disabled { opacity: .3; cursor: not-allowed; background: var(--muted-2); border-color: var(--muted-2); }

/* Figures are <p>s; admin paragraph colour would otherwise grey them out. */
.tm-charge-amt, .tm-idle-t, .tm-pay-amount, .tm-disp-amount { color: var(--ink); }
.tm-disp-amount.is-sm { color: var(--ink-4); }

.tm-waiting { display: flex; align-items: center; gap: .7rem; color: var(--ink-3); font-weight: 600; }
.tm-spin { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: tm-spin .8s linear infinite; }
@keyframes tm-spin { to { transform: rotate(360deg); } }

.tm-paid { text-align: center; padding: 1.4rem 0 1rem; }
.tm-check { display: inline-block; width: 4.2rem; height: 4.2rem; border-radius: 50%; background: var(--green); position: relative; animation: tm-pop .35s cubic-bezier(.2,.9,.3,1.3); }
.tm-check::after { content: ''; position: absolute; left: 1.45rem; top: .95rem; width: 1rem; height: 1.85rem; border: solid var(--on-ink); border-width: 0 .32rem .32rem 0; transform: rotate(45deg); }
@keyframes tm-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.tm-paid-t { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; margin: .6rem 0 .1rem; color: var(--green); }
.tm-paid-s { color: var(--ink-4); margin: 0 0 .9rem; }
.tm-charge-foot { display: flex; gap: .5rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: .9rem; }
.tm-charge-foot [data-tm-next] { margin-left: auto; }

.tm-displays { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.tm-displays li.tm-disp-row { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: 12px; background: var(--surface-2); flex-wrap: wrap; }
.tm-disp-row strong { flex: 1; min-width: 8rem; }
.tm-disp-row em { font-style: normal; font-size: .8rem; color: var(--ink-4); }
.tm-disp-row .tm-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted-3); }
.tm-disp-row .tm-dot.is-on { background: var(--green); }
.tm-recent { display: grid; }
.tm-rrow { display: grid; grid-template-columns: 4.6rem 1fr auto auto; gap: .7rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.tm-rrow:last-child { border-bottom: 0; }
.tm-rrow span:first-child { font-variant-numeric: tabular-nums; color: var(--muted-2); font-size: .78rem; }
.tm-rrow em { font-style: normal; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-rrow b { font-variant-numeric: tabular-nums; }

.tm-setup { margin-top: 1.1rem; }
.tm-setup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
.tm-setup-grid strong { display: flex; gap: .45rem; align-items: center; margin-bottom: .35rem; }
.tm-setup-grid p { font-size: .88rem; color: var(--ink-3); margin: 0 0 .5rem; }
.tm-cb { width: 100%; font: inherit; font-size: .8rem; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; background: var(--surface-2); color: var(--ink-3); margin-bottom: .5rem; }
.tm-ok { color: var(--green); font-weight: 650; }
.tm-no { color: var(--red); font-weight: 650; }

.tm-pairbox { text-align: center; }
.tm-paircode { font-size: 2.6rem; font-weight: 800; letter-spacing: .18em; font-variant-numeric: tabular-nums; margin: .4rem 0; }
.tm-pairbox .tm-qr { margin: .6rem auto; width: 10rem; }

@media (max-width: 1100px) {
  .tm-grid, .tm-grid-lo { grid-template-columns: 1fr; }
  .tm-setup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .tm { padding: .8rem .6rem 2rem; }
  .tm-rails { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm-rrow { grid-template-columns: 1fr auto; }
  .tm-rrow span:first-child, .tm-rrow em { display: none; }
  .tm-live { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-spin, .tm-check { animation: none; }
}

/* ── Customer pay page (/t/…) ───────────────────────────────────────────── */
.tm-pay { padding-block: 3rem 5rem; }
.tm-pay-card { max-width: 30rem; margin: 0 auto; text-align: center; border: 1px solid var(--line); border-radius: 22px; padding: 2.2rem 1.6rem; box-shadow: var(--tm-shadow); }
.tm-pay-desc { color: var(--ink-4); margin: .4rem 0 0; }
.tm-pay-amount { font-size: clamp(2.8rem, 12vw, 4rem); font-weight: 800; letter-spacing: -.045em; margin: .3rem 0 1.4rem; font-variant-numeric: tabular-nums; }
.tm-pay-amount small { font-size: .9rem; letter-spacing: .1em; color: var(--muted-2); font-weight: 600; }
.tm-pay-go { width: 100%; min-height: 3.3rem; font-size: 1rem; border-radius: 14px; }
.tm-pay-ok, .tm-cb-ok { color: var(--green); font-weight: 750; font-size: 1.2rem; }
.tm-pay-wait { color: var(--ink-3); }

/* ── Paired customer display (/terminal/display, /terminal/pair) ─────────── */
body.tm-screen { min-height: 100vh; min-height: 100dvh; background: var(--bg); margin: 0; }
.tm-screen-logo { height: 2.4rem; width: auto; }
.tm-pair { max-width: 26rem; margin: 0 auto; padding: 3rem 1.25rem; }
.tm-pair h1 { font-size: 2.2rem; letter-spacing: -.04em; margin: .3rem 0 .4rem; }
.tm-pair-form { display: grid; gap: .8rem; margin-top: 1.4rem; }
.tm-pair-label { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.tm-pair-code { font: inherit; font-size: 2.2rem; font-weight: 800; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; border: 1.5px solid var(--ink); border-radius: 16px; padding: .6rem; width: 100%; }
.tm-disp { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; padding: 1.2rem clamp(1rem, 4vw, 3rem) 1.5rem; text-align: center; }
.tm-disp-top { display: flex; justify-content: space-between; align-items: center; }
.tm-disp-name { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted-2); }
.tm-disp-idle, .tm-disp-charge, .tm-disp-paid { align-self: center; }
.tm-disp-idle .bcos-lead { margin-inline: auto; }
.tm-disp-idle h1, .tm-disp-paid h1 { font-size: clamp(2.6rem, 8vw, 5rem); letter-spacing: -.05em; margin: .3rem 0; }
.tm-disp-desc { color: var(--ink-4); font-size: clamp(1rem, 2.4vw, 1.4rem); margin: 0; }
.tm-disp-amount { font-size: clamp(3.4rem, 14vw, 8rem); font-weight: 800; letter-spacing: -.05em; font-variant-numeric: tabular-nums; margin: .1rem 0 1rem; line-height: 1; }
.tm-disp-amount.is-sm { font-size: clamp(1.6rem, 5vw, 2.6rem); color: var(--ink-4); }
.tm-disp-qr { width: min(18rem, 60vw); margin: 0 auto 1rem; background: #fff; padding: .6rem; border-radius: 18px; border: 1px solid var(--line); }
.tm-disp-prompt { font-size: clamp(1.1rem, 3vw, 1.6rem); font-weight: 650; margin: 0; }
.tm-disp-paid .tm-check { width: 6rem; height: 6rem; }
.tm-disp-paid .tm-check::after { left: 2.1rem; top: 1.3rem; width: 1.45rem; height: 2.7rem; border-width: 0 .45rem .45rem 0; }
.tm-disp-offline { color: var(--muted-2); font-size: .85rem; }
