/* Radex UI — the shared design system for Radex mini apps.
   Follows the WeChat mini program design spec principles (re-implemented, original styles):
   type scale 22/17/15/14/12, touch targets >= 48px, local (in-place) loading with skeletons,
   one primary action per screen, every error offers a way out. RTL-first, light + dark. */

/* TOKENS: generated by brand/design/build.mjs from brand/design/tokens.json — edit there */
:root {
  --brand: #0B7A4B;
  --brand-soft: rgba(11,122,75,.12);
  --on-brand: #FFFFFF;
  --bg: #EDEDED;
  --surface: #FFFFFF;
  --surface-2: #F7F7F7;
  --surface-3: #EFEFEF;
  --ink: rgba(0,0,0,.9);
  --ink-2: rgba(0,0,0,.55);
  --ink-3: rgba(0,0,0,.3);
  --line: rgba(0,0,0,.1);
  --line-2: rgba(0,0,0,.18);
  --link: #576B95;
  --danger: #FA5151;
  --warn: #FA9D3B;
  --warn-bg: #FFF4E5;
  --warn-ink: #8A4B00;
  --star: #F2A900;
  --mask: rgba(0,0,0,.6);
  --accent: var(--brand); --accent-ink: var(--on-brand); --accent-soft: var(--brand-soft);
  --r-tag: 4px;
  --r-button: 8px;
  --r-card: 12px;
  --r-sheet: 16px;
  --r-round: 999px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --h-touch: 48px;
  --h-button-lg: 48px;
  --h-button-md: 40px;
  --h-button-sm: 32px;
  --h-cell: 56px;
  --h-navbar: 44px;
  --h-tabbar: 56px;
  --h-icon: 24px;
  --m-fast: 150ms;
  --m-base: 200ms;
  --m-slow: 300ms;
  --m-toast: 1500ms;
  --m-easing: cubic-bezier(.2,0,0,1);
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #3FB67C;
    --brand-soft: rgba(63,182,124,.16);
    --on-brand: #FFFFFF;
    --bg: #111111;
    --surface: #191919;
    --surface-2: #202020;
    --surface-3: #2C2C2C;
    --ink: rgba(255,255,255,.85);
    --ink-2: rgba(255,255,255,.55);
    --ink-3: rgba(255,255,255,.3);
    --line: rgba(255,255,255,.08);
    --line-2: rgba(255,255,255,.16);
    --link: #7D90A9;
    --danger: #FA5151;
    --warn: #FFB341;
    --warn-bg: #33270F;
    --warn-ink: #FFD28A;
    --star: #F2B90D;
    --mask: rgba(0,0,0,.7);
    --shadow: none;
    color-scheme: dark;
  }
}
/* /TOKENS */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", sans-serif;
  font-size: 15px; line-height: 1.45; background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- type ---------- */
.t-22 { font-size: 22px; line-height: 30px; font-weight: 700; }
.t-17 { font-size: 17px; line-height: 24px; font-weight: 600; }
.t-15 { font-size: 15px; line-height: 22px; }
.t-14 { font-size: 14px; line-height: 20px; }
.t-12 { font-size: 12px; line-height: 16px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.accent { color: var(--accent); }
.bold { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.page { padding: 16px 16px calc(24px + var(--safe-b)); }
.page--bar { padding-bottom: calc(104px + var(--safe-b)); }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 22px 4px 10px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow); overflow: hidden; }
.card--pad { padding: 16px; }
.card--tap { transition: transform .12s ease; }
.card--tap:active { transform: scale(.985); }
.divider { height: 1px; background: var(--line); margin: 12px 0; border: 0; }

/* ---------- cells (grouped list) ---------- */
.cells { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow); overflow: hidden; }
.cell { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; position: relative; width: 100%;
        background: none; border: 0; text-align: start; }
