/* ==========================================================================
   CRS (Consumption Recycling System) — Production Design System & Stylesheet
   Brand Palette: White & Purple (#6D28D9, #4C1D95, #8B5CF6, #F5F0FF, #FAF9FC)
   Impeccable Craft Standards: Zero AI Slop, Themed Browser Surfaces, Tabular Digits
   ========================================================================== */

:root {
    --primary-purple: #6D28D9;
    --deep-purple: #4C1D95;
    --bright-purple: #8B5CF6;
    --pale-lavender: #F5F0FF;
    --surface-white: #FFFFFF;
    --bg-main: #FAF9FC;
    --text-main: #191526;
    --text-muted: #777187;
    --border-color: #EAE5F2;
    --border-hover: #D8CEE8;
    
    --success: #15803D;
    --success-bg: #DCFCE7;
    --warning: #B45309;
    --warning-bg: #FEF3C7;
    --error: #DC2626;
    --error-bg: #FEE2E2;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-arabic: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans Arabic', Tahoma, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    
    --shadow-subtle: 0 1px 3px rgba(25, 21, 38, 0.04), 0 1px 2px rgba(25, 21, 38, 0.02);
    --shadow-card: 0 4px 6px -1px rgba(109, 40, 217, 0.04), 0 2px 4px -2px rgba(25, 21, 38, 0.04);
    --shadow-lifted: 0 10px 15px -3px rgba(109, 40, 217, 0.08), 0 4px 6px -4px rgba(25, 21, 38, 0.03);
    --shadow-dropdown: 0 20px 25px -5px rgba(25, 21, 38, 0.1), 0 8px 10px -6px rgba(25, 21, 38, 0.04);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset & Themed Browser Surfaces */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html[dir="rtl"] {
    font-family: var(--font-arabic);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: clip;
    font-family: inherit;
}

/* Universal Form Controls Font Inheritance & Arabic Typography Perfection */
button, input, select, textarea, optgroup {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    letter-spacing: inherit;
}

/* Explicit RTL Font Rules for Every Interactive Element */
html[dir="rtl"] body,
html[dir="rtl"] button,
html[dir="rtl"] input,
html[dir="rtl"] select,
html[dir="rtl"] textarea,
html[dir="rtl"] optgroup,
html[dir="rtl"] .form-input,
html[dir="rtl"] .form-select,
html[dir="rtl"] .form-textarea,
html[dir="rtl"] .form-label,
html[dir="rtl"] .btn,
html[dir="rtl"] .badge,
html[dir="rtl"] .dropdown,
html[dir="rtl"] .modal,
html[dir="rtl"] table {
    font-family: var(--font-arabic);
    letter-spacing: normal !important;
}

html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6,
html[dir="rtl"] p,
html[dir="rtl"] span,
html[dir="rtl"] a,
html[dir="rtl"] label,
html[dir="rtl"] small,
html[dir="rtl"] .form-hint {
    letter-spacing: normal !important;
}

html[dir="rtl"] small,
html[dir="rtl"] .form-hint {
    font-family: var(--font-arabic);
    font-size: 0.8125rem;
    line-height: 1.45;
}

/* Crisp, legible Arabic placeholders across all inputs */
input::placeholder,
textarea::placeholder {
    font-family: var(--font-arabic), var(--font-sans) !important;
    letter-spacing: normal !important;
    font-style: normal;
    font-weight: 500;
    opacity: 0.65;
}

html[dir="rtl"] input::placeholder,
html[dir="rtl"] textarea::placeholder {
    font-family: var(--font-arabic) !important;
    letter-spacing: normal !important;
    font-style: normal;
    font-weight: 500;
    opacity: 0.65;
}

/* Select and option typography for clean dropdowns */
select, option, optgroup {
    font-family: inherit;
}
html[dir="rtl"] select,
html[dir="rtl"] option,
html[dir="rtl"] optgroup {
    font-family: var(--font-arabic) !important;
    letter-spacing: normal !important;
    line-height: 1.5;
}

/* Monospace and serial inputs with proper Arabic fallback */
.input-monospace,
.font-mono,
input[style*="monospace"],
textarea[style*="monospace"] {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, var(--font-arabic) !important;
}

/* 1. Theme browser selection */
::selection {
    background-color: var(--pale-lavender);
    color: var(--deep-purple);
}

/* 2. Theme caret */
input, textarea {
    caret-color: var(--primary-purple);
}

/* 3. Theme focus ring */
:focus-visible {
    outline: 2px solid var(--bright-purple);
    outline-offset: 2px;
}

/* 4. Tabular numbers & strict LTR formatting for financial precision */
.tnum, [data-tnum], .tabular-nums, .currency-val, .amount-val, .points-val {
    font-feature-settings: "tnum" 1;
    font-variant-numeric: tabular-nums;
    direction: ltr !important;
    unicode-bidi: isolate !important;
}

span.tnum, strong.tnum, b.tnum, div.tnum,
span[data-tnum], strong[data-tnum], b[data-tnum], div[data-tnum],
.currency-val, .amount-val, .points-val {
    display: inline-block;
}

td.tnum, th.tnum,
.data-table td.tnum, .data-table th.tnum {
    display: table-cell !important;
}

html[dir="rtl"] .tnum,
html[dir="rtl"] [data-tnum],
html[dir="rtl"] .tabular-nums,
html[dir="rtl"] .currency-val,
html[dir="rtl"] .amount-val,
html[dir="rtl"] .points-val {
    direction: ltr !important;
    unicode-bidi: isolate !important;
}

/* 5. Custom subtle scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #D8CEE8;
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--bright-purple);
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-main);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem; }

p {
    color: var(--text-muted);
    font-size: 0.975rem;
    line-height: 1.6;
}

a {
    color: var(--primary-purple);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--deep-purple);
}

/* Layout Utilities */
.container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.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; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }

.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.col-span-1 { grid-column: span 1 / span 1; }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-3 { grid-column: span 3 / span 3; }
.col-span-full { grid-column: 1 / -1; }

@media (min-width: 640px) {
    .sm\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sm\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .sm\:col-span-1 { grid-column: span 1 / span 1; }
    .sm\:col-span-2 { grid-column: span 2 / span 2; }
    .sm\:col-span-3 { grid-column: span 3 / span 3; }
    .sm\:col-span-full { grid-column: 1 / -1; }
}

@media (min-width: 768px) {
    .md\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .md\:col-span-1 { grid-column: span 1 / span 1; }
    .md\:col-span-2 { grid-column: span 2 / span 2; }
    .md\:col-span-3 { grid-column: span 3 / span 3; }
    .md\:col-span-full { grid-column: 1 / -1; }
}

.gap-0\.5 { gap: 0.125rem; }
.gap-1 { gap: 0.25rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }
.gap-3\.5 { gap: 0.875rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.gap-7 { gap: 1.75rem; }
.gap-8 { gap: 2rem; }
.gap-10 { gap: 2.5rem; }
.gap-12 { gap: 3rem; }

/* Spacing */
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.py-16 { padding-top: 4rem; padding-bottom: 4rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }

.m-0 { margin: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

/* Surfaces & Containers */
.surface {
    background-color: var(--surface-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-subtle);
}

.surface-lavender {
    background-color: var(--pale-lavender);
    border: 1px solid #E4D9F8;
    border-radius: var(--radius-lg);
}

/* Button Component System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.925rem;
    font-weight: 600;
    padding: 0.625rem 1.15rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.25;
    min-height: 44px; /* Native touch target floor */
    user-select: none;
    white-space: nowrap;
}

html[dir="rtl"] .btn {
    font-family: var(--font-arabic);
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: normal !important;
}

.btn-primary {
    background-color: var(--primary-purple);
    color: #FFFFFF !important;
}
.btn-primary:hover {
    background-color: var(--deep-purple);
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.25);
}
.btn:active,
.chip-preset:active,
.btn-quick-fill:active,
.service-tap-btn:active,
.quick-pts-btn:active,
.ops-tab-btn:active,
.card-interactive:active {
    transform: scale(0.975);
    transition: transform 0.08s ease;
}

