/* =============================================================================
   Softex — MC Client Online · Design System
   Refined enterprise: white surfaces on a cool canvas, one dominant Softex blue,
   IBM Plex (Latin + Arabic + Mono for figures). Mobile-first, RTL via logical props.
   ========================================================================== */

:root {
    /* Brand */
    --sx-blue: #1D63B8;
    --sx-blue-600: #1a59a6;
    --sx-blue-700: #154d8f;
    --sx-blue-300: #6fa3da;
    --sx-blue-100: #dbe8f7;
    --sx-blue-50: #eef4fc;

    /* Ink & neutrals */
    --sx-ink: #1b2733;
    --sx-grey: #4a4a4a;
    --sx-muted: #6b7785;
    --sx-faint: #9aa6b2;
    --sx-line: #e6eaf1;
    --sx-line-soft: #eef1f6;
    --sx-canvas: #f4f6fa;
    --sx-surface: #ffffff;

    /* Financial states */
    --sx-green: #1f9d6b;
    --sx-green-50: #e7f6ef;
    --sx-red: #d6453f;
    --sx-red-50: #fbe9e8;
    --sx-amber: #d9920b;
    --sx-amber-50: #fbf2dd;

    /* Accent palette (module tiles) */
    --acc-blue: #1D63B8;
    --acc-teal: #0f9aa8;
    --acc-indigo: #4257c4;
    --acc-violet: #7b4dd1;
    --acc-amber: #d9920b;
    --acc-green: #1f9d6b;
    --acc-slate: #5b6b7d;
    --acc-red: #d6453f;

    /* Typography */
    --sx-font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
    --sx-font-ar: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
    --sx-mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", monospace;

    /* Shape & depth */
    --sx-r-sm: 10px;
    --sx-r: 14px;
    --sx-r-lg: 20px;
    --sx-r-pill: 999px;
    --sx-shadow-sm: 0 1px 2px rgba(20, 40, 70, .06), 0 1px 3px rgba(20, 40, 70, .05);
    --sx-shadow: 0 2px 6px rgba(20, 40, 70, .06), 0 8px 24px rgba(20, 40, 70, .07);
    --sx-shadow-lg: 0 12px 40px rgba(15, 35, 65, .16);
    --sx-ring: 0 0 0 3px rgba(29, 99, 184, .22);

    /* Metrics */
    --sx-topbar-h: 58px;
    --sx-bottomnav-h: 66px;
    --sx-tap: 48px;
    --sx-pad: 16px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.sx-app {
    margin: 0;
    font-family: var(--sx-font);
    color: var(--sx-ink);
    background: var(--sx-canvas);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-size: 15px;
    line-height: 1.5;
}

body.sx-app.rtl { font-family: var(--sx-font-ar); }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.01em; margin: 0; }

a { color: var(--sx-blue); text-decoration: none; }

/* Tabular figures everywhere numbers matter */
.sx-num, .sx-money, .sx-mono { font-family: var(--sx-mono); font-variant-numeric: tabular-nums; }
.sx-money { font-weight: 600; }

/* =========================================================================
   App shell
   ========================================================================= */
.sx-shell { min-height: 100%; }

.sx-main {
    padding: calc(var(--sx-topbar-h) + 14px) var(--sx-pad) calc(var(--sx-bottomnav-h) + var(--safe-b) + 22px);
    max-width: 920px;
    margin-inline: auto;
}

/* Top bar */
.sx-topbar {
    position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 1030;
    height: var(--sx-topbar-h);
    background: rgba(255, 255, 255, .86);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-block-end: 1px solid var(--sx-line);
}
.sx-topbar::after { /* thin brand accent line */
    content: ""; position: absolute; inset-block-end: -1px; inset-inline: 0; height: 2px;
    background: linear-gradient(90deg, var(--sx-blue), var(--sx-blue-300));
    opacity: .9;
}
.sx-topbar-inner {
    height: 100%; max-width: 920px; margin-inline: auto;
    display: flex; align-items: center; gap: 8px;
    padding-inline: 10px;
}
.sx-brand { display: flex;justify-content: flex-start; align-items: center; flex: 1; min-width: 0; }
@media (max-width: 559.98px) {
    .sx-brand {
        flex: 1 1 auto;
        justify-content: center;
    }
}
.sx-brand-logo { height: 140px; width: auto; display: block; }
.sx-page-title { flex: 1; font-size: 1.05rem; font-weight: 600; text-align: center; color: var(--sx-ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-topbar-actions { display: flex; align-items: center; gap: 4px; }
.sx-lang-form { margin: 0; }

.sx-iconbtn {
    display: inline-grid; place-items: center;
    width: 42px; height: 42px; border: 0; border-radius: var(--sx-r-sm);
    background: transparent; color: var(--sx-grey); font-size: 1.2rem; cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.sx-iconbtn:hover, .sx-iconbtn:focus-visible { background: var(--sx-blue-50); color: var(--sx-blue); outline: none; }
.sx-back .bi { font-size: 1.35rem; }
.rtl .sx-back .bi { transform: scaleX(-1); }
.sx-lang-text { font-weight: 700; font-size: .95rem; letter-spacing: .02em; }

/* Bottom navigation */
.sx-bottomnav {
    position: fixed; inset-block-end: 0; inset-inline: 0; z-index: 1030;
    height: calc(var(--sx-bottomnav-h) + var(--safe-b));
    padding-block-end: var(--safe-b);
    display: flex; align-items: stretch;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-block-start: 1px solid var(--sx-line);
    box-shadow: 0 -6px 24px rgba(20, 40, 70, .05);
}
.sx-navitem {
    flex: 1; border: 0; background: transparent; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--sx-muted); font-size: .68rem; font-weight: 500; text-decoration: none;
    position: relative; padding-block-start: 6px;
    transition: color .15s ease;
}
.sx-navicon { font-size: 1.3rem; transition: transform .15s ease; }
.sx-navitem.is-active { color: var(--sx-blue); }
.sx-navitem.is-active .sx-navicon { transform: translateY(-1px); }
.sx-navitem.is-active::before {
    content: ""; position: absolute; inset-block-start: 0; inset-inline-start: 50%; transform: translateX(-50%);
    width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--sx-blue);
}
.rtl .sx-navitem.is-active::before { transform: translateX(50%); }
.sx-navitem:not(.is-disabled):active .sx-navicon { transform: scale(.9); }
.sx-navitem.is-disabled { color: var(--sx-faint); opacity: .55; cursor: default; }

/* =========================================================================
   Drawer (More menu)
   ========================================================================= */
.sx-drawer { width: min(86vw, 360px); background: var(--sx-surface); }
.sx-drawer-head { display: flex; align-items: center; justify-content: space-between;
    padding: 0px 0px; border-block-end: 1px solid var(--sx-line); }
.sx-drawer-logo { height: 90px; }
.sx-drawer-body { padding: 12px 12px 28px; }
.sx-drawer-section { margin: 14px 8px 6px; font-size: .72rem; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: var(--sx-faint); }
.sx-drawer-list { list-style: none; margin: 0; padding: 0; }
.sx-drawer-link, .sx-drawer-link-form button.sx-drawer-link {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 11px 10px; border-radius: var(--sx-r-sm); border: 0; background: transparent;
    color: var(--sx-ink); font-size: .95rem; font-weight: 500; cursor: pointer; text-align: start;
    transition: background .15s ease;
}
.sx-drawer-link:hover { background: var(--sx-blue-50); }
.sx-drawer-link.is-disabled { color: var(--sx-faint); cursor: default; }
.sx-drawer-link.is-disabled:hover { background: transparent; }
.sx-drawer-ico { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
    font-size: 1.05rem; color: #fff; flex: none; }
.sx-drawer-chev { margin-inline-start: auto; color: var(--sx-faint); font-size: .85rem; }
.rtl .sx-drawer-chev { transform: scaleX(-1); }
.sx-soon, .sx-tile-soon { margin-inline-start: auto; font-size: .64rem; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--sx-amber); background: var(--sx-amber-50);
    padding: 2px 7px; border-radius: var(--sx-r-pill); }
.sx-drawer-logout { color: var(--sx-red); }
.sx-drawer-link-form { margin: 0; }
.sx-drawer-user { display: flex; align-items: center; gap: 12px; padding: 8px 10px 12px; }
.sx-drawer-user-name { display: block; font-weight: 600; font-size: .95rem; }
.sx-drawer-user-sub { display: block; font-size: .78rem; color: var(--sx-muted); }

/* Accent backgrounds */
.sx-accent-blue   { background: var(--acc-blue); }
.sx-accent-teal   { background: var(--acc-teal); }
.sx-accent-indigo { background: var(--acc-indigo); }
.sx-accent-violet { background: var(--acc-violet); }
.sx-accent-amber  { background: var(--acc-amber); }
.sx-accent-green  { background: var(--acc-green); }
.sx-accent-slate  { background: var(--acc-slate); }
.sx-accent-red    { background: var(--acc-red); }

/* =========================================================================
   Cards, sections, hero
   ========================================================================= */
.sx-stack { margin-block-end: 18px; }
.sx-card {
    background: var(--sx-surface); border: 1px solid var(--sx-line);
    border-radius: var(--sx-r); box-shadow: var(--sx-shadow-sm); padding: 16px;
}
.sx-card-title { font-size: 1rem; display: flex; align-items: center; gap: 8px; margin-block-end: 12px; }
.sx-card-title .bi { color: var(--sx-blue); }
.sx-section-title { font-size: 1.05rem; margin-block-end: 2px; }
.sx-section-hint, .sx-hint { color: var(--sx-muted); font-size: .85rem; margin: 6px 0 0; }

.sx-hero {
    position: relative; overflow: hidden;
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(29, 99, 184, .14), transparent 60%),
        radial-gradient(120% 140% at 0% 0%, rgba(29, 99, 184, .08), transparent 55%),
        linear-gradient(180deg, #ffffff, #fbfcfe);
    border: 1px solid var(--sx-line); border-radius: var(--sx-r-lg);
    padding: 22px 20px; margin-block-end: 18px; box-shadow: var(--sx-shadow-sm);
}
.sx-hero-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase; color: var(--sx-blue);
    background: var(--sx-blue-50); border: 1px solid var(--sx-blue-100);
    padding: 4px 10px; border-radius: var(--sx-r-pill); }
