/*
 * Shared UI core for the storefront and the admin: design tokens (light +
 * dark), base elements, the standard components (buttons, form fields,
 * cards, badges, alerts, tables, tabs, key/value lists, stat cards, empty
 * states, pagination) and a small set of utilities.
 *
 * shop-core.css and admin-core.css add their own chrome on top in the same
 * layers. Page <style> blocks are unlayered, so they always win over these
 * files without !important. Colours in page styles must come from the tokens
 * below so dark mode works.
 *
 * Contents
 *   1. Tokens ............ colours, radius, control height, fonts (light + dark)
 *   2. Base .............. body, headings, links, form controls, tables
 *   3. Components
 *      3.1 Buttons ........ .btn  .btn-light .btn-outline .btn-ghost .btn-danger .btn-ok
 *                           sizes .btn-xs .btn-sm .btn-lg .btn-block, .icon-btn, .link-btn
 *      3.2 Forms .......... .field .hint .error .form-grid (.wide spans the row) .form-actions .check .input-group
 *      3.3 Cards .......... .card .card-head .card-flush .card-foot, details.card
 *      3.4 Page head ...... .page-head .page-actions
 *      3.5 Badges ......... .badge  -green -yellow -red -blue -primary
 *      3.6 Alerts ......... .alert  -success -error -warn -info
 *      3.7 Tables ......... .table-wrap, td.num, .table-cards (rows as cards on phones)
 *      3.8 Key/value ...... .kv (dl/dt/dd), .kv-sm, .copy-value + [data-copy] buttons
 *      3.9 Tabs ........... .tabs (.on), .seg (.on)
 *      3.10 Stats ......... .stats (.stats-2 .stats-3) .stat
 *      3.11 Empty state ... .empty
 *      3.12 Pagination .... .pager .pagination
 *      3.13 Secret value .. .secret
 *      3.14 Modal ......... .modal-backdrop(.open) .modal, .ui-confirm (UiConfirm dialog)
 *      3.15 Progress ...... .progress > span (width = done %)
 *      3.16 Timeline ...... .timeline (order progress, complaint steps)
 *      3.17 Order chat .... .order-chat, .oc-msg
 *      3.18 Date range .... [data-date-range] calendar with quick ranges (ui-core.js)
 *      3.19 Rank badge .... .rank-badge SVG emblem (.is-sm .is-lg + .rank-badge-fx glow .is-locked) + .rank-{style} colour stops
 *   4. Utilities ......... .sr-only, text colour/size/weight, spacing (4px steps), flex, width
 *   Icons: ui-icons.css (loaded right after this file) redraws the common boxicons classes in witchacademy's outline style.
 */
@layer icons, base, components, utilities;

