/* ==========================================================================
   LoyalBite — Admin Design System
   --------------------------------------------------------------------------
   Sections:  TOKENS · RESET · LAYOUT · COMPONENTS · UTILITIES · RESPONSIVE
   Class names are shared by all 41 views. Restyle them here; do not rename.
   ========================================================================== */


/* ==========================================================================
   TOKENS
   ========================================================================== */

:root {
    /* ---- Brand ---------------------------------------------------------- */
    --coral:             #E8553D;  /* Ember Coral  - primary action */
    --coral-dark:        #C8412C;  /* 4.94:1 on white - the only coral safe for text/fills */
    --coral-deep:        #A93521;
    --coral-soft:        #FDEFEB;
    --ink:               #14213D;  /* Midnight Ink - text + dark UI */
    --ink-soft:          #23345C;
    --gold:              #F4B63F;  /* Reward Gold  - points + stars only */
    --gold-dark:         #D89A22;
    --gold-soft:         #FEF6E3;
    --cream:             #FBF6EE;  /* Cream        - page background */
    --cream-deep:        #F3EADC;

    /* ---- Surfaces & text ------------------------------------------------ */
    --bg:                var(--cream);
    --card:              #FFFFFF;
    --surface-alt:       #FDFAF4;
    --border:            #EADFCF;
    --border-strong:     #DCCDB8;
    --text:              var(--ink);
    --muted:             #5A6A8A;  /* 5.44:1 - #6B7A99 was 4.31, under AA */
    --muted-light:       #93A1BD;

    /* ---- Semantic (harmonised with cream, not cool grey) ---------------- */
    --success:           #0A7D52;  /* 5.16:1 */
    --success-bg:        #E9F8F1;
    --success-border:    #B6E6D2;
    --warning:           #8F5E00;  /* 5.18:1 on gold tint */
    --warning-bg:        var(--gold-soft);
    --warning-border:    #F6DFA6;
    --danger:            #B42318;
    --danger-bg:         #FDEDEB;
    --danger-border:     #F6C9C2;
    --info:              #2B5C9B;
    --info-bg:           #ECF2FA;
    --info-border:       #C3D6EE;

    /* ---- Spacing (4px base) --------------------------------------------- */
    --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;  --sp-5: 20px;
    --sp-6: 24px;  --sp-7: 32px;  --sp-8: 40px;  --sp-9: 56px;  --sp-10: 72px;

    /* ---- Radius ---------------------------------------------------------- */
    --r-sm:   8px;
    --r-md:  12px;
    --r-lg:  16px;
    --r-xl:  20px;
    --r-pill: 999px;

    /* ---- Shadows (warm-tinted, layered) --------------------------------- */
    --sh-xs: 0 1px 2px rgba(20,33,61,0.04);
    --sh-sm: 0 1px 2px rgba(20,33,61,0.04), 0 2px 6px rgba(20,33,61,0.04);
    --sh-md: 0 2px 4px rgba(20,33,61,0.04), 0 8px 20px rgba(20,33,61,0.06);
    --sh-lg: 0 4px 8px rgba(20,33,61,0.05), 0 18px 44px rgba(20,33,61,0.10);
    --sh-focus: 0 0 0 3px rgba(232,85,61,0.15);

    /* ---- Type ------------------------------------------------------------ */
    --font:      'Inter', system-ui, -apple-system, sans-serif;
    --font-ar:   'Noto Sans Arabic', 'Inter', system-ui, sans-serif;
    --fs-xs:  11px; --fs-sm:  12px; --fs-base: 13px; --fs-md: 14px;
    --fs-lg:  16px; --fs-xl:  20px; --fs-2xl:  26px; --fs-3xl: 34px;
    --lh-tight: 1.15; --lh-normal: 1.5; --lh-relaxed: 1.65;

    /* ---- Motion ---------------------------------------------------------- */
    --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 180ms cubic-bezier(0.4, 0, 0.2, 1);

    /* ---- Z-index --------------------------------------------------------- */
    --z-sticky:   100;
    --z-dropdown: 200;
    --z-overlay:  900;
    --z-modal:   1000;

    /* ---- Shell dimensions ------------------------------------------------ */
    --sidebar-w:  256px;
    --topnav-h:    64px;

    /* ---- Sidebar --------------------------------------------------------- */
    --sidebar-bg:        var(--ink);
    --sidebar-border:    rgba(255,255,255,0.08);
    --sidebar-text:      #9CAAC6;
    --sidebar-hover-bg:  rgba(255,255,255,0.07);
    --sidebar-active-bg: rgba(232,85,61,0.18);
    --sidebar-active-c:  #FF8C74;

    /* ---- Legacy aliases (kept: referenced across views) ------------------ */
    --accent:      var(--coral);
    --accent-dark: var(--coral-dark);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ==========================================================================
   RESET
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    font-family: var(--font);
    font-size: var(--fs-md);
    line-height: var(--lh-normal);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Arabic content — the font is loaded on every page; actually use it. */
[dir="rtl"], :lang(ar), .field-group [dir="rtl"] { font-family: var(--font-ar); }

:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }


