/* =============================================================================
   CASHLEX — Design System Tokens
   All CSS custom properties. NEVER hardcode colors anywhere else.
   ============================================================================= */

/* =============================================================================
   DARK MODE (default)
   ============================================================================= */
:root,
[data-theme="dark"] {
    /* Backgrounds */
    --bg-primary:     #0D0E1A;
    --bg-card:        #13152A;
    --bg-input:       #1A1D35;
    --bg-sidebar:     #0A0B16;
    --bg-overlay:     rgba(0, 0, 0, 0.7);

    /* Text */
    --text-primary:   #E8EAFF;
    --text-secondary: #A0A8CC;
    --text-muted:     #6B7280;

    /* Borders */
    --border-subtle:  rgba(124, 58, 237, 0.2);
    --border-card:    rgba(124, 58, 237, 0.15);
    --border-input:   rgba(124, 58, 237, 0.25);

    /* Glass morphism */
    --glass-bg:       rgba(255, 255, 255, 0.03);
    --glass-hover:    rgba(255, 255, 255, 0.05);

    /* Skeleton loading */
    --skeleton-base:  #1A1D35;
    --skeleton-shine: #232645;

    /* Scrollbar */
    --scrollbar-track: #0D0E1A;
    --scrollbar-thumb: rgba(124, 58, 237, 0.3);
}

/* =============================================================================
   LIGHT MODE
   ============================================================================= */
html[data-theme="light"],
:root[data-theme="light"] {
    --bg-primary:     #F0F2FF;
    --bg-card:        #FFFFFF;
    --bg-input:       #F8F9FF;
    --bg-sidebar:     #FAFAFF;
    --bg-overlay:     rgba(0, 0, 0, 0.5);

    --surface-solid:  #FFFFFF;
    --overlay-scrim:  rgba(17, 20, 40, 0.45);
    --loader-color:   #7C3AED;
    --loader-track:   rgba(17, 20, 40, 0.12);

    --text-primary:   #0D0E1A;
    --text-secondary: #374151;
    --text-muted:     #6B7280;

    --border-subtle:  rgba(124, 58, 237, 0.15);
    --border-card:    rgba(124, 58, 237, 0.1);
    --border-input:   rgba(124, 58, 237, 0.2);

    --glass-bg:       rgba(255, 255, 255, 0.8);
    --glass-hover:    rgba(255, 255, 255, 0.95);

    --skeleton-base:  #E8EAFF;
    --skeleton-shine: #D4D8FF;

    --scrollbar-track: #F0F2FF;
    --scrollbar-thumb: rgba(124, 58, 237, 0.2);
}

/* =============================================================================
   SHARED TOKENS (theme-independent)
   ============================================================================= */
