/* Design tokens — only place hex/rgb colours may appear */
:root {
  --tb-primary: #16181D;
  --tb-primary-hover: #2A2D34;
  --tb-on-primary: #FFFFFF;
  --tb-accent: #1F8F63;
  --tb-accent-hover: #187651;
  --tb-accent-soft: #E8F5EF;
  --tb-surface: #FFFFFF;
  --tb-surface-subtle: #F2F4F2;
  --tb-page: #F7F8F7;
  --tb-text: #16181D;
  --tb-text-secondary: #5F6B64;
  --tb-text-muted: #97A09A;
  --tb-border: #E4E7E4;
  --tb-border-strong: #CDD3CE;
  --tb-danger: #C2413B;
  --tb-danger-soft: #FBEAE9;
  --tb-warning: #D97706;
  --tb-radius-sm: 10px;
  --tb-radius-md: 16px;
  --tb-radius-lg: 20px;
  --tb-radius-xl: 24px;

  /* Derived from tokens (no raw hex) */
  --tb-shadow-sm: 0 1px 2px color-mix(in srgb, var(--tb-text) 10%, transparent);
  --tb-shadow-md: 0 4px 16px color-mix(in srgb, var(--tb-text) 12%, transparent);
  --tb-focus-ring: 0 0 0 3px color-mix(in srgb, var(--tb-accent) 35%, transparent);
  --tb-touch: 52px;
  --tb-font: "Manrope", "Segoe UI", sans-serif;
  --tb-kaspi: #F14635;
  --tb-kaspi-hover: #D93A2B;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--tb-font);
  background: var(--tb-page);
  color: var(--tb-text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--tb-page);
}

/* ——— Banners ——— */
.app-banner {
  display: none;
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.app-banner.is-visible {
  display: block;
}

.app-banner--error {
  background: var(--tb-danger-soft);
  color: var(--tb-danger);
  border-bottom: 1px solid color-mix(in srgb, var(--tb-danger) 25%, var(--tb-border));
}

.app-banner__text {
  font-weight: 600;
  color: inherit;
}

.app-banner__ref {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--tb-text-muted);
}

.app-banner--timeout {
  background: color-mix(in srgb, var(--tb-warning) 16%, var(--tb-surface));
  color: var(--tb-text);
  border-bottom: 1px solid color-mix(in srgb, var(--tb-warning) 35%, var(--tb-border));
}

/* ——— Header ——— */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--tb-surface);
  border-bottom: 1px solid var(--tb-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--tb-touch);
  text-decoration: none;
  color: var(--tb-text);
}

.app-logo-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--tb-radius-sm);
  background: var(--tb-accent);
  color: var(--tb-on-primary);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  /* Latin monogram only — avoid Cyrillic lookalikes next to brand */
  font-family: "Manrope", "Segoe UI", "Arial", sans-serif;
  font-feature-settings: "kern" 1;
  unicode-bidi: isolate;
}

.app-logo-text {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  font-family: "Manrope", "Segoe UI", "Arial", sans-serif;
  unicode-bidi: isolate;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ——— Stepper area ——— */
.app-stepper-area {
  padding: 1rem 1.25rem 0;
  min-height: 0;
}

.app-stepper-area:empty {
  display: none;
}

/* ——— Main / stage: content + actions as one group ——— */
.app-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.25rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

/* Tall flows: top-align and scroll; sticky action bar only here */
.app-shell--layout-fill .app-main {
  justify-content: flex-start;
  overflow: auto;
}

/* Payment/print takeover: fill the main area and centre the status card as one group */
.app-shell--takeover .app-main {
  justify-content: flex-start;
}

.app-shell--takeover .app-stage {
  flex: 1 1 auto;
  min-height: 0;
}

.app-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
}

.app-shell--layout-fill .app-stage {
  flex: 1 1 auto;
  min-height: 0;
}

.app-stage__body {
  width: 100%;
  min-width: 0;
}

.app-shell--layout-fill .app-stage__body {
  flex: 1 1 auto;
  min-height: 0;
}

.screen {
  display: none;
  animation: screen-in 180ms ease-out;
}

.screen.is-active {
  display: block;
  width: 100%;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.screen-title {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--tb-text);
}

.screen-lead {
  margin: 0 0 1.5rem;
  color: var(--tb-text-secondary);
  font-size: 1rem;
}