.btn-secondary {
    background-color: var(--surface-white);
    color: var(--text-main) !important;
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--pale-lavender);
    border-color: var(--bright-purple);
    color: var(--deep-purple) !important;
}

.btn-lavender {
    background-color: var(--pale-lavender);
    color: var(--deep-purple) !important;
    border-color: #E2D7F6;
}
.btn-lavender:hover {
    background-color: #EDE4FE;
    color: var(--primary-purple) !important;
}

.btn-danger {
    background-color: var(--error);
    color: #FFFFFF !important;
}
.btn-danger:hover {
    background-color: #B91C1C;
}

.btn-sm {
    min-height: 36px;
    padding: 0.4rem 0.85rem;
    font-size: 0.825rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    min-height: 52px;
    padding: 0.85rem 1.75rem;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
}

.btn-full {
    width: 100%;
}

.btn:disabled, .btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Form Input Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.1rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    display: block;
}

html[dir="rtl"] .form-label {
    font-family: var(--font-arabic);
    font-weight: 700;
    font-size: 0.885rem;
    line-height: 1.45;
    letter-spacing: normal !important;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: var(--surface-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

html[dir="rtl"] .form-input,
html[dir="rtl"] .form-select,
html[dir="rtl"] .form-textarea {
    font-family: var(--font-arabic);
    font-size: 0.935rem;
    line-height: 1.55;
    letter-spacing: normal !important;
    text-align: right;
}

html[dir="rtl"] .form-select {
    padding-left: 2rem;
    padding-right: 0.875rem;
}

.form-input:hover, .form-select:hover {
    border-color: var(--border-hover);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--bright-purple);
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.form-input::placeholder {
    color: #A39DB5;
}

/* Badges & Status Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.775rem;
    font-weight: 600;
    line-height: 1.2;
}

html[dir="rtl"] .badge {
    font-family: var(--font-arabic);
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: normal !important;
}

.badge-purple {
    background-color: var(--pale-lavender);
    color: var(--deep-purple);
    border: 1px solid #E5DAF9;
}

.badge-success {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid #BBF7D0;
}

.badge-warning {
    background-color: var(--warning-bg);
    color: var(--warning);
    border: 1px solid #FDE68A;
}

.badge-error {
    background-color: var(--error-bg);
    color: var(--error);
    border: 1px solid #FECACA;
}

/* Toast System */
#toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}
html[dir="rtl"] #toast-container {
    right: auto;
    left: 1.25rem;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.15rem;
    background-color: var(--surface-white);
    color: var(--text-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-dropdown);
    font-size: 0.9rem;
    animation: toastIn 220ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
    min-width: 280px;
    max-width: 420px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile Fixed Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: var(--surface-white);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 10px rgba(25, 21, 38, 0.04);
}

.mobile-bottom-nav-inner {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    flex: 1;
    height: 100%;
    min-height: 44px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    transition: color var(--transition);
    text-decoration: none;
    padding: 2px 2px;
    box-sizing: border-box;
}

.mobile-nav-item span {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 600;
}

html[dir="rtl"] .mobile-nav-item span {
    font-family: var(--font-arabic);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0 !important;
}

.mobile-nav-item.active, .mobile-nav-item:hover {
    color: var(--primary-purple);
}

.mobile-nav-item.active span {
    font-weight: 800;
}

.mobile-nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
    flex-shrink: 0;
}

/* Desktop App Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 260px;
    background-color: var(--surface-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    flex-shrink: 0;
}
html[dir="rtl"] .app-sidebar {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ==========================================================================
   Modern Appbar Architecture (Desktop + Mobile Responsive)
   ========================================================================== */
.app-topbar {
    height: 64px;
    background-color: var(--surface-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 200;
    box-sizing: border-box;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.appbar-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1;
}

.appbar-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #FAF5FF, #F3E8FF);
    border: 1px solid #E9D5FF;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(109, 40, 217, 0.1);
    text-decoration: none;
}

.appbar-brand-icon img {
    width: 22px;
    height: 22px;
    display: block;
}

.appbar-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.appbar-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #191526;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    unicode-bidi: plaintext;
    text-align: start;
}

.appbar-subtitle {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-purple);
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.appbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.appbar-lang-switcher {
    display: inline-flex;
    align-items: center;
    border: 1px solid #E2DDF0;
    border-radius: 8px;
    padding: 2px;
    background: #F8FAFC;
    direction: ltr;
    box-sizing: border-box;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

.appbar-lang-switcher a {
    padding: 3px 8px;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: 6px;
    text-decoration: none;
    color: #64748B;
    line-height: 1.3;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.appbar-lang-switcher a:hover:not(.active) {
    color: var(--primary-purple);
    background: rgba(109, 40, 217, 0.05);
}

.appbar-lang-switcher a.active {
    background-color: var(--primary-purple);
    color: #FFFFFF !important;
    box-shadow: 0 1px 4px rgba(109, 40, 217, 0.25);
}

.appbar-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #4B4658;
}

.appbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #F5F0FF;
    border: 1px solid #E9D5FF;
    color: var(--primary-purple);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    font-weight: 700;
    flex-shrink: 0;
}

.appbar-user-name {
    font-weight: 600;
    color: #191526;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.appbar-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #DC2626 !important;
    background: #FEF2F2;
    border: 1px solid #FEE2E2;
    text-decoration: none;
    transition: all 0.15s ease;
    flex-shrink: 0;
    cursor: pointer;
}

.appbar-logout-btn:hover {
    background: #FEE2E2;
    border-color: #FECACA;
    color: #B91C1C !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(220, 38, 38, 0.15);
}

.appbar-logout-btn:active {
    transform: scale(0.97);
}

html[dir="rtl"] .appbar-logout-btn svg {
    transform: scaleX(-1);
}

/* Public Topbar */
.public-topbar {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #EAE5F2;
    position: sticky;
    top: 0;
    z-index: 100;
    direction: ltr;
}

.public-topbar-inner {
    height: 68px;
}

.public-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.public-logo {
    height: 44px;
    width: 108px;
    max-height: 44px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}

.sidebar-link:hover {
    background-color: var(--pale-lavender);
    color: var(--deep-purple);
}

.sidebar-link.active {
    background-color: var(--pale-lavender);
    color: var(--primary-purple);
    font-weight: 600;
}