/* ==========================================================================
   LAYOUT
   ========================================================================== */

.admin-wrapper { display: flex; min-height: 100vh; flex-direction: column; }
.admin-body    { display: flex; flex: 1; }

.main-content {
    flex: 1;
    padding: var(--sp-7) var(--sp-7);
    background: var(--bg);
    min-width: 0;
}

.content-inner {
    max-width: 1320px;
    margin: 0 auto;
}

.divider { height: 1px; background: var(--border); margin: var(--sp-6) 0; }


/* ---- Topnav: flat on the cream canvas, not a stacked white bar ---------- */
.topnav {
    height: var(--topnav-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-6) 0 0;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    flex-shrink: 0;
}

.topnav-left  { display: flex; align-items: center; gap: var(--sp-3); }
.topnav-right { display: flex; align-items: center; gap: var(--sp-3); }

.topnav-logo {
    max-width: 148px;
    height: auto;
    display: block;
    padding: var(--sp-2) 0 var(--sp-2) var(--sp-6);
}

.topnav-title {
    color: var(--text);
    font-size: var(--fs-lg);
    font-weight: 600;
    padding-left: var(--sp-5);
    letter-spacing: -0.2px;
}

.topnav-username { color: var(--text); font-size: var(--fs-base); font-weight: 500; }

.role-badge {
    background: var(--coral-soft);
    color: var(--coral-dark);
    border: 1px solid rgba(232,85,61,0.22);
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 3px 10px;
    letter-spacing: 0.2px;
}


/* ---- Sidebar ------------------------------------------------------------ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--topnav-h));
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: var(--sp-4) 0 var(--sp-2);
    list-style: none;
    margin: 0;
    overflow-y: auto;
}

.sidebar-section-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255,255,255,0.28);
    padding: var(--sp-5) var(--sp-5) var(--sp-2);
    letter-spacing: 1.2px;
}
.sidebar-nav > li:first-child .sidebar-section-label { padding-top: var(--sp-2); }

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px var(--sp-3);
    margin: 2px var(--sp-3);
    border-radius: var(--r-md);
    color: var(--sidebar-text);
    font-size: var(--fs-md);
    font-weight: 500;
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
    position: relative;
}

.sidebar-nav-item:hover { background: var(--sidebar-hover-bg); color: #EAF0F8; }

.sidebar-nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-c);
    font-weight: 600;
}

.sidebar-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.75; }
.sidebar-nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: var(--sp-3);
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
    color: #EAF0F8;
    font-size: var(--fs-base);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role { color: var(--sidebar-text); font-size: var(--fs-xs); margin-top: 1px; }

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--r-md);
    background: transparent;
    border: 1px solid rgba(232,85,61,0.32);
    color: #FF8C74;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
    flex-shrink: 0;
    padding: 0;
}
.sidebar-logout-btn:hover { background: rgba(232,85,61,0.16); border-color: rgba(232,85,61,0.5); }


/* ---- Page header -------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.page-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--text);
    margin: 0 0 var(--sp-1);
    letter-spacing: -0.5px;
    line-height: var(--lh-tight);
}

.page-subtitle { font-size: var(--fs-base); color: var(--muted); margin: 0; }

.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-base);
    color: var(--muted);
    margin-bottom: var(--sp-2);
}
.breadcrumb a { color: var(--muted); text-decoration: none; transition: color var(--t-fast); }
.breadcrumb a:hover { color: var(--coral-dark); }
.breadcrumb svg { width: 14px; height: 14px; opacity: 0.6; }


/* ==========================================================================
   COMPONENTS
   ========================================================================== */

/* ---- Icon (sprite) ------------------------------------------------------ */
/* <svg class="icon"><use href="/icons.svg#i-users"></use></svg> */
.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    color: inherit;
}
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 22px; height: 22px; }
.icon--xl { width: 28px; height: 28px; }