.cell + .cell::before { content: ""; position: absolute; top: 0; inset-inline-start: 56px; inset-inline-end: 0; height: 1px; background: var(--line); }
.cell--tap:active { background: var(--surface-2); }
.cell__icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.cell__body { flex: 1; min-width: 0; }
.cell__title { font-size: 15px; font-weight: 600; }
.cell__desc { font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.cell__extra { color: var(--ink-2); font-size: 14px; }
.cell--link::after { content: "›"; color: var(--ink-3); font-size: 22px; line-height: 1; margin-inline-start: 4px; }
[dir="ltr"] .cell--link::after { content: "›"; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
       min-height: 48px; padding: 0 20px; border-radius: 14px; border: 0; font-weight: 700; font-size: 16px;
       transition: transform .1s ease, opacity .15s ease; user-select: none; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--secondary { background: var(--accent-soft); color: var(--accent); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--danger { background: transparent; color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 18px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); display: grid; place-items: center; font-size: 18px; }

/* bottom action bar: one primary action, always reachable by thumb */
.bottom-bar { position: fixed; inset-inline: 0; bottom: 0; padding: 12px 16px calc(12px + var(--safe-b));
              background: var(--surface);
              background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
              border-top: 1px solid var(--line); z-index: 20; animation: slide-up .25s ease; }

/* ---------- chips / segmented ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line-2);
        background: var(--surface); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.options { display: grid; gap: 10px; }
.option { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-md);
          border: 2px solid var(--line); background: var(--surface); width: 100%; text-align: start; }
.option.on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- small pieces ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600;
         background: var(--accent-soft); color: var(--accent); }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge--danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.price { font-size: 17px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.price--big { font-size: 28px; }
.stars { color: var(--star); font-size: 13px; font-weight: 700; }
.avatar { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 19px; flex: none; }
.avatar--lg { width: 72px; height: 72px; border-radius: 22px; font-size: 30px; }
.cover { height: 120px; display: grid; place-items: center; font-size: 52px; position: relative; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }

.search { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 12px; background: var(--surface-3); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; min-width: 0; }

.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 0; font-size: 20px; font-weight: 700; line-height: 1;
                  background: var(--accent); color: var(--accent-ink); }
.stepper button.minus { background: var(--accent-soft); color: var(--accent); }
.stepper span { min-width: 24px; text-align: center; font-weight: 700; }

/* progress tracker */
.steps { display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 24px 1fr; gap: 12px; min-height: 46px; position: relative; }
.step__dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface); margin: 4px auto 0; position: relative; z-index: 1; }
.step:not(:last-child)::after { content: ""; position: absolute; inset-inline-start: 11px; top: 20px; bottom: -2px; width: 2px; background: var(--line); }
.step.done .step__dot { background: var(--accent); border-color: var(--accent); }
.step.done:not(:last-child)::after { background: var(--accent); }
.step.now .step__dot { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); animation: pulse 1.4s ease infinite; }
.step__label { font-size: 15px; font-weight: 600; }
.step:not(.done):not(.now) .step__label { color: var(--ink-3); font-weight: 500; }

/* ---------- loading: in place, never a blocking modal ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
            background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
.sk-line { height: 14px; margin: 8px 0; }
.sk-card { height: 86px; border-radius: var(--r-md); margin-bottom: 12px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }

/* ---------- empty + error: always a way out ---------- */
.state { text-align: center; padding: 48px 24px; }
.state__icon { color: var(--faint, #8b8b8b); line-height: 0; }
[hidden] { display: none !important; }
.ic { display: inline-block; vertical-align: -0.2em; flex: none; }
.state__title { font-size: 17px; font-weight: 700; margin-top: 12px; }
.state__body { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.state .btn { margin-top: 18px; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; animation: fade .2s ease; }
.sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 22px 22px 0 0;
         padding: 8px 16px calc(20px + var(--safe-b)); max-height: 80vh; overflow-y: auto; animation: slide-up .25s cubic-bezier(.2,.8,.2,1); }
.sheet__grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 4px auto 14px; }

/* ---------- motion ---------- */
.fade-in { animation: fade .25s ease both; }
.rise { animation: rise .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px transparent; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ===================================================================================================
   radex.ma design system components (WeChat mini program design guidelines, WeUI conventions).
   Buttons 48/40/32px, cells 56px, radius 8 for buttons, 12 for cards, 16 for sheets.
   =================================================================================================== */
.btn { min-height: var(--h-button-lg); border-radius: var(--r-button); font-size: 17px; font-weight: 600; padding: 0 20px; }
.btn--md { min-height: var(--h-button-md); font-size: 15px; }
.btn--sm { min-height: var(--h-button-sm); font-size: 14px; padding: 0 12px; border-radius: 6px; }
.btn--default { background: var(--surface-3); color: var(--brand); }
.btn--warn { background: var(--surface-3); color: var(--danger); }
.btn--loading::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Text link (WeChat link color, not the brand color) */
.link { color: var(--link); text-decoration: none; }

/* Tags */
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: var(--r-tag); font-size: 12px; background: var(--surface-3); color: var(--ink-2); }
.tag--brand { background: var(--brand-soft); color: var(--brand); }
.tag--warn { background: var(--warn-bg); color: var(--warn-ink); }

/* Search bar with history (reduce typing: offer choices) */
.searchbar { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 8px; background: var(--surface); color: var(--ink-3); }
.searchbar input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--ink); }
.history { display: flex; flex-wrap: wrap; gap: 8px; }
.history button { border: 0; background: var(--surface-3); color: var(--ink-2); border-radius: 999px; padding: 6px 12px; font-size: 14px; min-height: 32px; }