.sx-hero-title { font-size: 1.7rem; margin-block: 12px 6px; }
.sx-hero-sub { color: var(--sx-muted); margin: 0; max-width: 46ch; }

.sx-checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.sx-checklist li { display: flex; align-items: center; gap: 10px; font-size: .92rem; color: var(--sx-grey); }
.sx-checklist .bi { color: var(--sx-green); font-size: 1.05rem; }

/* =========================================================================
   Module launcher grid — one unified, permission-driven set of cards.
   The grid reads [data-count] so 1–4 permitted modules always land on a
   balanced arrangement instead of leaving an orphaned card.
   ========================================================================= */
.sx-modulegrid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);   /* mobile: one card per row */
    gap: 12px;
    margin-block-start: 12px;
    margin-inline: auto;
    max-width: 760px;
}

.sx-tile,
.sx-tile.is-disabled {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    min-height: 92px;                         /* roomy tap target for mobile / PWA */
    padding: 16px 18px;
    background: var(--sx-surface);
    border: 1px solid var(--sx-line);
    border-radius: var(--sx-r);
    box-shadow: var(--sx-shadow-sm);
    color: var(--sx-ink);
    text-align: start;
    overflow: hidden;
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
    animation: sx-rise .5s both;
}

.sx-tile:not(.is-disabled):hover {
    box-shadow: var(--sx-shadow);
    transform: translateY(-2px);
    border-color: var(--sx-blue-100, var(--sx-line));
}

.sx-tile:not(.is-disabled):active { transform: scale(.985); }

/* Visible keyboard focus */
.sx-tile:focus-visible {
    outline: 3px solid var(--sx-blue);
    outline-offset: 2px;
    box-shadow: var(--sx-shadow);
}

.sx-tile-ico {
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 6px 16px rgba(20, 40, 70, .18);
}

.sx-tile-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1 1 auto;
}

.sx-tile-label {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.25;
}