/* ---- Card --------------------------------------------------------------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-6) var(--sp-7);
    box-shadow: var(--sh-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.card-body { padding: var(--sp-6); }

/* Icon chip used in card headers and stat cards */
.icon-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
    background: var(--coral-soft);
    color: var(--coral-dark);
    flex-shrink: 0;
}
.icon-chip svg { width: 19px; height: 19px; }
.icon-chip--gold    { background: var(--gold-soft);    color: var(--gold-dark); }
.icon-chip--success { background: var(--success-bg);   color: var(--success); }
.icon-chip--info    { background: var(--info-bg);      color: var(--info); }
.icon-chip--ink     { background: rgba(20,33,61,0.06); color: var(--ink); }


/* ---- Stat cards --------------------------------------------------------- */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-5) var(--sp-6);
    box-shadow: var(--sh-sm);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
    transition: box-shadow var(--t-base), transform var(--t-base);
}
.stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }

.stat-label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 var(--sp-2);
}

.stat-value {
    font-size: var(--fs-3xl);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -1px;
    line-height: var(--lh-tight);
    margin: 0;
}

.stat-delta {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--fs-sm);
    font-weight: 600;
    margin-top: var(--sp-2);
    color: var(--muted);
}
.stat-delta--up   { color: var(--success); }
.stat-delta--down { color: var(--danger); }

/* Dark hero variant — one per dashboard, keeps a moment of brand drama */
.stat-card-dark {
    background: linear-gradient(135deg, var(--ink) 0%, var(--ink-soft) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-xl);
    padding: var(--sp-5) var(--sp-6);
    color: #FFFFFF;
    position: relative;
    overflow: hidden;
    box-shadow: var(--sh-md);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
}

.stat-card-dark::after {
    content: '';
    position: absolute;
    right: -40px;
    top: -40px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232,85,61,0.18) 0%, transparent 70%);
    pointer-events: none;
}

.stat-card-dark .stat-label { color: rgba(255,255,255,0.55); }
.stat-card-dark .stat-value { color: var(--gold); }
.stat-card-dark .icon-chip  { background: rgba(255,255,255,0.10); color: var(--gold); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}


/* ---- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    border: 1.5px solid transparent;
    border-radius: var(--r-pill);
    padding: 10px 20px;
    font-size: var(--fs-base);
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--t-fast), border-color var(--t-fast),
                box-shadow var(--t-fast), color var(--t-fast), transform var(--t-fast);
    line-height: 1;
    white-space: nowrap;
    position: relative;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
    background: var(--coral-dark);
    color: #FFFFFF;
    box-shadow: 0 1px 2px rgba(200,65,44,0.28);
}
.btn-primary:hover { background: var(--coral-deep); color: #FFFFFF; box-shadow: 0 3px 10px rgba(200,65,44,0.30); }

/* Gold: reward / points-related calls to action */
.btn-accent {
    background: var(--gold);
    color: var(--ink);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(244,182,63,0.35);
}
.btn-accent:hover { background: var(--gold-dark); color: var(--ink); }

/* Deliberately a deeper, cooler red so it never reads as the coral primary */
.btn-danger {
    background: var(--danger);
    color: #FFFFFF;
    box-shadow: 0 1px 2px rgba(180,35,24,0.25);
}
.btn-danger:hover { background: #8F1B12; color: #FFFFFF; }

.btn-outline {
    background: var(--card);
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--surface-alt); border-color: var(--border-strong); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(20,33,61,0.05); color: var(--text); }

.btn-icon { padding: 9px; width: 36px; height: 36px; }
.btn-icon svg { width: 17px; height: 17px; }

.btn-sm { padding: 7px 14px; font-size: var(--fs-sm); }
.btn-sm svg { width: 14px; height: 14px; }

.btn:disabled,
.btn.disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}

/* Loading state — replaces the old JS that overwrote button text and
   destroyed any icon inside it. Markup stays intact; label just fades. */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 15px;
    margin: -7.5px 0 0 -7.5px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    color: #FFFFFF;
    animation: btn-spin 0.6s linear infinite;
}
.btn-outline.is-loading::after,
.btn-ghost.is-loading::after { color: var(--muted); }

@keyframes btn-spin { to { transform: rotate(360deg); } }


/* ---- Forms -------------------------------------------------------------- */
.form-label {
    display: block;
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--sp-2);
}

.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    padding: 11px 14px;
    font-size: var(--fs-md);
    font-family: var(--font);
    background: var(--card);
    color: var(--text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    outline: none;
}

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

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--coral);
    box-shadow: var(--sh-focus);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--muted-light); }

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled { background: var(--cream); color: var(--muted); cursor: not-allowed; }