/* ========== 1. Tokens ========== */
:root {
    color-scheme: light;
    --primary: #ea2424; /* overridden inline from the site.primary_color setting */
    --primary-soft: color-mix(in srgb, var(--primary) 10%, var(--card));
    --primary-strong: color-mix(in srgb, var(--primary) 82%, #000);
    --grad: linear-gradient(135deg, color-mix(in srgb, var(--primary) 80%, #fff), var(--primary-strong)); /* one hue, light to deep, so it suits any shop colour */
    --boost-grad: linear-gradient(135deg, #f59e0b, #f97316);
    --popular-grad: linear-gradient(135deg, #ef4444, #f97316);
    /* Currency coins drawn on game packages (partials/game-coin): Robux, Kim Cương, Quân Huy, FV. */
    --coin-light: #fde68a; --coin: #f5b301; --coin-deep: #b45309;
    --gem-light: #bae6fd; --gem: #38bdf8; --gem-deep: #0369a1;
    --honor-light: #fde68a; --honor: #f97316; --honor-deep: #9a3412;
    --fv-light: #d1fae5; --fv: #10b981; --fv-deep: #047857;
    /* Member rank badges (MemberRankStyle): light, mid and deep stop of each emblem. */
    --rank-bronze-a: #f8c9a0; --rank-bronze-b: #c8763a; --rank-bronze-c: #8a4216;
    --rank-silver-a: #f1f5f9; --rank-silver-b: #a3b1c2; --rank-silver-c: #5b6b80;
    --rank-gold-a: #fde68a; --rank-gold-b: #f5b301; --rank-gold-c: #b45309;
    --rank-platinum-a: #a7f3d0; --rank-platinum-b: #2dd4bf; --rank-platinum-c: #0f766e;
    --rank-diamond-a: #bae6fd; --rank-diamond-b: #38bdf8; --rank-diamond-c: #1d4ed8;
    --rank-master-a: #e9d5ff; --rank-master-b: #a855f7; --rank-master-c: #6d28d9;
    --rank-legend-a: #fde68a; --rank-legend-b: #f43f5e; --rank-legend-c: #9f1239;
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);

    /* Fixed palette, only for gradients, filled buttons and brand art. */
    --red-500: #ef4444; --red-600: #dc2626; --pink-500: #ec4899; --blue-600: #2563eb; --orange-500: #f97316; --violet-600: #7c3aed; --amber-500: #f59e0b; --yellow-500: #fbc02d; --sky-500: #279eff; --indigo-700: #4d2db7;
    --zinc-300: #d4d4d8; --zinc-800: #27272a;
    /* Discord's own dark theme, only for the "Kênh khoe đơn" preview. */
    --discord-bg: #313338; --discord-embed: #2b2d31; --discord-text: #dbdee1; --discord-muted: #949ba4; --discord-link: #00a8fc; --discord-blurple: #5865f2;

    --bg: #f4f5f8;
    --card: #fff;
    --surface-2: #f8fafc;
    --hover: #f4f7fb;
    --input-bg: #fff;
    --line: #eef2f7;
    --border: #e2e8f0;
    --field-border: #d5dde8;
    --ink: #0f172a;
    --ink-strong: #0b1222;
    --text: #334155;
    --text-2: #475569;
    --muted: #64748b;
    --faint: #94a3b8;

    /* Prices, highlights and "sale" text: the primary colour, a shade darker for contrast. */
    --accent: var(--primary);
    --accent-strong: var(--primary-strong);
    --accent-soft: var(--primary-soft);
    --highlight: #ea580c;

    --ok: #16a34a; --ok-ink: #166534;
    --warn: #d97706; --warn-ink: #92400e;
    --info: #2563eb; --info-ink: #1e40af;
    --bad: #dc2626; --bad-ink: #991b1b;
    --ok-soft: color-mix(in srgb, var(--ok) 12%, var(--card));
    --warn-soft: color-mix(in srgb, var(--warn) 14%, var(--card));
    --info-soft: color-mix(in srgb, var(--info) 11%, var(--card));
    --bad-soft: color-mix(in srgb, var(--bad) 11%, var(--card));
    /* A white notice card that stays white in dark mode too (the blind bag's "Hết hàng" card). */
    --paper: #fff; --paper-muted: #64748b;

    --overlay: rgba(15, 23, 42, .5);
    --veil: rgba(255, 255, 255, .65);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
    --shadow-pop: 0 16px 40px rgba(15, 23, 42, .16);
    /* Borderless storefront cards: resting and lifted (hover). */
    --shadow-card: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .06);
    --shadow-lift: 0 14px 34px rgba(15, 23, 42, .13);

    /* Panels (cards) and buttons in the witchacademy style: a faint tint of the shop colour in two corners, a soft glow under filled buttons. */
    --panel-border: color-mix(in srgb, var(--primary) 9%, var(--border));
    --panel-grad: radial-gradient(620px 250px at -6% 105%, color-mix(in srgb, var(--primary) 5%, transparent), transparent 68%), radial-gradient(520px 230px at 100% 0%, color-mix(in srgb, var(--info) 4%, transparent), transparent 70%), var(--card);
    --panel-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .06);
    /* Small pickable tiles inside a card (card types, amounts): flatter than a panel. */
    --tile-bg: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--primary) 2%, var(--card)));
    --tile-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 12px rgba(15, 23, 42, .04);
    --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.4l2.6 2.5L12 5.4' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --glow: 0 8px 20px color-mix(in srgb, var(--primary) 26%, transparent);
    --glow-strong: 0 14px 32px color-mix(in srgb, var(--primary) 38%, transparent), 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent);
    --radius-btn: 12px;

    /* Login scene (layouts.auth, auth.css): by day a pale blue-grey sky with the sun over the video author's mountains in blue (--land-*)
       and a white glass card; at night (dark block) a deep sky with stars and the moon over the same mountains in dusky violet,
       the wolf on the summit rimmed by moonlight. The button takes the shop
       colour; Halloween turns it teal by day and, at night, the scene a dusky mauve with an orange button. */
    --auth-sky-top: #c3d6df; --auth-sky-high: #dee8eb; --auth-sky-low: #ebeeeb; --auth-sky-foot: #f1f0e8;
    --auth-sun: radial-gradient(circle at 42% 40%, #fffdf2, #fff3c4 46%, #ffe08a);
    --auth-sun-glow: 0 0 34px 10px rgba(255, 236, 168, .65), 0 0 110px 40px rgba(255, 244, 205, .5);
    --auth-moon: radial-gradient(circle at 40% 38%, #fffdf3, #f4ecd2 50%, #d9cba4);
    --auth-moon-glow: 0 0 36px 10px rgba(244, 236, 210, .35), 0 0 130px 46px rgba(200, 190, 255, .16);
    --auth-crater: rgba(160, 146, 110, .35);
    /* The video author's halo breathing round the sun and the moon and the faint ring spreading from them. */
    --celestial-breath: radial-gradient(circle, rgba(255, 221, 164, .23) 12%, rgba(255, 215, 147, .09) 45%, transparent 72%);
    --celestial-ring: rgba(255, 225, 185, .13); --celestial-ring-glow: rgba(255, 215, 151, .13);
    --sun-breath: radial-gradient(circle, rgba(255, 230, 129, .4), rgba(255, 215, 99, .19) 43%, transparent 72%);
    --sun-ring: rgba(255, 241, 180, .23);
    --land-far-top: #a4c6d0; --land-far-foot: #6a9db0; --land-mid-top: #72a0b0; --land-mid-foot: #447a90;
    --land-peak-top: #648995; --land-peak-foot: #294f64; --land-sun: #c3d3c8; --land-shade: #3c6578;
    --land-mist: #e4ecdf; --land-wood: #224b59; --land-edge: rgba(226, 232, 203, .8);
    --land-cloud: #fffdf1; --land-cloud-foot: #c8dce2; --land-cloud-opacity: .75;
    /* The video author's torch and night sky on the login (auth.css): beam, revealed letters, owl, bats and witch. */
    --auth-beam: linear-gradient(90deg, rgb(255 224 156 / 75.4%) 0%, rgb(255 219 145 / 55.9%) 16%, rgb(255 214 140 / 32.5%) 35%, rgb(255 207 130 / 14.3%) 55%, rgb(255 202 124 / 3.9%) 75%, rgb(255 202 124 / 0%) 96%, transparent 100%);
    --auth-reveal-ink: #e9fbf9; --auth-reveal-mask: #f5f8fa; --auth-caret: #e5f7f5; --auth-placeholder-lit: #b1c7d4;
    --auth-flash-glow: rgb(255 246 157 / 80%); --auth-owl-shadow: rgb(0 0 0 / 30%);
    --sky-bat: #100919; --sky-bat-rim: rgb(255 214 176 / 55%); --sky-bat-glow: rgb(226 122 52 / 40%); --sky-witch: #281831; --sky-witch-rim: #ae7b9655;
    --auth-star: rgba(255, 244, 225, 0); --auth-firefly: rgba(255, 211, 107, 0);
    --auth-glass: rgba(255, 255, 255, .7); --auth-glass-line: rgba(255, 255, 255, .9);
    --auth-glass-shadow: 0 30px 70px -28px rgba(30, 70, 80, .45);
    --auth-field: rgba(255, 255, 255, .86);
    --auth-accent: var(--primary);
    --auth-btn: var(--grad);
    --auth-btn-glow: color-mix(in srgb, var(--primary) 50%, transparent);

    --radius-lg: 18px;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --control-h: 40px;
    --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    /* The only fonts on the site: one text font for everything (codes and numbers too, digits kept even), the telco wordmark stand-in and the login scene's serif headings. */
    --font-wordmark: Arial, Helvetica, sans-serif;
    /* Headings of the login scene only (loaded by layouts.auth), as in its reference design. */
    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --primary-soft: color-mix(in srgb, var(--primary) 18%, var(--card));
    --primary-strong: color-mix(in srgb, var(--primary) 70%, #fff);

    --bg: #070817;
    --card: #13152b;
    --surface-2: #191b36;
    --hover: #1c1e3c;
    --input-bg: #0c0e22;
    --line: #22243f;
    --border: #2b2d4d;
    --field-border: #36395e;
    --ink: #f8fafc;
    --ink-strong: #fff;
    --text: #cbd5e1;
    --text-2: #b6c2d3;
    --muted: #98a2b8;
    --faint: #64708a;
    --highlight: #fb923c;

    --ok: #22c55e; --ok-ink: #86efac;
    --warn: #f59e0b; --warn-ink: #fcd34d;
    --info: #3b82f6; --info-ink: #93c5fd;
    --bad: #ef4444; --bad-ink: #fca5a5;
    --ok-soft: color-mix(in srgb, var(--ok) 18%, var(--card));
    --warn-soft: color-mix(in srgb, var(--warn) 18%, var(--card));
    --info-soft: color-mix(in srgb, var(--info) 20%, var(--card));
    --bad-soft: color-mix(in srgb, var(--bad) 18%, var(--card));

    --overlay: rgba(0, 0, 0, .65);
    --veil: rgba(10, 15, 28, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, .55);
    --shadow-card: 0 0 0 1px rgba(255, 255, 255, .05), 0 2px 10px rgba(0, 0, 0, .35);
    --shadow-lift: 0 0 0 1px rgba(255, 255, 255, .08), 0 14px 34px rgba(0, 0, 0, .55);
    --panel-border: color-mix(in srgb, var(--primary) 24%, transparent);
    --panel-grad: radial-gradient(620px 250px at -6% 105%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 68%), radial-gradient(520px 230px at 100% 0%, rgba(14, 165, 233, .06), transparent 70%), linear-gradient(180deg, #1c1d33, #121322);
    --panel-shadow: 0 22px 58px rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255, 255, 255, .055);
    --tile-bg: linear-gradient(180deg, #1f2037, #17182a);
    --tile-shadow: 0 6px 16px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .05);

    --auth-sky-top: #070814; --auth-sky-high: #111232; --auth-sky-low: #201c45; --auth-sky-foot: #2b2352;
    --land-far-top: #665883; --land-far-foot: #322943; --land-mid-top: #413550; --land-mid-foot: #241c32;
    --land-peak-top: #3d3049; --land-peak-foot: #110d1c; --land-sun: #956982; --land-shade: #211729;
    --land-mist: #b39aa2; --land-wood: #130d1b; --land-edge: transparent;
    --land-cloud: #b7a5c5; --land-cloud-foot: #63516f; --land-cloud-opacity: .46;
    --auth-star: rgba(255, 244, 225, .9); --auth-firefly: #ffd36b;
    --auth-glass: rgba(20, 12, 36, .62); --auth-glass-line: rgba(255, 255, 255, .09);
    --auth-glass-shadow: 0 30px 80px -24px rgba(0, 0, 0, .7), 0 0 60px -20px rgba(124, 58, 237, .3);
    --auth-field: rgba(8, 5, 18, .58);
}

/* Seasonal theme (SeasonTheme, <html data-season>): Halloween recolours the storefront pumpkin orange on
   witch purple, warm parchment by day and a moonless night in dark mode. season-halloween.css only draws
   the decorations (spider, bats, candles, graves) from the --hw-* colours here. */
:root[data-season="halloween"] {
    --primary: #ea5f0c;
    --grad: linear-gradient(135deg, #ff9b3d, #e2560a 55%, #b8400a);
    --hw-orange: #ff7a1a; --hw-orange-deep: #c2410c; --hw-ember: #ffb357;
    --hw-purple: #7c3aed;
    --hw-wax: #f5ead6; --hw-wax-shade: #c9b38c; --hw-flame: #ffd36b; --hw-flame-core: #fff8dc;
    --hw-moon: rgba(255, 196, 110, .28); --hw-mist: rgba(124, 58, 237, .07); --hw-star: rgba(124, 58, 237, .25);
    /* The author's Halloween moon (season/moon-halloween.svg): its amber rim and the light and shade on the glass. */
    --hw-moon-rim: rgba(255, 219, 170, .84);
    --hw-moon-shade: inset 2px 3px 7px rgba(255, 238, 209, .7), inset -4px -5px 10px rgba(180, 80, 33, .28), 0 0 34px 10px rgba(255, 163, 78, .18);
    --hw-footer: #120a1c; --hw-footer-box: #1e1430; --hw-grave: #120a1c;
    --hw-castle: #05030a;
    --auth-accent: #0f8f84; --auth-btn: linear-gradient(135deg, #3cc4b4, #11968a 55%, #0b7a70); --auth-btn-glow: rgba(17, 150, 138, .5);

    --bg: #f7f0e6;
    --card: #fffaf3;
    --surface-2: #fbf3e8;
    --hover: #f8ecdc;
    --input-bg: #fffdf9;
    --line: #f0e3d2;
    --border: #e7d5bf;
    --field-border: #dcc6ac;
    --ink: #1f1428;
    --ink-strong: #160d1e;
    --text: #3b2f45;
    --text-2: #4c3f57;
    --muted: #776783;
    --faint: #a596ae;
    --highlight: #c2410c;
    --panel-border: color-mix(in srgb, var(--primary) 16%, var(--border));
    --panel-grad: radial-gradient(620px 250px at -6% 105%, color-mix(in srgb, var(--primary) 8%, transparent), transparent 68%), radial-gradient(520px 230px at 100% 0%, color-mix(in srgb, var(--hw-purple) 7%, transparent), transparent 70%), var(--card);
}

:root[data-season="halloween"][data-theme="dark"] {
    --primary: #ff7a1a;
    --grad: linear-gradient(135deg, #ffa149, #f2620e 55%, #c2410c);
    --hw-moon: rgba(255, 186, 92, .2); --hw-mist: rgba(124, 58, 237, .13); --hw-star: rgba(255, 240, 220, .55);
    --hw-footer: #06030b; --hw-footer-box: #140c20; --hw-grave: #06030b;
    --auth-sky-top: #120f19; --auth-sky-high: #211c2a; --auth-sky-low: #322a39; --auth-sky-foot: #3d3443;
    --auth-star: rgba(255, 240, 225, .55); --auth-firefly: #f2b06a;
    --auth-glass: rgba(22, 18, 28, .9); --auth-glass-line: rgba(255, 232, 210, .07);
    --auth-glass-shadow: 0 34px 90px -26px rgba(0, 0, 0, .8);
    --auth-field: rgba(10, 8, 14, .62);
    --auth-accent: #f0a050; --auth-btn: linear-gradient(135deg, #f6a65a, #e27a34 52%, #c65a22); --auth-btn-glow: rgba(226, 122, 52, .5);

    --bg: #0b0714;
    --card: #160e22;
    --surface-2: #1d1430;
    --hover: #241838;
    --input-bg: #0f0919;
    --line: #261a37;
    --border: #312346;
    --field-border: #3d2c56;
    --ink: #fbf7ff;
    --ink-strong: #fff;
    --text: #d9cfe6;
    --text-2: #c3b6d4;
    --muted: #a294b5;
    --faint: #6f6185;
    --highlight: #ffa94d;
    --panel-border: color-mix(in srgb, var(--primary) 22%, transparent);
    --panel-grad: radial-gradient(620px 250px at -6% 105%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 68%), radial-gradient(520px 230px at 100% 0%, color-mix(in srgb, var(--hw-purple) 16%, transparent), transparent 70%), linear-gradient(180deg, #1d1229, #130c1d);
    --tile-bg: linear-gradient(180deg, #211630, #170f24);
}

/* ========== 2. Base ========== */
@layer base {
    *, *::before, *::after { box-sizing: border-box; }
    html { -webkit-text-size-adjust: 100%; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--primary) 75%, transparent) transparent; }
    body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
    a { color: var(--primary); text-decoration: none; }
    img { max-width: 100%; }
    h1, h2, h3, h4 { color: var(--ink); line-height: 1.3; letter-spacing: -.01em; }
    h1 { font-size: 24px; margin: 0 0 20px; font-weight: 700; }
    h2 { font-size: 18px; margin: 0 0 12px; font-weight: 700; }
    h3 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
    p { margin: 0 0 12px; }
    b, strong { font-weight: 600; color: var(--ink); }
    small { font-size: 12.5px; }
    hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
    code, kbd, samp, pre { font-family: var(--font); font-variant-numeric: tabular-nums; }
    code { font-size: .92em; padding: 1px 5px; border-radius: var(--radius-xs); background: var(--surface-2); color: var(--ink); }
    label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink); }

    button, input, select, textarea { font: inherit; color: inherit; }
    input[type=text], input[type=number], input[type=password], input[type=email], input[type=date], input[type=datetime-local], input[type=time], input[type=month], input[type=file], input[type=search], input[type=url], input[type=tel], select, textarea {
        width: 100%; min-height: var(--control-h); padding: 8px 12px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--ink); font-size: 14px; transition: border-color .15s, box-shadow .15s;
    }
    /* File pickers: dashed drop box with a soft primary "Chọn tệp" pill instead of the grey system button. */
    input[type=file] { display: block; padding: 5px 12px 5px 5px; border-style: dashed; background: var(--surface-2); color: var(--muted); font-size: 13px; line-height: 28px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    input[type=file]:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--field-border)); background: var(--primary-soft); color: var(--ink); }
    input[type=file]::file-selector-button { height: 28px; margin-right: 12px; padding: 0 14px; border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); border-radius: var(--radius-xs); background: var(--primary-soft); color: color-mix(in srgb, var(--primary) 60%, var(--ink)); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s; }
    input[type=file]:hover::file-selector-button { border-color: transparent; background: var(--primary); color: #fff; }
    input::placeholder, textarea::placeholder { color: var(--faint); }
    input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: var(--focus-ring); }
    input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--surface-2); color: var(--muted); }
    textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
    input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; vertical-align: -3px; }

    table { width: 100%; border-collapse: collapse; }
    th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
    th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: var(--surface-2); white-space: nowrap; }
    tbody tr:hover td { background: var(--hover); }

    :focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 60%, transparent); outline-offset: 2px; }
}