.demo-section {
  margin: 0 0 2rem;
  padding: 1.25rem;
  background: var(--tb-surface);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-lg);
  box-shadow: var(--tb-shadow-sm);
}

.demo-section h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.demo-section > p {
  margin: 0 0 1rem;
  color: var(--tb-text-muted);
  font-size: 0.9rem;
}

.demo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.demo-row:last-child {
  margin-bottom: 0;
}

.demo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 560px) {
  .demo-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.demo-label {
  display: block;
  width: 100%;
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tb-text-muted);
}

/* ——— Footer actions ——— */
/* Balanced layout: actions sit directly under content (not pinned to viewport). */
.app-footer {
  position: static;
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: stretch;
  padding: 0;
  margin: 0;
  background: transparent;
  border-top: none;
  backdrop-filter: none;
  min-height: 0;
}

.app-footer:empty {
  display: none;
}

.app-footer .tb-btn {
  flex: 1 1 auto;
  min-width: 140px;
}

/* Fill layout only: sticky bottom bar when content scrolls the viewport */
.app-shell--layout-fill .app-footer {
  position: sticky;
  bottom: 0;
  z-index: 15;
  padding: 0.85rem 0 calc(0.35rem + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--tb-page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--tb-border);
}

/* ——— Buttons ——— */
.tb-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--tb-radius-md);
  min-height: var(--tb-touch);
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease,
    transform 80ms ease, opacity 120ms ease;
  box-shadow: var(--tb-shadow-sm);
}

.tb-btn:focus-visible {
  outline: none;
  box-shadow: var(--tb-focus-ring);
}

.tb-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.tb-btn--primary {
  background: var(--tb-primary);
  color: var(--tb-on-primary);
}

.tb-btn--primary:hover:not(:disabled) {
  background: var(--tb-primary-hover);
}

.tb-btn--secondary {
  background: var(--tb-surface);
  color: var(--tb-text);
  border-color: var(--tb-border-strong);
}

.tb-btn--secondary:hover:not(:disabled) {
  background: var(--tb-surface-subtle);
}

.tb-btn--ghost {
  background: transparent;
  color: var(--tb-text-secondary);
  box-shadow: none;
}

.tb-btn--ghost:hover:not(:disabled) {
  background: var(--tb-surface-subtle);
  color: var(--tb-text);
}

.tb-btn--danger {
  background: var(--tb-danger);
  color: var(--tb-on-primary);
}

.tb-btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--tb-danger) 88%, var(--tb-text));
}

.tb-btn--loading {
  pointer-events: none;
  cursor: wait;
}

.tb-btn:disabled,
.tb-btn--disabled {
  opacity: 0.45;
  box-shadow: none;
}

.tb-btn--loading.tb-btn--disabled {
  opacity: 1;
}

/* Fixed-width slot so loading does not resize the button */
.tb-btn__spin-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  flex-shrink: 0;
}

.tb-btn:not(.tb-btn--loading) .tb-btn__spinner {
  visibility: hidden;
  animation: none;
}

.tb-btn__label {
  display: inline-block;
}

.tb-btn__spinner {
  box-sizing: border-box;
  width: 1.35em;
  height: 1.35em;
  border-radius: 50%;
  border-style: solid;
  border-width: 0.22em;
  animation: tb-spin 0.55s linear infinite;
}

/* Light spinner on dark / saturated fills */
.tb-btn--primary .tb-btn__spinner,
.tb-btn--danger .tb-btn__spinner {
  border-color: color-mix(in srgb, var(--tb-on-primary) 30%, transparent);
  border-top-color: var(--tb-on-primary);
  border-right-color: var(--tb-on-primary);
}

/* Graphite spinner on grey / ghost surfaces — never grey-on-grey */
.tb-btn--secondary .tb-btn__spinner,
.tb-btn--ghost .tb-btn__spinner {
  border-color: color-mix(in srgb, var(--tb-primary) 18%, transparent);
  border-top-color: var(--tb-primary);
  border-right-color: var(--tb-primary);
}