.form-group { margin-bottom: var(--sp-5); }

.form-hint {
    font-size: var(--fs-sm);
    color: var(--muted);
    margin-top: var(--sp-1);
    line-height: var(--lh-normal);
}

.form-error,
.text-danger,
.field-validation-error {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--danger);
    margin-top: var(--sp-1);
}

.form-input.input-error,
.form-select.input-error,
.form-textarea.input-error { border-color: var(--danger); }

.field-lang-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--sp-1);
    display: block;
}

.field-group { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }


/* ---- Tables ------------------------------------------------------------- */
.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--card);
}

.admin-table thead tr { background: var(--cream); }

.admin-table thead th {
    padding: var(--sp-3) var(--sp-5);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    text-align: left;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.admin-table tbody tr { transition: background var(--t-fast); }
.admin-table tbody tr:hover { background: var(--surface-alt); }

.admin-table tbody td {
    padding: var(--sp-4) var(--sp-5);
    font-size: var(--fs-base);
    color: var(--text);
    vertical-align: middle;
    border-bottom: 1px solid var(--cream-deep);
}
.admin-table tbody tr:last-child td { border-bottom: none; }

/* A table sitting flush inside a .card (13 views use `.card` + `padding:0`)
   must not draw a second border, and must match the card's corner radius. */
.card > .admin-table,
.card-body > .admin-table { border: none; border-radius: inherit; }
.card > .admin-table thead tr:first-child th:first-child { border-top-left-radius: inherit; }
.card > .admin-table thead tr:first-child th:last-child  { border-top-right-radius: inherit; }


/* ---- Badges ------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 4px 11px;
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    font-family: var(--font);
    letter-spacing: 0.1px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge-neutral { background: var(--cream);      color: var(--muted);   border-color: var(--border); }
.badge-gold    { background: var(--gold-soft);  color: var(--warning); border-color: var(--warning-border); }
.badge-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }


/* ---- Alerts ------------------------------------------------------------- */
.alert {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    margin-bottom: var(--sp-4);
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }


/* ---- Empty state -------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--sp-9) var(--sp-6);
}
.empty-state__icon {
    width: 56px;
    height: 56px;
    border-radius: var(--r-lg);
    background: var(--cream);
    color: var(--muted-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sp-4);
}
.empty-state__icon svg { width: 28px; height: 28px; }
.empty-state__title { font-size: var(--fs-lg); font-weight: 600; color: var(--text); margin: 0 0 var(--sp-2); }
.empty-state__hint  { font-size: var(--fs-base); color: var(--muted); margin: 0; max-width: 380px; line-height: var(--lh-relaxed); }
.empty-state__action { margin-top: var(--sp-5); }


/* ---- Pagination --------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    margin-top: var(--sp-6);
    flex-wrap: wrap;
}
.pagination__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 var(--sp-3);
    border-radius: var(--r-pill);
    border: 1.5px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: var(--fs-base);
    font-weight: 600;
    text-decoration: none;
    transition: background var(--t-fast), border-color var(--t-fast);
}
.pagination__item:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.pagination__item--active {
    background: var(--coral-dark);
    border-color: var(--coral-dark);
    color: #FFFFFF;
}
.pagination__item--active:hover { background: var(--coral-deep); border-color: var(--coral-deep); }
.pagination__item--disabled { opacity: 0.45; pointer-events: none; }
.pagination__ellipsis { color: var(--muted); padding: 0 var(--sp-1); }


/* ---- Modal -------------------------------------------------------------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20,33,61,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
}
.modal.open { display: flex; }

.modal__panel {
    background: var(--card);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-lg);
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 2 * var(--sp-8));
    overflow-y: auto;
    padding: var(--sp-7);
}
.modal__title { font-size: var(--fs-xl); font-weight: 700; margin: 0 0 var(--sp-2); letter-spacing: -0.3px; }
.modal__body  { font-size: var(--fs-md); color: var(--muted); line-height: var(--lh-relaxed); margin-bottom: var(--sp-6); }
.modal__footer { display: flex; gap: var(--sp-3); justify-content: flex-end; }


/* ---- Avatar / thumbnail ------------------------------------------------- */
.avatar-circle,
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ink-soft), var(--ink));
    color: #FFFFFF;
    font-size: var(--fs-base);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 30px; height: 30px; font-size: var(--fs-xs); }
.avatar--lg { width: 60px; height: 60px; font-size: var(--fs-xl); }

.thumb {
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--cream);
    flex-shrink: 0;
}
.thumb--lg { width: 64px; height: 64px; border-radius: var(--r-lg); }