:root {
    /* Brand */
    --accent-primary:    #7C3AED;
    --accent-secondary:  #06B6D4;
    --gradient-main:     linear-gradient(135deg, #7C3AED 0%, #06B6D4 100%);
    --gradient-hover:    linear-gradient(135deg, #6D28D9 0%, #0891B2 100%);
    --gradient-subtle:   linear-gradient(135deg, rgba(124,58,237,0.1) 0%, rgba(6,182,212,0.1) 100%);

    /* Semantic */
    --success:      #10B981;
    --success-bg:   rgba(16, 185, 129, 0.1);
    --warning:      #F59E0B;
    --warning-bg:   rgba(245, 158, 11, 0.1);
    --danger:       #EF4444;
    --danger-bg:    rgba(239, 68, 68, 0.1);
    --info:         #3B82F6;
    --info-bg:      rgba(59, 130, 246, 0.1);

    /* Solid, guaranteed-opaque surface for modals / toasts / popovers.
       (Card skins make --bg-card translucent glass, which is wrong for
       overlays — they must never show the page through them.) */
    --surface-solid: #181A30;
    --overlay-scrim:  rgba(3, 4, 12, 0.72);
    /* Loader / spinner — a bright, high-visibility colour on any background */
    --loader-color:  #22D3EE;
    --loader-track:  rgba(255, 255, 255, 0.16);

    /* Radius */
    --radius-sm:     6px;
    --radius-card:   12px;
    --radius-input:  8px;
    --radius-btn:    8px;
    --radius-lg:     16px;
    --radius-xl:     20px;
    --radius-full:   9999px;

    /* Spacing (8px base grid) */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-8:  32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Sidebar */
    --sidebar-width:          260px;
    --sidebar-width-collapsed: 0px;
    --topbar-height:          60px;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

    /* Transitions */
    --transition:       200ms ease;
    --transition-slow:  400ms ease;
    --transition-fast:  100ms ease;

    /* Shadows */
    --shadow-sm:   0 1px 3px rgba(0,0,0,0.3);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 24px rgba(124,58,237,0.2);

    /* Z-index stack */
    --z-base:    1;
    --z-card:    10;
    --z-sticky:  100;
    /* Stacking: overlay dims the PAGE; the sidebar rides ABOVE the overlay.
       (overlay < sidebar is essential — reversed, taps on the menu hit the
       overlay's close handler and the menu appears broken) */
    --z-overlay: 300;
    --z-sidebar: 400;
    --z-modal:   400;
    --z-toast:   500;
}

/* =============================================================================
   RESET + BASE
   ============================================================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition), color var(--transition);
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

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

img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: var(--font-sans); }
input, textarea, select { font-family: var(--font-sans); }

/* Numeric displays */
.num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* =============================================================================
   TYPOGRAPHY SCALE
   ============================================================================= */
.text-display { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -0.02em; }
.text-h1      { font-size: clamp(1.5rem,  3vw, 2rem);   font-weight: 700; letter-spacing: -0.02em; }
.text-h2      { font-size: clamp(1.25rem, 2.5vw, 1.5rem); font-weight: 700; }
.text-h3      { font-size: 1.125rem; font-weight: 600; }
.text-body    { font-size: 0.9375rem; }
.text-sm      { font-size: 0.8125rem; }
.text-xs      { font-size: 0.75rem; }

/* =============================================================================
   GLASS CARD PATTERN
   ============================================================================= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-card);
    position: relative;
}
/* The gradient top-accent uses a clipped ::before; we inset it slightly and
   round its corners instead of relying on overflow:hidden on the card, which
   (with backdrop-filter) truncated tall cards on mobile browsers. */

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10px;
    right: 10px;
    height: 2px;
    background: var(--gradient-main);
    opacity: 0.8;
    border-radius: 0 0 2px 2px;
}

.card-body { padding: var(--space-5); }
.card-sm   { padding: var(--space-4); }

.card-hover {
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
    border-color: rgba(124, 58, 237, 0.4);
}

/* =============================================================================
   BUTTON PATTERNS
   ============================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-btn);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary */
.btn-primary {
    background: var(--gradient-main);
    color: #ffffff;
    border-color: transparent;
}
.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
    color: #ffffff;
}
.btn-primary:active { transform: translateY(0); }

/* Secondary */
.btn-secondary {
    background: transparent;
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}
.btn-secondary:hover {
    background: rgba(124, 58, 237, 0.08);
    transform: translateY(-1px);
    color: var(--accent-primary);
}

/* Danger */
.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-subtle);
}
.btn-ghost:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
    border-color: var(--border-input);
}

/* Sizes */
.btn-sm  { padding: 0.4rem 0.875rem; font-size: 0.8125rem; }
.btn-lg  { padding: 0.875rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; }

/* Loading state */
.btn-loading { position: relative; color: transparent !important; }
.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 18px; height: 18px;
    margin: -9px 0 0 -9px;
    border: 2.5px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
/* Ghost / secondary buttons sit on a light-ish surface — use the bright loader colour */
.btn-ghost.btn-loading::after,
.btn-secondary.btn-loading::after,
.btn-outline.btn-loading::after {
    border-color: var(--loader-track);
    border-top-color: var(--loader-color);
}

/* =============================================================================
   INPUT PATTERN
   ============================================================================= */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }

.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-input);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    width: 100%;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.form-input.error { border-color: var(--danger); }
.form-input.error:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }

.form-error {
    font-size: 0.8125rem;
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Input with icon */
.input-wrap { position: relative; }
.input-wrap .form-input { padding-left: 2.75rem; }
.input-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* =============================================================================
   BADGES + STATUS
   ============================================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-accent  { background: rgba(124,58,237,0.12); color: var(--accent-primary); }

/* =============================================================================
   SKELETON LOADERS
   ============================================================================= */
.skeleton {
    background: var(--skeleton-base);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--skeleton-shine) 50%,
        transparent 100%);
    animation: shimmer 1.4s infinite;
}

.skeleton-text  { height: 14px; border-radius: 4px; }
.skeleton-title { height: 22px; border-radius: 4px; }
.skeleton-card  { height: 120px; border-radius: var(--radius-card); }

/* =============================================================================
   TABLE
   ============================================================================= */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.75rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
}

.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: var(--glass-hover);
}

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

/* =============================================================================
   MODAL
   ============================================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-scrim, var(--bg-overlay));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    /* Opaque surface so the page never shows through an open dialog */
    background: var(--surface-solid, var(--bg-card));
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(20px);
    transition: transform var(--transition);
}
@media (max-width: 480px) {
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-5) 0;
}

.modal-title { font-size: 1.125rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-body { padding: var(--space-5); }
.modal-footer {
    padding: 0 var(--space-5) var(--space-5);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 360px;
    width: calc(100vw - 2rem);
}
@media (max-width: 560px) {
    .toast-container {
        top: calc(env(safe-area-inset-top, 0px) + 12px);
        bottom: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: calc(100vw - 24px);
        max-width: 460px;
    }
    .toast { animation: toastPopDown 220ms ease forwards; }
}
@keyframes toastPopDown {
    from { opacity: 0; transform: translateY(-14px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    /* Opaque surface — never translucent glass, so notifications are always legible */
    background: var(--surface-solid);
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid var(--border-card);
    border-left-width: 4px;
    border-radius: var(--radius-card);
    box-shadow: 0 16px 44px -14px rgba(0,0,0,0.55);
    animation: slideInRight 200ms ease forwards;
    position: relative;
    overflow: hidden;
}
/* Coloured left edge per type (in addition to the ::before accent bar) */
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info    { border-left-color: var(--info); }

.toast::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
}

.toast-success::before { background: var(--success); }
.toast-error::before   { background: var(--danger); }
.toast-warning::before { background: var(--warning); }
.toast-info::before    { background: var(--info); }

.toast-icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--info); }