@keyframes tb-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ——— ActionCard ——— */
.tb-action-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
  text-align: left;
  padding: 1.15rem 1.2rem;
  background: var(--tb-surface);
  border: 2px solid var(--tb-border);
  border-radius: var(--tb-radius-lg);
  color: var(--tb-text);
  box-shadow: var(--tb-shadow-sm);
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.tb-action-card:hover:not(:disabled):not(.tb-action-card--disabled) {
  border-color: var(--tb-border-strong);
  box-shadow: var(--tb-shadow-md);
  background: var(--tb-surface);
}

.tb-action-card--selected,
.tb-action-card--selected:hover:not(:disabled) {
  border-color: var(--tb-accent);
  background: var(--tb-accent-soft);
  box-shadow: var(--tb-shadow-sm);
}

.tb-action-card--disabled,
.tb-action-card:disabled {
  opacity: 0.5;
  box-shadow: none;
}

.tb-action-card:focus-visible {
  outline: none;
  box-shadow: var(--tb-focus-ring);
}

.tb-action-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--tb-radius-sm);
  background: var(--tb-surface-subtle);
  color: var(--tb-accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
}

.tb-action-card--selected .tb-action-card__icon {
  background: var(--tb-accent);
  color: var(--tb-on-primary);
}

.tb-action-card__body {
  flex: 1;
  min-width: 0;
}

.tb-action-card__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.tb-action-card__desc {
  margin: 0.25rem 0 0;
  color: var(--tb-text-secondary);
  font-size: 0.95rem;
}

/* ——— OptionTile ——— */
.tb-option-tile {
  appearance: none;
  width: 100%;
  min-height: 88px;
  padding: 1rem;
  text-align: center;
  background: var(--tb-surface);
  border: 2px solid var(--tb-border);
  border-radius: var(--tb-radius-md);
  color: var(--tb-text);
  font-weight: 700;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.tb-option-tile:hover:not(:disabled) {
  border-color: var(--tb-border-strong);
}

.tb-option-tile--selected {
  border-color: var(--tb-accent);
  background: var(--tb-accent-soft);
  color: var(--tb-accent-hover);
}

.tb-option-tile:disabled {
  opacity: 0.45;
}

.tb-option-tile:focus-visible {
  outline: none;
  box-shadow: var(--tb-focus-ring);
}

.tb-option-tile__label {
  display: block;
  font-size: 1.05rem;
}

.tb-option-tile__hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--tb-text-muted);
}

.tb-option-tile--selected .tb-option-tile__hint {
  color: var(--tb-accent-hover);
}

/* ——— ErrorState ——— */
.tb-error-state {
  padding: 1.5rem;
  background: var(--tb-danger-soft);
  border: 1px solid color-mix(in srgb, var(--tb-danger) 22%, var(--tb-border));
  border-radius: var(--tb-radius-lg);
}

.tb-error-state__title {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  font-weight: 750;
  color: var(--tb-danger);
}

.tb-error-state__text {
  margin: 0 0 1.25rem;
  color: var(--tb-text);
  font-weight: 500;
}

.tb-error-state__ref {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  color: var(--tb-text-secondary);
  font-family: ui-monospace, "Cascadia Code", monospace;
}

.tb-error-state__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ——— Stepper ——— */
.tb-stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.tb-stepper__item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  color: var(--tb-text-muted);
  font-size: 0.85rem;
  font-weight: 650;
}

.tb-stepper__dot {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 2px solid var(--tb-border-strong);
  background: var(--tb-surface);
  font-size: 0.75rem;
  font-weight: 800;
}

.tb-stepper__item--done {
  color: var(--tb-accent);
}

.tb-stepper__item--done .tb-stepper__dot {
  background: var(--tb-accent);
  border-color: var(--tb-accent);
  color: var(--tb-on-primary);
}

.tb-stepper__item--current {
  color: var(--tb-text);
}

.tb-stepper__item--current .tb-stepper__dot {
  border-color: var(--tb-accent);
  color: var(--tb-accent);
  box-shadow: var(--tb-focus-ring);
}

.tb-stepper__line {
  width: 1.25rem;
  height: 2px;
  background: var(--tb-border);
  flex: 0 0 auto;
}

.tb-stepper__item--done + .tb-stepper__line {
  background: var(--tb-accent);
}

/* ——— NumericKeypad ——— */
.tb-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  max-width: 320px;
}