/* Tables & Universal Mobile Responsiveness */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    border: 1px solid var(--border-color, #E4E4E7);
    background: #FFFFFF;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F8FAFC;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #F8FAFC;
    border-radius: 8px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 8px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

.data-table {
    width: 100%;
    min-width: 680px; /* Crucial: Prevents columns and monospace serials from collapsing into unreadable vertical text */
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    text-align: left;
}

html[dir="rtl"] .data-table {
    text-align: right;
}

.data-table th {
    background-color: #F8F6FC;
    color: var(--text-muted, #71717A);
    font-weight: 750;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 0.85rem;
    border-bottom: 1.5px solid var(--border-color, #E4E4E7);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid #F1F5F9;
    color: var(--text-main, #18181B);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:nth-child(even) td {
    background-color: #FAFAFD;
}

.data-table tbody tr:hover td {
    background-color: #F4F0FF !important;
}

.data-table code,
.data-table .badge,
.data-table button {
    white-space: nowrap;
}

.data-table td.cell-wrap,
.data-table th.cell-wrap {
    white-space: normal;
    word-break: break-word;
}

/* Alignment helpers for financial tables */
.data-table th.text-end,
.data-table td.text-end {
    text-align: right !important;
}
html[dir="rtl"] .data-table th.text-end,
html[dir="rtl"] .data-table td.text-end {
    text-align: left !important;
}

.data-table th.text-start,
.data-table td.text-start {
    text-align: left !important;
}
html[dir="rtl"] .data-table th.text-start,
html[dir="rtl"] .data-table td.text-start {
    text-align: right !important;
}

.data-table th.text-center,
.data-table td.text-center {
    text-align: center !important;
}

/* Compact Table Action Group for Desktop */
.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: flex-start;
}
html[dir="rtl"] .table-actions {
    justify-content: flex-start;
}
.table-actions.justify-center {
    justify-content: center !important;
}
.table-actions .btn {
    height: 28px;
    min-height: 28px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    line-height: 1;
}

.table-actions-grid {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    width: 165px;
}
.table-actions-grid .btn {
    height: 28px;
    min-height: 28px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    white-space: nowrap;
    line-height: 1;
}

/* Sticky Headers & Refined Density on Desktop */
@media (min-width: 992px) {
    .table-responsive {
        border-radius: 14px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    }
    .data-table thead th {
        position: sticky;
        top: 0;
        z-index: 5;
        background-color: #F8F6FC;
        box-shadow: 0 1px 0 var(--border-color, #E4E4E7);
    }
}

/* ==========================================================================
   POS Terminal Components & Scanner Overhaul
   ========================================================================== */
.pos-tab-bar {
    display: flex;
    background: #FFFFFF;
    border: 1.5px solid #EAE5F2;
    border-radius: 16px;
    padding: 5px;
    box-shadow: 0 4px 14px rgba(109, 40, 217, 0.05);
    gap: 6px;
    width: 100%;
}
.pos-tab-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 10px 14px;
    border-radius: 11px;
    font-size: 13.5px;
    font-weight: 700;
    color: #52525B;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    min-height: 44px;
}
@media (max-width: 520px) {
    .pos-tab-item {
        padding: 8px 6px;
        font-size: 12px;
        gap: 5px;
        min-height: 42px;
    }
}
.pos-tab-item:hover:not(.active) {
    background: #FAF5FF;
    color: #6D28D9;
}
.pos-tab-item.active {
    background: linear-gradient(135deg, #4C1D95 0%, #6D28D9 100%);
    color: #FFFFFF !important;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.28);
}
.pos-tab-item svg {
    flex-shrink: 0;
    transition: stroke 0.2s ease;
}
.pos-tab-item.active svg {
    stroke: #FFFFFF !important;
}

/* Submode switcher (App OTP vs Carte) */
.pos-submode-bar {
    display: flex;
    background: #F4F4F5;
    border: 1.5px solid #E4E4E7;
    border-radius: 14px;
    padding: 4px;
    gap: 6px;
    margin-bottom: 20px;
}
.pos-submode-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #71717A;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    min-height: 44px;
}
@media (max-width: 520px) {
    .pos-submode-item {
        padding: 8px 6px;
        font-size: 12px;
        gap: 6px;
        min-height: 42px;
    }
}
.pos-submode-item svg {
    flex-shrink: 0;
    stroke: currentColor;
    transition: stroke 0.2s ease;
}
.pos-submode-item:hover:not(.active) {
    color: #18181B;
    background: rgba(255, 255, 255, 0.6);
}
.pos-submode-item.active {
    background: linear-gradient(135deg, #4C1D95 0%, #6D28D9 100%);
    color: #FFFFFF !important;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.28);
}
.pos-submode-item.active svg {
    stroke: #FFFFFF !important;
}
.submode-pill {
    font-size: 10.5px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
    background: #E4E4E7;
    color: #52525B;
    transition: all 0.2s ease;
}
.pos-submode-item.active .submode-pill {
    background: rgba(255, 255, 255, 0.22);
    color: #FFFFFF;
}
.submode-pill.pill-amber {
    background: #FEF3C7;
    color: #92400E;
}
.pos-submode-item.active .submode-pill.pill-amber {
    background: rgba(255, 255, 255, 0.22);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.clean-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 9px;
    border-radius: 7px;
    border: 1px solid #DDD6FE;
    background: #FAF5FF;
    color: #6D28D9;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}
.clean-action-btn:hover {
    background: #EDE9FE;
    border-color: #C4B5FD;
    color: #5B21B6;
}
.clean-action-btn:active {
    transform: scale(0.97);
}

/* Mode B: Service Tap Buttons */
.service-tap-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    background-color: #FFFFFF;
    border: 1px solid #EAE5F2;
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    min-height: 108px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}
html[dir="rtl"] .service-tap-btn {
    text-align: right;
}
.service-tap-btn:hover {
    border-color: #7C3AED;
    background-color: #FAF8FE;
    transform: translateY(-2px);
    box-shadow: 0 8px 18px -4px rgba(109, 40, 217, 0.12);
}
.service-tap-btn:active {
    transform: scale(0.985);
}
.service-reward-pill {
    font-size: 11.5px;
    font-weight: 800;
    background: #DCFCE7;
    color: #15803D;
    padding: 3px 8px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #BBF7D0;
}
.service-price-val {
    font-size: 1.25rem;
    font-weight: 850;
    color: #0F172A;
    line-height: 1.1;
    direction: ltr;
}
.service-tap-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 700;
    color: #6D28D9;
}

/* Form Input Groups & Addons */
.pos-input-group {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}
.btn-quick-fill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    background: #FAF5FF;
    border: 1px solid #DDD6FE;
    color: #6D28D9;
    font-weight: 700;
    font-size: 12.5px;
    border-radius: 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.18s ease;
}
.btn-quick-fill:hover {
    background: #EDE9FE;
    border-color: #C4B5FD;
}
.currency-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.currency-input-wrap .form-input {
    padding-right: 56px !important;
}
html[dir="rtl"] .currency-input-wrap .form-input {
    padding-right: 14px !important;
    padding-left: 56px !important;
}
.currency-tag {
    position: absolute;
    right: 14px;
    font-size: 13px;
    font-weight: 800;
    color: #6B7280;
    pointer-events: none;
    letter-spacing: 0.04em;
}
html[dir="rtl"] .currency-tag {
    right: auto;
    left: 14px;
}

/* Live Receipt Card */
.pos-receipt-card {
    background: #FAF9FC;
    border: 1px solid #EAE5F2;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 20px;
}
.pos-receipt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin-bottom: 6px;
}
.pos-receipt-row:last-child {
    margin-bottom: 0;
}
.pos-receipt-divider {
    height: 1px;
    background: #EAE5F2;
    margin: 10px 0;
}
.pos-receipt-total {
    font-size: 1.35rem;
    font-weight: 850;
    color: #0F172A;
}

/* Camera Scanner Viewfinder */
.scanner-viewport {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 320px;
    margin: 0 auto;
    background-color: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lifted);
}

.scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-laser {
    position: absolute;
    top: 20%;
    left: 10%;
    right: 10%;
    height: 2px;
    background-color: var(--bright-purple);
    box-shadow: 0 0 12px var(--bright-purple);
    animation: scanLaser 2s infinite ease-in-out;
}

@keyframes scanLaser {
    0%, 100% { top: 20%; }
    50% { top: 80%; }
}