.toast-msg { font-size: 0.875rem; color: var(--text-primary); line-height: 1.5; }
.toast-dismiss {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    width: 20px; height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.toast-dismiss:hover { color: var(--text-primary); }

/* =============================================================================
   EMPTY STATE
   ============================================================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-16) var(--space-4);
    text-align: center;
}

.empty-icon {
    color: var(--text-muted);
    opacity: 0.4;
    width: 56px;
    height: 56px;
}

.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-desc  { font-size: 0.875rem; color: var(--text-muted); max-width: 280px; }

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-5  { gap: var(--space-5); }
.gap-6  { gap: var(--space-6); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent-primary); }

.mt-auto { margin-top: auto; }
.w-full  { width: 100%; }
.hidden  { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Gradient text */
.gradient-text {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0%   { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

.animate-fade-in { animation: fadeIn 300ms ease forwards; }
.animate-pop-in  { animation: popIn 200ms ease forwards; }

/* =============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================= */
@media (max-width: 640px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .hide-mobile { display: none !important; }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .hide-tablet { display: none !important; }
}

@media (min-width: 1025px) {
    .hide-desktop { display: none !important; }
}

/* =============================================================================
   SHARED CONTROLS — used by BOTH user and admin shells.
   (Previously only in layout.css, which admin pages don't load — this left
    the admin theme toggle and hamburger unstyled/misaligned.)
   ============================================================================= */
.topbar-hamburger {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}
.topbar-hamburger:hover { background: var(--glass-hover); }
@media (min-width: 1025px) { .topbar-hamburger { display: none; } }

.theme-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    width: 44px;
    height: 24px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    padding: 0;
    display: inline-block;
    vertical-align: middle;
}
.theme-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    transition: transform var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
[data-theme="light"] .theme-toggle-thumb {
    transform: translateX(20px);
    background: var(--warning);
}
.theme-toggle-icon { width: 10px; height: 10px; color: white; display: block; }

/* =============================================================================
   BUTTON PROCESSING STATE (all pages, both UI versions, admin)
   app.js adds .is-busy on click while the action runs: the button switches to
   the secondary colour, shows a spinner + "Processing…", and ignores clicks.
   ========================================================================== */
:root { --busy-bg: var(--accent-secondary, #06B6D4); --busy-fg: #fff; }
html[data-ui="profiz1"] { --busy-bg: rgb(var(--pz-accent-rgb, 124, 124, 240)); }
@keyframes hwBusySpin { to { transform: rotate(360deg); } }
/* High specificity so theme / page / inline button colours can't hide the state */
:root body .is-busy.is-busy.is-busy, :root body .btn-loading.btn-loading.btn-loading { pointer-events: none !important; cursor: progress !important; transition: background-color .15s, border-color .15s; }
:root body .is-busy.is-busy.is-busy {
  position: relative !important; color: transparent !important; text-shadow: none !important;
  background: var(--busy-bg) !important; border-color: var(--busy-bg) !important; box-shadow: none !important; opacity: 1 !important;
}
:root body .btn-loading.btn-loading.btn-loading { background: var(--busy-bg) !important; border-color: var(--busy-bg) !important; box-shadow: none !important; opacity: 1 !important; }
:root body .is-busy.is-busy.is-busy > *, :root body .is-busy.is-busy.is-busy svg, :root body .is-busy.is-busy.is-busy i { visibility: hidden !important; }
:root body .is-busy.is-busy.is-busy::after {
  content: attr(data-busy-label) !important; position: absolute !important; top: 50% !important; left: 50% !important; right: auto !important; bottom: auto !important;
  transform: translate(calc(-50% + var(--busy-tx, 0px)), -50%) !important; display: inline-flex !important; align-items: center;
  width: auto !important; height: auto !important; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
  background: none !important; box-shadow: none !important; opacity: 1 !important; animation: none !important; visibility: visible !important;
  color: var(--busy-fg) !important; font-size: inherit; font-weight: 600; line-height: 1; letter-spacing: 0; white-space: nowrap; pointer-events: none; z-index: 2;
}
:root body .is-busy.is-busy.is-busy::before {
  content: "" !important; position: absolute !important; top: 50% !important; left: var(--busy-spin-x, 50%) !important; right: auto !important; bottom: auto !important;
  width: 1.05em !important; height: 1.05em !important; margin: -.525em 0 0 -.525em !important; padding: 0 !important; inset: 50% auto auto var(--busy-spin-x, 50%) !important;
  border: 2px solid rgba(255,255,255,.35) !important; border-top-color: var(--busy-fg) !important; border-radius: 50% !important; background: none !important;
  box-shadow: none !important; opacity: 1 !important; visibility: visible !important; display: block !important; z-index: 3; pointer-events: none;
  animation: hwBusySpin .65s linear infinite !important; filter: none !important;
}
:root body .is-busy.is-busy.is-busy[data-busy-label=""]::after { display: none !important; }

/* =============================================================================
   "New team members today" banner — both UI versions (dashboard)
   ========================================================================== */
.tm-new { position: relative; display: flex; align-items: center; gap: .625rem; margin: 0 0 .75rem; padding: .625rem 2rem .625rem .625rem; border-radius: 14px;
  border: 1px solid rgba(59,130,246,.3); color: var(--ui-text, var(--text-primary, #111827));
  background: linear-gradient(120deg, rgba(59,130,246,.09), var(--ui-sheet-bg, var(--surface-solid, var(--bg-card, #fff))) 70%);
  box-shadow: 0 1px 2px rgba(15,23,42,.05); }
html[data-theme="dark"] .tm-new { background: linear-gradient(120deg, rgba(37,46,99,.6), rgba(15,17,30,.92) 70%); border-color: rgba(79,139,255,.3); }
.tm-new__ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2.375rem; height: 2.375rem; border-radius: .75rem;
  background: rgba(59,130,246,.14); color: #3B82F6; }
html[data-theme="dark"] .tm-new__ic { background: rgba(59,130,246,.18); color: #6EA0FF; }
.tm-new__txt { flex: 1; min-width: 0; }
.tm-new__txt .t { margin: 0; font-size: .8125rem; font-weight: 700; line-height: 1.25; color: #2563EB; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-theme="dark"] .tm-new__txt .t { color: #6EA0FF; }
.tm-new.is-zero .tm-new__txt .t { color: var(--ui-heading, var(--text-primary, #111827)); }
.tm-new__txt .s { margin: .125rem 0 0; font-size: .6875rem; line-height: 1.3; color: var(--ui-muted, var(--text-muted, #6B7280)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-new__btn { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 2rem; padding: 0 .875rem; border-radius: .625rem; border: 0; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: .75rem !important; line-height: 1; color: #fff !important; text-decoration: none !important;
  background: linear-gradient(135deg, #3B82F6, #6366F1); box-shadow: 0 6px 14px -8px rgba(59,130,246,.8); }
.tm-new__btn:hover { filter: brightness(1.08); }
.tm-new__x { position: absolute; top: .3125rem; right: .3125rem; display: inline-flex; align-items: center; justify-content: center; width: 1.375rem; height: 1.375rem; padding: 0;
  border: 0; border-radius: 999px; background: transparent; color: var(--ui-muted, var(--text-muted, #6B7280)); cursor: pointer; }
.tm-new__x:hover { background: rgba(127,127,127,.14); }
html[data-ui="profiz1"] .tm-new { margin: 0; border-radius: var(--ui-radius-card, 14px); }
@media (min-width: 64rem) { .tm-new { padding: .75rem 2.25rem .75rem .75rem; } .tm-new__txt .t { font-size: .9375rem; } .tm-new__txt .s { font-size: .75rem; } }

/* =============================================================================
   SLIM TOP NOTIFICATIONS (N2.3.6) — payment status + toasts, every page.
   A wide, short bar that drops in from the top (16:9-style strip), never a
   full-screen blackout. Same look in both UI versions and both themes.
   ========================================================================== */
:root { --sn-bg: rgba(16,16,30,.95); --sn-line: rgba(255,255,255,.09); --sn-fg: #fff; --sn-sub: rgba(255,255,255,.72);
        --sn-accent: var(--brand, #F706A1); --sn-ok: #22C55E; --sn-err: #EF4444; --sn-warn: #F59E0B; --sn-info: #6366F1;
        --sn-top: calc(env(safe-area-inset-top, 0px) + 8px); --sn-w: min(calc(100vw - 16px), 26rem); }
@keyframes snIn  { from { opacity: 0; transform: translateY(-120%); } to { opacity: 1; transform: translateY(0); } }
@keyframes snBar { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ---- payment status bar ---- */
:root body #payWaitOverlay {
  position: fixed !important; inset: var(--sn-top) auto auto 50% !important; width: var(--sn-w) !important; height: auto !important;
  display: block !important; padding: 0 !important; background: none !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  z-index: 10001 !important; opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%, -140%); transition: transform .34s cubic-bezier(.2,.9,.3,1.15), opacity .2s ease, visibility .34s;
}
:root body #payWaitOverlay.show { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); }
:root body #payWaitOverlay .paywait-card {
  position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0,1fr) auto; grid-template-rows: auto auto;
  column-gap: .625rem; row-gap: 1px; align-items: center; width: 100%; max-width: none; min-height: 2.75rem; margin: 0;
  padding: .4375rem .5rem .4375rem .5rem; border-radius: .875rem; text-align: left;
  background: var(--sn-bg) !important; border: 1px solid var(--sn-line) !important; color: var(--sn-fg);
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.55); -webkit-backdrop-filter: blur(10px) !important; backdrop-filter: blur(10px) !important;
}
:root body #payWaitOverlay .paywait-visual { grid-row: 1 / 3; grid-column: 1; width: 1.875rem; height: 1.875rem; margin: 0; display: flex; align-items: center; justify-content: center;
  border-radius: .625rem; background: rgba(255,255,255,.08); }
:root body #payWaitOverlay .paywait-spinner { width: 1.125rem; height: 1.125rem; border-width: 2.5px; border-color: rgba(255,255,255,.18); border-top-color: var(--sn-accent); }
:root body #payWaitOverlay .paywait-mark { width: 1.375rem; height: 1.375rem; }
:root body #payWaitOverlay .paywait-title { grid-column: 2; grid-row: 1; margin: 0; font-size: .8125rem; font-weight: 700; line-height: 1.2; color: var(--sn-fg) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root body #payWaitOverlay .paywait-sub { grid-column: 2; grid-row: 2; margin: 0; font-size: .6875rem; line-height: 1.3; color: var(--sn-sub) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root body #payWaitOverlay .paywait-timer { grid-column: 3; grid-row: 1 / 3; margin: 0; min-height: 0; padding: .25rem .5rem; border-radius: 999px; background: rgba(255,255,255,.08);
  font-size: .6875rem; font-weight: 600; color: var(--sn-sub) !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
:root body #payWaitOverlay .paywait-timer:empty { display: none; }
:root body #payWaitOverlay .paywait-btn { grid-column: 3; grid-row: 1 / 3; width: auto; min-height: 1.875rem; margin: 0; padding: 0 .875rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; border: 0; background: rgba(255,255,255,.12); color: #fff; }
:root body #payWaitOverlay.state-waiting .paywait-card::after { content: ""; position: absolute; left: 0; bottom: 0; width: 40%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--sn-accent), transparent); animation: snBar 1.3s ease-in-out infinite; }
:root body #payWaitOverlay.state-success .paywait-card { border-color: rgba(34,197,94,.45) !important; }
:root body #payWaitOverlay.state-success .paywait-visual { background: rgba(34,197,94,.16); }
:root body #payWaitOverlay.state-success .paywait-title { color: #4ADE80 !important; }
:root body #payWaitOverlay.state-error .paywait-card { border-color: rgba(239,68,68,.5) !important; }
:root body #payWaitOverlay.state-error .paywait-visual { background: rgba(239,68,68,.16); }
:root body #payWaitOverlay.state-error .paywait-title { color: #F87171 !important; }
:root body #payWaitOverlay.state-error .paywait-btn { background: var(--sn-err); }
:root body #payWaitOverlay .paywait-circle, :root body #payWaitOverlay .paywait-check, :root body #payWaitOverlay .paywait-cross { stroke-width: 4; }

/* ---- toasts ---- */
:root body .toast-container {
  position: fixed !important; top: var(--sn-top) !important; bottom: auto !important; left: 50% !important; right: auto !important;
  transform: translateX(-50%) !important; width: var(--sn-w) !important; max-width: none !important;
  display: flex; flex-direction: column; gap: .375rem; z-index: 10002 !important; pointer-events: none;
}
:root body .toast-container .toast {
  pointer-events: auto; display: flex !important; align-items: center !important; gap: .5rem !important; min-height: 2.5rem;
  padding: .375rem .375rem .375rem .5rem !important; margin: 0 !important; border-radius: .875rem !important;
  background: var(--sn-bg) !important; border: 1px solid var(--sn-line) !important; border-left-width: 1px !important;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.55) !important; -webkit-backdrop-filter: blur(10px) !important; backdrop-filter: blur(10px) !important;
  animation: snIn .3s cubic-bezier(.2,.9,.3,1.15) both; overflow: hidden; position: relative;
}
:root body .toast-container .toast::before { content: "" !important; display: block !important; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sn-t, var(--sn-info)) !important; }
:root body .toast-container .toast-success { --sn-t: var(--sn-ok); }
:root body .toast-container .toast-error   { --sn-t: var(--sn-err); }
:root body .toast-container .toast-warning { --sn-t: var(--sn-warn); }
:root body .toast-container .toast-info    { --sn-t: var(--sn-info); }
:root body .toast-container .toast-icon { width: 1.75rem !important; height: 1.75rem !important; padding: .3125rem; margin: 0 !important; border-radius: .5rem;
  color: var(--sn-t, var(--sn-info)) !important; background: color-mix(in srgb, var(--sn-t, #6366F1) 18%, transparent); flex-shrink: 0; }
:root body .toast-container .toast-msg { flex: 1; min-width: 0; color: var(--sn-fg) !important; font-size: .75rem !important; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
:root body .toast-container .toast-dismiss { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; flex-shrink: 0; padding: 0;
  border: 0; border-radius: 999px; background: transparent; color: rgba(255,255,255,.6) !important; cursor: pointer; }
:root body .toast-container .toast-dismiss:hover { background: rgba(255,255,255,.1); color: #fff !important; }
@media (prefers-reduced-motion: reduce) {
  :root body #payWaitOverlay, :root body .toast-container .toast { transition: none; animation: none; }
}
:root body #payWaitOverlay.state-error .paywait-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* activate page: the top bar replaces the big in-page "check your phone" box */
.act-page #paymentStatus.stk-status { display: none !important; }
:root body #payWaitOverlay .paywait-spinner { display: block; box-sizing: border-box; border-style: solid; border-radius: 50%; animation: hwBusySpin .8s linear infinite; }
:root body #payWaitOverlay .paywait-mark { display: block; }
:root body #payWaitOverlay .paywait-circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: snDraw .5s ease forwards; }
:root body #payWaitOverlay .paywait-check, :root body #payWaitOverlay .paywait-cross { stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: snDraw .4s ease .3s forwards; }
:root body #payWaitOverlay.state-success .paywait-circle, :root body #payWaitOverlay.state-success .paywait-check { stroke: var(--sn-ok); }
:root body #payWaitOverlay.state-error .paywait-circle, :root body #payWaitOverlay.state-error .paywait-cross { stroke: var(--sn-err); }
@keyframes snDraw { to { stroke-dashoffset: 0; } }
/* toasts stack under the payment bar while it is showing */
:root body:has(#payWaitOverlay.show) .toast-container { top: calc(var(--sn-top) + 3.375rem) !important; }

/* =============================================================================
   INSTALL APP BAR (PWA) — all versions
   ========================================================================== */
.hw-pwa { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); z-index: 9990; width: min(calc(100vw - 20px), 26rem);
  display: flex; align-items: center; gap: .75rem; padding: .625rem .625rem .625rem .75rem; border-radius: 1rem;
  background: var(--ui-sheet-bg, var(--surface-solid, #fff)); color: var(--ui-heading, var(--text-primary, #111827));
  border: 1px solid color-mix(in srgb, var(--brand, var(--accent-primary, #F706A1)) 22%, transparent);
  box-shadow: 0 18px 40px -16px rgba(20,19,43,.35); opacity: 0; transform: translate(-50%, 24px); transition: opacity .25s, transform .3s cubic-bezier(.2,.9,.3,1.1); }
.hw-pwa.show { opacity: 1; transform: translate(-50%, 0); }
html[data-ui="profiz1"] .hw-pwa { bottom: calc(env(safe-area-inset-bottom, 0px) + 5.25rem); }
@media (min-width: 64rem) { html[data-ui="profiz1"] .hw-pwa { bottom: 1.25rem; } }
.hw-pwa__ic { width: 2.75rem; height: 2.75rem; border-radius: .75rem; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.hw-pwa__t { flex: 1; min-width: 0; line-height: 1.3; }
.hw-pwa__t b { display: block; font-size: .875rem; font-weight: 700; }
.hw-pwa__t span { display: block; margin-top: .125rem; font-size: .75rem; color: var(--ui-muted, var(--text-muted, #6B7280)); }
.hw-pwa__t span b { display: inline; font-size: inherit; color: var(--ui-heading, var(--text-primary, #111827)); }
.hw-pwa__go { flex-shrink: 0; min-height: 2.125rem; padding: 0 .875rem; border: 0; border-radius: .625rem; cursor: pointer; font: inherit; font-size: .8125rem; font-weight: 700;
  color: #fff; background: var(--brand, var(--accent-primary, #F706A1)); }
.hw-pwa__x { flex-shrink: 0; width: 1.75rem; height: 1.75rem; border: 0; border-radius: .5rem; background: transparent; cursor: pointer; font-size: 1.25rem; line-height: 1;
  color: var(--ui-muted, var(--text-muted, #6B7280)); }
.hw-pwa__x:hover { background: rgba(127,127,127,.12); }