.tb-keypad__key {
  appearance: none;
  min-height: 64px;
  border-radius: var(--tb-radius-md);
  border: 1px solid var(--tb-border-strong);
  background: var(--tb-surface);
  color: var(--tb-text);
  font-size: 1.35rem;
  font-weight: 750;
  box-shadow: var(--tb-shadow-sm);
}

.tb-keypad__key:hover:not(:disabled) {
  background: var(--tb-surface-subtle);
}

.tb-keypad__key:active:not(:disabled) {
  transform: scale(0.97);
}

.tb-keypad__key--action {
  font-size: 0.95rem;
  color: var(--tb-text-secondary);
}

.tb-keypad__key:focus-visible {
  outline: none;
  box-shadow: var(--tb-focus-ring);
}

.tb-keypad__display {
  grid-column: 1 / -1;
  min-height: 56px;
  margin-bottom: 0.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--tb-radius-md);
  border: 1px solid var(--tb-border);
  background: var(--tb-surface-subtle);
  font-size: 1.5rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-align: center;
  color: var(--tb-text);
}

.tb-keypad__display--sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  min-height: 0;
}

.tb-keypad__slots {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
}

.tb-keypad__slot {
  width: 3rem;
  height: 3.25rem;
  border-radius: var(--tb-radius-md);
  border: 1px solid var(--tb-border-strong);
  background: var(--tb-surface);
  color: var(--tb-text);
  font-size: 1.5rem;
  font-weight: 750;
  text-align: center;
  letter-spacing: 0;
  box-shadow: var(--tb-shadow-sm);
}

.tb-keypad__slot:focus {
  outline: none;
  border-color: var(--tb-accent);
  box-shadow: var(--tb-focus-ring);
}

/* ——— Pickup where-label ——— */
.tb-pickup-where {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--tb-radius-md);
  border: 1px solid var(--tb-border);
  background: var(--tb-surface-subtle);
  text-align: center;
}

.tb-pickup-where__label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--tb-text-secondary);
}

.tb-pickup-where__name {
  margin: 0.25rem 0 0;
  font-size: 1.25rem;
  font-weight: 750;
  color: var(--tb-text);
}

.tb-actions-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  max-width: 28rem;
}

/* ——— File dropzone / file card (in-place transform) ——— */
.screen--file-select {
  overflow-anchor: none;
}

.tb-dropzone-slot {
  min-height: 11rem;
  margin-top: 0.5rem;
}

.tb-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 11rem;
  padding: 1.5rem 1.25rem;
  border: 2px dashed var(--tb-border-strong);
  border-radius: var(--tb-radius-lg);
  background: var(--tb-surface);
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.tb-dropzone--idle:hover,
.tb-dropzone--dragover {
  border-color: var(--tb-accent);
  background: var(--tb-accent-soft);
}

.tb-dropzone__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.tb-dropzone__icon {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--tb-accent);
  line-height: 1;
}

.tb-dropzone__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--tb-text);
}

.tb-dropzone__hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--tb-text-secondary);
}

.tb-file-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 11rem;
  padding: 1.25rem;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-lg);
  background: var(--tb-surface);
  box-shadow: var(--tb-shadow-sm);
}

.tb-file-card--success {
  border-color: color-mix(in srgb, var(--tb-accent) 45%, var(--tb-border));
  background: var(--tb-accent-soft);
}

.tb-file-card--analyzing,
.tb-file-card--uploading {
  border-color: var(--tb-border-strong);
}

.tb-file-card__icon {
  flex: 0 0 auto;
  font-size: 1.75rem;
  line-height: 1;
}

.tb-file-card__body {
  flex: 1 1 auto;
  min-width: 0;
}

.tb-file-card__name {
  font-weight: 700;
  color: var(--tb-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-file-card__meta {
  margin-top: 0.2rem;
  font-size: 0.9rem;
  color: var(--tb-text-secondary);
}

.tb-file-card__status {
  margin-top: 0.45rem;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--tb-text);
}

.tb-file-card--success .tb-file-card__status {
  color: var(--tb-accent-hover);
}

.tb-file-card__spinner {
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 2px solid var(--tb-border-strong);
  border-top-color: var(--tb-accent);
  animation: tb-spin 0.7s linear infinite;
}

/* ——— Preview ——— */
.tb-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin: 0.5rem 0 0.85rem;
}

.tb-preview-counter {
  min-width: 6.5rem;
  text-align: center;
  font-weight: 700;
  color: var(--tb-text);
}