/* Offline Sync Status Bar */
.offline-banner {
    display: none;
    background-color: #FEF3C7;
    border-bottom: 1px solid #FDE68A;
    color: #92400E;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    text-align: center;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    .app-sidebar {
        display: none;
    }
    .mobile-bottom-nav {
        display: block;
    }
    .app-content {
        padding-bottom: 84px; /* Space for fixed bottom nav */
    }
    .app-topbar {
        height: 56px;
        padding: 0 0.75rem;
        gap: 8px;
    }
    .appbar-left {
        flex: 1;
        min-width: 0;
        gap: 8px;
    }
    .appbar-right {
        gap: 0.35rem;
        flex-shrink: 0;
    }
    .appbar-brand-icon {
        display: flex;
    }
    .appbar-title {
        font-size: 0.95rem;
        font-weight: 800;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }
    .appbar-subtitle {
        font-size: 0.65rem;
    }
    .appbar-user-badge {
        display: inline-flex !important;
        align-items: center !important;
        text-decoration: none !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }
    .appbar-user-name {
        display: none !important;
    }
    .appbar-user-avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 13px !important;
        font-weight: 800 !important;
        border-radius: 9px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .appbar-logout-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 6px !important;
        width: 32px !important;
        height: 32px !important;
        border-radius: 9px !important;
        box-sizing: border-box !important;
    }
    .appbar-logout-text {
        display: none !important;
    }
    .appbar-lang-switcher a {
        padding: 2px 6px;
        font-size: 11px;
    }
    @media (max-width: 380px) {
        .appbar-user-badge {
            display: none !important;
        }
    }
    .pwa-install-label {
        display: none !important;
    }
    .pwa-install-btn {
        padding: 5px 8px !important;
        font-size: 11px !important;
        border-radius: 8px !important;
    }
    .public-topbar-inner {
        height: 58px;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }
    .public-logo {
        height: 34px;
        width: 83px;
    }
    .admin-drawer-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
    .grid-cols-2 > *, .grid-cols-3 > *, .grid-cols-4 > * {
        grid-column: span 1 !important;
    }
    h1 { font-size: 1.85rem; }
    h2 { font-size: 1.45rem; }
}

/* ==========================================================================
   Admin Mobile & Responsive Layout Enhancements
   ========================================================================== */
.admin-drawer-backdrop,
.merchant-drawer-backdrop,
.consumer-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2999;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.admin-drawer-backdrop.active,
.merchant-drawer-backdrop.active,
.consumer-drawer-backdrop.active {
    display: block !important;
    opacity: 1 !important;
}

