/* Merchant app: register, customers, card, integrations */
html, body { overscroll-behavior: none; }
.shell {
  max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(112px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.shell::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 19; pointer-events: none;
  height: calc(104px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 40%, rgba(247, 244, 239, 0));
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; }
.topbar .logo { height: 34px; width: auto; margin-left: -2px; }
.who {
  display: flex; align-items: center; gap: 8px; max-width: 60%;
  padding: 6px 12px 6px 6px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.7); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 4px 14px rgba(26,23,20,0.06); font-size: 0.8125rem; font-weight: 600;
  min-height: 44px; transition: transform 120ms var(--ease-out);
}
.who:active { transform: scale(0.97); }
.who .badge {
  width: 24px; height: 24px; border-radius: 8px; background: var(--ink); color: #FFFFFF; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem;
}
.who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h1.title { margin: 0; font-size: 2rem; line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; }
.view { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.caisse-bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.back {
  display: inline-flex; align-items: center; gap: 4px; height: 44px; padding: 0 14px 0 8px; border: 0; border-radius: 14px;
  background: var(--fill); font-size: 0.875rem; font-weight: 600; color: var(--ink);
  transition: transform 120ms var(--ease-out), background-color 120ms ease;
}
.back:active { transform: scale(0.97); background: rgba(120, 113, 104, 0.2); }

/* Segmented control */
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 16px; background: var(--fill); }
.segmented button {
  height: 44px; border: 0; border-radius: 12px; background: transparent; font-size: 0.875rem; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 120ms var(--ease-out), background-color 120ms ease;
}
.segmented button:active { transform: scale(0.97); }
.segmented button[aria-pressed="true"] { background: #FFFFFF; color: var(--ink); box-shadow: 0 2px 8px rgba(26,23,20,0.08); }

/* PIN */
.pin-label { text-align: center; font-size: 0.875rem; color: var(--muted); }
.pin-boxes { display: flex; gap: 10px; justify-content: center; }
.pin-boxes span {
  width: 58px; height: 62px; border-radius: 17px; background: #FFFFFF; display: flex; align-items: center; justify-content: center;
  font-size: 1.875rem; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line);
}
.pin-boxes span.cur { box-shadow: inset 0 0 0 2px var(--ink); }
.pin-msg { min-height: 20px; margin-top: -4px; text-align: center; font-size: 0.875rem; font-weight: 500; color: var(--danger); }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.keypad button {
  height: 56px; border: 0; border-radius: 18px; background: rgba(255,255,255,0.92); color: var(--ink);
  box-shadow: 0 1px 2px rgba(26,23,20,0.06), inset 0 1px 0 #FFFFFF; font-size: 1.625rem; font-weight: 500;
  transition: transform 100ms var(--ease-out), background-color 100ms ease;
}
.keypad button:active { transform: scale(0.96); background: #EFEAE3; }
.keypad button.small { font-size: 0.875rem; font-weight: 600; }
/* Short screens (phone browser with its toolbars): slightly shorter keys so the whole pad stays above the dock */
@media (max-height: 720px) {
  .keypad button { height: 52px; }
}
@media (min-height: 760px) {
  .keypad { gap: 10px; }
  .keypad button { height: 64px; }
  .pin-boxes span { width: 60px; height: 68px; }
}

/* Client */
.client { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.client-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px; border-radius: 14px; background: var(--ink); color: #FFFFFF; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 0.9375rem; font-weight: 700;
}
.client-head .info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.client-head .info b { font-size: 1.0625rem; }
.client-head .info span { font-size: 0.8125rem; color: var(--muted); }
.client-head .pts { display: flex; flex-direction: column; align-items: flex-end; }
.client-head .pts b { font-size: 1.5rem; letter-spacing: -0.4px; }
.client-head .pts span { font-size: 0.75rem; color: var(--muted); }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.reward-ready {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 16px; border-radius: 18px; background: #EAD58F; color: #3D3000; font-size: 0.875rem; font-weight: 600;
}
.reward-ready .btn { height: 44px; padding: 0 16px; font-size: 0.875rem; }
.section-label { font-size: 0.9375rem; font-weight: 600; }
.amounts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.amounts button {
  height: 56px; border: 0; border-radius: 18px; background: #FFFFFF; box-shadow: var(--shadow-1);
  font-size: 1.25rem; font-weight: 600; color: var(--ink); transition: transform 100ms var(--ease-out);
}
.amounts button:active { transform: scale(0.97); }
.custom { display: flex; gap: 10px; }
.custom .input { height: 52px; border-radius: 16px; }
.custom .btn { height: 52px; }

/* Confirm / done */
.confirm { padding: 30px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; border-radius: 26px; }
.confirm .big { font-size: 3rem; font-weight: 700; letter-spacing: -1.2px; line-height: 1.1; }
.countdown { width: 100%; height: 6px; border-radius: 3px; background: rgba(120,113,104,0.16); overflow: hidden; margin-top: 8px; }
.countdown span { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 3px; transform: translateX(-100%); }
.countdown span.run { transform: translateX(0); transition: transform 5s linear; }
.center-col { display: flex; flex-direction: column; gap: 14px; flex: 1; justify-content: center; align-items: center; text-align: center; }
.done-icon {
  width: 76px; height: 76px; border-radius: 22px; background: var(--ok); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(30,122,69,0.30);
}
.done-icon.accent { background: var(--accent); box-shadow: 0 10px 30px rgba(30,94,255,0.35); }
.done-title { font-size: 1.75rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.note { background: #FFFFFF; border-radius: 18px; padding: 14px 16px; font-size: 0.875rem; line-height: 1.4; max-width: 340px; }
.note.accent { background: #DCE6FF; color: #102F86; font-weight: 600; }

/* Lists */
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 42px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.375rem; letter-spacing: -0.4px; }
.stat span { font-size: 0.75rem; color: var(--muted); }
.list { display: flex; flex-direction: column; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; background: transparent; text-align: left; width: 100%;
  border-bottom: 1px solid var(--line); transition: background-color 120ms ease;
}
.row:active { background: var(--fill); }
.row:last-child { border-bottom: 0; }
.row .avatar { width: 38px; height: 38px; border-radius: 11px; font-size: 0.8125rem; }
.row .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .info b { font-size: 0.9375rem; font-weight: 600; }
.row .info span { font-size: 0.75rem; color: var(--muted); }
.row .right { text-align: right; font-size: 0.9375rem; font-weight: 600; }
.row .right span { display: block; font-size: 0.6875rem; font-weight: 500; color: var(--muted); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 0.875rem; }

/* Card tab */
.pass-mini {
  aspect-ratio: 1.586; border-radius: 16px; padding: 16px 18px; display: grid; grid-template-rows: auto 1fr auto; gap: 6px;
  box-shadow: 0 18px 40px rgba(26,23,20,0.25), inset 0 1px 0 rgba(255,255,255,0.14);
}
.pass-mini .lbl { font-size: 0.625rem; letter-spacing: 0.8px; font-weight: 600; text-transform: uppercase; }
.pass-mini .val { font-size: 1.25rem; font-weight: 600; }
.pass-mini .row-top { display: flex; justify-content: space-between; gap: 10px; }
.pass-mini .mid { align-self: center; }
.share { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.share .link { font-size: 0.875rem; word-break: break-all; padding: 12px 14px; border-radius: 12px; background: var(--fill); }
.share .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.share .actions .btn { height: 46px; font-size: 0.875rem; padding: 0 12px; }
.qr { display: flex; justify-content: center; padding: 8px 0; }
.qr svg { width: 180px; height: 180px; }
.form-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* Integrations */
.integ { display: flex; align-items: center; gap: 12px; padding: 14px; }
.integ .ico {
  width: 40px; height: 40px; border-radius: 12px; background: var(--fill); display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem; font-weight: 700; flex-shrink: 0;
}
.integ .info { flex: 1; min-width: 0; }
.integ .info b { display: block; font-size: 0.9375rem; }
.integ .info span { font-size: 0.8125rem; color: var(--muted); }

/* Dock */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(14px, env(safe-area-inset-bottom));
  width: min(488px, calc(100% - 28px)); z-index: 20;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 6px; border-radius: 26px;
}
.dock button {
  height: 56px; border: 0; border-radius: 18px; background: transparent; color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 0.6875rem; font-weight: 600;
  transition: transform 120ms var(--ease-out), background-color 150ms ease;
}
.dock button:active { transform: scale(0.94); }
.dock button[aria-current="page"] { background: rgba(255,255,255,0.95); color: var(--ink); box-shadow: 0 2px 10px rgba(26,23,20,0.10), inset 0 1px 0 #FFFFFF; }

/* Sheets and toast */
.backdrop { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
/* The scrim dims on its own layer, so the sheet itself never turns see-through */
.backdrop::before {
  content: ""; position: absolute; inset: 0; background: rgba(26,23,20,0.35);
  opacity: 0; transition: opacity 260ms ease;
}
.backdrop.open::before { opacity: var(--scrim, 1); }
.backdrop.dragging::before { transition: none; }
.sheet {
  position: relative; width: min(520px, 100%); max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 -10px 40px rgba(26,23,20,0.25);
  transform: translateY(100%); transition: transform 420ms var(--ease-sheet); will-change: transform;
}
.backdrop.open .sheet { transform: translateY(0); }
.sheet.dragging { transition: none; }
.grabber { align-self: center; width: 36px; height: 5px; border-radius: 3px; background: rgba(60, 60, 67, 0.3); flex-shrink: 0; }
.sheet-drag {
  display: flex; flex-direction: column; gap: 10px; padding-top: 2px; touch-action: none; cursor: grab;
  -webkit-user-select: none; user-select: none;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head b { font-size: 1.125rem; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 14px; background: var(--fill); display: flex; align-items: center; justify-content: center;
  transition: transform 120ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
.video-box { position: relative; aspect-ratio: 1; border-radius: 22px; overflow: hidden; background: #000; }
.video-box video { width: 100%; height: 100%; object-fit: cover; }
.video-box .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,0.9); border-radius: 22px; }
.toast {
  position: fixed; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #FFFFFF;
  font-size: 0.875rem; font-weight: 500; box-shadow: var(--shadow-2);
  opacity: 0; transform: translate(-50%, calc(-100% - 16px));
  transition: transform 360ms var(--ease-out), opacity 220ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Auth */
.auth { max-width: 420px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: max(48px, calc(env(safe-area-inset-top, 0px) + 24px)) 20px calc(32px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 18px; }
.auth .logo { height: 40px; width: auto; }
.auth h1 { margin: 12px 0 0; font-size: 1.875rem; line-height: 1.1; letter-spacing: -0.025em; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth .switch { text-align: center; font-size: 0.875rem; }
.auth .switch button { border: 0; background: none; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; padding: 0 8px; }
.success-box { padding: 16px; font-size: 0.875rem; line-height: 1.5; }

@media print {
  body * { visibility: hidden; }
  #poster, #poster * { visibility: visible; }
  #poster { position: fixed; inset: 0; display: flex !important; }
}
.poster {
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 24px; text-align: center;
  background: #FFFFFF; padding: 48px; font-family: var(--font);
}
.poster h2 { margin: 0; font-size: 2.5rem; letter-spacing: -1px; }
.poster p { margin: 0; font-size: 1.375rem; color: #3D3935; }
.poster .qr svg { width: 320px; height: 320px; }
.poster img { height: 28px; width: auto; }

/* Last operation, undoable for 15 minutes */
.last-op {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px;
  padding: 0 6px 0 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow-1); font-size: 0.8125rem;
}
.last-op span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.last-op button {
  height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--danger);
  font-size: 0.8125rem; font-weight: 600; flex-shrink: 0;
}
.last-op button:active { background: rgba(180, 35, 24, 0.08); }

/* Reduced motion: sheets and toasts fade instead of sliding */
@media (prefers-reduced-motion: reduce) {
  .sheet, .backdrop.open .sheet { transform: none; transition: opacity 200ms ease; opacity: 0; }
  .backdrop.open .sheet { opacity: 1; }
  .toast, .toast.show { transform: translate(-50%, 0); }
}
/* Reduced transparency: solid chip and dock */
@media (prefers-reduced-transparency: reduce) {
  .who { background: #FFFFFF; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .who { background: #FFFFFF; border-color: var(--ink); }
}