.tb-preview-stage-wrap {
  position: relative;
  min-height: 16rem;
}

.tb-preview-skeleton {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--tb-surface-subtle);
  border-radius: var(--tb-radius-md);
  border: 1px solid var(--tb-border);
}

.tb-preview-skeleton[hidden] {
  display: none;
}

.tb-preview-skeleton__bar {
  height: 0.75rem;
  width: 40%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tb-text-muted) 35%, var(--tb-surface));
  animation: tb-pulse 1.1s ease-in-out infinite;
}

.tb-preview-skeleton__page {
  flex: 1 1 auto;
  min-height: 14rem;
  border-radius: var(--tb-radius-sm);
  background: color-mix(in srgb, var(--tb-text-muted) 22%, var(--tb-surface));
  animation: tb-pulse 1.1s ease-in-out infinite;
}

@keyframes tb-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.tb-preview-stage {
  max-width: 100%;
}

.tb-preview-error-host {
  margin-top: 0.85rem;
}

.file-print-preview-page {
  position: relative;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-md);
  background: var(--tb-surface-subtle);
  overflow: hidden;
  max-width: 100%;
  margin: 0 auto;
}

.file-print-preview-page canvas {
  display: block;
  width: 100%;
  height: auto;
}

.file-print-preview-page-label {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 1;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--tb-text-secondary);
  background: color-mix(in srgb, var(--tb-surface) 88%, transparent);
  padding: 0.15rem 0.4rem;
  border-radius: var(--tb-radius-sm);
}

.file-print-preview-watermark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  /* Instantly readable as an on-screen overlay; document stays legible underneath */
  font-size: clamp(2.75rem, 16vw, 5.75rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1;
  color: color-mix(in srgb, var(--tb-danger) 52%, transparent);
  transform: rotate(-28deg);
  user-select: none;
  text-shadow: 0 1px 0 color-mix(in srgb, var(--tb-surface) 55%, transparent);
}

.tb-preview-watermark-note {
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
  font-weight: 550;
  line-height: 1.4;
  color: var(--tb-text-secondary);
  text-align: center;
}

/* ——— Settings + sticky price bar ——— */
.tb-settings-block {
  margin: 0 0 1.25rem;
}

.tb-settings-block__title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 750;
}

.tb-settings-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0 0 1.15rem;
}

.tb-settings-row__label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--tb-text);
}

.tb-option-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.tb-option-row .tb-option-tile {
  width: 100%;
}

.tb-settings-range {
  margin-top: 0.75rem;
}

.tb-settings-input {
  width: 100%;
  min-height: var(--tb-touch);
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--tb-border-strong);
  border-radius: var(--tb-radius-md);
  background: var(--tb-surface);
  color: var(--tb-text);
}

.tb-settings-input:focus {
  outline: none;
  box-shadow: var(--tb-focus-ring);
  border-color: var(--tb-accent);
}

.tb-settings-hint {
  margin: 0.45rem 0 0;
  font-size: 0.88rem;
  color: var(--tb-text-secondary);
}

.tb-settings-error {
  margin: 0.45rem 0 0;
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--tb-danger);
}