/* Admin KPI Grid */
/* Universal Stat & KPI Card Architecture */
.grid-cols-2 > .surface,
.grid-cols-3 > .surface,
.grid-cols-4 > .surface,
.grid > .surface {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.grid-cols-2 > .surface.is-hidden,
.grid-cols-3 > .surface.is-hidden,
.grid-cols-4 > .surface.is-hidden,
.grid > .surface.is-hidden,
.grid-cols-2 > .surface[style*="display: none"],
.grid-cols-3 > .surface[style*="display: none"],
.grid-cols-4 > .surface[style*="display: none"],
.grid > .surface[style*="display: none"],
.landing-merchant-card.is-hidden,
.landing-merchant-card[style*="display: none"],
.consumer-partner-card.is-hidden,
.consumer-partner-card[style*="display: none"],
.is-hidden {
    display: none !important;
}

.grid-cols-2 > .surface > span:first-child,
.grid-cols-3 > .surface > span:first-child,
.grid-cols-4 > .surface > span:first-child,
.grid > .surface > span:first-child {
    display: block !important;
    width: 100% !important;
    margin-bottom: 4px !important;
}

.grid-cols-2 > .surface > .tnum,
.grid-cols-3 > .surface > .tnum,
.grid-cols-4 > .surface > .tnum,
.grid > .surface > .tnum {
    display: block !important;
    width: 100% !important;
    margin: 4px 0 !important;
}

.grid-cols-2 > .surface > span:last-child,
.grid-cols-3 > .surface > span:last-child,
.grid-cols-4 > .surface > span:last-child,
.grid > .surface > span:last-child {
    display: block !important;
    width: 100% !important;
    margin-top: 2px !important;
}

.admin-kpis-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}
.admin-kpi-card {
    background: #FFFFFF;
    border: 1px solid #EAE5F2;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(25, 21, 38, 0.04);
}
.admin-kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.admin-kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.admin-kpi-badge {
    font-size: 10.5px;
    font-weight: 750;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.admin-kpi-value {
    font-size: clamp(1.45rem, 3.5vw, 1.85rem);
    font-weight: 900;
    line-height: 1.15;
    margin: 4px 0 2px 0;
}
.admin-kpi-label {
    font-size: 0.72rem;
    color: #71717A;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.25;
}
.admin-kpi-sub {
    font-size: 11px;
    color: #71717A;
    margin-top: 3px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-solvency-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.audit-desktop-table {
    display: block;
}
.audit-mobile-feed {
    display: none;
}
.admin-header-actions,
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    box-sizing: border-box;
}
.admin-header-actions .admin-btn-row-2,
.page-header-actions .admin-btn-row-2 {
    display: flex;
    align-items: center;
    gap: 8px;
}
@media (min-width: 861px) {
    #admin-drawer-toggle,
    #merchant-drawer-toggle,
    #consumer-drawer-toggle,
    .admin-drawer-btn,
    .merchant-drawer-btn,
    .consumer-drawer-btn {
        display: none !important;
    }
    .admin-drawer-close-btn,
    .merchant-drawer-close-btn,
    .consumer-drawer-close-btn {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .admin-header-actions,
    .page-header-actions {
        width: auto !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-end !important;
    }
    .admin-header-actions .btn,
    .page-header-actions .btn,
    .admin-header-actions a.btn,
    .page-header-actions a.btn,
    .admin-header-actions button,
    .page-header-actions button,
    .admin-header-actions .admin-hdr-btn,
    .admin-header-actions .admin-hdr-btn-primary {
        flex: 0 0 auto !important;
        width: auto !important;
        min-height: 40px !important;
    }
}
.admin-bottom-nav {
    display: none;
}

@media (max-width: 1024px) {
    .admin-kpis-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }
}

html, body {
    overflow-x: clip !important;
    max-width: 100% !important;
}
.app-shell {
    overflow-x: clip !important;
    max-width: 100% !important;
}

@media (max-width: 860px) {
    #admin-sidebar,
    #merchant-sidebar,
    #consumer-sidebar {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 290px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        z-index: 3000 !important;
        background: #FFFFFF !important;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s !important;
    }
    #admin-sidebar:not(.open),
    #merchant-sidebar:not(.open),
    #consumer-sidebar:not(.open) {
        visibility: hidden !important;
        pointer-events: none !important;
    }
    #admin-sidebar.open,
    #merchant-sidebar.open,
    #consumer-sidebar.open {
        visibility: visible !important;
        pointer-events: auto !important;
    }
    html[dir="ltr"] #admin-sidebar,
    html[dir="ltr"] #merchant-sidebar,
    html[dir="ltr"] #consumer-sidebar {
        left: 0 !important;
        right: auto !important;
        transform: translateX(-100%) !important;
    }
    html[dir="ltr"] #admin-sidebar.open,
    html[dir="ltr"] #merchant-sidebar.open,
    html[dir="ltr"] #consumer-sidebar.open {
        transform: translateX(0) !important;
    }
    html[dir="rtl"] #admin-sidebar,
    html[dir="rtl"] #merchant-sidebar,
    html[dir="rtl"] #consumer-sidebar {
        right: 0 !important;
        left: auto !important;
        transform: translateX(100%) !important;
    }
    html[dir="rtl"] #admin-sidebar.open,
    html[dir="rtl"] #merchant-sidebar.open,
    html[dir="rtl"] #consumer-sidebar.open {
        transform: translateX(0) !important;
    }
    #admin-drawer-toggle,
    #merchant-drawer-toggle,
    #consumer-drawer-toggle,
    .admin-drawer-btn,
    .merchant-drawer-btn,
    .consumer-drawer-btn {
        display: inline-flex !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 10px !important;
        background: #FFFFFF !important;
        border: 1px solid #E2E8F0 !important;
        color: #475569 !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
        cursor: pointer !important;
    }
    .admin-drawer-close-btn,
    .merchant-drawer-close-btn,
    .consumer-drawer-close-btn {
        display: inline-flex !important;
    }
    .admin-bottom-nav {
        display: block !important;
    }

    /* Sticky Action Columns in Data Tables for Mobile */
    .table-responsive .data-table th:last-child,
    .table-responsive .data-table td:last-child {
        position: sticky !important;
        inset-inline-end: 0 !important;
        background-color: #FFFFFF !important;
        z-index: 4 !important;
        box-shadow: -4px 0 10px rgba(0, 0, 0, 0.08) !important;
    }
    html[dir="rtl"] .table-responsive .data-table th:last-child,
    html[dir="rtl"] .table-responsive .data-table td:last-child {
        box-shadow: 4px 0 10px rgba(0, 0, 0, 0.08) !important;
    }
    .table-responsive .data-table thead th:last-child {
        background-color: #F8F6FC !important;
        z-index: 6 !important;
    }
    .table-responsive .data-table tbody tr:hover td:last-child {
        background-color: #F4F0FF !important;
    }
    .admin-kpis-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    .admin-kpi-card {
        padding: 12px !important;
        gap: 8px !important;
        border-radius: 14px !important;
    }
    .admin-kpi-icon {
        width: 32px !important;
        height: 32px !important;
    }
    .admin-kpi-value {
        font-size: 1.45rem !important;
    }
    .admin-kpi-label {
        font-size: 0.68rem !important;
    }
    .admin-kpi-sub {
        font-size: 10px !important;
    }
    .admin-solvency-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .audit-desktop-table {
        display: none !important;
    }
    .audit-mobile-feed {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    .admin-header-actions,
    .page-header-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .admin-header-actions > *,
    .page-header-actions > *,
    .admin-header-actions .btn,
    .page-header-actions .btn,
    .admin-header-actions a.btn,
    .page-header-actions a.btn,
    .admin-header-actions button,
    .page-header-actions button,
    .admin-header-actions .admin-hdr-btn,
    .admin-header-actions .admin-hdr-btn-primary {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-height: 42px !important;
        justify-content: center !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    .admin-header-actions .admin-btn-row-2,
    .page-header-actions .admin-btn-row-2 {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .admin-header-actions .admin-btn-row-2 .btn,
    .page-header-actions .admin-btn-row-2 .btn,
    .admin-header-actions .admin-btn-row-2 a.btn,
    .page-header-actions .admin-btn-row-2 a.btn {
        width: 100% !important;
        flex: 1 1 auto !important;
        min-height: 40px !important;
    }
    .surface form.flex {
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .surface form.flex input,
    .surface form.flex select {
        max-width: 100% !important;
        width: 100% !important;
    }
    .surface form.flex button,
    .surface form.flex .btn {
        width: 100% !important;
        justify-content: center !important;
    }
    .table-responsive {
        -webkit-overflow-scrolling: touch !important;
        border-radius: 12px !important;
    }
}

@media (max-width: 420px) {
    .pwa-install-btn {
        display: none !important;
    }
    .btn-public-register {
        padding: 5px 8px !important;
        font-size: 11px !important;
    }
    .btn-public-login {
        padding: 5px 4px !important;
        font-size: 11px !important;
    }
}

@media (min-width: 769px) {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    .appbar-subtitle {
        display: inline-flex;
        align-items: center;
        padding: 3px 9px;
        background: #FAF5FF;
        border: 1px solid #E9D5FF;
        border-radius: 6px;
        font-size: 0.72rem;
        font-weight: 700;
        color: #6D28D9;
        letter-spacing: 0.04em;
    }
    .appbar-title {
        font-size: 1.12rem;
        font-weight: 800;
        color: #191526;
    }
    .appbar-user-name {
        display: inline-block !important;
        font-size: 0.88rem;
        font-weight: 600;
        color: #191526;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .grid-cols-3, .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ==========================================================================
   Premium UI Micro-Interactions & Ambient Polish
   ========================================================================== */

/* Ambient light backgrounds */
.bg-ambient {
    background: radial-gradient(circle at 85% 15%, rgba(139, 92, 246, 0.09) 0%, transparent 45%),
                radial-gradient(circle at 10% 75%, rgba(109, 40, 217, 0.06) 0%, transparent 50%),
                var(--bg-main);
}

.hero-ambient {
    background: radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
                radial-gradient(ellipse at 20% 80%, rgba(109, 40, 217, 0.05) 0%, transparent 50%),
                linear-gradient(180deg, #FFFFFF 0%, #FAF9FC 100%);
}

/* Shimmer on loyalty and balance cards */
.shimmer-card {
    position: relative;
    overflow: hidden;
}
.shimmer-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(60deg, transparent 20%, rgba(255, 255, 255, 0.14) 25%, transparent 30%);
    transform: rotate(25deg);
    animation: cardShimmer 6s infinite ease-in-out;
    pointer-events: none;
}
@keyframes cardShimmer {
    0% { transform: translateX(-100%) rotate(25deg); }
    22%, 100% { transform: translateX(100%) rotate(25deg); }
}

/* Live pulsing status indicator dot */
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #15803D;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.7);
    animation: livePulse 2s infinite;
}
@keyframes livePulse {
    0% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(21, 128, 61, 0); }
    100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); }
}

/* Interactive Card Elevation */
.card-interactive {
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.28s ease;
}
.card-interactive:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px -4px rgba(109, 40, 217, 0.12), 0 4px 8px -2px rgba(25, 21, 38, 0.04);
    border-color: #D8CEE8;
}

/* Subtle continuous float */
.floating-card {
    animation: floatAnim 4s ease-in-out infinite alternate;
}
@keyframes floatAnim {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-8px); }
}

/* Perspective wrapper for 3D GSAP tilts */
.perspective-container {
    perspective: 1000px;
}

/* Logo Styling & Micro-interactions */
.crs-logo, .crs-logo-icon {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), filter 0.3s ease;
    user-select: none;
}

.logo-interactive {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), filter 0.3s ease;
}
.logo-interactive:hover {
    transform: scale(1.03);
    filter: drop-shadow(0 4px 12px rgba(109, 40, 217, 0.25));
}

.crs-logo-icon:hover {
    transform: scale(1.06) rotate(2deg);
}

.hover-lift {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.hover-lift:hover {
    transform: translateY(-2px);
}

@media (min-width: 900px) {
    #desktop-nav {
        display: flex !important;
    }
}
@media (max-width: 899px) {
    #desktop-nav {
        display: none !important;
    }
}

/* ==========================================================================
   3D Flippable Smart Loyalty Card with Realistic Physical Depth
   ========================================================================== */
.crs-card-3d-scene {
    perspective: 1400px;
    width: 100%;
    user-select: none;
    position: relative;
}

.crs-card-flipper {
    position: relative;
    width: 100%;
    min-height: 290px;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 24px;
}

.crs-card-flipper.is-flipped {
    transform: rotateY(180deg);
}

.crs-card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 24px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-style: preserve-3d;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 24px 50px -12px rgba(30, 10, 60, 0.45), 0 4px 16px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    overflow: hidden;
    color: #FFFFFF;
}