.sx-tile-sub {
    font-size: .82rem;
    color: var(--sx-muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sx-tile-go {
    flex: 0 0 auto;
    color: var(--sx-faint);
    font-size: 1rem;
    transition: transform .2s ease, color .2s ease;
}
.sx-tile:not(.is-disabled):hover .sx-tile-go { color: var(--sx-blue); transform: translateX(3px); }
[dir="rtl"] .sx-tile-go { transform: scaleX(-1); }
[dir="rtl"] .sx-tile:not(.is-disabled):hover .sx-tile-go { transform: scaleX(-1) translateX(3px); }

/* Staggered reveal */
.sx-modulegrid .sx-tile:nth-child(1) { animation-delay: .04s; }
.sx-modulegrid .sx-tile:nth-child(2) { animation-delay: .09s; }
.sx-modulegrid .sx-tile:nth-child(3) { animation-delay: .14s; }
.sx-modulegrid .sx-tile:nth-child(4) { animation-delay: .19s; }

/* ── Tablet and up: two equal columns (the 2×2 for four modules) ── */
@media (min-width: 560px) {
    .sx-modulegrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .sx-tile, .sx-tile.is-disabled { min-height: 100px; padding: 18px 20px; }

    /* A lone card should not stretch the full width */
    .sx-modulegrid[data-count="1"] {
        grid-template-columns: minmax(0, 380px);
        justify-content: center;
    }
}

/* ── Desktop: keep the 2×2 centred; three modules get a balanced single row ── */
@media (min-width: 992px) {
    .sx-modulegrid { max-width: 820px; }
    .sx-modulegrid[data-count="3"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.sx-tile.is-disabled { color: var(--sx-muted); box-shadow: none; }
.sx-tile.is-disabled .sx-tile-ico { filter: grayscale(.55) opacity(.65); box-shadow: none; }
/* tile accent applies to icon chip only */
.sx-tile.is-disabled.sx-accent-blue, .sx-tile.is-disabled.sx-accent-teal, .sx-tile.is-disabled.sx-accent-indigo,
.sx-tile.is-disabled.sx-accent-violet, .sx-tile.is-disabled.sx-accent-amber, .sx-tile.is-disabled.sx-accent-green,
.sx-tile.is-disabled.sx-accent-slate, .sx-tile.is-disabled.sx-accent-red,
.sx-tile.sx-accent-blue, .sx-tile.sx-accent-teal, .sx-tile.sx-accent-indigo, .sx-tile.sx-accent-violet,
.sx-tile.sx-accent-amber, .sx-tile.sx-accent-green, .sx-tile.sx-accent-slate, .sx-tile.sx-accent-red {
    background: var(--sx-surface); /* keep tile white; accent only on .sx-tile-ico via nested rule below */
}
.sx-tile.sx-accent-blue .sx-tile-ico   { background: var(--acc-blue); }
.sx-tile.sx-accent-teal .sx-tile-ico   { background: var(--acc-teal); }
.sx-tile.sx-accent-indigo .sx-tile-ico { background: var(--acc-indigo); }
.sx-tile.sx-accent-violet .sx-tile-ico { background: var(--acc-violet); }
.sx-tile.sx-accent-amber .sx-tile-ico  { background: var(--acc-amber); }
.sx-tile.sx-accent-green .sx-tile-ico  { background: var(--acc-green); }
.sx-tile.sx-accent-slate .sx-tile-ico  { background: var(--acc-slate); }
.sx-tile.sx-accent-red .sx-tile-ico    { background: var(--acc-red); }

@keyframes sx-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================================
   Dashboard "Statements" — featured account-statement cards (deep-link to Reports)
   ========================================================================= */
.sx-stmts-section { margin-block-end: 22px; }
.sx-stmts { display: grid; gap: 10px; }
.sx-stmt {
    --_acc: var(--sx-blue);
    position: relative; display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: var(--sx-r);
    background: var(--sx-surface); border: 1px solid var(--sx-line);
    box-shadow: var(--sx-shadow-sm); color: var(--sx-ink); text-decoration: none;
    overflow: hidden; isolation: isolate;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    animation: sx-rise .5s both;
}
.sx-stmt::before {                       /* accent spine */
    content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--_acc);
}
.sx-stmt::after {                        /* soft accent wash, revealed on hover */
    content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .25s;
    background: radial-gradient(130% 150% at 0% 50%, color-mix(in srgb, var(--_acc) 13%, transparent), transparent 62%);
}
.sx-stmt:hover { transform: translateY(-2px); box-shadow: var(--sx-shadow);
    border-color: color-mix(in srgb, var(--_acc) 38%, var(--sx-line)); }
.sx-stmt:hover::after { opacity: 1; }
.sx-stmt:active { transform: scale(.99); }
.sx-stmt-ico {
    flex: 0 0 auto; width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
    color: #fff; font-size: 1.25rem; background: var(--_acc);
    box-shadow: 0 6px 14px color-mix(in srgb, var(--_acc) 32%, transparent);
}
.sx-stmt-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.sx-stmt-title { font-weight: 600; font-size: 1rem; line-height: 1.25; }
.sx-stmt-sub { font-size: .8rem; color: var(--sx-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-stmt-arrow { flex: 0 0 auto; color: var(--_acc); font-size: 1.05rem; transition: transform .25s ease; }
.sx-stmt:hover .sx-stmt-arrow { transform: translateX(3px); }
[dir="rtl"] .sx-stmt-arrow { transform: scaleX(-1); }
[dir="rtl"] .sx-stmt:hover .sx-stmt-arrow { transform: scaleX(-1) translateX(3px); }
.sx-stmt:nth-child(1) { animation-delay: .04s; }
.sx-stmt:nth-child(2) { animation-delay: .09s; }
.sx-stmt:nth-child(3) { animation-delay: .14s; }
@media (min-width: 640px) { .sx-stmts { grid-template-columns: repeat(3, 1fr); } }

/* =========================================================================
   Statement flows (client list view/share icons, treasury single-select)
   ========================================================================= */
.rs-client { gap: 10px; }
.rs-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.rs-iconbtn {
    width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--sx-line);
    background: var(--sx-blue-50); color: var(--sx-blue); font-size: 1.05rem;
    display: grid; place-items: center; cursor: pointer;
    transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.rs-iconbtn:hover { background: var(--sx-blue-100); box-shadow: var(--sx-shadow-sm); }
.rs-iconbtn:active { transform: scale(.92); }
.rs-iconbtn.rs-share { background: var(--sx-green-50); color: var(--sx-green); border-color: #cdeadd; }
.rs-iconbtn.rs-share:hover { background: #d6f0e3; }
.rs-iconbtn.rs-call { background: #e6f6f7; color: var(--acc-teal); border-color: #c5e9ec; }
.rs-iconbtn.rs-call:hover { background: #d3eff1; }

/* =========================================================================
   Cash Payment — unpaid invoice detail cards
   ========================================================================= */
.cash-inv-card { display: flex; flex-direction: column; gap: 12px; }
.cash-inv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.cash-inv-grid > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cash-inv-grid span { font-size: .68rem; color: var(--sx-muted); text-transform: uppercase; letter-spacing: .05em; }
.cash-inv-grid b { font-size: .95rem; font-weight: 600; }
.cash-inv-remarks { font-size: .84rem; color: var(--sx-grey); line-height: 1.4;
    border-block-start: 1px dashed var(--sx-line); padding-block-start: 10px; }
.cash-inv-remarks span { color: var(--sx-muted); font-weight: 600; }
.sx-chip-mini { flex: 0 0 auto; font-size: .72rem; font-weight: 600; color: var(--sx-blue);
    background: var(--sx-blue-50); padding: 3px 9px; border-radius: var(--sx-r-pill); }

.rs-treasury { gap: 12px; text-align: start; width: 100%; }
.rs-radio {
    flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--sx-faint); position: relative; transition: border-color .15s ease;
}
.rs-treasury.is-selected { border-color: var(--sx-blue); box-shadow: var(--sx-ring); }
.rs-treasury.is-selected .rs-radio { border-color: var(--sx-blue); }
.rs-treasury.is-selected .rs-radio::after {
    content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--sx-blue);
}

/* =========================================================================
   Buttons (reusable, large tap targets)
   ========================================================================= */
.sx-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--sx-tap); padding: 0 18px; border-radius: var(--sx-r-sm);
    font-family: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; background: var(--sx-blue-50); color: var(--sx-blue);
    transition: filter .15s ease, background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.sx-btn:active { transform: scale(.98); }
.sx-btn:focus-visible { outline: none; box-shadow: var(--sx-ring); }
.sx-btn-primary { background: var(--sx-blue); color: #fff; box-shadow: 0 6px 16px rgba(29, 99, 184, .26); }
.sx-btn-primary:hover { background: var(--sx-blue-600); }
.sx-btn-ghost { background: transparent; color: var(--sx-grey); border-color: var(--sx-line); }
.sx-btn-ghost:hover { background: var(--sx-canvas); }
.sx-btn-danger { background: var(--sx-red); color: #fff; }
.sx-btn-success { background: var(--sx-green); color: #fff; }
.sx-btn-block { width: 100%; }
.sx-btn[disabled], .sx-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.sx-btn-sm { min-height: 38px; padding: 0 12px; font-size: .85rem; }

/* Sticky action bar (form footers) */
.sx-actionbar {
    position: sticky; inset-block-end: calc(var(--sx-bottomnav-h) + var(--safe-b));
    background: rgba(255,255,255,.95); backdrop-filter: blur(8px);
    margin: 18px calc(-1 * var(--sx-pad)) calc(-1 * (var(--sx-bottomnav-h) + var(--safe-b) + 22px));
    padding: 12px var(--sx-pad) calc(12px + var(--safe-b));
    border-block-start: 1px solid var(--sx-line); display: flex; gap: 10px;
}
.sx-actionbar .sx-btn { flex: 1; }

/* When the scroll area holds a floating action bar, its negative margin cancels the
   base bottom padding — so add clearance back, otherwise the last list rows hide
   behind the bar (and the bottom nav). Applies to every screen with an action bar. */
.sx-main:has(.sx-actionbar) {
    padding-block-end: calc(var(--sx-bottomnav-h) + var(--safe-b) + 116px);
}

/* =========================================================================
   Forms
   ========================================================================= */
.sx-field { margin-block-end: 14px; }
.sx-label { display: block; font-size: .8rem; font-weight: 600; color: var(--sx-grey); margin-block-end: 6px; }
.sx-label .req { color: var(--sx-red); }
.sx-input, .sx-select, .sx-textarea {
    width: 100%; min-height: var(--sx-tap); padding: 10px 14px;
    font-family: inherit; font-size: .98rem; color: var(--sx-ink);
    background: var(--sx-surface); border: 1.5px solid var(--sx-line);
    border-radius: var(--sx-r-sm); transition: border-color .15s ease, box-shadow .15s ease;
    appearance: none;
}
.sx-textarea { min-height: 88px; padding-block: 12px; resize: vertical; }
.sx-input:focus, .sx-select:focus, .sx-textarea:focus {
    outline: none; border-color: var(--sx-blue); box-shadow: var(--sx-ring);
}
.sx-input::placeholder, .sx-textarea::placeholder { color: var(--sx-faint); }
/* Locked date (no CHANGE_DATE_ON_NEW_DOCUMENT permission) — fixed to today, not editable. */
.sx-input.is-locked { background: var(--sx-canvas); color: var(--sx-ink); cursor: default; }
.sx-input.is-locked::-webkit-calendar-picker-indicator { display: none; }
.sx-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7785' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 5.6 8 10.4l4.8-4.8'/%3E%3Cpath stroke='%236b7785' stroke-width='1.6' fill='none' d='M3.2 5.6 8 10.4l4.8-4.8'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-inline-end: 38px;
}
.rtl .sx-select { background-position: left 12px center; padding-inline-end: 14px; padding-inline-start: 38px; }
.sx-input-group { position: relative; }
.sx-input-group .bi { position: absolute; inset-block-start: 50%; inset-inline-start: 14px; transform: translateY(-50%);
    color: var(--sx-faint); pointer-events: none; }
.sx-input-group .sx-input { padding-inline-start: 42px; }

/* stepper +/- */
.sx-stepper { display: inline-flex; align-items: stretch; border: 1.5px solid var(--sx-line); border-radius: var(--sx-r-sm);
    overflow: hidden; }
.sx-stepper button { width: 46px; min-height: var(--sx-tap); border: 0; background: var(--sx-canvas); color: var(--sx-blue);
    font-size: 1.25rem; cursor: pointer; }
.sx-stepper button:active { background: var(--sx-blue-50); }
.sx-stepper input { width: 72px; border: 0; border-inline: 1.5px solid var(--sx-line); text-align: center;
    font-family: var(--sx-mono); font-weight: 600; font-size: 1rem; }
.sx-stepper input:focus { outline: none; }

/* =========================================================================
   Tabs & segmented control
   ========================================================================= */
.sx-tabs { display: flex; gap: 4px; background: #eef1f6; padding: 4px; border-radius: var(--sx-r-pill);
    margin-block-end: 16px; }
.sx-tab { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: var(--sx-r-pill);
    font-family: inherit; font-weight: 600; font-size: .9rem; color: var(--sx-muted); cursor: pointer;
    transition: all .18s ease; }
.sx-tab.is-active { background: #fff; color: var(--sx-blue); box-shadow: var(--sx-shadow-sm); }

/* Segmented control */
.sx-seg { display: inline-flex; width: 100%; gap: 4px; background: #eef1f6; padding: 4px; border-radius: var(--sx-r-sm); }
.sx-seg-opt { flex: 1; min-height: 42px; border: 0; background: transparent; border-radius: calc(var(--sx-r-sm) - 2px);
    font-family: inherit; font-weight: 600; font-size: .92rem; color: var(--sx-muted); cursor: pointer; transition: all .16s ease; }
.sx-seg-opt.is-active { background: #fff; color: var(--sx-blue); box-shadow: var(--sx-shadow-sm); }

/* Preview chips (settings) */
.sx-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-block-start: 6px;
    padding: 11px 13px; background: var(--sx-blue-50); border-radius: var(--sx-r-sm); }
.sx-preview-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--sx-blue); }
.sx-preview-val { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--sx-ink); }
.sx-preview-val .bi { color: var(--sx-blue); }
.sx-preview-inline { margin: 8px 0 0; font-size: .85rem; color: var(--sx-muted); }
.sx-preview-inline .sx-num { color: var(--sx-ink); font-weight: 600; }

/* Home hero */
/* Dashboard header — aligned to the same measure as the module grid */
.sx-home-hero { position: relative; padding: 2px 0 0; margin-block-end: 18px;
    max-width: 760px; margin-inline: auto; animation: sx-rise .4s both; }
.sx-home-modules { margin-inline: auto; }
.sx-home-modules-title { max-width: 760px; margin: 0 auto 2px; }
@media (min-width: 992px) {
    .sx-home-hero, .sx-home-modules-title { max-width: 820px; }
}
.sx-home-greet { margin: 0; font-size: .95rem; color: var(--sx-grey); display: flex; align-items: center; gap: 6px; }
.sx-home-wave { display: inline-block; transform-origin: 70% 70%; animation: sx-wave 2.4s ease-in-out 1s 2; }
@keyframes sx-wave { 0%,60%,100% { transform: rotate(0); } 10%,30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } }
.sx-home-title { margin: 4px 0 8px; font-size: 1.9rem; font-weight: 700; letter-spacing: -.01em; color: var(--sx-ink); }
.sx-home-date { margin: 0; font-size: .88rem; color: var(--sx-muted); display: inline-flex; align-items: center; gap: 7px; }

/* =========================================================================
   List rows, chips, badges
   ========================================================================= */
.sx-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--sx-surface);color:black;
    border: 1px solid var(--sx-line); border-radius: var(--sx-r); box-shadow: var(--sx-shadow-sm);
    margin-block-end: 10px; }
.sx-row-main { flex: 1; min-width: 0; }
.sx-row-title { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-row-sub { font-size: .8rem; color: var(--sx-muted); margin-block-start: 2px; }
.sx-row-end { text-align: end; flex: none; }
.sx-row.is-tappable { cursor: pointer; transition: box-shadow .14s, transform .12s; }
.sx-row.is-tappable:active { transform: scale(.99); }
.sx-row.is-tappable:hover { box-shadow: var(--sx-shadow); }

.sx-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 600;
    padding: 3px 10px; border-radius: var(--sx-r-pill); background: var(--sx-blue-50); color: var(--sx-blue); }
.sx-chip-green { background: var(--sx-green-50); color: var(--sx-green); }
.sx-chip-red { background: var(--sx-red-50); color: var(--sx-red); }
.sx-chip-amber { background: var(--sx-amber-50); color: var(--sx-amber); }
.sx-chip-grey { background: #eef1f6; color: var(--sx-muted); }

/* =========================================================================
   Empty / error / loading states
   ========================================================================= */
.sx-empty { text-align: center; padding: 40px 20px; color: var(--sx-muted); }
.sx-empty .bi { font-size: 2.4rem; color: var(--sx-faint); display: block; margin-block-end: 10px; }
.sx-empty-title { font-weight: 600; color: var(--sx-grey); }
.sx-skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 50%, #eef1f6 75%);
    background-size: 200% 100%; animation: sx-shimmer 1.3s infinite; border-radius: 8px; }
@keyframes sx-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sx-spinner { width: 22px; height: 22px; border: 2.5px solid var(--sx-blue-100); border-top-color: var(--sx-blue);
    border-radius: 50%; animation: sx-spin .7s linear infinite; display: inline-block; }
@keyframes sx-spin { to { transform: rotate(360deg); } }

/* =========================================================================
   Bottom sheet (fragment-style modal) — reused by Add Item / Pay flows
   ========================================================================= */
.sx-sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 25, 40, .42); z-index: 1080;
    opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.sx-sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.sx-sheet {
    position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 1090;
    background: var(--sx-surface); border-radius: var(--sx-r-lg) var(--sx-r-lg) 0 0;
    box-shadow: var(--sx-shadow-lg); max-height: 92vh; display: flex; flex-direction: column;
    transform: translateY(100%); transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    max-width: 560px; margin-inline: auto;
    padding-block-end: var(--safe-b);
}
.sx-sheet.is-open { transform: translateY(0); }
.sx-sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: #d3d9e2; margin: 10px auto 4px; flex: none; }
.sx-sheet-head { display: flex; align-items: center; gap: 10px; padding: 6px 18px 12px; border-block-end: 1px solid var(--sx-line); }
.sx-sheet-title { font-size: 1.05rem; font-weight: 600; flex: 1; }
.sx-sheet-body { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sx-sheet-foot { padding: 12px 18px calc(12px + var(--safe-b)); border-block-start: 1px solid var(--sx-line);
    display: flex; gap: 10px; }
.sx-sheet-foot .sx-btn { flex: 1; }

/* =========================================================================
   Toasts
   ========================================================================= */
.sx-toast-host { position: fixed; inset-block-start: calc(var(--sx-topbar-h) + 8px); inset-inline: 0; z-index: 1200;
    display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding-inline: 14px; }
.sx-toast { pointer-events: auto; max-width: 480px; width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: var(--sx-r-sm); background: var(--sx-ink); color: #fff;
    box-shadow: var(--sx-shadow-lg); font-size: .9rem; font-weight: 500;
    animation: sx-toast-in .25s ease; }
.sx-toast .bi { font-size: 1.15rem; }
.sx-toast-success { background: #14532d; }
.sx-toast-error { background: #7f1d1d; }
.sx-toast-info { background: var(--sx-blue-700); }
@keyframes sx-toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================================
   Login / auth
   ========================================================================= */
.sx-auth { background: var(--sx-blue-700); }
.sx-auth-bg { position: fixed; inset: 0; z-index: 0;
    background:
        radial-gradient(80% 60% at 80% -10%, rgba(111, 163, 218, .55), transparent 60%),
        radial-gradient(90% 70% at -10% 110%, rgba(21, 77, 143, .8), transparent 55%),
        linear-gradient(160deg, #2266BA 0%, #154d8f 55%, #103f76 100%); }
.sx-auth-wrap { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column;
    justify-content: center; align-items: center; padding: 28px 20px; }

/* =========================================================================
   Helpers
   ========================================================================= */
.sx-flex { display: flex; align-items: center; gap: 10px; }
.sx-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sx-grow { flex: 1; min-width: 0; }
.sx-muted-text { color: var(--sx-muted); }
.sx-divider { height: 1px; background: var(--sx-line); margin: 14px 0; border: 0; }
.sx-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sx-totalrow { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; }
.sx-totalrow.sx-net { border-block-start: 1px dashed var(--sx-line); margin-block-start: 6px; padding-block-start: 12px;
    font-size: 1.15rem; font-weight: 700; }
.sx-totalrow .sx-money { color: var(--sx-ink); }

@media (min-width: 768px) {
    .sx-hero-title { font-size: 2rem; }
}

/* =========================================================================
   Inventory Check (§6.4)
   ========================================================================= */
.sx-searchbar { display: flex; gap: 8px; align-items: center; margin-block-end: 14px; }
.sx-iconbtn-solid { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border: 0;
    border-radius: var(--sx-r-sm); background: var(--sx-blue); color: #fff; font-size: 1.2rem; cursor: pointer;
    transition: filter .15s ease; }
.sx-iconbtn-solid:active { transform: scale(.96); }
.sx-iconbtn-solid.sx-ghost { background: var(--sx-blue-50); color: var(--sx-blue); }
.sx-chevdim { color: var(--sx-faint); }
.rtl .sx-chevdim, .rtl .sx-row-end .bi-chevron-right, .rtl .inv-seemore .bi-chevron-right { transform: scaleX(-1); }
.rtl .inv-back .bi-chevron-left { transform: scaleX(-1); }
.sx-text-center { text-align: center; }

.sx-scanner-region { width: 100%; min-height: 240px; background: #0d1620; border-radius: var(--sx-r); overflow: hidden; }
.sx-scanner-region video { width: 100% !important; border-radius: var(--sx-r); }

/* Image slider (detail §6.4 A) */
.sx-slider { position: relative; }
.sx-slider-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; aspect-ratio: 16 / 10;
    background: var(--sx-canvas); border: 1px solid var(--sx-line); border-radius: var(--sx-r);
    scrollbar-width: none; }
.sx-slider-track::-webkit-scrollbar { display: none; }
.sx-slider-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; cursor: zoom-in; }
.sx-slider-track img.is-broken { display: none; }
.sx-slider-dots { display: flex; gap: 6px; justify-content: center; margin-block-start: 8px; }
.sx-dot { width: 7px; height: 7px; border-radius: 50%; background: #cdd5df; transition: all .2s ease; }
.sx-dot.is-active { background: var(--sx-blue); width: 18px; border-radius: 4px; }
.sx-slider-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    aspect-ratio: 16 / 10; background: var(--sx-canvas); color: var(--sx-faint);
    border: 1px dashed var(--sx-line); border-radius: var(--sx-r); }
.sx-slider-empty .bi { font-size: 2rem; }

/* Fullscreen image lightbox */
.sx-lightbox { display: none; position: fixed; inset: 0; z-index: 9999; align-items: center; justify-content: center; background: rgba(0,0,0,.88); cursor: zoom-out; }
.sx-lightbox.is-open { display: flex; }
.sx-lightbox-img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 6px; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
.sx-lightbox-close { position: absolute; top: 14px; inset-inline-end: 16px; background: rgba(255,255,255,.15); border: none; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.1rem; cursor: pointer; }

.sx-detail-head { margin: 14px 0 4px; }
.sx-detail-name { font-size: 1.25rem; }
.sx-detail-sub { color: var(--sx-muted); font-size: .85rem; margin-block-start: 2px; }
.sx-detail-section { font-size: .95rem; margin-block-end: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.sx-detail-total { color: var(--sx-blue); font-size: 1.1rem; }
.sx-detail-share { border-block-start: 1px solid var(--sx-line); padding: 12px 0 0; margin-block-start: 4px; }

/* Prices (§6.4 C) */
.sx-price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sx-price-card { background: var(--sx-blue-50); border-radius: var(--sx-r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.sx-price-n { font-size: .7rem; font-weight: 700; color: var(--sx-blue); text-transform: uppercase; letter-spacing: .04em; }
.sx-price-v { font-size: 1.05rem; font-weight: 600; }

/* Files & links (§6.4 D, E) */
.sx-file-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--sx-line);
    border-radius: var(--sx-r-sm); margin-block-end: 8px; color: var(--sx-ink); }
.sx-file-row:hover { background: var(--sx-blue-50); }
.sx-file-row .bi:first-child { color: var(--sx-blue); }
.sx-link-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sx-link-chip { display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: var(--sx-r-pill);
    background: var(--sx-canvas); border: 1px solid var(--sx-line); color: var(--sx-blue); font-size: .85rem; font-weight: 500; }

/* Per-warehouse balances (§6.4 F + See more) */
.sx-balance-row { display: grid; grid-template-columns: 1fr 92px 92px; gap: 8px; align-items: center;
    padding: 9px 4px; border-block-end: 1px solid var(--sx-line-soft); }
.sx-balance-row--2 { grid-template-columns: 1fr 120px; }
.sx-balance-row .sx-num { text-align: end; }
.sx-balance-wh { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-balance-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--sx-faint); font-weight: 700; }
.sx-balance-head .sx-balance-val { text-align: end; }
.sx-balance-total { font-weight: 700; border-block-end: 0; border-block-start: 1.5px solid var(--sx-line); color: var(--sx-ink); margin-block-start: 4px; }

/* =========================================================================
   Sales flow (§6.5–6.8): steps, picker, cart, packs, summary, result, history
   ========================================================================= */
.sx-steps { display: flex; align-items: flex-start; gap: 4px; list-style: none; padding: 0; margin: 2px 0 18px; }
.sx-steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: .72rem; font-weight: 600; color: var(--sx-faint); text-align: center; }
.sx-steps li span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    background: #eef1f6; color: var(--sx-faint); font-weight: 700; transition: all .2s ease; }
.sx-steps li.is-active { color: var(--sx-blue); }
.sx-steps li.is-active span { background: var(--sx-blue); color: #fff; box-shadow: 0 4px 10px rgba(29, 99, 184, .3); }
.sx-steps li.is-done { color: var(--sx-green); }
.sx-steps li.is-done span { background: var(--sx-green-50); color: var(--sx-green); }

.sx-picker { display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--sx-tap);
    padding: 10px 14px; background: var(--sx-surface); border: 1.5px solid var(--sx-line);
    border-radius: var(--sx-r-sm); font: inherit; cursor: pointer; text-align: start; }
.sx-picker:focus-visible { outline: none; border-color: var(--sx-blue); box-shadow: var(--sx-ring); }
.sx-picker .bi:first-child { color: var(--sx-muted); }
.sx-picker .bi-chevron-down { color: var(--sx-faint); }
#sfClientName { color: var(--sx-faint); }
#sfClientName.is-filled { color: var(--sx-ink); font-weight: 600; }

.sx-pill-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
    border-radius: var(--sx-r-pill); background: rgba(255, 255, 255, .25); color: #fff; font-size: .78rem; font-weight: 700; margin-inline-start: 6px; }

.sx-kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; }
.sx-kv span { color: var(--sx-muted); }
.sx-kv b { text-align: end; }

/* Cart lines */
.sx-cartline { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-block-end: 1px solid var(--sx-line-soft); }
.sx-cartline:last-child { border-block-end: 0; }
.sx-cartline-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.sx-cartline-acts { display: flex; gap: 2px; }
.sx-cartline-acts .sx-iconbtn { width: 34px; height: 34px; font-size: .95rem; }
.sx-cartline-acts .sf-cart-del { color: var(--sx-red); }
.sf-additem-ico { color: var(--sx-blue); font-size: 1.4rem; margin-inline-start: 8px; }

/* Price-tier selection (Add Item §6.5) — Price 1–4, with ×1 (piece) or ×N (package) */
.sx-tiergrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-block-start: 2px; }
.sx-tier { display: flex; flex-direction: column; gap: 5px; padding: 9px 11px; border: 1.5px solid var(--sx-line);
    border-radius: var(--sx-r-sm); background: var(--sx-surface); cursor: pointer; text-align: start;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.sx-tier:active { transform: scale(.99); }
.sx-tier.is-active { border-color: var(--sx-blue); background: var(--sx-blue-50); box-shadow: var(--sx-ring); }
.sx-tier:disabled { opacity: .5; cursor: not-allowed; }
.sx-tier-label { font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--sx-muted); }
.sx-tier.is-active .sx-tier-label { color: var(--sx-blue); }
.sx-tier-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sx-tier-mult { font-size: .68rem; font-weight: 700; color: #fff; background: var(--sx-blue); border-radius: var(--sx-r-pill); padding: 1px 8px; flex: none; }
.sx-tier:disabled .sx-tier-mult { background: var(--sx-faint); }
.sx-tier-price { font-size: 1rem; font-weight: 600; font-family: var(--sx-mono); font-variant-numeric: tabular-nums; }

/* Percentage input (taxes / discount) */
.sx-pct { position: relative; }
.sx-pct .sx-input { padding-inline-end: 34px; }
.sx-pct-sign { position: absolute; inset-block-start: 50%; inset-inline-end: 14px; transform: translateY(-50%);
    color: var(--sx-muted); font-weight: 600; pointer-events: none; }
[dir="rtl"] {
    .sx-pct-sign {
        inset-inline-start: 14px;
        inset-inline-end: auto;
    }
}
.sx-pct-tag { display: inline-block; font-size: .68rem; font-weight: 700; color: var(--sx-blue);
    background: var(--sx-blue-50); border-radius: var(--sx-r-pill); padding: 0 6px; margin-inline-start: 4px; vertical-align: middle; }

/* Auto-growing textarea (remarks) */
.sx-autogrow { overflow: hidden; resize: none; min-height: 44px; transition: height .08s ease; }

/* Credit limit */
.sx-creditrow { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; border-block-end: 1px solid var(--sx-line-soft); }
.sx-credit-avail { border-block-end: 0; border-block-start: 1.5px solid var(--sx-line); margin-block-start: 4px; font-size: 1.05rem; }
.sx-credit-avail b { color: var(--sx-green); }

/* Result */
.sx-result { text-align: center; padding: 18px 6px; animation: sx-rise .4s both; }
.sx-result-badge { width: 72px; height: 72px; border-radius: 50%; background: var(--sx-green-50); color: var(--sx-green);
    display: grid; place-items: center; font-size: 2.2rem; margin: 0 auto 16px; animation: sx-pop .45s both; }
.sx-result-title { font-size: 1.5rem; }
.sx-result-sub { color: var(--sx-muted); margin: 6px 0 18px; }
.sx-result-card { background: var(--sx-surface); border: 1px solid var(--sx-line); border-radius: var(--sx-r);
    padding: 14px; margin-block-end: 14px; box-shadow: var(--sx-shadow-sm); text-align: start; }
.sx-result-kv { display: flex; justify-content: space-between; padding: 6px 0; }
.sx-result-kv b { font-family: var(--sx-mono); font-size: 1.05rem; }
.sx-result .sx-btn-block { margin-block-end: 10px; }
.sx-result-actions { display: flex; gap: 10px; margin-block-start: 4px; }
.sx-result-actions .sx-btn { flex: 1; }
.sx-viewchoice { display: flex; flex-direction: column; gap: 10px; }
@keyframes sx-pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }

/* History filter */
.sx-chiprow { display: flex; flex-wrap: wrap; gap: 8px; margin-block-end: 12px; }
.sx-fchip { padding: 8px 14px; border-radius: var(--sx-r-pill); border: 1.5px solid var(--sx-line);
    background: var(--sx-surface); color: var(--sx-grey); font: 600 .82rem var(--sx-font); cursor: pointer; }
.rtl .sx-fchip { font-family: var(--sx-font-ar); }
.sx-fchip.is-active { background: var(--sx-blue); color: #fff; border-color: var(--sx-blue); }

/* Sales flow — summary document-type badge + negative-stock warning */
.sf-typebadge { display: inline-flex; align-items: center; gap: 8px; margin-block-end: 14px;
    padding: 8px 15px; border-radius: var(--sx-r-pill); font-weight: 600; font-size: .92rem;
    color: var(--sx-blue); background: var(--sx-blue-50); border: 1px solid var(--sx-blue-100);
    animation: sx-rise .4s both; }
.sf-typebadge i { font-size: 1.05rem; }
.sf-warn { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-block-end: 14px;
    border-radius: var(--sx-r-sm); font-size: .88rem; line-height: 1.45;
    color: #9a6a06; background: var(--sx-amber-50); border: 1px solid #f0d79a; }
.sf-warn i { font-size: 1.1rem; margin-block-start: 1px; flex: none; color: var(--sx-amber); }
.sx-balance-row.is-over .sx-balance-val { color: var(--sx-red); font-weight: 700; }

/* ── In-app report / document / receipt viewer (§9) ───────────────────────── */
.rv-stage { display: flex; flex-direction: column; }
.rv-frame {
    position: relative; flex: 1 1 auto; min-height: 58vh;
    height: calc(100dvh - var(--sx-topbar-h) - var(--sx-bottomnav-h) - var(--safe-b) - 172px);
    background: var(--sx-surface); border: 1px solid var(--sx-line);
    border-radius: var(--sx-r); overflow: hidden; box-shadow: var(--sx-shadow-sm);
}
/* PDF.js render surface — scrollable column of page canvases (no native PDF viewer). */
.rv-doc {
    width: 100%; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: #525659; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.rv-page {
    display: block; width: 100%; max-width: 920px; height: auto;
    background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); border-radius: 2px;
}
.rv-object { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #525659; }
.rv-fallback {
    position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
    align-items: center; justify-content: center; text-align: center; padding: 28px;
    color: var(--sx-muted); background: var(--sx-surface);
}
.rv-fallback i { font-size: 2.6rem; color: var(--sx-blue); }
.rv-fallback p { margin: 0; max-width: 320px; line-height: 1.5; }
.rv-loading {
    position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
    align-items: center; justify-content: center; color: var(--sx-muted); background: var(--sx-surface);
}
.rv-actionbar {
    position: sticky; inset-block-end: calc(var(--sx-bottomnav-h) + var(--safe-b)); z-index: 5;
    display: flex; gap: 6px; padding: 8px 6px;
    margin: 14px calc(-1 * var(--sx-pad)) calc(-1 * (var(--sx-bottomnav-h) + var(--safe-b) + 22px));
    background: var(--sx-surface); border-block-start: 1px solid var(--sx-line);
    box-shadow: 0 -4px 16px rgba(20, 40, 70, .05); overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.rv-act {
    flex: 1 0 auto; min-width: 62px; display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 8px 6px; border: 0; background: transparent; color: var(--sx-ink); border-radius: var(--sx-r-sm);
    font: inherit; font-size: .7rem; font-weight: 600; cursor: pointer; transition: background .15s;
}
.rv-act i { font-size: 1.3rem; line-height: 1; color: var(--sx-blue); }
.rv-act:hover { background: var(--sx-blue-50); }
.rv-act:disabled { opacity: .55; cursor: default; }
.rv-act .sx-spinner { width: 1.1rem; height: 1.1rem; }

/* ── Public (no-login) viewer shell ───────────────────────────────────────── */
.pv-body { display: flex; flex-direction: column; min-height: 100dvh; background: var(--sx-canvas); }
.pv-head {
    display: flex; flex-direction: column; gap: 2px; padding: 16px 18px;
    background: linear-gradient(135deg, var(--sx-blue), #154d92); color: #fff;
}
.pv-brand { font-size: .78rem; font-weight: 600; opacity: .85; display: inline-flex; align-items: center; gap: 6px; }
.pv-title { font-size: 1.18rem; font-weight: 700; }
.pv-frame { flex: 1 1 auto; min-height: 0; height: auto; margin: 14px; }
.pv-actionbar {
    position: sticky; inset-block-end: 0; margin: 0; border-radius: 0;
    padding-block-end: calc(8px + var(--safe-b));
}
.pv-expired { align-items: center; justify-content: center; }
.pv-expired-card { text-align: center; padding: 48px 24px; max-width: 360px; margin: auto; }
.pv-expired-ico {
    display: inline-flex; width: 64px; height: 64px; border-radius: 50%; align-items: center; justify-content: center;
    background: var(--sx-blue-50); color: var(--sx-blue); font-size: 1.9rem; margin-block-end: 16px;
}
.pv-expired-card h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 8px; color: var(--sx-ink); }
.pv-expired-card p { color: var(--sx-muted); margin: 0; line-height: 1.5; }

/* Reports (§6.10) */
.sx-rep-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--sx-blue-50); color: var(--sx-blue);
    display: grid; place-items: center; font-size: 1.1rem; flex: none; }

/* Payment fragment (§6.6 / §6.9) */
.sx-paybox { background: var(--sx-blue-50); border: 1px solid var(--sx-blue-100); border-radius: var(--sx-r-sm); padding: 12px 14px; margin-block-end: 14px; }
.sx-payrow { display: flex; justify-content: space-between; align-items: center; }
.sx-payrow b { font-size: 1.15rem; color: var(--sx-blue); }

/* =========================================================================
   Login screen
   ========================================================================= */
.sx-login-card {
    position: relative; z-index: 1; width: 100%; max-width: 400px;
    background: var(--sx-surface); border-radius: var(--sx-r-lg);
    box-shadow: var(--sx-shadow-lg); padding: 30px 24px 22px;
    animation: sx-rise .45s both;
}
.sx-login-logo { display: block; height: 90px; width: auto; margin: 2px auto 18px; }
.sx-login-title { text-align: center; font-size: 1.5rem; }
.sx-login-sub { text-align: center; color: var(--sx-muted); font-size: .9rem; margin: 4px 0 22px; }
.sx-remember { display: flex; align-items: center; gap: 9px; margin: 14px 0 4px;
    font-size: .9rem; color: var(--sx-grey); cursor: pointer; user-select: none; }
.sx-remember input { width: 17px; height: 17px; accent-color: var(--sx-blue); cursor: pointer; flex: 0 0 auto; }
.sx-login-btn { margin-block-start: 6px; }
.sx-login-foot { text-align: center; color: var(--sx-faint); font-size: .76rem; margin: 18px 0 0; }
.sx-pw-toggle { position: absolute; inset-block-start: 50%; inset-inline-end: 6px; transform: translateY(-50%);
    width: 38px; height: 38px; border: 0; background: transparent; color: var(--sx-muted);
    border-radius: var(--sx-r-sm); cursor: pointer; display: grid; place-items: center; font-size: 1.05rem; }
.sx-pw-toggle:hover { color: var(--sx-blue); background: var(--sx-blue-50); }
.sx-input-group:has(.sx-pw-toggle) .sx-input { padding-inline-end: 46px; }
.sx-login-lang { position: fixed; inset-block-start: 16px; inset-inline-end: 16px; z-index: 3; margin: 0; }
.sx-login-langbtn { min-width: 42px; height: 38px; padding: 0 12px; border-radius: var(--sx-r-pill);
    border: 1px solid rgba(255,255,255,.5); background: rgba(255,255,255,.16); color: #fff;
    font-weight: 700; font-size: .95rem; cursor: pointer; backdrop-filter: blur(6px);
    transition: background .15s ease; }
.sx-login-langbtn:hover { background: rgba(255,255,255,.28); }

/* =========================================================================
   Page footer
   ========================================================================= */
.sx-footer {
    margin-block-start: 28px; padding-block-start: 18px;
    border-block-start: 1px solid var(--sx-line);
    text-align: center; color: var(--sx-faint); font-size: .8rem;
}

/* =========================================================================
   Desktop (≥ 992px) — widen the shell, drop the bottom nav, 4-up modules.
   The phone keeps its native app shell; on a wide screen it reads like the
   web dashboard: navigation lives in the top bar + the module cards.
   ========================================================================= */
@media (min-width: 992px) {
    .sx-topbar-inner { max-width: 1200px; padding-inline: 24px; }
    .sx-main {
        max-width: 1200px;
        padding-block: calc(var(--sx-topbar-h) + 5px) 8px;
        padding-inline: 24px;
    }
   /* .sx-bottomnav { display: none; }    */        /* nav via top bar + cards on desktop */
    .sx-home-title { font-size: 2.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* =========================================================================
   Boot splash — full-screen artwork, shown once per browser session
   ========================================================================= */
.sx-splash {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
    opacity: 1;
    transition: opacity .45s ease;
}
.sx-splash.is-hiding { opacity: 0; pointer-events: none; }
.sx-splash[hidden]   { display: none; }

/* Lock the page while the splash is up, so nothing scrolls behind it and no
   scrollbar shows through at the edge. */
body:has(.sx-splash:not([hidden]):not(.is-hiding)) { overflow: hidden; }

/*
   The artwork is portrait (941×1672). "contain" keeps the whole composition visible and
   never crops the wordmark or footer: on tall phones the height governs, on wide desktops
   the height still governs (portrait art), so it stays comfortably centred on white.
*/
.sx-splash-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    animation: sx-splash-in .45s ease both;
}

@keyframes sx-splash-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }

/* Phones: let the artwork use the full height it can get */
@media (max-width: 767px) {
    .sx-splash-img { max-height: 100%; max-width: 100%; }
}

/* Wide screens: cap it so the splash doesn't become a giant billboard */
@media (min-width: 768px) {
    .sx-splash-img { max-height: min(88vh, 720px); }
}

/* Landscape phones / short viewports: height is the tight constraint */
@media (orientation: landscape) and (max-height: 520px) {
    .sx-splash-img { max-height: 92vh; }
}

@media (prefers-reduced-motion: reduce) {
    .sx-splash-img { animation: none; }
    .sx-splash { transition: none; }
}