.tb-copies-stepper {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.tb-copies-stepper .tb-btn {
  flex: 0 0 auto;
  min-width: var(--tb-touch);
  padding-left: 0;
  padding-right: 0;
}

.tb-copies-stepper__value {
  min-width: 3rem;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
}

.app-footer .tb-price-footer {
  flex: 1 1 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tb-price-footer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tb-price-footer__actions .tb-btn {
  flex: 1 1 auto;
  min-width: 140px;
}

.tb-price-bar {
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-md);
  background: var(--tb-surface);
  overflow: hidden;
}

.tb-price-bar__summary {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 0;
  background: var(--tb-surface);
  color: var(--tb-text);
  text-align: left;
  cursor: pointer;
}

.tb-price-bar__summary:focus-visible {
  outline: none;
  box-shadow: var(--tb-focus-ring);
}

.tb-price-bar__summary-text {
  flex: 1 1 auto;
  min-width: 0;
}

.tb-price-bar__label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--tb-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tb-price-bar__meta {
  margin-top: 0.15rem;
  font-size: 0.88rem;
  color: var(--tb-text-secondary);
}

.tb-price-bar__total {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.tb-price-bar__chevron {
  color: var(--tb-text-muted);
  font-size: 1rem;
}

.tb-price-bar__detail {
  padding: 0 1rem 0.9rem;
  border-top: 1px solid var(--tb-border);
  background: var(--tb-surface-subtle);
}

.tb-price-bar__detail[hidden] {
  display: none;
}

.tb-price-bar__line {
  padding-top: 0.45rem;
  font-size: 0.9rem;
  color: var(--tb-text);
}

.tb-price-bar__line:last-child {
  font-weight: 750;
}

/* ——— Order review + payment takeover ——— */
.app-stage.flow-takeover-active > .app-stage__body,
.app-stage.flow-takeover-active > .app-footer {
  display: none !important;
}

.app-stage.flow-takeover-active {
  flex: 1 1 auto;
  min-height: 0;
  justify-content: center;
  align-items: center;
}

.app-stage.flow-takeover-active > .flow-takeover {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  min-height: min(70vh, 36rem);
}

.flow-takeover[hidden] {
  display: none !important;
}

.tb-print-progress-card {
  width: 100%;
}

.tb-scan-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0 0.5rem;
}

.tb-scan-progress__spinner {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 4px solid rgba(15, 23, 42, 0.12);
  border-top-color: var(--tb-accent, #0f766e);
  animation: tb-scan-spin 0.9s linear infinite;
}

@keyframes tb-scan-spin {
  to {
    transform: rotate(360deg);
  }
}

.tb-print-progress .screen-title {
  margin-bottom: 1.25rem;
  text-align: center;
}

.tb-print-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.tb-print-timeline__item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--tb-muted, #64748b);
}

.tb-print-timeline__dot {
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.15rem;
  border-radius: 50%;
  border: 3px solid currentColor;
  flex-shrink: 0;
  background: transparent;
  box-sizing: border-box;
}

.tb-print-timeline__text {
  flex: 1 1 auto;
  min-width: 0;
}

.tb-print-timeline__label {
  font-weight: 650;
}

.tb-print-timeline__item--pending {
  opacity: 0.55;
}

.tb-print-timeline__item--done {
  color: var(--tb-accent);
  opacity: 1;
}

.tb-print-timeline__item--done .tb-print-timeline__dot {
  background: var(--tb-accent);
  border-color: var(--tb-accent);
}

.tb-print-timeline__item--active {
  color: var(--tb-text, #0f172a);
  opacity: 1;
}

.tb-print-timeline__item--active .tb-print-timeline__label {
  font-size: 1.35rem;
  font-weight: 800;
}

.tb-print-timeline__item--active .tb-print-timeline__dot {
  width: 1.55rem;
  height: 1.55rem;
  border-color: var(--tb-accent);
  background: var(--tb-accent);
  animation: tb-timeline-dot-pulse 1.5s ease-in-out infinite;
}

.tb-print-timeline__hint {
  margin-top: 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--tb-text-secondary, #334155);
  line-height: 1.4;
}

.tb-print-timeline__pulse-bar {
  margin-top: 0.55rem;
  height: 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tb-accent) 25%, var(--tb-border));
  overflow: hidden;
  position: relative;
}

.tb-print-timeline__pulse-bar::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  border-radius: inherit;
  background: var(--tb-accent);
  animation: tb-timeline-bar-slide 1.84s ease-in-out infinite;
}

@keyframes tb-timeline-dot-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--tb-accent) 55%, transparent);
  }
  50% {
    transform: scale(1.35);
    box-shadow: 0 0 0 14px color-mix(in srgb, var(--tb-accent) 0%, transparent);
  }
}

@keyframes tb-timeline-bar-slide {
  0% {
    left: -40%;
  }
  100% {
    left: 100%;
  }
}

.tb-review-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 1rem 0 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--tb-surface);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-lg);
}

.tb-review-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.tb-review-row__label {
  color: var(--tb-text-secondary);
  font-size: 0.95rem;
}

.tb-review-row__value {
  font-weight: 650;
  text-align: right;
  word-break: break-word;
}

.tb-review-price {
  padding: 1rem 1.1rem;
  background: var(--tb-accent-soft);
  border-radius: var(--tb-radius-lg);
  margin-bottom: 0.5rem;
}