/* ========== 3. Components ========== */
@layer components {
    /* 3.1 Buttons: .btn is the filled primary action; the rest are variants and sizes. */
    .btn {
        position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
        min-height: var(--control-h); padding: 0 17px; border-radius: var(--radius-btn); border: 1px solid transparent;
        background: var(--grad); color: #fff; font: inherit; font-size: 14px; font-weight: 700; line-height: 1.2; text-align: center; cursor: pointer; white-space: nowrap;
        box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, .18); --sheen: rgba(255, 255, 255, .24);
        transition: background-color .15s, border-color .15s, color .15s, box-shadow .25s, filter .2s, transform .32s cubic-bezier(.34, 1.56, .64, 1);
    }
    /* A soft light that follows the pointer inside the button (ui-core.js sets --bx / --by). */
    .btn::after { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .25s; background: radial-gradient(110px circle at var(--bx, 50%) var(--by, 50%), var(--sheen), transparent 72%); }
    .btn:hover { transform: translateY(-1px); filter: brightness(1.06) saturate(1.06); box-shadow: var(--glow-strong), inset 0 1px 0 rgba(255, 255, 255, .22); }
    .btn:hover::after { opacity: 1; }
    .btn:active { transform: translateY(1px) scale(.97); transition-duration: .08s; }
    .btn > i { font-size: 18px; }
    .btn[hidden] { display: none; }
    .btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; filter: none; }
    .btn-light { background: var(--card); color: var(--ink); border-color: var(--field-border); box-shadow: 0 1px 2px rgba(15, 23, 42, .05); --sheen: color-mix(in srgb, var(--primary) 14%, transparent); }
    .btn-light:hover { background: color-mix(in srgb, var(--primary) 4%, var(--card)); border-color: color-mix(in srgb, var(--primary) 40%, var(--field-border)); color: var(--primary); filter: none; box-shadow: 0 8px 20px rgba(15, 23, 42, .08); }
    .btn-outline { background: var(--card); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 55%, var(--field-border)); box-shadow: none; --sheen: color-mix(in srgb, var(--primary) 16%, transparent); }
    .btn-outline:hover { background: var(--primary-soft); border-color: var(--primary); filter: none; box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 14%, transparent); }
    .btn-ghost { background: none; color: var(--text); box-shadow: none; --sheen: color-mix(in srgb, var(--primary) 12%, transparent); }
    .btn-ghost:hover { background: color-mix(in srgb, var(--primary) 7%, transparent); color: var(--primary); filter: none; box-shadow: none; transform: none; }
    .btn-danger { background: linear-gradient(135deg, color-mix(in srgb, var(--bad) 82%, #fff), color-mix(in srgb, var(--bad) 85%, #000)); box-shadow: 0 8px 20px color-mix(in srgb, var(--bad) 24%, transparent), inset 0 1px 0 rgba(255, 255, 255, .18); }
    .btn-danger:hover { box-shadow: 0 14px 32px color-mix(in srgb, var(--bad) 34%, transparent), inset 0 1px 0 rgba(255, 255, 255, .22); }
    .btn-ok { background: linear-gradient(135deg, color-mix(in srgb, var(--ok) 82%, #fff), color-mix(in srgb, var(--ok) 85%, #000)); box-shadow: 0 8px 20px color-mix(in srgb, var(--ok) 24%, transparent), inset 0 1px 0 rgba(255, 255, 255, .18); }
    .btn-ok:hover { box-shadow: 0 14px 32px color-mix(in srgb, var(--ok) 34%, transparent), inset 0 1px 0 rgba(255, 255, 255, .22); }
    :root[data-theme="dark"] .btn-light, :root[data-theme="dark"] .btn-outline { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045); }
    :root[data-theme="dark"] .btn-light:hover { box-shadow: 0 8px 20px rgba(0, 0, 0, .28), 0 0 0 1px color-mix(in srgb, var(--primary) 12%, transparent); }
    .btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
    .btn-sm > i { font-size: 16px; }
    .btn-xs { min-height: 26px; padding: 0 9px; font-size: 12px; border-radius: 8px; }
    .btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; border-radius: 14px; }
    .btn-block { display: flex; width: 100%; }
    .icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 20px; cursor: pointer; }
    .icon-btn:hover { color: var(--primary); border-color: var(--primary); }
    .link-btn { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
    .link-btn:hover { text-decoration: underline; }

    /* 3.2 Forms: <div class="field"><label>..</label><input>..<p class="hint">..</p></div> */
    .field { margin-bottom: 16px; }
    .field > label small, label .optional { font-weight: 500; color: var(--muted); }
    .hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; font-weight: 400; }
    .error, .field .error { color: var(--bad); font-size: 12.5px; margin: 4px 0 0; font-weight: 500; }
    .form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 0 16px; }
    .form-grid > .wide { grid-column: 1 / -1; }
    .form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
    .check { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; color: var(--text); cursor: pointer; }
    .input-group { display: flex; gap: 8px; }
    .input-group > input, .input-group > select { flex: 1; min-width: 0; }

    /* 3.3 Card: the standard panel, a faint tint of the shop colour in the corners (witchacademy .ui-card). */
    .card { background: var(--panel-grad); border: 1px solid var(--panel-border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 20px; box-shadow: var(--panel-shadow); }
    .card h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
    .card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
    .card-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
    /* Icon tile (witchacademy): the icon sits in a small square tinted with its tone (--tone, else the shop colour),
       a fine border of the same tone, a soft glow under it and a light top edge. */
    .card-head h2 > i, details.card > summary > i, .empty > i {
        --ic: var(--tone, var(--primary));
        flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; font-size: 18px; color: var(--ic);
        border: 1px solid color-mix(in srgb, var(--ic) 26%, transparent);
        background: radial-gradient(circle at 35% 22%, color-mix(in srgb, var(--card) 70%, transparent), transparent 45%), color-mix(in srgb, var(--ic) 12%, var(--card));
        box-shadow: 0 6px 16px color-mix(in srgb, var(--ic) 16%, transparent), inset 0 1px 0 rgba(255, 255, 255, .12);
    }
    .card-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
    .card-flush { padding: 0; overflow: hidden; }
    .card-flush > .card-head { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--line); }
    .card-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line); }
    /* A card that folds open: <details class="card"><summary>Title</summary>...</details> */
    details.card > summary { display: flex; align-items: center; gap: 8px; min-height: 24px; font-weight: 600; color: var(--ink); cursor: pointer; list-style: none; }
    details.card > summary::-webkit-details-marker { display: none; }
    details.card > summary::after { content: ''; flex: none; width: 8px; height: 8px; margin-left: auto; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
    details.card[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
    details.card > summary > i { width: 30px; height: 30px; border-radius: 10px; font-size: 16px; }

    /* 3.4 Page head: <x-page-head> */
    .page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
    .page-head h1 { margin: 0; display: flex; align-items: center; gap: 10px; }
    .page-head h1 > i { flex: none; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 22px; box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, .22); }
    .page-head p { margin: 4px 0 0; color: var(--muted); }
    .page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

    /* 3.5 Badges: status pills. green = done, yellow = waiting, red = failed/cancelled, blue = info. */
    .badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; background: var(--surface-2); color: var(--muted); white-space: nowrap; box-shadow: inset 0 0 0 1px var(--line); }
    .badge-green { background: var(--ok-soft); color: var(--ok-ink); box-shadow: none; }
    .badge-red { background: var(--bad-soft); color: var(--bad-ink); box-shadow: none; }
    .badge-yellow { background: var(--warn-soft); color: var(--warn-ink); box-shadow: none; }
    .badge-blue { background: var(--info-soft); color: var(--info-ink); box-shadow: none; }
    .badge-primary { background: var(--primary-soft); color: var(--primary-strong); box-shadow: none; }

    /* 3.6 Alerts */
    .alert { display: flex; gap: 10px; align-items: flex-start; border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-weight: 500; line-height: 1.5; border: 1px solid transparent; }
    .alert > i { font-size: 20px; line-height: 1.1; flex: none; }
    .alert-success { background: var(--ok-soft); color: var(--ok-ink); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
    .alert-error { background: var(--bad-soft); color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
    .alert-warn { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 24%, transparent); }
    .alert-info { background: var(--info-soft); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
    .alert b, .alert strong { color: inherit; }
    .alert ul, .alert ol { margin: 0; padding-left: 18px; }

    /* 3.7 Tables: wrap any wide table so it scrolls instead of breaking the page. */
    .table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
    .table-wrap table { background: var(--card); }
    .table-wrap tr:last-child td { border-bottom: 0; }
    .card > .table-wrap:last-child, .card-flush > .table-wrap { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
    .card-flush > .table-wrap { border: 0; }
    td.num, th.num { text-align: right; white-space: nowrap; }
    /*
     * <div class="table-wrap table-cards">: on phones each row becomes a card, each <td data-label="…">
     * a "label: value" line (admin-core.js fills a missing data-label from the column heading).
     * td.cell-main is the card title, td.cell-check sits top right, td.cell-actions holds the buttons
     * along the bottom.
     */
    @media (max-width: 560px) {
        .table-cards { overflow: visible; border: 0; border-radius: 0; background: none; }
        .card:has(> .table-cards) { padding: 0; border: 0; background: none; box-shadow: none; }
        .table-cards table, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; background: none; }
        .table-cards thead { display: none; }
        .table-cards tr { position: relative; display: flex; flex-direction: column; margin-bottom: 10px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
        .table-cards td { display: flow-root; padding: 6px 0; border: 0; text-align: right; white-space: normal; }
        .table-cards td[data-label]::before { content: attr(data-label); float: left; margin: 1px 12px 0 0; color: var(--muted); font-size: 12.5px; font-weight: 500; text-align: left; }
        .table-cards td[data-label] > * { margin-left: auto; }
        .table-cards tbody tr > td.cell-main { display: block; order: -1; margin-bottom: 2px; padding: 4px 34px 10px 0; border-bottom: 1px solid var(--line); text-align: left; }
        .table-cards td.cell-main > a:first-child { display: inline-block; margin: -8px 0; padding: 8px 16px 8px 0; }
        .table-cards tr:has(> td.cell-thumb:not(:empty)) { display: grid; grid-template-columns: auto minmax(0, 1fr); }
        .table-cards tr:has(> td.cell-thumb:not(:empty)) > td { grid-column: 1 / -1; }
        .table-cards tr:has(> td.cell-thumb:not(:empty)) > td.cell-thumb { grid-column: 1; grid-row: 1; margin-bottom: 2px; padding: 4px 12px 10px 0; border-bottom: 1px solid var(--line); }
        .table-cards tr:has(> td.cell-thumb:not(:empty)) > td.cell-main { grid-column: 2; grid-row: 1; }
        .table-cards td.cell-check { position: absolute; top: 12px; right: 14px; width: auto; padding: 0; }
        .table-cards td.cell-actions { display: block; padding-top: 8px; }
        .table-cards td.cell-block { text-align: left; }
        .table-cards td.cell-block[data-label]::before { display: block; float: none; margin: 0 0 4px; }
        .table-cards td:empty { display: none; }
        .table-cards td[colspan] { text-align: center; }
        .table-cards td.cell-actions > * { justify-content: flex-end; }
        .table-cards td.cell-actions > .btn:only-child { width: 100%; justify-content: center; }
    }

    /* 3.8 Key/value list for order and account details: <dl class="kv"><dt>..</dt><dd>..</dd></dl> */
    .kv { display: grid; grid-template-columns: minmax(104px, 32%) minmax(0, 1fr); margin: 0; }
    @media (min-width: 640px) { .kv { grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); } }
    .kv > dt, .kv > dd { margin: 0; padding: 10px 0; border-bottom: 1px dashed var(--line); }
    .kv > dt { color: var(--muted); font-weight: 500; padding-right: 12px; }
    .kv > dd { color: var(--ink); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
    .kv > :nth-last-child(-n+2) { border-bottom: 0; }
    /* Compact variant for list cards: label left, value right-aligned. */
    .kv-sm { grid-template-columns: auto minmax(0, 1fr); font-size: 13px; }
    .kv-sm > dt, .kv-sm > dd { padding: 5px 0; }
    .kv-sm > dd { text-align: right; }
    /* A value with its copy button (ui-core.js): <div class="copy-value"><code>..</code><button data-copy="..">..</button></div> */
    .copy-value { display: flex; align-items: center; gap: 8px; }
    .copy-value > code, .copy-value > b { flex: 0 1 auto; min-width: 0; font-variant-numeric: tabular-nums; font-size: 14.5px; font-weight: 700; color: var(--ink); background: none; padding: 0; overflow-wrap: anywhere; }
    .copy-value > button { flex: none; }
    [data-copy].is-copied { color: var(--ok-ink); border-color: var(--ok); }
    .btn[data-copy].is-copied { background: var(--ok); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--ok) 28%, transparent); }
    .btn-light[data-copy].is-copied { background: var(--ok-soft); color: var(--ok-ink); box-shadow: none; }
    /* Copying was blocked: the text sits selected in a bar above the phone's bottom nav for a long-press copy. */
    .copy-manual { position: fixed; z-index: 1700; left: 8px; right: 8px; bottom: calc(var(--bottom-nav-h, 0px) + env(safe-area-inset-bottom, 0px) + 10px); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); animation: ui-confirm-rise .2s ease-out; }
    .copy-manual > p { grid-column: 1 / -1; display: flex; gap: 6px; align-items: flex-start; margin: 0; font-size: 13px; color: var(--muted); }
    .copy-manual > p > i { flex: none; font-size: 17px; color: var(--primary); }
    .copy-manual > input { min-width: 0; min-height: 38px; padding: 0 10px; font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
    .copy-manual > button { min-height: 38px; }
    @media (min-width: 768px) { .copy-manual { left: auto; right: 16px; bottom: 16px; width: 380px; } }

    /* 3.9 Tabs: links or buttons in a row; the current one carries .on (or aria-selected). */
    .tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 16px; scrollbar-width: none; }
    .tabs > a, .tabs > button { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }
    .tabs > a:hover, .tabs > button:hover { color: var(--ink); }
    .tabs > .on, .tabs > [aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
    .seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg); border-radius: var(--radius-sm); }
    .seg button, .seg a { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
    .seg .on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }

    /* 3.10 Stats: <x-admin.stat> inside .stats. A short card: the icon tile on the left, label, number in the
       card's tone and an optional note stacked beside it, a soft glow of the tone in the corners. Cards rise in one after another; hovering lifts
       the card, lights its border and tilts the icon. */
    .stats { display: grid; grid-template-columns: repeat(var(--stats-cols, 4), minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
    .stats-2 { --stats-cols: 2; }
    .stats-3 { --stats-cols: 3; }
    .stats-5 { --stats-cols: 5; }
    @media (max-width: 1180px) { .stats { grid-template-columns: repeat(min(2, var(--stats-cols, 4)), minmax(0, 1fr)); } }
    .stat {
        --stat-tone: var(--tone, var(--primary));
        display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; align-content: center; gap: 1px 12px;
        min-width: 0; padding: 12px 14px; color: inherit;
        border: 1px solid color-mix(in srgb, var(--stat-tone) 18%, var(--border)); border-radius: var(--radius);
        background:
            radial-gradient(260px 130px at -8% 115%, color-mix(in srgb, var(--stat-tone) 14%, transparent), transparent 70%),
            radial-gradient(220px 120px at 105% -12%, color-mix(in srgb, var(--stat-tone) 8%, transparent), transparent 70%),
            var(--card);
        box-shadow: var(--shadow);
        animation: stat-rise .36s ease backwards;
        transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
    }
    .stats > .stat:nth-child(2) { animation-delay: .04s; }
    .stats > .stat:nth-child(3) { animation-delay: .08s; }
    .stats > .stat:nth-child(n+4) { animation-delay: .12s; }
    .stat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--stat-tone) 45%, var(--border)); box-shadow: 0 14px 30px color-mix(in srgb, var(--stat-tone) 16%, transparent), var(--shadow); }
    .stat > i {
        grid-row: 1 / span 3; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; color: var(--stat-tone);
        border: 1px solid color-mix(in srgb, var(--stat-tone) 28%, transparent);
        background: radial-gradient(circle at 35% 22%, color-mix(in srgb, var(--card) 75%, transparent), transparent 45%), var(--tone-soft, var(--primary-soft));
        box-shadow: 0 6px 16px color-mix(in srgb, var(--stat-tone) 18%, transparent);
        transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
    }
    .stat:hover > i { transform: scale(1.08) rotate(-6deg); }
    .stat > div { display: contents; }
    .stat > div > * { min-width: 0; }
    .stat > div > * { grid-column: 2; }
    .stat small { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .stat b { display: block; font-size: 19px; font-weight: 800; line-height: 1.25; color: var(--stat-tone); letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .stat span { display: block; font-size: 11.5px; font-weight: 500; line-height: 1.3; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    @keyframes stat-rise { from { opacity: 0; transform: translateY(8px); } }
    @media (prefers-reduced-motion: reduce) { .stat, .stat > i { animation: none; transition: none; } }
    /* Phones: two compact cards per row; an odd last card takes the full row. */
    @media (max-width: 560px) {
        .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
        .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
        .stats .stat { gap: 0 9px; padding: 10px; }
        .stats .stat > i { width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
        .stats .stat small, .stats .stat span { white-space: normal; }
        .stats .stat small { font-size: 12px; }
        .stats .stat b { font-size: 16px; }
        .stats .stat span { font-size: 11px; }
    }

    /* 3.11 Empty state */
    .empty { padding: 28px 18px; text-align: center; color: var(--faint); }
    .empty:not(.card) { border: 1px dashed color-mix(in srgb, var(--primary) 24%, var(--border)); border-radius: var(--radius); background: color-mix(in srgb, var(--primary) 3%, transparent); }
    .empty > i { width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 14px; font-size: 24px; }
    .empty p { margin: 0 0 12px; color: var(--muted); }

    /* 3.12 Pagination (resources/views/vendor/pagination/default): the pager centred on the page, the row count under it.
       Phones: "Trước · Trang x / y · Sau" across the full width instead of the page numbers. */
    .pager { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 20px 0 0; }
    .pager-info { order: 1; margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
    .pager-info b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
    .pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; list-style: none; padding: 0; margin: 0; }
    .pagination .page-link { display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-width: 38px; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; transition: border-color .15s, color .15s, background .15s; }
    .pagination .page-link i { font-size: 20px; }
    .pagination a.page-link:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
    .pagination .active .page-link { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 14px color-mix(in srgb, var(--primary) 28%, transparent); }
    .pagination .disabled .page-link { color: var(--faint); background: var(--surface-2); }
    .pagination .page-gap .page-link { min-width: 24px; padding: 0; border-color: transparent; background: none; color: var(--faint); }
    .pagination .page-step .page-link > span, .pagination .page-of { display: none; }
    @media (max-width: 640px) {
        .pagination { flex-wrap: nowrap; width: 100%; }
        .pagination .page-num, .pagination .page-gap { display: none; }
        .pagination .page-of { display: block; flex: 1; text-align: center; }
        .pagination .page-of .page-link { border: 0; background: none; color: var(--muted); font-weight: 500; }
        .pagination .page-of b { margin: 0 2px; color: var(--ink); }
        .pagination .page-step .page-link { padding: 0 14px 0 10px; }
        .pagination .page-step:last-child .page-link { padding: 0 10px 0 14px; }
        .pagination .page-step .page-link > span { display: inline; }
    }

    /* 3.13 Secret value: copyable login or card code on a tinted strip. */
    .secret { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border); font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink); word-break: break-all; }

    /* 3.14 Modal: dialog shell shared by the shop modals */
    .modal-backdrop { position: fixed; inset: 0; background: var(--overlay); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 2000; }
    .modal-backdrop.open { display: flex; }
    .modal { background: var(--card); border-radius: var(--radius); width: 100%; max-width: 440px; padding: 20px; box-shadow: var(--shadow-pop); max-height: calc(100vh - 32px); overflow-y: auto; }
    .modal h3 { margin: 0 0 14px; display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 17px; }
    .modal h3 > i { color: var(--primary); font-size: 22px; }

    /* 3.14b Confirm dialog (UiConfirm in ui-core.js): centred card with a round icon, heading, note, optional rows and total, two big buttons. is-danger turns it red. */
    .ui-confirm { z-index: 2100; }
    .ui-confirm.open { animation: ui-confirm-fade .15s ease-out; }
    .ui-confirm .modal { max-width: 400px; padding: 26px 20px 20px; border-radius: var(--radius-lg); text-align: center; animation: ui-confirm-pop .22s cubic-bezier(.2, .9, .3, 1.15); }
    .ui-confirm [hidden] { display: none; }
    .ui-confirm-icon { --ring: var(--primary); position: relative; display: inline-grid; place-items: center; width: 60px; height: 60px; margin-bottom: 14px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 32px; box-shadow: 0 0 0 7px color-mix(in srgb, var(--primary) 6%, transparent); }
    /* Every box keeps blinking softly while it waits: a ring keeps spreading out of the round icon and a shine keeps crossing the main button. */
    .ui-confirm-icon::before { content: ''; position: absolute; inset: 0; border: 2px solid var(--ring); border-radius: 50%; opacity: 0; pointer-events: none; animation: ui-confirm-ring 1.7s calc(var(--fx, 0s) + .4s) ease-out infinite; }
    .ui-confirm-actions .btn:not(.btn-light) { overflow: hidden; }
    .ui-confirm-actions .btn:not(.btn-light)::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%); transform: translateX(-100%); pointer-events: none; animation: ui-confirm-shine 2.6s calc(var(--fx, 0s) + .9s) ease-in-out infinite; }
    .ui-confirm.is-danger .ui-confirm-icon { --ring: var(--bad); background: var(--bad-soft); color: var(--bad); box-shadow: 0 0 0 7px color-mix(in srgb, var(--bad) 6%, transparent); }
    .ui-confirm.is-success .ui-confirm-icon { --ring: var(--ok); background: var(--ok); color: #fff; box-shadow: 0 0 0 7px color-mix(in srgb, var(--ok) 14%, transparent); }
    .ui-confirm .modal h3 { display: block; margin: 0; font-size: 18px; line-height: 1.4; }
    .ui-confirm-lead { margin: 6px 0 0; color: var(--accent); font-size: 16px; font-weight: 700; }
    .ui-confirm-text { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; white-space: pre-line; }
    .ui-confirm-rows { margin: 16px 0 0; padding: 2px 14px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: left; }
    .ui-confirm-rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; font-size: 14px; }
    .ui-confirm-rows > div + div { border-top: 1px dashed var(--border); }
    .ui-confirm-rows dt { color: var(--muted); flex: none; }
    .ui-confirm-rows dd { margin: 0; color: var(--ink); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
    .ui-confirm-total { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); text-align: left; }
    .ui-confirm-total span { color: var(--text); font-size: 14px; font-weight: 600; }
    .ui-confirm-total b { color: var(--accent); font-size: 21px; font-weight: 800; }
    .ui-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
    .ui-confirm.is-alert .ui-confirm-actions { grid-template-columns: 1fr; }
    .ui-confirm.is-danger [data-ok] { background: var(--bad); box-shadow: 0 6px 16px color-mix(in srgb, var(--bad) 28%, transparent); }
    /* is-success plays a short celebration each time the box shows: the card springs up, the green circle pops with a few confetti
       dots, the tick draws itself and the lines rise in one by one. --reveal-delay holds it all back (the ring and shine above too)
       while something else plays first (the blind bag burst in shop-pages.css). */
    .ui-confirm.is-success { --fx: var(--reveal-delay, 0s); }
    .ui-confirm.is-success .modal { animation: ui-confirm-spring .5s var(--fx) cubic-bezier(.2, 1.1, .3, 1.12) both; }
    .ui-confirm.is-success .ui-confirm-icon { animation: ui-confirm-icon .55s calc(var(--fx) + .1s) cubic-bezier(.3, 1.5, .5, 1) both; }
    .ui-confirm.is-success .ui-confirm-icon i { display: block; animation: ui-confirm-tick .35s calc(var(--fx) + .4s) ease-out both; }
    .ui-confirm.is-success .ui-confirm-icon::after {
        content: ''; position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; opacity: 0; pointer-events: none;
        box-shadow: 0 -50px 0 var(--ok), 35px -35px 0 var(--warn), 50px 0 0 var(--primary), 35px 35px 0 var(--info), 0 50px 0 var(--ok), -35px 35px 0 var(--warn), -50px 0 0 var(--info), -35px -35px 0 var(--primary),
            19px -46px 0 -1px var(--info), 46px -19px 0 -1px var(--ok), 46px 19px 0 -1px var(--warn), 19px 46px 0 -1px var(--primary), -19px 46px 0 -1px var(--ok), -46px 19px 0 -1px var(--primary), -46px -19px 0 -1px var(--ok), -19px -46px 0 -1px var(--warn);
        animation: ui-confirm-confetti .75s calc(var(--fx) + .38s) cubic-bezier(.15, .7, .3, 1);
    }
    .ui-confirm.is-success .modal > :is(h3, .ui-confirm-lead, .ui-confirm-text, .ui-confirm-actions), .ui-confirm.is-success :is(.ui-confirm-rows > div, .ui-confirm-total) { animation: ui-confirm-rise .4s calc(var(--fx) + var(--rise, .2s)) ease-out both; }
    .ui-confirm.is-success .modal > .ui-confirm-lead { --rise: .27s; }
    .ui-confirm.is-success .modal > .ui-confirm-text { --rise: .34s; }
    .ui-confirm.is-success .ui-confirm-rows > div { --rise: .4s; }
    .ui-confirm.is-success .ui-confirm-rows > div:nth-child(2) { --rise: .46s; }
    .ui-confirm.is-success .ui-confirm-rows > div:nth-child(3) { --rise: .52s; }
    .ui-confirm.is-success .ui-confirm-rows > div:nth-child(n + 4) { --rise: .58s; }
    .ui-confirm.is-success .ui-confirm-total { --rise: .6s; }
    .ui-confirm.is-success .modal > .ui-confirm-actions { --rise: .64s; }
    @media (prefers-reduced-motion: reduce) {
        .ui-confirm.is-success :is(.modal, .modal > *, .ui-confirm-icon i, .ui-confirm-rows > div, .ui-confirm-total), .ui-confirm.is-success .ui-confirm-icon::after, .ui-confirm-icon::before, .ui-confirm-actions .btn:not(.btn-light)::before { animation: none; }
    }
    @keyframes ui-confirm-fade { from { opacity: 0; } }
    @keyframes ui-confirm-pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }
    @keyframes ui-confirm-spring { from { opacity: 0; transform: translateY(22px) scale(.86); } 60% { opacity: 1; } }
    @keyframes ui-confirm-icon { from { transform: scale(0) rotate(-35deg); } 60% { transform: scale(1.14) rotate(4deg); } }
    @keyframes ui-confirm-tick { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
    @keyframes ui-confirm-ring { from { opacity: .75; transform: scale(1); } 65%, to { opacity: 0; transform: scale(1.8); } }
    @keyframes ui-confirm-confetti { from { opacity: 1; transform: scale(.3); } 70% { opacity: 1; } to { opacity: 0; transform: scale(1.12); } }
    @keyframes ui-confirm-rise { from { opacity: 0; transform: translateY(8px); } }
    @keyframes ui-confirm-shine { from { transform: translateX(-100%); } 40%, to { transform: translateX(100%); } }

    /* 3.15 Progress bar: <div class="progress"><span style="width: 40%"></span></div> */
    .progress { height: 8px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
    .progress > span { display: block; height: 100%; border-radius: inherit; background: var(--grad); }
    .progress-ok > span { background: var(--ok); }

    /* 3.16 Timeline: order progress, complaint steps. A tone on the <li> (is-info / is-ok / is-warn / is-bad, grey without one); is-now rings the current step and tints its card.
       Long timelines fold: a hidden .tl-toggle checkbox before the <ol>, .is-extra on the older <li>s and a <label class="tl-more"> after it.
       <ol class="timeline"><li class="is-ok"><span class="tl-dot"><i class="bx .."></i></span><div class="tl-main"><div class="tl-head"><strong>..</strong><span class="tl-time">..</span></div><p class="tl-body">..</p></div></li></ol> */
    .timeline { list-style: none; margin: 0 0 14px; padding: 0; }
    .timeline > li { position: relative; display: flex; gap: 12px; padding-bottom: 10px; }
    .timeline > li:last-child { padding-bottom: 0; }
    .timeline > li:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; border-radius: 2px; background: var(--line); }
    .tl-dot { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; background: var(--line); color: var(--muted); }
    .timeline > .is-info .tl-dot { background: var(--info-soft); color: var(--info); }
    .timeline > .is-ok .tl-dot { background: var(--ok-soft); color: var(--ok); }
    .timeline > .is-warn .tl-dot { background: var(--warn-soft); color: var(--warn); }
    .timeline > .is-bad .tl-dot { background: var(--bad-soft); color: var(--bad); }
    .timeline > .is-now .tl-dot { box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent); }
    .tl-main { flex: 1; min-width: 0; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
    .timeline > .is-now .tl-main { background: color-mix(in srgb, var(--primary) 6%, var(--card)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 26%, transparent); }
    .timeline > .is-now.is-info .tl-main { background: var(--info-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info) 26%, transparent); }
    .timeline > .is-now.is-ok .tl-main { background: var(--ok-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 30%, transparent); }
    .timeline > .is-now.is-warn .tl-main { background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 30%, transparent); }
    .timeline > .is-now.is-bad .tl-main { background: var(--bad-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 30%, transparent); }
    .tl-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; }
    .tl-head strong { color: var(--ink); font-size: 14.5px; }
    .timeline > .is-warn .tl-head strong { color: var(--warn-ink); }
    .tl-time { font-size: 12.5px; color: var(--muted); }
    .tl-body { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
    .tl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
    .tl-meta form { margin: 0 0 0 auto; }
    .tl-toggle:not(:checked) + .timeline > .is-extra { display: none; }
    .tl-more { display: inline-flex; align-items: center; gap: 4px; margin: -4px 0 14px 44px; color: var(--primary); font-size: 13px; font-weight: 600; cursor: pointer; }
    .tl-toggle:checked ~ .tl-more { display: none; }
    .tl-shots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
    .tl-shots a { display: block; width: 88px; height: 88px; border-radius: var(--radius-xs); border: 1px solid var(--border); overflow: hidden; }
    .tl-shots img { display: block; width: 100%; height: 100%; object-fit: cover; }

    /* 3.17 Order chat: thread between customer and staff on a service order (partials/order-chat, shop and admin). */
    .order-chat { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); margin: 0 0 20px; box-shadow: var(--shadow); }
    .order-chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .order-chat-head > i { font-size: 20px; color: var(--primary); }
    .order-chat-head b { display: block; color: var(--ink); }
    .order-chat-head small { display: block; font-size: 12.5px; color: var(--muted); }
    .order-chat-empty { margin: auto; color: var(--faint); font-size: 13px; }
    .order-chat-body { max-height: 360px; min-height: 120px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
    .order-chat-body.is-closed { min-height: 0; }
    .oc-msg { max-width: 80%; padding: 8px 11px; border-radius: 12px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; font-weight: 500; }
    .oc-msg small { display: block; font-size: 10.5px; opacity: .65; margin-top: 3px; }
    .oc-msg img { display: block; max-width: 100%; border-radius: 8px; margin-top: 4px; }
    .oc-msg.mine { align-self: flex-end; background: var(--primary); color: #fff; }
    .oc-msg.theirs { align-self: flex-start; background: var(--card); border: 1px solid var(--border); color: var(--ink); }
    .oc-msg .who { display: block; font-size: 11px; font-weight: 700; opacity: .8; }
    .order-chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: center; }
    .order-chat-form textarea { flex: 1; min-width: 0; resize: none; height: 40px; min-height: 40px; max-height: 120px; padding: 9px 12px; line-height: 20px; overflow-y: hidden; scrollbar-width: thin; }
    .order-chat-form button, .order-chat-form label { flex: none; }
    .order-chat-closed { padding: 10px 14px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

    /* 3.18 Date range: <div class="date-range" data-date-range> around two date inputs. A bottom sheet on phones, a dropdown with the quick ranges in a side column from 640px. */
    .date-range { position: relative; display: flex; gap: 8px; }
    .date-range-btn { display: inline-flex; align-items: center; gap: 8px; width: 100%; min-width: 0; height: var(--control-h); padding: 0 12px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
    .date-range-btn > i:first-child { font-size: 18px; color: var(--primary); }
    .date-range-btn > span { flex: 1; overflow: hidden; text-overflow: ellipsis; text-align: left; }
    .date-range-btn > i:last-child { font-size: 18px; transition: transform .15s; }
    .date-range-btn.has-value { color: var(--ink); font-weight: 600; }
    .date-range-btn:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--field-border)); }
    .date-range-btn[aria-expanded="true"] { border-color: var(--primary); box-shadow: var(--focus-ring); }
    .date-range-btn[aria-expanded="true"] > i:last-child { transform: rotate(180deg); }
    .date-range-pop { position: fixed; z-index: 1990; left: 0; right: 0; bottom: 0; display: grid; gap: 12px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: var(--card); box-shadow: 0 0 0 100vmax var(--overlay); animation: drp-up .18s ease-out; }
    .date-range-pop[hidden] { display: none; }
    @keyframes drp-up { from { transform: translateY(24px); } }
    .drp-presets { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
    .drp-presets button { flex: none; height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; }
    .drp-presets button:hover { border-color: var(--primary); color: var(--primary); }
    .drp-presets button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
    .drp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
    .drp-head b { font-size: 15px; color: var(--ink); }
    .drp-step { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink); font-size: 20px; cursor: pointer; }
    .drp-step:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
    .drp-step:disabled { opacity: .35; cursor: default; }
    .drp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
    .drp-wd { display: grid; place-items: center; height: 28px; font-size: 12px; font-weight: 600; color: var(--muted); }
    .drp-day { position: relative; height: 38px; border: 0; background: none; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
    .drp-day::before { content: ""; position: absolute; inset: 2px; z-index: -1; border-radius: 50%; }
    .drp-day { isolation: isolate; }
    .drp-day:hover:not(:disabled)::before { background: var(--hover); }
    .drp-day.is-out { color: var(--faint); }
    .drp-day.is-today::before { box-shadow: inset 0 0 0 1.5px var(--primary); }
    .drp-day.is-in { background: var(--primary-soft); color: var(--primary-strong); }
    .drp-day.is-start, .drp-day.is-end { color: #fff; font-weight: 700; }
    .drp-day.is-start::before, .drp-day.is-end::before, .drp-day.is-start:hover::before, .drp-day.is-end:hover::before { background: var(--grad); box-shadow: 0 4px 10px color-mix(in srgb, var(--primary) 35%, transparent); }
    .drp-day.is-start:not(.is-end) { background: linear-gradient(90deg, transparent 50%, var(--primary-soft) 50%); }
    .drp-day.is-end:not(.is-start) { background: linear-gradient(90deg, var(--primary-soft) 50%, transparent 50%); }
    .drp-day:disabled { color: var(--faint); opacity: .45; cursor: default; }
    .drp-hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
    .drp-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
    .drp-foot .btn { min-width: 96px; }
    @media (min-width: 640px) {
        .date-range-pop { position: absolute; top: calc(100% + 8px); left: 0; right: auto; bottom: auto; width: 480px; grid-template-columns: 132px 1fr; gap: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); animation: drp-drop .15s ease-out; }
        .date-range-pop.is-right { left: auto; right: 0; }
        @keyframes drp-drop { from { transform: translateY(-6px); } }
        .drp-presets { flex-direction: column; overflow: visible; padding-right: 14px; border-right: 1px solid var(--line); }
        .drp-presets button { height: 36px; border: 0; border-radius: var(--radius-xs); background: none; text-align: left; }
        .drp-presets button:hover { background: var(--hover); }
        .drp-presets button.on { background: var(--primary-soft); }
        .drp-day { height: 36px; }
    }

    /* 3.19 Rank badge: <x-rank-badge :rank="…" /> draws an SVG emblem (faceted hexagon gem + the ornaments of its tier) whose
       facets take the rank's colour stops through the rb-* classes; .rank-badge-face is the hexagon-clipped layer the shine
       sweeps across on the large badge. .rank-{style} only sets --rank-a/-b/-c. */
    .rank-bronze { --rank-a: var(--rank-bronze-a); --rank-b: var(--rank-bronze-b); --rank-c: var(--rank-bronze-c); }
    .rank-silver { --rank-a: var(--rank-silver-a); --rank-b: var(--rank-silver-b); --rank-c: var(--rank-silver-c); }
    .rank-gold { --rank-a: var(--rank-gold-a); --rank-b: var(--rank-gold-b); --rank-c: var(--rank-gold-c); }
    .rank-platinum { --rank-a: var(--rank-platinum-a); --rank-b: var(--rank-platinum-b); --rank-c: var(--rank-platinum-c); }
    .rank-diamond { --rank-a: var(--rank-diamond-a); --rank-b: var(--rank-diamond-b); --rank-c: var(--rank-diamond-c); }
    .rank-master { --rank-a: var(--rank-master-a); --rank-b: var(--rank-master-b); --rank-c: var(--rank-master-c); }
    .rank-legend { --rank-a: var(--rank-legend-a); --rank-b: var(--rank-legend-b); --rank-c: var(--rank-legend-c); }
    .rank-badge { --size: 40px; position: relative; display: inline-block; flex: none; width: var(--size); height: var(--size); vertical-align: middle;
        filter: drop-shadow(0 2px 3px color-mix(in srgb, var(--rank-c) 40%, transparent)); }
    .rank-badge > svg { display: block; width: 100%; height: 100%; overflow: visible; }
    .rank-badge .rb-a { fill: var(--rank-a); }
    .rank-badge .rb-al { fill: color-mix(in srgb, var(--rank-a) 55%, #fff); }
    .rank-badge .rb-b { fill: var(--rank-b); }
    .rank-badge .rb-bc { fill: color-mix(in srgb, var(--rank-b) 50%, var(--rank-c)); }
    .rank-badge .rb-c { fill: var(--rank-c); }
    .rank-badge .rb-hi { fill: #fff; opacity: .2; }
    .rank-badge .rb-edge { fill: none; stroke: #fff; stroke-opacity: .5; stroke-width: .9; }
    .rank-badge .rb-line { stroke: var(--rank-c); stroke-width: .9; stroke-linejoin: round; }
    .rank-badge-face { position: absolute; inset: 0; overflow: hidden; pointer-events: none; clip-path: polygon(50% 20.3%, 77% 35.9%, 77% 67.2%, 50% 82.8%, 23% 67.2%, 23% 35.9%); }
    .rank-badge-face::after { content: ''; position: absolute; inset: -20% auto -20% -60%; width: 40%; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .6), transparent); transform: skewX(-20deg); }
    .rank-badge > i { position: absolute; top: 51.6%; left: 50%; translate: -50% -50%; color: #fff; font-size: calc(var(--size) * .32); line-height: 1;
        filter: drop-shadow(0 1px 1px color-mix(in srgb, var(--rank-c) 85%, transparent)); }
    .rank-badge.is-sm { --size: 24px; filter: none; }
    .rank-badge.is-lg { --size: 88px; isolation: isolate; filter: none; }
    .rank-badge.is-lg > svg { filter: drop-shadow(0 6px 12px color-mix(in srgb, var(--rank-b) 45%, transparent)); }
    .rank-badge.is-lg .rank-badge-face::after { animation: rank-shine 3.2s ease-in-out infinite; }
    .rank-badge-fx { position: absolute; z-index: -1; inset: -34%; pointer-events: none; }
    .rank-badge-fx::before { content: ''; position: absolute; inset: 0; border-radius: 50%; animation: rank-rays 18s linear infinite;
        background: repeating-conic-gradient(color-mix(in srgb, var(--rank-a) 55%, transparent) 0 6deg, transparent 6deg 24deg);
        -webkit-mask: radial-gradient(closest-side, #000 30%, transparent); mask: radial-gradient(closest-side, #000 30%, transparent); }
    .rank-badge-fx::after { content: ''; position: absolute; inset: 16%; border-radius: 50%; animation: rank-aura 2.8s ease-in-out infinite;
        background: radial-gradient(closest-side, color-mix(in srgb, var(--rank-b) 55%, transparent), transparent); }
    .rank-badge-fx > i { position: absolute; z-index: 1; width: 10px; height: 10px; scale: 0; animation: rank-spark 2.4s ease-in-out infinite;
        background: color-mix(in srgb, var(--rank-a) 35%, #fff); clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); }
    .rank-badge-fx > i:nth-child(1) { top: 16%; left: 18%; }
    .rank-badge-fx > i:nth-child(2) { top: 9%; right: 22%; width: 7px; height: 7px; animation-delay: .6s; }
    .rank-badge-fx > i:nth-child(3) { top: 50%; right: 7%; animation-delay: 1.2s; }
    .rank-badge-fx > i:nth-child(4) { bottom: 13%; left: 10%; width: 7px; height: 7px; animation-delay: 1.8s; }
    .rank-badge-fx > i:nth-child(5) { bottom: 7%; right: 25%; width: 8px; height: 8px; animation-delay: .9s; }
    .rank-badge.is-locked { filter: grayscale(1) opacity(.5); }
    @keyframes rank-shine { 0%, 55% { translate: 0 0; } 100% { translate: 475% 0; } }
    @keyframes rank-rays { to { rotate: 360deg; } }
    @keyframes rank-aura { 0%, 100% { opacity: .55; scale: .9; } 50% { opacity: 1; scale: 1.06; } }
    @keyframes rank-spark { 0%, 100% { scale: 0; rotate: 0deg; } 50% { scale: 1; rotate: 90deg; } }
    @media (prefers-reduced-motion: reduce) {
        .rank-badge.is-lg .rank-badge-face::after, .rank-badge-fx::before, .rank-badge-fx::after, .rank-badge-fx > i { animation: none; }
        .rank-badge-fx > i { scale: .8; }
    }

    /* 3.x Pointer light (ui-core.js): a clickable card under the mouse lifts a little and a
       light follows the pointer along its edge; title="…" shows as a styled tip near the pointer. */
    .ui-spot { position: fixed; left: 0; top: 0; z-index: 900; pointer-events: none; opacity: 0; transition: opacity .22s ease;
        background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--primary) 9%, transparent), transparent 65%); }
    .ui-spot::before { content: ''; position: absolute; inset: 0; padding: 1px; border-radius: inherit;
        background: radial-gradient(150px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--primary) 80%, transparent), color-mix(in srgb, var(--primary) 22%, transparent) 45%, transparent 75%);
        -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
    .ui-spot.is-on { opacity: 1; }
    .ui-spot-on { transform: translateY(-2px); box-shadow: var(--panel-shadow), 0 16px 34px -12px color-mix(in srgb, var(--primary) 30%, transparent); }
    .ui-tip { position: fixed; left: 0; top: 0; z-index: 1000; max-width: 320px; padding: 7px 11px 8px; border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border)); border-radius: 10px;
        background: color-mix(in srgb, var(--card) 88%, transparent); color: var(--ink); font-size: 12.5px; font-weight: 600; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere;
        box-shadow: 0 14px 34px -12px rgba(15, 23, 42, .35), 0 2px 8px rgba(15, 23, 42, .12); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
        pointer-events: none; opacity: 0; visibility: hidden; will-change: transform; transition: transform .14s cubic-bezier(.22, .9, .3, 1), opacity .16s ease, visibility 0s linear .16s; }
    .ui-tip.is-on { opacity: 1; visibility: visible; transition: transform .14s cubic-bezier(.22, .9, .3, 1), opacity .16s ease; }
    .ui-tip.is-snap { transition: none; }
    @media (prefers-reduced-motion: reduce) { .ui-spot-on { transform: none; } }

    /* 3.x Mountains (x-shop.scene-land, the video author's drawing widened to 26:10) behind the login screens and the
       Halloween night sky (both fixed to the viewport), with his clouds drifting over them. The picture is --land-w wide with
       its summit (x 320 of -500..2100) a quarter of the way in, so the rock on the left stays on screen on a phone too and the
       wide drawing keeps the mountains far off on a computer. It sits on the bottom of the screen, except on a wide, low screen
       where that would lift the summit (at 44% of its height) under the header: there it drops until the summit clears the
       header by 60px, its foot running off the bottom. */
    .scene-land { --land-w: max(118vw, 130vh); position: absolute; left: 25%; top: max(calc(100% - var(--land-w) / 2.6), calc(var(--sticky-top, 0px) + 60px - var(--land-w) * .127)); width: var(--land-w); height: auto; aspect-ratio: 26 / 10; translate: -34.6% 0; }
    .scene-land .is-far-top { stop-color: var(--land-far-top); }
    .scene-land .is-far-foot { stop-color: var(--land-far-foot); }
    .scene-land .is-mid-top { stop-color: var(--land-mid-top); }
    .scene-land .is-mid-foot { stop-color: var(--land-mid-foot); }
    .scene-land .is-peak-top { stop-color: var(--land-peak-top); }
    .scene-land .is-peak-foot { stop-color: var(--land-peak-foot); }
    .scene-land .is-mist { stop-color: var(--land-mist); }
    .scene-layer { position: absolute; inset: 0; width: 100%; height: 100%; will-change: transform; }
    .scene-clouds { position: absolute; inset: 0; }
    .scene-cloud { position: absolute; height: auto; overflow: visible; will-change: transform; }
    .scene-land .is-cloud { stop-color: var(--land-cloud); }
    .scene-land .is-cloud-foot { stop-color: var(--land-cloud-foot); }
    .scene-clouds { opacity: var(--land-cloud-opacity); }
    .scene-land .is-sun { fill: var(--land-sun); stop-color: var(--land-sun); }
    .scene-land .is-shade { fill: var(--land-shade); stop-color: var(--land-shade); }
    .scene-land .is-crack { fill: none; stroke: var(--land-shade); stroke-opacity: .6; stroke-width: 1.3; }
    .scene-land .is-forest { fill: var(--land-mid-foot); opacity: .85; }
    .scene-land .is-tree { fill: var(--land-wood); }
    .scene-land .is-edge { fill: none; stroke: var(--land-edge); stroke-width: 1.3; stroke-linejoin: round; }
    .scene-firs, .scene-ground { fill: var(--land-wood); }
    /* The sun by day and the moon with its craters at night, in the same place in the sky over the mountains (the login's,
       x-shop.auth-scene, and the Halloween storefront sky, x-shop.season-decor; each sets --orb-right/-top/-size): as the
       sky turns one sinks behind the mountains and the other rises (half a second), the author's halo breathing round
       it and a faint ring spreading from it. In the Halloween season the moon is his amber glass one (season-halloween.css). */
    .sky-orb { position: absolute; right: var(--orb-right, 9%); top: var(--orb-top, 34px); width: var(--orb-size, 64px); aspect-ratio: 1; border-radius: 50%; transition: translate .5s cubic-bezier(.45, 0, .25, 1), opacity .5s ease; }
    .sky-orb.is-sun { background: var(--auth-sun); box-shadow: var(--auth-sun-glow); }
    .sky-orb.is-moon { box-shadow: var(--auth-moon-glow);
        background: radial-gradient(circle at 34% 40%, var(--auth-crater) 0 9%, transparent 10%), radial-gradient(circle at 62% 66%, var(--auth-crater) 0 13%, transparent 14%), radial-gradient(circle at 68% 30%, var(--auth-crater) 0 6%, transparent 7%), radial-gradient(circle at 30% 70%, var(--auth-crater) 0 5%, transparent 6%), var(--auth-moon); }
    :root[data-theme="dark"] .sky-orb.is-sun, :root:not([data-theme="dark"]) .sky-orb.is-moon { translate: 0 40vh; opacity: 0; }
    .sky-orb::before, .sky-orb::after { content: ''; position: absolute; border-radius: 50%; }
    .sky-orb::before { inset: -27px; background: var(--celestial-breath); opacity: .5; }
    .sky-orb::after { inset: -10px; border: 1px solid var(--celestial-ring); box-shadow: 0 0 12px var(--celestial-ring-glow); opacity: 0; }
    .sky-orb.is-sun::before { background: var(--sun-breath); }
    .sky-orb.is-sun::after { border-color: var(--sun-ring); }
    /* The author's clouds drift to and fro, each at its own pace. */
    @media (prefers-reduced-motion: no-preference) {
        .scene-cloud { animation: cloud-float 26s ease-in-out infinite alternate; }
        .scene-clouds .is-slow { animation-duration: 37s; animation-delay: -13s; }
        .scene-clouds .is-far { animation-duration: 31s; animation-delay: -8s; }
        .sky-orb { animation: sky-orb-glow 5s ease-in-out infinite alternate; }
        .sky-orb::before { animation: celestial-breathe 4.8s ease-in-out infinite; }
        .sky-orb::after { animation: celestial-ring 4.8s ease-out infinite; }
        .sky-orb.is-sun::before, .sky-orb.is-sun::after { animation-duration: 3.9s; }
    }
    @media (prefers-reduced-motion: reduce) { .sky-orb { transition-duration: .01ms; } }
}