/* Card Front Face */
.crs-card-front {
    background: linear-gradient(135deg, #160B2E 0%, #2A0E5C 45%, #4C1D95 100%);
    padding: 26px 28px;
    z-index: 2;
    transform: rotateY(0deg);
    color: #FFFFFF;
}

/* Card Back Face */
.crs-card-back {
    background: linear-gradient(135deg, #0F071E 0%, #1A0B33 45%, #2E1065 100%);
    padding: 0 0 18px 0;
    transform: rotateY(180deg);
    color: #FFFFFF;
}

.crs-card-balance-number {
    color: #FFFFFF !important;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    font-weight: 850;
}

/* Hologram Shimmer Seal */
.crs-hologram-seal {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FDE047 0%, #EC4899 25%, #8B5CF6 50%, #06B6D4 75%, #10B981 100%);
    background-size: 200% 200%;
    animation: hologramShine 4s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
}

@keyframes hologramShine {
    0% { background-position: 0% 50%; filter: hue-rotate(0deg); }
    50% { background-position: 100% 50%; filter: hue-rotate(180deg); }
    100% { background-position: 0% 50%; filter: hue-rotate(360deg); }
}

/* Interactive Glare Reflection */
.crs-card-glare {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 24px;
    background: radial-gradient(circle at var(--glare-x, 50%) var(--glare-y, 50%), rgba(255,255,255,0.18) 0%, transparent 60%);
    opacity: 0.75;
    transition: opacity 0.3s ease;
}

/* Flip Prompt Pill */
.card-flip-prompt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #DDD6FE;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 99px;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    cursor: pointer;
}
.card-flip-prompt:hover {
    background: rgba(255, 255, 255, 0.24);
    color: #FFF;
    transform: translateY(-1px);
}

/* ==========================================================================
   App Main Content & Responsive Utilities
   ========================================================================== */
.app-main-content {
    flex: 1;
    padding: 1.5rem;
    box-sizing: border-box;
    max-width: 100%;
}

@media (max-width: 768px) {
    .app-main-content {
        padding: 1rem 0.85rem calc(85px + env(safe-area-inset-bottom, 16px)) 0.85rem !important;
    }
    .mobile-bottom-nav-inner {
        padding: 0 4px;
    }
    .mobile-nav-item {
        font-size: 0.68rem;
        padding: 4px 2px;
        gap: 2px;
    }
    .mobile-nav-item span {
        font-size: 10.5px;
    }
    html[dir="rtl"] .mobile-nav-item span {
        font-size: 11px;
        letter-spacing: 0 !important;
    }
    .mobile-nav-item svg {
        width: 19px;
        height: 19px;
    }
}

/* Responsive Action Button Rows (Stack vertically on mobile, side-by-side on tablet/desktop) */
.form-actions-responsive {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}
@media (min-width: 640px) {
    .form-actions-responsive {
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
    }
    .form-actions-responsive .btn-primary {
        flex: 1 1 auto !important;
        width: auto !important;
    }
    .form-actions-responsive .btn-secondary {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 120px !important;
    }
}
.form-actions-responsive .btn {
    width: 100% !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    text-align: center !important;
}

/* Page Header Action Groups (Wraps smoothly on mobile) */
.page-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
}
@media (max-width: 640px) {
    .page-header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap !important;
        gap: 6px;
    }
    .page-header-actions .btn {
        flex: 1 1 calc(50% - 6px);
        min-width: 120px;
        justify-content: center;
        text-align: center;
        font-size: 11.5px;
        padding: 8px 10px;
        white-space: normal;
        box-sizing: border-box;
    }
}

/* Responsive Tab Labels */
.tab-label-short {
    display: none;
}
@media (max-width: 520px) {
    .tab-label-full {
        display: none !important;
    }
    .tab-label-short {
        display: inline !important;
    }
}

/* Balance summary responsive card */
.balance-summary-card {
    background: #FFF;
    border: 1px solid #EAE5F2;
    border-radius: 14px;
    padding: 12px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 20px;
}
@media (max-width: 520px) {
    .balance-summary-card {
        width: 100%;
        justify-content: space-between;
        padding: 10px 14px;
        gap: 12px;
    }
}

.mobile-nav-item.active {
    color: var(--primary-purple);
    font-weight: 700;
}
.mobile-nav-item.active svg {
    stroke-width: 2.3;
}

/* ==========================================================================
   Recharge Cards / Voucher UI Components
   ========================================================================== */
.crs-voucher-ticket {
    background: linear-gradient(135deg, #2E1065 0%, #4C1D95 60%, #6D28D9 100%);
    color: #FFFFFF;
    border-radius: 18px;
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(76, 29, 149, 0.28), 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.crs-voucher-ticket::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255,255,255,0.12) 1px, transparent 1px);
    background-size: 10px 10px;
    opacity: 0.7;
    pointer-events: none;
}

.crs-voucher-scratch-box {
    background: linear-gradient(135deg, #E2E8F0 0%, #CBD5E1 50%, #94A3B8 100%);
    border: 2px dashed #94A3B8;
    border-radius: 10px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
    color: #0F172A;
    font-family: monospace;
    font-weight: 800;
    letter-spacing: 0.18em;
    user-select: all;
}

.chip-preset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.82rem;
    font-weight: 600;
    background: #FAF9FC;
    border: 1px solid #D8CEE8;
    color: #4C1D95;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
}
.chip-preset:hover, .chip-preset.active {
    background: #6D28D9;
    color: #FFFFFF;
    border-color: #6D28D9;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(109, 40, 217, 0.2);
}

/* Print styles for vouchers */
@media print {
    .app-sidebar, .app-topbar, .mobile-bottom-nav, .no-print, header, nav {
        display: none !important;
    }
    .app-content, .app-main-content {
        padding: 0 !important;
        margin: 0 !important;
    }
    .crs-voucher-ticket {
        box-shadow: none !important;
        border: 2px solid #000 !important;
        color: #000 !important;
        background: #FFF !important;
        page-break-inside: avoid;
    }
    .crs-voucher-scratch-box {
        border-style: solid !important;
        color: #000 !important;
        background: #EEE !important;
    }
}

/* ==========================================================================
   Merchant UI/UX Modernization Components (Mobile-First Polish)
   ========================================================================== */

/* 1. Recharge Balance & Capacity Card */
.recharge-balance-card {
    background: #FFFFFF;
    border: 1px solid #E9D5FF;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 8px 24px -6px rgba(109, 40, 217, 0.12), 0 2px 6px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}
.recharge-balance-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}
.recharge-stat-label {
    font-size: 10.5px;
    font-weight: 700;
    color: #777187;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 2px;
}
.recharge-stat-val {
    font-size: 1.55rem;
    font-weight: 850;
    line-height: 1.1;
}
.recharge-stat-val.text-purple { color: #6D28D9; }
.recharge-stat-val.text-dark { color: #191526; }
.recharge-stat-unit {
    font-size: 0.85rem;
    font-weight: 600;
    color: #777187;
}
.recharge-ceiling-col {
    text-align: right;
    border-left: 1px solid #EAE5F2;
    padding-left: 14px;
    flex-shrink: 0;
}
.recharge-margin-badge {
    font-size: 10px;
    color: #15803D;
    font-weight: 700;
    display: block;
    margin-top: 2px;
}
.recharge-progress-wrap {
    width: 100%;
}
.recharge-progress-track {
    width: 100%;
    height: 7px;
    background: #F3E8FF;
    border-radius: 99px;
    overflow: hidden;
}
.recharge-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8B5CF6, #6D28D9);
    border-radius: 99px;
    transition: width 0.6s ease;
}
.recharge-progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 10.5px;
    color: #777187;
    font-weight: 600;
    margin-top: 4px;
}