/* Forms: errors at the top (banner) and in place (field) */
.form-error { display: flex; gap: 8px; align-items: flex-start; padding: 12px 16px; background: var(--warn-bg); color: var(--danger); font-size: 14px; border-radius: var(--r-card); margin-bottom: 12px; }
.field--error { color: var(--danger) !important; }
.field--error input, .field--error textarea { color: var(--danger); }
.field-msg { font-size: 12px; color: var(--danger); padding: 4px 16px 0; }

/* Dialog (modal): for results people must know, with the next step */
.dialog-mask { position: fixed; inset: 0; background: var(--mask); z-index: 60; animation: fade var(--m-base) ease; }
.dialog { position: fixed; z-index: 61; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(320px, calc(100vw - 64px));
  background: var(--surface); border-radius: var(--r-card); overflow: hidden; text-align: center; animation: pop var(--m-base) var(--m-easing); }
.dialog__hd { padding: 32px 24px 8px; font-size: 17px; font-weight: 600; }
.dialog__bd { padding: 0 24px 24px; font-size: 15px; color: var(--ink-2); line-height: 22px; overflow-wrap: anywhere; }
.dialog__ft { display: flex; border-top: 1px solid var(--line); }
.dialog__ft button { flex: 1; min-height: 56px; border: 0; background: transparent; font-size: 17px; font-weight: 600; color: var(--brand); }
.dialog__ft button + button { border-inline-start: 1px solid var(--line); }
.dialog__ft button.default { color: var(--ink); font-weight: 400; }
.dialog__ft button.warn { color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Action sheet */
.actionsheet { position: fixed; z-index: 61; inset-inline: 0; bottom: 0; background: var(--bg); border-radius: var(--r-sheet) var(--r-sheet) 0 0; overflow: hidden;
  padding-bottom: var(--safe-b); animation: rise var(--m-slow) var(--m-easing); }
.actionsheet__title { padding: 16px 24px; text-align: center; font-size: 14px; color: var(--ink-2); background: var(--surface); border-bottom: 1px solid var(--line); }
.actionsheet button { display: block; width: 100%; min-height: 56px; border: 0; background: var(--surface); font-size: 17px; color: var(--ink); }
.actionsheet button + button { border-top: 1px solid var(--line); }
.actionsheet button.warn { color: var(--danger); }
.actionsheet .cancel { margin-top: 8px; }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }

/* Result page: the end of a flow (success, warning, info) */
.result { text-align: center; padding: 56px 32px 32px; }
.result__icon { width: 64px; height: 64px; margin: 0 auto 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--brand); }
.result--warn .result__icon { background: var(--warn); } .result--error .result__icon { background: var(--danger); } .result--info .result__icon { background: var(--link); }
.result__title { font-size: 22px; line-height: 30px; font-weight: 600; }
.result__body { font-size: 15px; color: var(--ink-2); margin-top: 8px; line-height: 22px; }
.result__actions { display: flex; flex-direction: column; gap: 12px; margin-top: 40px; }

/* Loading: in place and simple; one per page; long waits show progress */
.loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; color: var(--ink-3); font-size: 14px; }
.loading::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ink-3); animation: spin .8s linear infinite; }
.progress { height: 3px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); transition: width var(--m-base) ease; }

/* Top tab bar (2-5 tabs, at most one per page) */
.tabs-top { display: flex; background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs-top button { flex: 1; min-height: 48px; border: 0; background: transparent; color: var(--ink-2); font-size: 15px; position: relative; }
.tabs-top button.on { color: var(--brand); font-weight: 600; }
.tabs-top button.on::after { content: ""; position: absolute; bottom: 0; left: 50%; width: 24px; height: 3px; border-radius: 2px; transform: translateX(-50%); background: var(--brand); }

[dir="rtl"] .cell--link::after { content: "‹"; }