/* ========== 4. Utilities ========== */
@layer utilities {
    [hidden] { display: none !important; }
    /* Read by screen readers and search engines, not drawn (the home page's h1). */
    .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
    .muted { color: var(--muted); }
    .faint { color: var(--faint); }
    .ink { color: var(--ink); }
    .mono { font-variant-numeric: tabular-nums; font-size: 13px; word-break: break-all; }
    td.mono { white-space: nowrap; word-break: normal; }
    .text-primary { color: var(--primary); }
    .text-ok { color: var(--ok); }
    .text-warn { color: var(--warn); }
    .text-info { color: var(--info); }
    .text-bad { color: var(--bad); }
    .text-center { text-align: center; }
    .text-right { text-align: right; }
    .text-sm { font-size: 13px; }
    .text-xs { font-size: 12px; }
    .text-lg { font-size: 16px; }
    .fw-400 { font-weight: 400; }
    .fw-500 { font-weight: 500; }
    .fw-600 { font-weight: 600; }
    .fw-700 { font-weight: 700; }
    .nowrap { white-space: nowrap; }
    .break { overflow-wrap: anywhere; word-break: break-word; }
    .pre-line { white-space: pre-line; }
    .underline { text-decoration: underline; }
    .uppercase { text-transform: uppercase; }
    .uppercase::placeholder { text-transform: none; }
    .m-0 { margin: 0; }
    .mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
    .mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
    .p-0 { padding: 0; }
    .flex { display: flex; }
    .inline-flex { display: inline-flex; }
    .flex-col { flex-direction: column; }
    .wrap { flex-wrap: wrap; }
    .items-center { align-items: center; }
    .items-start { align-items: flex-start; }
    .items-end { align-items: flex-end; }
    .justify-between { justify-content: space-between; }
    .justify-center { justify-content: center; }
    .justify-end { justify-content: flex-end; }
    .grow { flex: 1; min-width: 0; }
    .gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
    .w-full { width: 100%; }
    .w-auto { width: auto; }
    .max-w-sm { max-width: 420px; }
    .max-w-md { max-width: 640px; }
    @media (max-width: 1024px) { .hide-sm { display: none !important; } }
    @media (max-width: 767px) { .hide-xs { display: none !important; } }
}

@keyframes cloud-float { from { transform: translate(-14px, 3px); } to { transform: translate(24px, -7px); } }
@keyframes sky-orb-glow { from { scale: 1; } to { scale: 1.035; } }
@keyframes celestial-breathe { 0%, 100% { scale: .92; opacity: .5; } 50% { scale: 1.17; opacity: 1; } }
@keyframes celestial-ring { 0% { scale: .85; opacity: 0; } 20% { opacity: .55; } 100% { scale: 1.7; opacity: 0; } }