/* 2. Merchant Profile Verified ID Card */
.merchant-profile-card {
    background: #FFFFFF;
    border: 1px solid #EAE5F2;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.04);
}
.merchant-profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid #EAE5F2;
    margin-bottom: 20px;
}
.merchant-profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: linear-gradient(135deg, #F5F0FF 0%, #EDE9FE 100%);
    border: 1px solid #DDD6FE;
    color: #6D28D9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 850;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.08);
}
.merchant-profile-title-block {
    flex: 1;
    min-width: 0;
}
.merchant-profile-badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.merchant-profile-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: #191526;
    margin: 0 0 2px 0;
    line-height: 1.2;
    word-break: break-word;
}
.merchant-profile-id {
    font-size: 11.5px;
    color: #777187;
    font-family: monospace;
    font-weight: 600;
    margin: 0;
}
.merchant-profile-sections {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.profile-info-group {
    background: #FAF9FC;
    border: 1px solid #EAE5F2;
    border-radius: 14px;
    padding: 14px 16px;
}
.profile-group-title {
    font-size: 11.5px;
    font-weight: 750;
    color: #4C1D95;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}
.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.profile-info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.profile-item-label {
    font-size: 10.5px;
    font-weight: 650;
    color: #777187;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.profile-item-val {
    font-size: 0.92rem;
    color: #191526;
    font-weight: 600;
    word-break: break-word;
}
.profile-item-mono-val {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFFFFF;
    border: 1px solid #D8CEE8;
    border-radius: 8px;
    padding: 6px 10px;
    font-family: monospace;
    font-size: 0.88rem;
    font-weight: 750;
    color: #191526;
}
.btn-copy-mini {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s;
    line-height: 1;
}
.btn-copy-mini:hover {
    background: #F3E8FF;
}
.profile-cap-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFFFFF;
    border: 1px solid #E9D5FF;
    border-radius: 10px;
    padding: 12px 14px;
}

/* 3. Mobile Transaction Feed & Dual Rendering */
.tx-desktop-table {
    display: block;
}
.tx-mobile-feed {
    display: none;
    flex-direction: column;
    gap: 10px;
}
.tx-feed-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #FFFFFF;
    border: 1px solid #EAE5F2;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tx-feed-item:active {
    transform: scale(0.99);
}
.tx-feed-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #FFFFFF;
    border: 1px solid #EAE5F2;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tx-feed-card:active {
    transform: scale(0.995);
}
.tx-feed-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.tx-feed-icon.icon-collect {
    background: #DCFCE7;
    color: #15803D;
}
.tx-feed-icon.icon-redeem {
    background: #F3E8FF;
    color: #6D28D9;
}
.tx-feed-icon.icon-service {
    background: #EFF6FF;
    color: #2563EB;
}
.tx-feed-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tx-feed-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
}
.tx-feed-type {
    font-size: 0.88rem;
    font-weight: 750;
    color: #191526;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tx-feed-time {
    font-size: 11px;
    color: #777187;
    font-weight: 500;
    flex-shrink: 0;
}
.tx-feed-meta {
    font-size: 11.5px;
    color: #6B7280;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tx-feed-account {
    font-weight: 650;
    color: #4C1D95;
}
.tx-feed-ref {
    font-family: monospace;
    font-size: 10.5px;
}
.tx-feed-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}
.tx-feed-bottom .badge {
    font-size: 9.5px;
    padding: 2px 6px;
}
.tx-feed-gross {
    font-size: 11px;
    color: #777187;
    font-weight: 600;
    direction: ltr !important;
    unicode-bidi: isolate !important;
    display: inline-block;
}
.tx-feed-amount {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    flex-shrink: 0;
}
html[dir="rtl"] .tx-feed-amount {
    align-items: flex-start;
    text-align: left;
}
.tx-points-plus {
    font-size: 0.95rem;
    font-weight: 850;
    color: #15803D;
    direction: ltr !important;
    unicode-bidi: isolate !important;
    display: inline-block;
}
.tx-points-minus {
    font-size: 0.95rem;
    font-weight: 850;
    color: #6D28D9;
    direction: ltr !important;
    unicode-bidi: isolate !important;
    display: inline-block;
}
.tx-discount-val {
    font-size: 11px;
    font-weight: 700;
    color: #DC2626;
    direction: ltr !important;
    unicode-bidi: isolate !important;
    display: inline-block;
}

/* 4. Compact 3-Column Metrics Strip */
.merchant-metrics-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}
.merchant-metric-card {
    background: #FFFFFF;
    border: 1px solid #EAE5F2;
    border-radius: 14px;
    padding: 12px 6px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 82px;
    box-sizing: border-box;
}
.merchant-metric-label {
    font-size: 10.5px;
    font-weight: 750;
    color: #777187;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: block;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.merchant-metric-num {
    font-size: clamp(1.1rem, 3.8vw, 1.35rem);
    font-weight: 850;
    line-height: 1.15;
    margin: 4px 0 2px 0;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    white-space: nowrap;
}
.merchant-metric-sub {
    font-size: 10.5px;
    color: #8E879F;
    font-weight: 500;
    display: block;
    line-height: 1.2;
}

/* 4b. Consumer Dashboard 2-Column Metrics Strip (Pixel-Perfect Alignment) */
.consumer-metrics-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
    align-items: stretch !important;
    width: 100%;
}
.consumer-metric-card {
    background: #FFFFFF;
    border: 1px solid #EAE5F2;
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 86px;
    box-sizing: border-box;
    transform: none !important;
    align-self: stretch;
    min-width: 0;
}
/* Big metric numbers must shrink/wrap inside narrow 2-col cards (360px phones) */
.consumer-metric-card > .tnum {
    font-size: clamp(1.1rem, 5vw, 1.45rem) !important;
    overflow-wrap: anywhere;
    max-width: 100%;
}

/* 5. Responsive Behavior on Mobile Screens (< 860px) */
@media (max-width: 860px) {
    .tx-desktop-table {
        display: none !important;
    }
    .tx-mobile-feed,
    .tx-mobile-list {
        display: flex !important;
    }
    .scanner-viewport {
        height: 200px !important;
    }
    .profile-info-grid {
        grid-template-columns: 1fr !important;
    }
    .merchant-profile-card {
        padding: 16px !important;
    }
    .merchant-profile-avatar {
        width: 48px !important;
        height: 48px !important;
        font-size: 20px !important;
    }
    .merchant-profile-name {
        font-size: 1.1rem !important;
    }
    .merchant-metrics-strip {
        gap: 6px !important;
        align-items: stretch !important;
    }
    .merchant-metric-card {
        padding: 10px 4px !important;
        min-height: 78px !important;
    }
    .merchant-metric-label {
        font-size: 9.5px !important;
        letter-spacing: 0.01em !important;
    }
    .merchant-metric-num {
        font-size: 1.2rem !important;
    }
    .merchant-metric-sub {
        font-size: 10px !important;
    }
}

/* ==========================================================================
   High-Performance Rendering Optimizations (Core Web Vitals & Paint Speed)
   ========================================================================== */
#how-it-works,
#benefits,
#merchants,
#map-section,
#faq {
    content-visibility: auto;
    contain-intrinsic-size: 600px;
}

