/* ══════════════════════════════════════════════════════════════════════
   b222 — SITE-WIDE SYSTEM PASS (loaded DEAD-LAST on storefront + CRM)
   Applies the locked b215 token system to every page. Rules here are
   either zero-specificity (:where) safety nets for raw controls, or
   targeted `html body` overrides for measured off-system elements.
   ══════════════════════════════════════════════════════════════════════ */
:root{--sys-panel:rgba(255,255,255,.035);--sys-hair:rgba(255,255,255,.055);--sys-r:16px;
  --sys-ctl-h:var(--ctl-h);--sys-ctl-r:var(--ctl-r);--sys-mono:'Geist Mono',ui-monospace,SFMono-Regular,Menlo,monospace}
/* management console keeps its own raw-control sizes (out of the storefront scale) */
.crm-body{--sys-ctl-h:40px;--sys-ctl-r:10px}
@media (max-width:899px){.crm-body{--sys-ctl-h:38px}}

/* ── 1. raw-control safety net (zero specificity: any styled rule wins) ── */
:where(button,select,textarea,input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=hidden]):not([type=color])){
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;font-size:13px;color:#EDEAF6;
  box-sizing:border-box;border-radius:var(--sys-ctl-r);border:1px solid rgba(255,255,255,.16);
  background-color:rgba(255,255,255,.05);-webkit-appearance:none;appearance:none}
:where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=hidden]):not([type=color]):not([type=submit]):not([type=button]),select){
  min-height:var(--sys-ctl-h);padding:0 12px;font-weight:500}
:where(textarea){padding:10px 12px;min-height:88px;line-height:1.45}
:where(button,input[type=submit],input[type=button]){min-height:var(--sys-ctl-h);padding:0 14px;font-weight:700;cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;gap:8px;line-height:1}
:where(select){background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23B9B3C6' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 12px center;padding-right:32px}
:where(select option){background:#0d0b16;color:#EDEAF6}
:where(input,select,textarea):focus-visible{outline:2px solid #C084FC;outline-offset:1px;border-color:rgba(168,85,247,.6)}
:where(input,select,textarea)::placeholder{color:rgba(237,234,246,.42)}
:where(input[type=checkbox],input[type=radio],input[type=range]){accent-color:#A855F7}
:where(input[type=file])::file-selector-button{font:700 12px/1 Inter,system-ui,sans-serif;height:34px;padding:0 12px;margin-right:10px;
  border-radius:8px;border:1px solid rgba(255,255,255,.16);background:rgba(255,255,255,.05);color:#EDEAF6;cursor:pointer}
:where(input[type=file]){color:#B9B3C6;font:500 12px Inter,system-ui,sans-serif}

/* ── 2. zero horizontal overflow 360→1920 ── */
html,body{max-width:100%;overflow-x:clip}
:where(img,video,svg,canvas,iframe){max-width:100%}
:where(pre,code){overflow-wrap:anywhere}
:where(table){max-width:100%}

/* ══════════════════════════════════════════════════════════════════════
   CONTROL SCALE — the single source of storefront control geometry.
     sm 36px · md 40px (default) · lg 48px — the same at every screen size
     radius 10px · Inter 700 · 1px border · border-box
   Every other sheet sets colours/surfaces only, or reads these tokens; none
   re-asserts a height. Deliberately NOT on this scale (they keep their own
   size): tiles, cards, icon buttons, amount presets, menu/nav rows.
   Mark any other intentional exception with [data-exempt-scale].
   Storefront only (body:not(.crm-body)); the management console keeps its own.
   Checked by tools/storefront-visual-audit.cjs.
   ══════════════════════════════════════════════════════════════════════ */
:root{--ctl-h-sm:36px;--ctl-h:40px;--ctl-h-lg:48px;--ctl-r:10px;--ctl-px:14px;--ctl-px-sm:12px;--ctl-px-lg:20px;--ctl-gap:8px;
  --ctl-font:700 13px/1 Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --ctl-font-sm:700 12.5px/1 Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --ctl-font-lg:800 14px/1 Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --ctl-input-font:500 13px/1 Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}
/* phones: 16px input text so iOS does not zoom the page on focus */
@media (max-width:767px){:root{--ctl-input-font:500 16px/1 Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}}

/* buttons: .btn (primary) · .ghost (secondary); .sm/.xs · .lg */
html body:not(.crm-body) :is(.btn,.ghost):where(:not([class*="preset"]):not([class*="amount"]):not([class*="tile"]):not([data-exempt-scale])){
  box-sizing:border-box!important;display:inline-flex;align-items:center!important;gap:var(--ctl-gap)!important;
  height:var(--ctl-h)!important;min-height:var(--ctl-h)!important;max-height:var(--ctl-h)!important;
  padding:0 var(--ctl-px)!important;border-radius:var(--ctl-r)!important;font:var(--ctl-font)!important;letter-spacing:0!important}
html body:not(.crm-body) :is(.btn,.ghost):is(.sm,.xs):where(:not([class*="preset"]):not([class*="amount"]):not([class*="tile"]):not([data-exempt-scale])){
  height:var(--ctl-h-sm)!important;min-height:var(--ctl-h-sm)!important;max-height:var(--ctl-h-sm)!important;
  padding:0 var(--ctl-px-sm)!important;font:var(--ctl-font-sm)!important}
html body:not(.crm-body) :is(.btn,.ghost).lg:where(:not([class*="preset"]):not([class*="amount"]):not([class*="tile"]):not([data-exempt-scale])){
  height:var(--ctl-h-lg)!important;min-height:var(--ctl-h-lg)!important;max-height:var(--ctl-h-lg)!important;
  padding:0 var(--ctl-px-lg)!important;font:var(--ctl-font-lg)!important}
/* text inside a control follows the control (no inner span can make it taller) */
html body:not(.crm-body) :is(.btn,.ghost) :is(span,b,strong,em,small){font-size:inherit;line-height:1!important}
/* header actions sit beside the 40px menu button: one row height */
html body:not(.crm-body) .pn-actions :is(.btn,.ghost):is(.sm,.xs){height:var(--ctl-h)!important;min-height:var(--ctl-h)!important;max-height:var(--ctl-h)!important}

/* fields: one height, one radius */
html body:not(.crm-body) main :is(input,select):where(:not([type=hidden]):not([type=radio]):not([type=checkbox]):not([type=range]):not([type=file]):not([type=color]):not([type=submit]):not([type=button]):not([type=image])){
  box-sizing:border-box!important;height:var(--ctl-h)!important;min-height:var(--ctl-h)!important;
  padding:0 var(--ctl-px)!important;border-radius:var(--ctl-r)!important;font:var(--ctl-input-font)!important;letter-spacing:0}
html body:not(.crm-body) main select{padding-right:32px!important}
html body:not(.crm-body) main textarea{box-sizing:border-box!important;height:auto!important;min-height:88px!important;padding:11px var(--ctl-px)!important;
  border-radius:var(--ctl-r)!important;font:var(--ctl-input-font)!important;line-height:1.45!important}
/* plain <button>s in page content (no class of their own) join the scale too */
html body:not(.crm-body) main button:not([class]):not([data-exempt-scale]){
  box-sizing:border-box!important;height:var(--ctl-h)!important;min-height:var(--ctl-h)!important;
  padding:0 var(--ctl-px)!important;border-radius:var(--ctl-r)!important;font:var(--ctl-font)!important}