/* ---- Progress ----------------------------------------------------------- */
.progress {
    flex: 1;
    max-width: 140px;
    height: 7px;
    background: var(--cream-deep);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-dark));
    border-radius: var(--r-pill);
    transition: width var(--t-base);
}


/* ---- Code / ID pill ----------------------------------------------------- */
.code-pill {
    display: inline-flex;
    align-items: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: var(--fs-sm);
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    background: var(--gold-soft);
    color: var(--ink);
    border: 1px solid var(--warning-border);
}
.code-pill--muted {
    background: var(--cream);
    color: var(--muted);
    border-color: var(--border);
    font-weight: 500;
}


/* ---- Chart legend key ---------------------------------------------------- */
.chart-key {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--muted);
}
.chart-key__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}
.chart-key__dot--issued   { background: var(--coral-dark); }
.chart-key__dot--redeemed { background: var(--info); }


/* ---- Points display ----------------------------------------------------- */
.points-display { display: flex; align-items: baseline; gap: var(--sp-2); }
.points-value   { font-size: var(--fs-2xl); font-weight: 800; color: var(--ink); letter-spacing: -0.5px; }
.points-label   { font-size: var(--fs-md); font-weight: 500; color: var(--muted); }


/* ---- Toolbar / filter bar ----------------------------------------------- */
.table-toolbar,
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    align-items: flex-end;
}
.filter-bar__label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--sp-2);
}

.search-input-wrap { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-input-wrap svg {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted-light);
    pointer-events: none;
}
.search-input-wrap .form-input { padding-left: 40px; }


/* ---- User dropdown ------------------------------------------------------ */
.user-dropdown { position: relative; }

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + var(--sp-2));
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
    min-width: 196px;
    padding: var(--sp-2);
    display: none;
    z-index: var(--z-dropdown);
}
.user-dropdown-menu.open { display: block; }

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px var(--sp-3);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: var(--fs-base);
    font-weight: 500;
    text-decoration: none;
    transition: background var(--t-fast);
    white-space: nowrap;
}
.user-dropdown-item:hover { background: var(--cream); }
.user-dropdown-item svg { color: var(--muted); flex-shrink: 0; }


/* ---- Error pages -------------------------------------------------------- */
.error-page {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--sp-9) var(--sp-6);
}
.error-code {
    font-size: 104px;
    font-weight: 800;
    color: var(--coral);
    line-height: 1;
    margin-bottom: var(--sp-4);
    letter-spacing: -3px;
}
.error-title   { font-size: var(--fs-2xl); font-weight: 700; color: var(--text); margin-bottom: var(--sp-2); }
.error-message { font-size: var(--fs-md); color: var(--muted); margin-bottom: var(--sp-7); max-width: 420px; line-height: var(--lh-relaxed); }


/* ==========================================================================
   UTILITIES
   ========================================================================== */

.hidden { display: none !important; }
.muted  { color: var(--muted); }
/* Clips a full-bleed table to the card's rounded corners */
.flush  { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.stack  { display: flex; flex-direction: column; gap: var(--sp-5); }
.row    { display: flex; align-items: center; gap: var(--sp-2); }
.row-end{ display: flex; align-items: center; gap: var(--sp-2); justify-content: flex-end; }


/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

.sidebar-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-5);
    line-height: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20,33,61,0.5);
    z-index: var(--z-overlay);
    backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 1240px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
    :root { --sidebar-w: 216px; }
    .main-content { padding: var(--sp-6) var(--sp-5); }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar-hamburger { display: flex; align-items: center; }

    .sidebar {
        position: fixed;
        top: var(--topnav-h);
        left: 0;
        bottom: 0;
        width: 264px;
        z-index: var(--z-overlay);
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { z-index: calc(var(--z-overlay) - 1); }

    .main-content { margin-left: 0 !important; padding: var(--sp-5) var(--sp-4); }
    .admin-body   { display: block; }

    .topnav-logo  { padding-left: var(--sp-4); max-width: 124px; }
    .topnav-title { display: none; }

    .page-header  { flex-direction: column; align-items: flex-start; gap: var(--sp-3); }
    .page-actions { width: 100%; }

    .stats-grid   { grid-template-columns: 1fr; }
    .field-group  { grid-template-columns: 1fr; }
    .card         { padding: var(--sp-5); border-radius: var(--r-lg); }
    .modal__panel { padding: var(--sp-6); }
}

@media (max-width: 480px) {
    .topnav-username, .role-badge { display: none; }
    .stat-value { font-size: var(--fs-2xl); }
}