.tb-review-price__total {
  font-size: 1.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tb-review-price__breakdown {
  margin-top: 0.65rem;
}

.tb-review-price__line {
  font-size: 0.9rem;
  color: var(--tb-text-secondary);
  padding-top: 0.25rem;
}

.tb-review-error {
  margin: 0.75rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--tb-radius-md);
  background: var(--tb-danger-soft);
  color: var(--tb-danger);
}

.tb-review-error__ref {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--tb-text-muted);
}

.tb-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

@media (max-width: 480px) {
  .tb-actions-row {
    grid-template-columns: 1fr;
  }
}

.tb-pay-card {
  text-align: center;
  padding: 1.25rem 1.1rem;
  background: var(--tb-surface);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-xl);
  box-shadow: var(--tb-shadow-sm);
}

.tb-pay-title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 750;
}

.tb-pay-muted {
  margin: 0.5rem 0 0;
  color: var(--tb-text-secondary);
  font-size: 0.95rem;
}

.tb-pay-fail-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 750;
  color: var(--tb-danger);
}

.tb-pay-ref {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--tb-text-muted);
}

.tb-pay-order-summary {
  margin: 0.75rem 0;
  padding: 0.75rem;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-md);
  background: var(--tb-surface-subtle);
  text-align: left;
}

.tb-pay-order-summary__name {
  font-weight: 650;
  word-break: break-word;
}

.tb-pay-order-summary__meta {
  margin-top: 0.25rem;
  color: var(--tb-text-secondary);
  font-size: 0.9rem;
}

.tb-pay-order-summary__amount {
  margin-top: 0.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.kaspi-pay-amount {
  font-size: 2rem;
  font-weight: 800;
  margin: 0.25rem 0 0.75rem;
  font-variant-numeric: tabular-nums;
}

.kaspi-pay-button {
  display: flex;
  width: 100%;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  background: var(--tb-kaspi);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--tb-radius-md);
  text-decoration: none;
  cursor: pointer;
  padding: 0.65rem 1rem;
  box-sizing: border-box;
}

.kaspi-pay-button:hover {
  background: var(--tb-kaspi-hover);
  color: #fff;
}

.kaspi-pay-button.expired {
  background: #c7c7c7;
  color: #f4f4f4;
  pointer-events: none;
  cursor: not-allowed;
}

.apipay-countdown {
  margin: 0.6rem 0 0;
  color: var(--tb-text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

.apipay-countdown.warn {
  color: var(--tb-danger);
  font-weight: 700;
}

.apipay-qr-fallback {
  margin-top: 0.5rem;
}

.apipay-qr-fallback img {
  width: 200px;
  height: 200px;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-md);
  background: #fff;
}

.apipay-pending {
  margin: 0.75rem 0 0;
  font-weight: 650;
}

.apipay-soft-hint {
  margin: 0.5rem 0 0;
  color: var(--tb-text-muted);
  font-size: 0.9rem;
}

.apipay-paid-badge {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 750;
  color: var(--tb-accent);
}

.apipay-stage {
  margin: 0.75rem 0 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.physical-callout {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--tb-accent) 35%, var(--tb-border));
  border-radius: var(--tb-radius-md);
  background: var(--tb-accent-soft);
  font-size: 0.95rem;
}

.tb-notice {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--tb-warning);
  border-radius: var(--tb-radius-md);
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--tb-warning);
}

.tb-pay-pickup-code {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  margin: 0.75rem 0;
}

.tb-pay-note {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-md);
  font: inherit;
  resize: vertical;
  min-height: 4.5rem;
  box-sizing: border-box;
}

.tb-link-button {
  display: inline-block;
  margin-top: 0.5rem;
  background: none;
  border: none;
  color: var(--tb-accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  min-height: 44px;
  padding: 0.25rem;
}

.kaspi-pay-card--local-expired .tb-pay-order-summary {
  margin-bottom: 1rem;
  border-color: color-mix(in srgb, var(--tb-warning) 45%, var(--tb-border));
  background: color-mix(in srgb, var(--tb-warning) 12%, var(--tb-surface));
}

.kaspi-pay-card--local-expired .kaspi-pay-amount,
.kaspi-pay-card--local-expired .kaspi-pay-button.expired {
  display: none;
}

.tb-pay-card .tb-btn {
  width: 100%;
  margin-top: 0.75rem;
}