.hero-ambient,
.card-interactive,
.floating-card,
.toast {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ===== Consumer security alert (single, localized, dismissible) ===== */
.sec-alert {
    --sec-accent: #D97706; --sec-bg: #FFFBEB; --sec-border: #FDE68A; --sec-title: #92400E; --sec-text: #78350F; --sec-icon-bg: #FEF3C7;
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--sec-bg); border: 1px solid var(--sec-border);
    border-inline-start: 4px solid var(--sec-accent);
    border-radius: 14px; padding: 14px 16px;
}
.sec-alert--locked { --sec-accent: #DC2626; --sec-bg: #FEF2F2; --sec-border: #FECACA; --sec-title: #991B1B; --sec-text: #7F1D1D; --sec-icon-bg: #FEE2E2; }
.sec-alert--info { --sec-accent: #64748B; --sec-bg: #F8FAFC; --sec-border: #E2E8F0; --sec-title: #1E293B; --sec-text: #475569; --sec-icon-bg: #F1F5F9; }
.sec-alert__icon { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--sec-icon-bg); color: var(--sec-accent); }
.sec-alert__body { flex: 1; min-width: 0; }
.sec-alert__title { font-weight: 800; font-size: 14px; color: var(--sec-title); line-height: 1.35; margin-bottom: 2px; }
.sec-alert__msg { font-size: 13px; color: var(--sec-text); line-height: 1.5; margin: 0; overflow-wrap: anywhere; }
.sec-alert__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: 11.5px; color: #6B7280; }
.sec-alert__chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; background: #FFF; border: 1px solid #E5E7EB; padding: 1px 7px; border-radius: 6px; color: #374151; white-space: nowrap; }
.sec-alert__merchant { font-weight: 650; color: #4B5563; }
.sec-alert__more { font-weight: 700; color: var(--sec-accent); }
.sec-alert__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sec-alert__btn { appearance: none; border: 1px solid var(--sec-border); background: #FFF; color: var(--sec-title); font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; line-height: 1.3; min-height: 32px; display: inline-flex; align-items: center; }
.sec-alert__btn--primary { background: var(--sec-accent); border-color: var(--sec-accent); color: #FFF !important; }
.sec-alert__btn:focus-visible { outline: 2px solid var(--sec-accent); outline-offset: 2px; }

/* ===== Consumer quick-action dock: primary full width, secondaries share a row, labels wrap ===== */
.consumer-action-dock { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.consumer-action-dock > .dock-btn { min-height: 50px; height: auto !important; padding: 10px 12px; white-space: normal !important; text-align: center; line-height: 1.25; font-size: 13.5px; font-weight: 700; border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; }
.consumer-action-dock > .dock-btn svg { flex-shrink: 0; }
.consumer-action-dock > .dock-btn--primary { grid-column: 1 / -1; }
@media (max-width: 360px) {
    .consumer-action-dock { grid-template-columns: 1fr; }
}
.consumer-metric-sub { font-size: 11.5px; color: #8E879F; font-weight: 600; margin-top: 2px; }
/* Metric cards: value sits directly under the label in both cards (sub-line no longer shifts alignment) */
.consumer-metric-card { justify-content: flex-start !important; }

/* Responsive table wrapper: used across admin/merchant views; tables scroll horizontally
   on narrow screens instead of being clipped by rounded `overflow:hidden` surfaces. */
.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

/* ==========================================================================
   Mobile stacked tables (labels injected by app.js -> labelDataTables)
   Opt out per table with class "no-stack".
   ========================================================================== */
@media screen and (max-width: 640px) {
    table.is-labelled:not(.no-stack) {
        min-width: 0 !important;
        width: 100% !important;
        border: 0;
    }
    table.is-labelled:not(.no-stack) thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    table.is-labelled:not(.no-stack),
    table.is-labelled:not(.no-stack) tbody,
    table.is-labelled:not(.no-stack) tr,
    table.is-labelled:not(.no-stack) td {
        display: block;
    }
    .table-responsive:has(> table.is-labelled:not(.no-stack)),
    .table-container:has(> table.is-labelled:not(.no-stack)) {
        overflow-x: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    table.is-labelled:not(.no-stack) tbody tr {
        background: #FFFFFF;
        border: 1px solid var(--border-color, #E4E4E7);
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 4px 0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    }
    table.is-labelled:not(.no-stack) tbody tr td,
    table.is-labelled:not(.no-stack) tbody tr:nth-child(even) td,
    table.is-labelled:not(.no-stack) tbody tr:hover td {
        background: transparent !important;
    }
    table.is-labelled:not(.no-stack) td {
        display: grid !important;
        grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
        column-gap: 10px;
        align-items: start;
        width: auto !important;
        max-width: none !important;
        min-height: 40px;
        padding: 9px 14px !important;
        border-bottom: 1px solid #F1F5F9;
        direction: inherit !important;
        text-align: start !important;
        white-space: normal !important;
        overflow-wrap: break-word;
        word-break: normal;
    }
    table.is-labelled:not(.no-stack) tr td:last-child {
        border-bottom: 0;
    }
    table.is-labelled:not(.no-stack) td::before {
        content: attr(data-label);
        font-family: var(--font-sans);
        grid-column: 1;
        padding-top: 2px;
        font-size: 0.68rem;
        line-height: 1.3;
        font-weight: 750;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--text-muted, #71717A);
        text-align: start;
        overflow-wrap: break-word;
    }
    table.is-labelled:not(.no-stack) td > .cell-val {
        grid-column: 2;
        min-width: 0;
        text-align: start;
    }
    html[dir="rtl"] table.is-labelled:not(.no-stack) td::before {
        font-family: var(--font-arabic);
        letter-spacing: 0;
    }
    html[dir="rtl"] table.is-labelled:not(.no-stack) td > .cell-val {
        text-align: right;
    }
    table.is-labelled:not(.no-stack) td[data-label=""],
    table.is-labelled:not(.no-stack) td.cell-full {
        display: block !important;
        padding: 10px 14px !important;
        text-align: center !important;
    }
    table.is-labelled:not(.no-stack) td[data-label=""]::before,
    table.is-labelled:not(.no-stack) td.cell-full::before {
        display: none;
    }
    table.is-labelled:not(.no-stack) td[data-label=""] > .cell-val {
        text-align: center;
    }
    table.is-labelled:not(.no-stack) .cell-val > * {
        max-width: 100%;
    }
    table.is-labelled:not(.no-stack) .table-actions,
    table.is-labelled:not(.no-stack) .table-actions-grid {
        flex-wrap: wrap;
        justify-content: flex-start;
        width: auto;
    }
}

/* ==========================================================================
   Touch targets (WCAG 2.5.8): enlarge hit areas on touch devices only.
   ========================================================================== */
@media (pointer: coarse) {
    .appbar-lang-switcher a {
        min-height: 32px;
        min-width: 36px;
        padding: 4px 10px !important;
    }
    .footer-legal-links a {
        display: inline-block;
        padding: 6px 0;
    }
    .btn-public-login,
    .btn-public-register {
        min-height: 34px;
        display: inline-flex;
        align-items: center;
    }
    button[onclick^="togglePasswordVisibility"] {
        min-width: 36px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    /* Standalone text links (auth pages, cards): vertical padding grows the hit box without moving layout. */
    .auth-card-surface a:not(.btn) {
        padding-block: 6px;
    }
}

/* Small icon/text controls: invisible ::after expands the tap area to ~36px without shifting layout. */
@media (pointer: coarse) {
    button[onclick*="clipboard"],
    button[onclick*="copyToClipboard"],
    button[onclick*="copyTxReference"],
    a[href*="/consumer/receipt"],
    .tx-preset-pill {
        position: relative;
    }
    button[onclick*="clipboard"]::after,
    button[onclick*="copyToClipboard"]::after,
    button[onclick*="copyTxReference"]::after,
    a[href*="/consumer/receipt"]::after,
    .tx-preset-pill::after {
        content: "";
        position: absolute;
        inset: -9px -6px;
    }
}

/* 3D loyalty card: stack both faces in one grid cell so the card grows to its tallest face
   (absolute faces inside a fixed min-height clipped the bottom strip on narrow/RTL screens). */
.crs-card-flipper {
    display: grid;
}
.crs-card-flipper > .crs-card-face {
    grid-area: 1 / 1;
    position: relative;
    inset: auto;
    height: auto;
    min-height: inherit;
}

/* Mobile: bottom-nav clearance was applied twice (.app-content + .app-main-content), leaving ~200px of blank space. */
@media (max-width: 768px) {
    .app-content:has(> .app-main-content) {
        padding-bottom: 0;
    }
    .app-main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }
}
